1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-02-11 01:05:47 +08:00
committed by cnb
parent 519f2c69a5
commit 1b930b5a19
3 changed files with 30 additions and 40 deletions

View File

@@ -17,7 +17,6 @@ import (
csmap "github.com/mhmtszr/concurrent-swiss-map"
)
// 是否注册,如果注册过,那么就会产生用户player信息
func (s *InfoService) IsReg() bool {
m := s.PModel(s.Model)
@@ -27,27 +26,34 @@ func (s *InfoService) IsReg() bool {
return record
}
// 是否注册,如果注册过,那么就会产生用户player信息
// 实现注册,id+昵称+颜色
func (s *InfoService) Reg(nick string, color uint32) *model.PlayerInfo {
if s.IsReg() {
return nil
m := cool.DBM(s.Model).Where("player_id", s.userid)
var tt *model.Player
m.Scan(&tt)
if tt == nil {
t := model.NewPlayer()
t.PlayerID = uint64(s.userid)
//设置用户信息
t.Data = model.NewPlayerInfo()
t.Data.Nick = nick
t.Data.UserID = s.userid
t.Data.Color = color
t.Data.RegisterTime = uint32(time.Now().Unix()) //写入注册时间
_, err := cool.DBM(s.Model).Data(t).FieldsEx("id").Insert()
if err != nil {
glog.Error(context.Background(), err)
}
return &t.Data
} else {
return &tt.Data
}
t := model.NewPlayer()
t.PlayerID = uint64(s.userid)
//设置用户信息
t.Data = model.NewPlayerInfo()
t.Data.Nick = nick
t.Data.UserID = s.userid
t.Data.Color = color
t.Data.RegisterTime = uint32(time.Now().Unix()) //写入注册时间
_, err := cool.DBM(s.Model).Data(t).FieldsEx("id").Insert()
if err != nil {
glog.Error(context.Background(), err)
}
return &t.Data
}
func (s *InfoService) Person(userid uint32) (out *model.Player) {