命名修改
This commit is contained in:
parent
b81ccf78e3
commit
9d47098166
@ -38,7 +38,7 @@ func (r *Robot) AccountLogin() {
|
|||||||
builders := []*builder{
|
builders := []*builder{
|
||||||
{
|
{
|
||||||
mainType: string(comm.SM_UserModule),
|
mainType: string(comm.SM_UserModule),
|
||||||
subType: user.User_SubType_Login,
|
subType: user.UserSubTypeLogin,
|
||||||
req: &pb.UserLoginReq{
|
req: &pb.UserLoginReq{
|
||||||
Account: r.opts.Account,
|
Account: r.opts.Account,
|
||||||
Sid: r.opts.ServerId,
|
Sid: r.opts.ServerId,
|
||||||
|
@ -11,7 +11,7 @@ var user_builders = []*builder{
|
|||||||
{
|
{
|
||||||
//create
|
//create
|
||||||
mainType: string(comm.SM_UserModule),
|
mainType: string(comm.SM_UserModule),
|
||||||
subType: user.User_SubType_Create,
|
subType: user.UserSubTypeCreate,
|
||||||
req: &pb.UserCreateReq{ //设置请求参数
|
req: &pb.UserCreateReq{ //设置请求参数
|
||||||
NickName: "乐谷6281",
|
NickName: "乐谷6281",
|
||||||
},
|
},
|
||||||
|
@ -9,26 +9,26 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
User_SubType_Login = "login"
|
UserSubTypeLogin = "login"
|
||||||
User_SubType_Logout = "logout"
|
UserSubTypeLogout = "logout"
|
||||||
User_SubType_Create = "create"
|
UserSubTypeCreate = "create"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Api_Comp struct {
|
type apiComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MComp_GateComp
|
||||||
service base.IRPCXService
|
service base.IRPCXService
|
||||||
module *User
|
module *User
|
||||||
hero comm.IHero
|
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.MComp_GateComp.Init(service, module, comp, options)
|
||||||
this.service = service.(base.IRPCXService)
|
this.service = service.(base.IRPCXService)
|
||||||
this.module = module.(*User)
|
this.module = module.(*User)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Api_Comp) Start() (err error) {
|
func (this *apiComp) Start() (err error) {
|
||||||
err = this.MComp_GateComp.Start()
|
err = this.MComp_GateComp.Start()
|
||||||
var module core.IModule
|
var module core.IModule
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"go_dreamfactory/utils"
|
"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{})
|
result = make(map[string]interface{})
|
||||||
self := &pb.DB_UserData{}
|
self := &pb.DB_UserData{}
|
||||||
err := this.module.modelUser.Get(session.GetUserId(), self)
|
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) {
|
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()), User_SubType_Create, req, nil)
|
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), UserSubTypeCreate, req, nil)
|
||||||
|
|
||||||
defer func() {
|
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 {
|
if err != nil {
|
||||||
code = pb.ErrorCode_SystemError
|
code = pb.ErrorCode_SystemError
|
||||||
}
|
}
|
||||||
|
@ -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{}{}
|
result = map[string]interface{}{}
|
||||||
return
|
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 (
|
var (
|
||||||
err error
|
err error
|
||||||
user *pb.DB_UserData
|
user *pb.DB_UserData
|
||||||
@ -26,7 +26,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if user != nil {
|
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,
|
Data: user,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,12 +6,12 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"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
|
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)
|
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const ( //Redis
|
const ( //Redis
|
||||||
DB_UserTable core.SqlTable = "user" //用户表
|
TableUser core.SqlTable = "user" //用户表
|
||||||
)
|
)
|
||||||
|
|
||||||
type ModelUser struct {
|
type ModelUser struct {
|
||||||
@ -31,7 +31,7 @@ func (this *ModelUser) User_FindByAccount(sid int32, account string) (*pb.DB_Use
|
|||||||
"sid": sid,
|
"sid": sid,
|
||||||
"binduid": account,
|
"binduid": account,
|
||||||
}
|
}
|
||||||
sr := this.DB.FindOne(DB_UserTable, filter)
|
sr := this.DB.FindOne(TableUser, filter)
|
||||||
var nd *pb.DB_UserData
|
var nd *pb.DB_UserData
|
||||||
err := sr.Decode(&nd)
|
err := sr.Decode(&nd)
|
||||||
return nd, err
|
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.Uid = fmt.Sprintf("%d_%s", user.Sid, _id)
|
||||||
user.Uuid = uuid.NewV4().String()
|
user.Uuid = uuid.NewV4().String()
|
||||||
user.Ctime = time.Now().Unix()
|
user.Ctime = time.Now().Unix()
|
||||||
_, err = this.DB.InsertOne(DB_UserTable, user)
|
_, err = this.DB.InsertOne(TableUser, user)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ func NewModule() core.IModule {
|
|||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
modules.ModuleBase
|
modules.ModuleBase
|
||||||
user_comp *Api_Comp
|
api *apiComp
|
||||||
modelUser *ModelUser
|
modelUser *ModelUser
|
||||||
modelSession *ModelSession
|
modelSession *ModelSession
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ func (this *User) Init(service core.IService, module core.IModule, options core.
|
|||||||
|
|
||||||
func (this *User) OnInstallComp() {
|
func (this *User) OnInstallComp() {
|
||||||
this.ModuleBase.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.modelUser = this.RegisterComp(new(ModelUser)).(*ModelUser)
|
||||||
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
|
this.modelSession = this.RegisterComp(new(ModelSession)).(*ModelSession)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user