From 4da4c572e569ec94fad41be3e97e0879d41c9176 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Thu, 16 Jun 2022 20:26:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3chk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/redis/sys_test.go | 26 +++++++---- modules/friend/api_addblack.go | 76 +++++++++++++++++++-------------- modules/friend/api_agree.go | 12 +++--- modules/friend/api_apply.go | 6 ++- modules/friend/api_applylist.go | 27 +++++++----- modules/friend/api_blacklist.go | 40 ++++++++++------- modules/friend/api_delblack.go | 37 ++++++++++------ modules/friend/api_list.go | 37 +++++++++------- modules/friend/api_refuse.go | 8 +++- modules/friend/api_search.go | 4 ++ modules/model_comp.go | 76 +++++++++++++++++++++++++++------ pb/errorcode.pb.go | 39 +++++++++-------- pb/proto/errorcode.proto | 62 +++++++++++++-------------- sys/cache/optionAttr.go | 2 +- 14 files changed, 284 insertions(+), 168 deletions(-) diff --git a/lego/sys/redis/sys_test.go b/lego/sys/redis/sys_test.go index ee6d804f1..9627590f2 100644 --- a/lego/sys/redis/sys_test.go +++ b/lego/sys/redis/sys_test.go @@ -190,15 +190,12 @@ func Test_Redis_Encoder_Hash(t *testing.T) { // fmt.Printf("data:%v err:%v\n", data, err) // redis.HSet("test:1003", "Name", "eeee") - name := "" - err := redis.HGet("test:103", "name", &name) - if err != nil { - fmt.Println(err) - } - fmt.Println(name) - - - redis.HMSet("",) + // name := "" + // err := redis.HGet("test:103", "name", &name) + // if err != nil { + // fmt.Println(err) + // } + // fmt.Println(name) // data1 := map[string]*TestData{"li_1": {Name: "liwei2dao", Agr: 56}, "li_2": {Name: "liwei3dao", Agr: 78}} // err := redis.HMSet("test:1004", data1) @@ -206,4 +203,15 @@ func Test_Redis_Encoder_Hash(t *testing.T) { // data2 := make(map[string]*TestData) // err = redis.HGetAll("test:1004", data2) // fmt.Printf("data2:%v err:%v\n", data2, err) + + // d1 := map[string]interface{}{"ll": "1", "age": 20} + // err := redis.HMSet("test:104", d1) + // fmt.Printf("err:%v\n", err) + // d2 := make(map[string]interface{}) + // err := redis.HGetAll("test:105", d2) + // fmt.Printf("data2:%v err:%v\n", d2, err) + + iskeep, err := redis.ExistsKey("test:105") + fmt.Printf("ok:%v err:%v\n", iskeep, err) + } diff --git a/modules/friend/api_addblack.go b/modules/friend/api_addblack.go index 6180240ef..a468f2b9a 100644 --- a/modules/friend/api_addblack.go +++ b/modules/friend/api_addblack.go @@ -6,68 +6,78 @@ import ( "go_dreamfactory/utils" ) -func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_BlackAdd_Req) (result map[string]interface{}, code comm.ErrorCode) { - return -} - -//加入黑名单 -func (this *ApiComp) Addblack(session comm.IUserSession, chk map[string]interface{}, req *pb.Friend_BlackAdd_Req) (err error) { +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 ( - code pb.ErrorCode - self *pb.DB_FriendData - target *pb.DB_FriendData - rsp *pb.Friend_BlackAdd_Rsp + err error blackNumMax = 50 //TODO 从配置中读取 ) - - defer func() { - if code == pb.ErrorCode_Success { - rsp = &pb.Friend_BlackAdd_Rsp{ - FriendId: req.FriendId, - UserId: session.GetUserId(), - } - } - session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp) - }() + self := &pb.DB_FriendData{UserId: session.GetUserId()} + target := &pb.DB_FriendData{UserId: req.FriendId} err = this.module.model_friend.GetObj(session.GetUserId(), self) if self == nil || err != nil { - code = pb.ErrorCode_FriendSelfNoData + code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} return } err = this.module.model_friend.GetObj(req.FriendId, target) if target == nil || err != nil { - code = pb.ErrorCode_FriendTargetNoData + code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetNoData} return } //判断目标是否在好友列表里面 if _, ok := utils.Find(self.FriendIds, req.FriendId); ok { - code = pb.ErrorCode_FriendSelfBlackYet + code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfBlackYet} return } // 判断自己是否在对方的黑名单中 if _, ok := utils.Find(target.BlackIds, self.UserId); ok { - code = pb.ErrorCode_FriendTargetBlackYet + code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetBlackYet} return } // 判断是否黑名单人数已满 if len(self.BlackIds) >= blackNumMax { - code = pb.ErrorCode_FriendBlackMax + code = comm.ErrorCode{Code: pb.ErrorCode_FriendBlackMax} return } - //将目标加入黑名单 - self.BlackIds = append(self.BlackIds, req.FriendId) + chk["self"] = self + chk["target"] = target + + return +} + +//加入黑名单 +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 + ) + + defer func() { + rsp = &pb.Friend_BlackAdd_Rsp{ + FriendId: req.FriendId, + UserId: session.GetUserId(), + } + session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp) + }() + + if v, ok := chk["self"]; ok { + self = v.(*pb.DB_FriendData) + //将目标加入黑名单 + self.BlackIds = append(self.BlackIds, req.FriendId) + + //更新黑名单 + err := this.module.model_friend.SetObj(self.UserId, self) + if err != nil { + code = pb.ErrorCode_DBError + return + } + } - //更新黑名单 - err = this.module.model_friend.SetObj(self.UserId, self) - if err != nil { - code = pb.ErrorCode_DBError - return - } return } diff --git a/modules/friend/api_agree.go b/modules/friend/api_agree.go index ce9e7b0f5..b98598bdf 100644 --- a/modules/friend/api_agree.go +++ b/modules/friend/api_agree.go @@ -42,12 +42,14 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{} ) defer func() { - if code == pb.ErrorCode_Success { - rsp = &pb.Friend_Agree_Rsp{ - Num: optNum, - } + rsp = &pb.Friend_Agree_Rsp{ + Num: optNum, + } + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_Agree, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return } - session.SendMsg(string(this.module.GetType()), Friend_SubType_Agree, rsp) }() if v, ok := chk["self"]; !ok { diff --git a/modules/friend/api_apply.go b/modules/friend/api_apply.go index 304a577ca..dd594d528 100644 --- a/modules/friend/api_apply.go +++ b/modules/friend/api_apply.go @@ -96,7 +96,11 @@ func (this *ApiComp) Apply(session comm.IUserSession, chk map[string]interface{} FriendId: req.FriendId, } } - session.SendMsg(string(this.module.GetType()), Friend_SubType_Apply, rsp) + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_Apply, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return + } }() if v, ok := chk["target"]; !ok { diff --git a/modules/friend/api_applylist.go b/modules/friend/api_applylist.go index ad2522346..bbeb4c5d7 100644 --- a/modules/friend/api_applylist.go +++ b/modules/friend/api_applylist.go @@ -6,6 +6,14 @@ import ( ) 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{UserId: session.GetUserId()} + err := this.module.model_friend.GetObj(session.GetUserId(), self) + if self == nil || err != nil { + code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} + return + } + chk["self"] = self return } @@ -26,17 +34,14 @@ func (this *ApiComp) ApplyList(session comm.IUserSession, chk map[string]interfa session.SendMsg(string(this.module.GetType()), Friend_SubType_ApplyList, rsp) }() - err := this.module.model_friend.GetObj(session.GetUserId(), self) - if self == nil || err != nil { - code = pb.ErrorCode_FriendSelfNoData - return - } - - for _, userId := range self.ApplyIds { - //TODO 组装FriendBase明细数据 - list = append(list, &pb.FriendBase{ - UserId: userId, - }) + if v, ok := chk["self"]; ok { + self = v.(*pb.DB_FriendData) + for _, userId := range self.ApplyIds { + //TODO 组装FriendBase明细数据 + list = append(list, &pb.FriendBase{ + UserId: userId, + }) + } } return diff --git a/modules/friend/api_blacklist.go b/modules/friend/api_blacklist.go index f45577436..1715d7bbf 100644 --- a/modules/friend/api_blacklist.go +++ b/modules/friend/api_blacklist.go @@ -6,6 +6,14 @@ import ( ) 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{UserId: session.GetUserId()} + err := this.module.model_friend.GetObj(session.GetUserId(), self) + if self == nil || err != nil { + code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} + return + } + chk["self"] = self return } @@ -18,25 +26,25 @@ func (this *ApiComp) Blacklist(session comm.IUserSession, chk map[string]interfa ) defer func() { - if code == pb.ErrorCode_Success { - rsp = &pb.Friend_BlackList_Rsp{ - Friends: list, - } + rsp = &pb.Friend_BlackList_Rsp{ + Friends: list, + } + + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_Blacklist, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return } - session.SendMsg(string(this.module.GetType()), Friend_SubType_Blacklist, rsp) }() - err := this.module.model_friend.GetObj(session.GetUserId(), self) - if self == nil || err != nil { - code = pb.ErrorCode_FriendSelfNoData - return - } - - for _, userId := range self.BlackIds { - //TODO 完善FriendBase信息 - list = append(list, &pb.FriendBase{ - UserId: userId, - }) + if v, ok := chk["self"]; ok { + self = v.(*pb.DB_FriendData) + for _, userId := range self.BlackIds { + //TODO 完善FriendBase信息 + list = append(list, &pb.FriendBase{ + UserId: userId, + }) + } } return diff --git a/modules/friend/api_delblack.go b/modules/friend/api_delblack.go index 4b9ce1f60..e7c7b7742 100644 --- a/modules/friend/api_delblack.go +++ b/modules/friend/api_delblack.go @@ -7,6 +7,14 @@ import ( ) 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{UserId: session.GetUserId()} + err := this.module.model_friend.GetObj(session.GetUserId(), self) + if self == nil || err != nil { + code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} + return + } + chk["self"] = self return } @@ -23,21 +31,24 @@ func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interfac UserId: session.GetUserId(), } } - session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp) + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return + } }() - err := this.module.model_friend.GetObj(session.GetUserId(), self) - if self == nil || err != nil { - code = pb.ErrorCode_FriendSelfNoData - return + + if v, ok := chk["self"]; ok { + self = v.(*pb.DB_FriendData) + //从黑名单列表中删除目标 + self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId) + //更新黑名单 + err := this.module.model_friend.SetObj(self.UserId, self) + if err != nil { + code = pb.ErrorCode_DBError + return + } } - //从黑名单列表中删除目标 - self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId) - //更新黑名单 - err = this.module.model_friend.SetObj(self.UserId, self) - if err != nil { - code = pb.ErrorCode_DBError - return - } return } diff --git a/modules/friend/api_list.go b/modules/friend/api_list.go index 280cd2a76..7bd6d5055 100644 --- a/modules/friend/api_list.go +++ b/modules/friend/api_list.go @@ -6,6 +6,14 @@ import ( ) 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{UserId: session.GetUserId()} + err := this.module.model_friend.GetObj(session.GetUserId(), self) + if self == nil || err != nil { + code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfNoData} + return + } + chk["self"] = self return } @@ -18,24 +26,23 @@ func (this *ApiComp) List(session comm.IUserSession, chk map[string]interface{}, ) defer func() { - if code == pb.ErrorCode_Success { - rsp = &pb.Friend_List_Rsp{ - List: list, - } + rsp = &pb.Friend_List_Rsp{ + List: list, + } + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_List, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return } - session.SendMsg(string(this.module.GetType()), Friend_SubType_List, rsp) }() - err := this.module.model_friend.GetObj(session.GetUserId(), self) - if self == nil || err != nil { - code = pb.ErrorCode_FriendSelfNoData - return - } - - for _, userId := range self.FriendIds { - list = append(list, &pb.FriendBase{ - UserId: userId, - }) + if v, ok := chk["self"]; ok { + self = v.(*pb.DB_FriendData) + for _, userId := range self.FriendIds { + list = append(list, &pb.FriendBase{ + UserId: userId, + }) + } } return diff --git a/modules/friend/api_refuse.go b/modules/friend/api_refuse.go index bd1272aba..d42b00acb 100644 --- a/modules/friend/api_refuse.go +++ b/modules/friend/api_refuse.go @@ -44,8 +44,12 @@ func (this *ApiComp) Refuse(session comm.IUserSession, chk map[string]interface{ rsp = &pb.Friend_Refuse_Rsp{ Num: optNum, } - - session.SendMsg(string(this.module.GetType()), Friend_SubType_Refuse, rsp) + + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_Refuse, rsp) + if err != nil { + code = pb.ErrorCode_SystemError + return + } }() if v, ok := chk["self"]; !ok { diff --git a/modules/friend/api_search.go b/modules/friend/api_search.go index c0b50b879..d9ef64eb8 100644 --- a/modules/friend/api_search.go +++ b/modules/friend/api_search.go @@ -6,6 +6,10 @@ import ( ) 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 + } return } diff --git a/modules/model_comp.go b/modules/model_comp.go index 8db82d068..3e310db2c 100644 --- a/modules/model_comp.go +++ b/modules/model_comp.go @@ -44,6 +44,11 @@ func (this *Model_Comp) Start() (err error) { err = this.ModuleCompBase.Start() return } + +func (this *Model_Comp) ukey(uid string) string { + return fmt.Sprintf("%s:%s", this.TableName, uid) +} + func (this *Model_Comp) InsertModelLogs(table string, uID string, target interface{}) (err error) { data := &comm.Autogenerated{ @@ -103,7 +108,7 @@ func (this *Model_Comp) UpdateModelLogs(table string, uID string, where bson.M, //data 值允许protobuf格式的对象 // attrs 操作可选项目 eg.传入WithDisabledMgoLog() 表示关闭日志,否则开启;WithND() 传入表示插入操作,不传表示更新,前提不能传入传入WithDisabledMgoLog() func (this *Model_Comp) SetObj(uid string, data proto.Message, attrs ...*cache.OperationAttr) error { - err := this.Redis.Set(fmt.Sprintf("%s:%s", this.TableName, uid), data, 0) + err := this.Redis.Set(this.ukey(uid), data, 0) if err != nil { log.Errorf("set err:%v", err) return err @@ -118,7 +123,7 @@ func (this *Model_Comp) SetObj(uid string, data proto.Message, attrs ...*cache.O // attrs 操作可选项目 eg.传入WithDisabledMgoLog() 表示关闭日志,否则开启;WithND() 传入表示插入操作,不传表示更新,前提不能传入传入WithDisabledMgoLog() //如果更新数据,uid作为where条件之一,如果检索结果不能确定唯一,此时data 必需是map[string]interface{}类型,必需包含_id 字段 func (this *Model_Comp) SetHM(uid string, data interface{}, attrs ...*cache.OperationAttr) error { - err := this.Redis.HMSet(fmt.Sprintf("%s:%s", this.TableName, uid), data) + err := this.Redis.HMSet(this.ukey(uid), data) if err != nil { log.Errorf("SetHM err: %v", err) return err @@ -130,7 +135,7 @@ func (this *Model_Comp) SetHM(uid string, data interface{}, attrs ...*cache.Oper //缓存一个字段的数据 //如果更新数据,uid作为where条件之一,如果检索结果不能确定唯一,此时data 必需是map[string]interface{}类型,必需包含_id 字段 func (this *Model_Comp) SetH(uid string, field string, data interface{}, attrs ...*cache.OperationAttr) error { - err := this.Redis.HSet(fmt.Sprintf("%s:%s", this.TableName, uid), field, data) + err := this.Redis.HSet(this.ukey(uid), field, data) if err != nil { log.Errorf("SetH err %v", err) return err @@ -140,7 +145,7 @@ func (this *Model_Comp) SetH(uid string, field string, data interface{}, attrs . //获取缓存JSON数据 func (this *Model_Comp) GetObj(uid string, v proto.Message) error { - err := this.Redis.Get(fmt.Sprintf("%s:%s", this.TableName, uid), v) + err := this.Redis.Get(this.ukey(uid), v) if err != nil { if err == redis.RedisNil { //query from mgo @@ -164,34 +169,77 @@ func (this *Model_Comp) GetObj(uid string, v proto.Message) error { return err } -//获取对象数据 -//data +//获取对象所有字段数据 +//data类型map或protobuf func (this *Model_Comp) GetHM(uid string, data interface{}) error { - return this.Redis.HGetAll(fmt.Sprintf("%s:%s", this.TableName, uid), data) + ok, err := this.Redis.ExistsKey(this.ukey(uid)) + if err != nil { + log.Errorf("key no exist %v", this.ukey(uid)) + return err + } + if ok { + return this.Redis.HGetAll(this.ukey(uid), data) + } else { + filter := bson.M{"uid": uid} + c, err2 := this.DB.Find(core.SqlTable(this.TableName), filter) + if err2 != nil { + log.Errorf("GetHM-find err:%v", err) + return err + } + err2 = c.Decode(data) + if err2 != nil { + log.Errorf("GetHM-find decode err:%v", err) + return err + } + //update cache without mgolog + return this.SetHM(this.ukey(uid), data, cache.WithDisabledMgoLog()) + } + return nil + } //获取字段数据 缓存存储的数据为hashmap时 func (this *Model_Comp) GetH(uid string, field string, v interface{}) error { - return this.Redis.HGet(fmt.Sprintf("%s:%s", this.TableName, uid), field, v) + return this.Redis.HGet(this.ukey(uid), field, v) } //删除一条数据 -func (this *Model_Comp) Del(uid string) error { - err := this.Redis.HDel(fmt.Sprintf("%s:%s", this.TableName, uid)) +func (this *Model_Comp) DelH(uid string) error { + err := this.Redis.HDel(this.ukey(uid)) if err != nil { log.Errorf("del err:%v", err) return err } - return this.DeleteModelLogs(this.TableName, uid, bson.M{"_id": uid}) + return this.DeleteModelLogs(this.TableName, uid, bson.M{"uid": uid}) +} + +//删除缓存字段 +func (this *Model_Comp) DelHF(uid string, fields ...string) error { + err := this.Redis.HDel(this.ukey(uid), fields...) + if err != nil { + log.Errorf("DelHF err: %v", err) + return err + } + + //get new data after delete + data := make(map[string]interface{}) + err = this.Redis.HGetAll(this.ukey(uid), data) + if err != nil { + log.Errorf("DelHF-HGetAll err: %v", err) + return err + } + + //cache with mgolog + return this.SetHM(this.ukey(uid), data) } //日志操作可选项 func (this *Model_Comp) logOpt(uid string, data interface{}, attrs ...*cache.OperationAttr) error { ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil) - if ret == nil { + if ret == nil { //启用mgolog ir := cache.OperationAttrs(attrs).Find(cache.ATTR_INSERT).Unwrap_Or(nil) - if ir != nil && ir.(bool) { + if ir == nil { //updte opt where := bson.M{"uid": uid} if reflect.ValueOf(data).Kind() == reflect.Map { if m, ok := data.(map[string]interface{}); ok { @@ -201,7 +249,7 @@ func (this *Model_Comp) logOpt(uid string, data interface{}, attrs ...*cache.Ope } } return this.UpdateModelLogs(this.TableName, uid, where, data) - } else { + } else { //insert opt return this.InsertModelLogs(this.TableName, uid, data) } } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 730d6ff0c..02c9aec68 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -26,7 +26,7 @@ const ( ErrorCode_Success ErrorCode = 0 //成功 ErrorCode_NoFindService ErrorCode = 10 //没有找到远程服务器 ErrorCode_NoFindServiceHandleFunc ErrorCode = 11 //远程服务器未找到执行方法 - ErrorCode_RpcFuncExecutionError ErrorCode = 12 //Rpc方法执行错误 + ErrorCode_RpcFuncExecutionError ErrorCode = 12 // Rpc方法执行错误 ErrorCode_CacheReadError ErrorCode = 13 //缓存读取失败 ErrorCode_SqlExecutionError ErrorCode = 14 //数据库执行错误 ErrorCode_ReqParameterError ErrorCode = 15 //请求参数错误 @@ -38,21 +38,22 @@ const ( ErrorCode_DBError ErrorCode = 21 // 数据库操作失败 ErrorCode_SystemError ErrorCode = 22 // 通用错误 ErrorCode_Exception ErrorCode = 100 //程序执行异常 - //user + // user ErrorCode_SecKeyInvalid ErrorCode = 1000 //秘钥无效 ErrorCode_SecKey ErrorCode = 1001 //秘钥格式错误 - //friend - ErrorCode_FriendNotSelf ErrorCode = 1100 //不能是自己 - ErrorCode_FriendSelfMax ErrorCode = 1101 //超出好友最大数量 - ErrorCode_FriendTargetMax ErrorCode = 1102 //超出目标好友最大数量 - ErrorCode_FriendSelfNoData ErrorCode = 1103 //无好友记录 - ErrorCode_FriendTargetNoData ErrorCode = 1104 //无目标好友记录 - ErrorCode_FriendYet ErrorCode = 1105 //已是好友 - ErrorCode_FriendApplyYet ErrorCode = 1106 //已申请该好友 - ErrorCode_FriendSelfBlackYet ErrorCode = 1107 //已在自己黑名单中 - ErrorCode_FriendTargetBlackYet ErrorCode = 1108 //已在对方的黑名单中 - ErrorCode_FriendApplyError ErrorCode = 1109 //申请失败 - ErrorCode_FriendBlackMax ErrorCode = 1110 //黑名单最大数量 + // friend + ErrorCode_FriendNotSelf ErrorCode = 1100 //不能是自己 + ErrorCode_FriendSelfMax ErrorCode = 1101 //超出好友最大数量 + ErrorCode_FriendTargetMax ErrorCode = 1102 //超出目标好友最大数量 + ErrorCode_FriendSelfNoData ErrorCode = 1103 //无好友记录 + ErrorCode_FriendTargetNoData ErrorCode = 1104 //无目标好友记录 + ErrorCode_FriendYet ErrorCode = 1105 //已是好友 + ErrorCode_FriendApplyYet ErrorCode = 1106 //已申请该好友 + ErrorCode_FriendSelfBlackYet ErrorCode = 1107 //已在自己黑名单中 + ErrorCode_FriendTargetBlackYet ErrorCode = 1108 //已在对方的黑名单中 + ErrorCode_FriendApplyError ErrorCode = 1109 //申请失败 + ErrorCode_FriendBlackMax ErrorCode = 1110 //黑名单最大数量 + ErrorCode_FriendSearchNameEmpty ErrorCode = 1111 //查询昵称为空 ) // Enum value maps for ErrorCode. @@ -86,6 +87,7 @@ var ( 1108: "FriendTargetBlackYet", 1109: "FriendApplyError", 1110: "FriendBlackMax", + 1111: "FriendSearchNameEmpty", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -116,6 +118,7 @@ var ( "FriendTargetBlackYet": 1108, "FriendApplyError": 1109, "FriendBlackMax": 1110, + "FriendSearchNameEmpty": 1111, } ) @@ -150,7 +153,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xc9, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xe5, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -186,8 +189,10 @@ var file_errorcode_proto_rawDesc = []byte{ 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x12, 0x1a, 0x0a, + 0x15, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, + 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index d7baebfa0..69bbe94f2 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -1,38 +1,38 @@ syntax = "proto3"; option go_package = ".;pb"; - enum ErrorCode { - Success = 0; //成功 - NoFindService = 10; //没有找到远程服务器 - NoFindServiceHandleFunc = 11; //远程服务器未找到执行方法 - RpcFuncExecutionError = 12; //Rpc方法执行错误 - CacheReadError = 13; //缓存读取失败 - SqlExecutionError = 14; //数据库执行错误 - ReqParameterError = 15; //请求参数错误 - SignError = 16; //签名错误 - InsufficientPermissions = 17; //权限不足 - NoLogin = 18; //未登录 - UserSessionNobeing = 19; //用户不存在 - StateInvalid = 20; //无效状态 - DBError = 21; // 数据库操作失败 - SystemError = 22; // 通用错误 - Exception = 100; //程序执行异常 + Success = 0; //成功 + NoFindService = 10; //没有找到远程服务器 + NoFindServiceHandleFunc = 11; //远程服务器未找到执行方法 + RpcFuncExecutionError = 12; // Rpc方法执行错误 + CacheReadError = 13; //缓存读取失败 + SqlExecutionError = 14; //数据库执行错误 + ReqParameterError = 15; //请求参数错误 + SignError = 16; //签名错误 + InsufficientPermissions = 17; //权限不足 + NoLogin = 18; //未登录 + UserSessionNobeing = 19; //用户不存在 + StateInvalid = 20; //无效状态 + DBError = 21; // 数据库操作失败 + SystemError = 22; // 通用错误 + Exception = 100; //程序执行异常 - //user - SecKeyInvalid = 1000; //秘钥无效 - SecKey = 1001; //秘钥格式错误 + // user + SecKeyInvalid = 1000; //秘钥无效 + SecKey = 1001; //秘钥格式错误 - //friend - FriendNotSelf = 1100; //不能是自己 - FriendSelfMax = 1101; //超出好友最大数量 - FriendTargetMax = 1102;//超出目标好友最大数量 - FriendSelfNoData = 1103; //无好友记录 - FriendTargetNoData = 1104; //无目标好友记录 - FriendYet = 1105; //已是好友 - FriendApplyYet =1106; //已申请该好友 - FriendSelfBlackYet = 1107;//已在自己黑名单中 - FriendTargetBlackYet = 1108;//已在对方的黑名单中 - FriendApplyError = 1109;//申请失败 - FriendBlackMax = 1110; //黑名单最大数量 + // friend + FriendNotSelf = 1100; //不能是自己 + FriendSelfMax = 1101; //超出好友最大数量 + FriendTargetMax = 1102; //超出目标好友最大数量 + FriendSelfNoData = 1103; //无好友记录 + FriendTargetNoData = 1104; //无目标好友记录 + FriendYet = 1105; //已是好友 + FriendApplyYet = 1106; //已申请该好友 + FriendSelfBlackYet = 1107; //已在自己黑名单中 + FriendTargetBlackYet = 1108; //已在对方的黑名单中 + FriendApplyError = 1109; //申请失败 + FriendBlackMax = 1110; //黑名单最大数量 + FriendSearchNameEmpty = 1111; //查询昵称为空 } \ No newline at end of file diff --git a/sys/cache/optionAttr.go b/sys/cache/optionAttr.go index 39a8745cb..2b175ac92 100644 --- a/sys/cache/optionAttr.go +++ b/sys/cache/optionAttr.go @@ -42,6 +42,6 @@ func WithDisabledMgoLog() *OperationAttr { func WithND() *OperationAttr { return &OperationAttr{ Name: ATTR_INSERT, - Value: true, + Value: empty{}, } }