命名修改

This commit is contained in:
meixiongfeng 2022-06-28 14:58:04 +08:00
parent b81ccf78e3
commit 9d47098166
8 changed files with 22 additions and 22 deletions

View File

@ -38,7 +38,7 @@ func (r *Robot) AccountLogin() {
builders := []*builder{
{
mainType: string(comm.SM_UserModule),
subType: user.User_SubType_Login,
subType: user.UserSubTypeLogin,
req: &pb.UserLoginReq{
Account: r.opts.Account,
Sid: r.opts.ServerId,

View File

@ -11,7 +11,7 @@ var user_builders = []*builder{
{
//create
mainType: string(comm.SM_UserModule),
subType: user.User_SubType_Create,
subType: user.UserSubTypeCreate,
req: &pb.UserCreateReq{ //设置请求参数
NickName: "乐谷6281",
},

View File

@ -9,26 +9,26 @@ import (
)
const (
User_SubType_Login = "login"
User_SubType_Logout = "logout"
User_SubType_Create = "create"
UserSubTypeLogin = "login"
UserSubTypeLogout = "logout"
UserSubTypeCreate = "create"
)
type Api_Comp struct {
type apiComp struct {
modules.MComp_GateComp
service base.IRPCXService
module *User
hero comm.IHero
}
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MComp_GateComp.Init(service, module, comp, options)
this.service = service.(base.IRPCXService)
this.module = module.(*User)
return
}
func (this *Api_Comp) Start() (err error) {
func (this *apiComp) Start() (err error) {
err = this.MComp_GateComp.Start()
var module core.IModule

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/utils"
)
func (this *Api_Comp) Create_Check(session comm.IUserSession, req *pb.UserCreateReq) (result map[string]interface{}, code comm.ErrorCode) {
func (this *apiComp) Create_Check(session comm.IUserSession, req *pb.UserCreateReq) (result map[string]interface{}, code comm.ErrorCode) {
result = make(map[string]interface{})
self := &pb.DB_UserData{}
err := this.module.modelUser.Get(session.GetUserId(), self)
@ -19,11 +19,11 @@ func (this *Api_Comp) Create_Check(session comm.IUserSession, req *pb.UserCreate
}
//创角
func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interface{}, req *pb.UserCreateReq) (code pb.ErrorCode) {
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
func (this *apiComp) Create(session comm.IUserSession, result map[string]interface{}, req *pb.UserCreateReq) (code pb.ErrorCode) {
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), UserSubTypeCreate, req, nil)
defer func() {
err := session.SendMsg(string(this.module.GetType()), User_SubType_Create, &pb.UserCreateRsp{})
err := session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateRsp{})
if err != nil {
code = pb.ErrorCode_SystemError
}

View File

@ -12,13 +12,13 @@ import (
)
//参数校验
func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) {
func (this *apiComp) Login_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) {
result = map[string]interface{}{}
return
}
//登录
func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) {
func (this *apiComp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (code pb.ErrorCode) {
var (
err error
user *pb.DB_UserData
@ -26,7 +26,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
defer func() {
if user != nil {
err = session.SendMsg(string(this.module.GetType()), User_SubType_Login, &pb.UserLoginResp{
err = session.SendMsg(string(this.module.GetType()), UserSubTypeLogin, &pb.UserLoginResp{
Data: user,
})
if err != nil {

View File

@ -6,12 +6,12 @@ import (
"go_dreamfactory/pb"
)
func (this *Api_Comp) Logout_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) {
func (this *apiComp) Logout_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code comm.ErrorCode) {
return
}
//注销
func (this *Api_Comp) Logout(session comm.IUserSession, result map[string]interface{}, rsp *pb.UserLoginReq) (code pb.ErrorCode) {
func (this *apiComp) Logout(session comm.IUserSession, result map[string]interface{}, rsp *pb.UserLoginReq) (code pb.ErrorCode) {
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)
return

View File

@ -13,7 +13,7 @@ import (
)
const ( //Redis
DB_UserTable core.SqlTable = "user" //用户表
TableUser core.SqlTable = "user" //用户表
)
type ModelUser struct {
@ -31,7 +31,7 @@ func (this *ModelUser) User_FindByAccount(sid int32, account string) (*pb.DB_Use
"sid": sid,
"binduid": account,
}
sr := this.DB.FindOne(DB_UserTable, filter)
sr := this.DB.FindOne(TableUser, filter)
var nd *pb.DB_UserData
err := sr.Decode(&nd)
return nd, err
@ -43,6 +43,6 @@ func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) {
user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id)
user.Uuid = uuid.NewV4().String()
user.Ctime = time.Now().Unix()
_, err = this.DB.InsertOne(DB_UserTable, user)
_, err = this.DB.InsertOne(TableUser, user)
return err
}

View File

@ -15,7 +15,7 @@ func NewModule() core.IModule {
type User struct {
modules.ModuleBase
user_comp *Api_Comp
api *apiComp
modelUser *ModelUser
modelSession *ModelSession
}
@ -32,7 +32,7 @@ func (this *User) Init(service core.IService, module core.IModule, options core.
func (this *User) OnInstallComp() {
this.ModuleBase.OnInstallComp()
this.user_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
}