This commit is contained in:
@@ -1,20 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"blazing/common/socket/errorcode"
|
||||
"blazing/cool"
|
||||
"blazing/modules/player/service"
|
||||
// // CreatePlayer 处理命令: 1001
|
||||
// func (h Controller) CreatePlayer(data *user.CreatePlayerInboundInfo, c gnet.Conn) (result *user.CreatePlayerOutInfo, err errorcode.ErrorCode) {
|
||||
// data.Nickname = strings.Trim(data.Nickname, "\x00")
|
||||
// service.NewUserService(data.Head.UserID).Info.Reg(cool.Filter.Replace(data.Nickname, '*'), data.Color)
|
||||
|
||||
"blazing/logic/service/user"
|
||||
"strings"
|
||||
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
|
||||
// CreatePlayer 处理命令: 1001
|
||||
func (h Controller) CreatePlayer(data *user.CreatePlayerInboundInfo, c gnet.Conn) (result *user.CreatePlayerOutInfo, err errorcode.ErrorCode) {
|
||||
data.Nickname = strings.Trim(data.Nickname, "\x00")
|
||||
service.NewUserService(data.Head.UserID).Info.Reg(cool.Filter.Replace(data.Nickname, '*'), data.Color)
|
||||
|
||||
return result, 0
|
||||
}
|
||||
// return result, 0
|
||||
// }
|
||||
|
||||
@@ -111,11 +111,6 @@ func (c *BaseSysUserController) Regrobot(ctx context.Context, req *RegReq) (res
|
||||
|
||||
t1 := service.NewBaseSysUserService().GetPerson(uint32(t.UserId))
|
||||
|
||||
if blazing.NewUserService(uint32(t1.ID)).Info.IsReg() {
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
ser := playerservice.NewUserService(uint32(t1.ID))
|
||||
|
||||
logininfo := ser.Info.Reg(cool.Filter.Replace(strings.Trim(req.Nickname, "\x00"), '*'), req.Color)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user