diff --git a/comm/imodule.go b/comm/imodule.go index 7a00bc57c..02a850302 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -38,7 +38,7 @@ type ( //消耗卡片 ChangeCard(uId string, heroCfgId int32, count int32) (code pb.ErrorCode) //创建新英雄 - CreatHero(uid string, heroCfgId ...int32) error + CreateHero(uid string, heroCfgId ...int32) error // 获取英雄 // heroId 英雄ID diff --git a/modules/friend/api.go b/modules/friend/api.go index b8b83edd2..9bb5c5785 100644 --- a/modules/friend/api.go +++ b/modules/friend/api.go @@ -17,12 +17,12 @@ const ( Friend_SubType_Search = "search" ) -type ApiComp struct { +type apiComp struct { modules.MComp_GateComp module *Friend } -func (this *ApiComp) 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.module = module.(*Friend) return diff --git a/modules/friend/api_addblack.go b/modules/friend/api_addblack.go index 7d8b3a4d3..d565f1230 100644 --- a/modules/friend/api_addblack.go +++ b/modules/friend/api_addblack.go @@ -6,7 +6,7 @@ import ( "go_dreamfactory/utils" ) -func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_BlackAdd_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_BlackAdd_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var ( err error @@ -15,13 +15,13 @@ func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_Bl self := &pb.DB_FriendData{UId: session.GetUserId()} target := &pb.DB_FriendData{UId: req.FriendId} - err = this.module.model_friend.Get(session.GetUserId(), self) + err = this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return } - err = this.module.model_friend.Get(req.FriendId, target) + err = this.module.modelFriend.Get(req.FriendId, target) if target == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData} return @@ -58,7 +58,7 @@ func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_Bl } //加入黑名单 -func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackAdd_Req) (code pb.ErrorCode) { +func (this *apiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackAdd_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_BlackAdd_Rsp @@ -78,7 +78,7 @@ func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interfac self.BlackIds = append(self.BlackIds, req.FriendId) //更新黑名单 - err := this.module.model_friend.Change(self.UId, map[string]interface{}{ + err := this.module.modelFriend.Change(self.UId, map[string]interface{}{ "blackIds": self.BlackIds, }) if err != nil { diff --git a/modules/friend/api_agree.go b/modules/friend/api_agree.go index ea0f92335..cb0aa4c52 100644 --- a/modules/friend/api_agree.go +++ b/modules/friend/api_agree.go @@ -6,13 +6,13 @@ import ( "go_dreamfactory/utils" ) -func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var err error self := &pb.DB_FriendData{UId: session.GetUserId()} //获取玩家自己好友数据 - err = this.module.model_friend.Get(session.GetUserId(), self) + err = this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return @@ -34,7 +34,7 @@ func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree } //单个/批量同意 -func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Agree_Req) (code pb.ErrorCode) { +func (this *apiComp) Agree(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Agree_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_Agree_Rsp @@ -71,7 +71,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{} //双向添加:将自己加入到申请人的好友列表中 target := &pb.DB_FriendData{} - err := this.module.model_friend.Get(userId, target) + err := this.module.modelFriend.Get(userId, target) if target == nil || err != nil { code = pb.ErrorCode_FriendTargetNoData @@ -82,7 +82,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{} } target.FriendIds = append(target.FriendIds, self.UId) } - err = this.module.model_friend.Change(target.UId, map[string]interface{}{ + err = this.module.modelFriend.Change(target.UId, map[string]interface{}{ "friendIds": target.FriendIds, }) if err != nil { @@ -95,7 +95,7 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{} } //更新 - err := this.module.model_friend.Change(self.UId, map[string]interface{}{ + err := this.module.modelFriend.Change(self.UId, map[string]interface{}{ "applyIds": self.ApplyIds, "friendIds": self.FriendIds, }) diff --git a/modules/friend/api_apply.go b/modules/friend/api_apply.go index 88e6f5580..532c2831d 100644 --- a/modules/friend/api_apply.go +++ b/modules/friend/api_apply.go @@ -7,21 +7,21 @@ import ( "go_dreamfactory/utils" ) -func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var err error self := &pb.DB_FriendData{UId: session.GetUserId()} target := &pb.DB_FriendData{UId: req.FriendId} //获取玩家自己好友数据 - err = this.module.model_friend.Get(session.GetUserId(), self) + err = this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return } //获取好友数据 - err = this.module.model_friend.Get(req.FriendId, target) + err = this.module.modelFriend.Get(req.FriendId, target) if target == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData} return @@ -79,7 +79,7 @@ func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply } //好友申请 -func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Apply_Req) (code pb.ErrorCode) { +func (this *apiComp) Apply(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Apply_Req) (code pb.ErrorCode) { var ( target *pb.DB_FriendData rsp *pb.Friend_Apply_Rsp @@ -116,7 +116,7 @@ func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{} } target.ApplyIds = append(target.ApplyIds, session.GetUserId()) - err := this.module.model_friend.Change(req.FriendId, map[string]interface{}{ + err := this.module.modelFriend.Change(req.FriendId, map[string]interface{}{ "applyIds": target.ApplyIds, }) if err != nil { diff --git a/modules/friend/api_applylist.go b/modules/friend/api_applylist.go index a470345ee..158684e4c 100644 --- a/modules/friend/api_applylist.go +++ b/modules/friend/api_applylist.go @@ -5,10 +5,10 @@ import ( "go_dreamfactory/pb" ) -func (this *ApiComp) ApplyList_Check(session comm.IUserSession, req *pb.Friend_ApplyList_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) ApplyList_Check(session comm.IUserSession, req *pb.Friend_ApplyList_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) self := &pb.DB_FriendData{UId: session.GetUserId()} - err := this.module.model_friend.Get(session.GetUserId(), self) + err := this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return @@ -18,7 +18,7 @@ func (this *ApiComp) ApplyList_Check(session comm.IUserSession, req *pb.Friend_A } //申请列表 -func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_ApplyList_Req) (code pb.ErrorCode) { +func (this *apiComp) ApplyList(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_ApplyList_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_ApplyList_Rsp diff --git a/modules/friend/api_blacklist.go b/modules/friend/api_blacklist.go index 61047e218..710075960 100644 --- a/modules/friend/api_blacklist.go +++ b/modules/friend/api_blacklist.go @@ -5,10 +5,10 @@ import ( "go_dreamfactory/pb" ) -func (this *ApiComp) Blacklist_Check(session comm.IUserSession, req *pb.Friend_BlackList_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Blacklist_Check(session comm.IUserSession, req *pb.Friend_BlackList_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) self := &pb.DB_FriendData{UId: session.GetUserId()} - err := this.module.model_friend.Get(session.GetUserId(), self) + err := this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return @@ -18,7 +18,7 @@ func (this *ApiComp) Blacklist_Check(session comm.IUserSession, req *pb.Friend_B } //黑名单 -func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackList_Req) (code pb.ErrorCode) { +func (this *apiComp) Blacklist(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackList_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_BlackList_Rsp diff --git a/modules/friend/api_del.go b/modules/friend/api_del.go index aecdbc260..b7e765035 100644 --- a/modules/friend/api_del.go +++ b/modules/friend/api_del.go @@ -5,11 +5,11 @@ import ( "go_dreamfactory/pb" ) -func (this *ApiComp) Del_Check(session comm.IUserSession, req *pb.Friend_Del_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Del_Check(session comm.IUserSession, req *pb.Friend_Del_Req) (chk map[string]interface{}, code comm.ErrorCode) { return } //删除好友 -func (this *ApiComp) Del(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Del_Req) error { +func (this *apiComp) Del(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Del_Req) error { return nil } diff --git a/modules/friend/api_delblack.go b/modules/friend/api_delblack.go index 91adb395d..e7111c72e 100644 --- a/modules/friend/api_delblack.go +++ b/modules/friend/api_delblack.go @@ -6,10 +6,10 @@ import ( "go_dreamfactory/utils" ) -func (this *ApiComp) Delblack_Check(session comm.IUserSession, req *pb.Friend_DelBlack_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Delblack_Check(session comm.IUserSession, req *pb.Friend_DelBlack_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) self := &pb.DB_FriendData{UId: session.GetUserId()} - err := this.module.model_friend.Get(session.GetUserId(), self) + err := this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return @@ -19,7 +19,7 @@ func (this *ApiComp) Delblack_Check(session comm.IUserSession, req *pb.Friend_De } //删除黑名单 -func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_DelBlack_Req) (code pb.ErrorCode) { +func (this *apiComp) Delblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_DelBlack_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_DelBlack_Rsp @@ -43,7 +43,7 @@ func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interfac //从黑名单列表中删除目标 self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId) //更新黑名单 - err := this.module.model_friend.Change(self.UId, map[string]interface{}{ + err := this.module.modelFriend.Change(self.UId, map[string]interface{}{ "blackIds": self.BlackIds, }) if err != nil { diff --git a/modules/friend/api_list.go b/modules/friend/api_list.go index 0ad9499a3..e0e4372f9 100644 --- a/modules/friend/api_list.go +++ b/modules/friend/api_list.go @@ -5,10 +5,10 @@ import ( "go_dreamfactory/pb" ) -func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) self := &pb.DB_FriendData{UId: session.GetUserId()} - err := this.module.model_friend.Get(session.GetUserId(), self) + err := this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return @@ -18,7 +18,7 @@ func (this *ApiComp) List_Check(session comm.IUserSession, req *pb.Friend_List_R } //好友列表 -func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_List_Req) (code pb.ErrorCode) { +func (this *apiComp) List(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_List_Req) (code pb.ErrorCode) { var ( self *pb.DB_FriendData rsp *pb.Friend_List_Rsp diff --git a/modules/friend/api_refuse.go b/modules/friend/api_refuse.go index 56ee1c593..d19be82c3 100644 --- a/modules/friend/api_refuse.go +++ b/modules/friend/api_refuse.go @@ -6,13 +6,13 @@ import ( "go_dreamfactory/utils" ) -func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refuse_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refuse_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var err error self := &pb.DB_FriendData{UId: session.GetUserId()} //获取玩家自己好友数据 - err = this.module.model_friend.Get(session.GetUserId(), self) + err = this.module.modelFriend.Get(session.GetUserId(), self) if self == nil || err != nil { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return @@ -33,7 +33,7 @@ func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refu } //单个/批量拒绝 -func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Refuse_Req) (code pb.ErrorCode) { +func (this *apiComp) Refuse(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Refuse_Req) (code pb.ErrorCode) { //将申请人从申请列表中删除 var ( self *pb.DB_FriendData @@ -66,7 +66,7 @@ func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{ } //更新 if optNum > 0 { - err := this.module.model_friend.Change(self.UId, map[string]interface{}{ + err := this.module.modelFriend.Change(self.UId, map[string]interface{}{ "applyIds": self.ApplyIds, }) if err != nil { diff --git a/modules/friend/api_search.go b/modules/friend/api_search.go index d9ef64eb8..cdbcdd518 100644 --- a/modules/friend/api_search.go +++ b/modules/friend/api_search.go @@ -5,7 +5,7 @@ import ( "go_dreamfactory/pb" ) -func (this *ApiComp) Search_Check(session comm.IUserSession, req *pb.Friend_Search_Req) (chk map[string]interface{}, code comm.ErrorCode) { +func (this *apiComp) Search_Check(session comm.IUserSession, req *pb.Friend_Search_Req) (chk map[string]interface{}, code comm.ErrorCode) { if req.NickName == "" { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSearchNameEmpty} return @@ -14,7 +14,7 @@ func (this *ApiComp) Search_Check(session comm.IUserSession, req *pb.Friend_Sear } //搜索 -func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Search_Req) (code pb.ErrorCode) { +func (this *apiComp) Search(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_Search_Req) (code pb.ErrorCode) { var ( rsp *pb.Friend_Search_Rsp friend *pb.FriendBase @@ -28,7 +28,7 @@ func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{ session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, rsp) }() - user := this.module.model_friend.Frined_FindCond(req.NickName) + user := this.module.modelFriend.Frined_FindCond(req.NickName) if user != nil { friend = &pb.FriendBase{ UserId: user.Uid, diff --git a/modules/friend/model_friend.go b/modules/friend/model_friend.go index f3402fe9e..047537f90 100644 --- a/modules/friend/model_friend.go +++ b/modules/friend/model_friend.go @@ -10,8 +10,8 @@ import ( ) const ( - DB_FriendTable core.SqlTable = "friend" - DB_UserTable core.SqlTable = "user" //用户表 + TableFriend core.SqlTable = "friend" + TableUser core.SqlTable = "user" //用户表 ) type ModelFriend struct { @@ -20,13 +20,13 @@ type ModelFriend struct { func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { err = this.Model_Comp.Init(service, module, comp, options) - this.TableName = "friend" + this.TableName = string(TableFriend) return } func (this *ModelFriend) Frined_FindCond(nickName string) *pb.DB_UserData { var user *pb.DB_UserData - err := this.DB.FindOne(DB_UserTable, bson.M{ + err := this.DB.FindOne(TableUser, bson.M{ "name": nickName, }).Decode(&user) if err != nil { diff --git a/modules/friend/module.go b/modules/friend/module.go index 7429626da..7aebe6189 100644 --- a/modules/friend/module.go +++ b/modules/friend/module.go @@ -14,8 +14,8 @@ func NewModule() core.IModule { type Friend struct { modules.ModuleBase - friend_comp *ApiComp - model_friend *ModelFriend + api *apiComp + modelFriend *ModelFriend } func (this *Friend) GetType() core.M_Modules { @@ -30,6 +30,6 @@ func (this *Friend) Init(service core.IService, module core.IModule, options cor func (this *Friend) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.friend_comp = this.RegisterComp(new(ApiComp)).(*ApiComp) - this.model_friend = this.RegisterComp(new(ModelFriend)).(*ModelFriend) + this.api = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelFriend = this.RegisterComp(new(ModelFriend)).(*ModelFriend) } diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 7f21d6add..8991feae8 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -62,14 +62,19 @@ func (this *ModelHero) createOneHero(uid string, heroCfgId int32) error { //创建多个指定的英雄 heroCfgIds可填入多个英雄ID func (this *ModelHero) createMultiHero(uid string, heroCfgIds ...int32) error { - data := make(map[string]interface{}) + // data := make(map[string]interface{}) for _, v := range heroCfgIds { - hero := this.initHero(uid, v) - if hero != nil { - data[hero.Id] = hero + if err := this.createOneHero(uid, v); err != nil { + return err } + // hero := this.initHero(uid, v) + // if hero != nil { + // data[hero.Id] = hero + // } } - return this.moduleHero.modelHero.AddLists(uid, data) + + return nil + // return this.moduleHero.model_hero.AddLists(uid, data) } //获取一个英雄 diff --git a/modules/hero/module.go b/modules/hero/module.go index 92a6c3171..d567963f1 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -40,7 +40,7 @@ func (this *Hero) OnInstallComp() { } //创建新英雄 -func (this *Hero) CreatHero(uid string, heroCfgId ...int32) error { +func (this *Hero) CreateHero(uid string, heroCfgId ...int32) error { return this.modelHero.createMultiHero(uid, heroCfgId...) } diff --git a/modules/user/api_create.go b/modules/user/api_create.go index ac4af665b..10ee383f4 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -41,7 +41,7 @@ func (this *apiComp) Create(session comm.IUserSession, result map[string]interfa //初始化英雄卡 defaultHero := []int32{15001, 25001} //TODO 从配置中读取 - err = this.hero.CreatHero(session.GetUserId(), defaultHero...) + err = this.hero.CreateHero(session.GetUserId(), defaultHero...) if err != nil { code = pb.ErrorCode_HeroInitCreat return