51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package user
|
|
|
|
import (
|
|
"context"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/utils"
|
|
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/event"
|
|
)
|
|
|
|
const (
|
|
User_SubType_Create = "create"
|
|
)
|
|
|
|
type UserComp struct {
|
|
modules.MComp_GateComp
|
|
module *User
|
|
}
|
|
|
|
func (this *UserComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
|
this.MComp_GateComp.Init(service, module, comp, options)
|
|
this.module = module.(*User)
|
|
return
|
|
}
|
|
|
|
//创角
|
|
func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) (err error) {
|
|
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
|
|
|
|
var code pb.ErrorCode
|
|
defer func() {
|
|
session.SendMsg(string(this.module.GetType()), User_SubType_Create, code, &pb.UserCreateRsp{})
|
|
}()
|
|
|
|
//更新昵称
|
|
update := map[string]interface{}{
|
|
"name": req.NickName,
|
|
}
|
|
err = this.module.modelUser.Set(session.GetUserId(), update)
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
|
|
event.RegisterGO(comm.Event_CreateUser, session.GetUserId())
|
|
return nil
|
|
}
|