Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
# Conflicts: # pb.bat # pb/friend_db.pb.go # pb/pack_db.pb.go
This commit is contained in:
commit
cb0576aaee
@ -8,15 +8,17 @@ import (
|
|||||||
|
|
||||||
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
||||||
switch msg.SubType {
|
switch msg.SubType {
|
||||||
case "add":
|
case "apply":
|
||||||
r.handleFriendAdd(msg)
|
r.handleFriendApply(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加好友
|
//添加好友
|
||||||
func (r *Robot) FriendAdd() {
|
func (r *Robot) FriendApply(friendId string) {
|
||||||
req := &pb.FriendAddReq{}
|
req := &pb.FriendApplyReq{
|
||||||
head := &pb.UserMessage{MainType: "friend", SubType: "add"}
|
FriendId: friendId,
|
||||||
|
}
|
||||||
|
head := &pb.UserMessage{MainType: "friend", SubType: "apply"}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -24,8 +26,8 @@ func (r *Robot) FriendAdd() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Robot) handleFriendAdd(msg *pb.UserMessage) {
|
func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
|
||||||
rsp := &pb.FriendAddRsp{}
|
rsp := &pb.FriendApplyRsp{}
|
||||||
if !comm.ProtoDecode(msg, rsp) {
|
if !comm.ProtoDecode(msg, rsp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
func (r *Robot) handlePackMsg(msg *pb.UserMessage) {
|
func (r *Robot) handlePackMsg(msg *pb.UserMessage) {
|
||||||
switch msg.SubType {
|
switch msg.SubType {
|
||||||
case "queryuserpackresp":
|
case "queryuserpackresp":
|
||||||
r.handleFriendAdd(msg)
|
r.handleQueryUserPack(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,3 +10,51 @@ go run cmd.go run --account yourAccount
|
|||||||
#使用新账号测试接口
|
#使用新账号测试接口
|
||||||
go run cmd.go run --account newAccount --create true
|
go run cmd.go run --account newAccount --create true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@[TOC]
|
||||||
|
|
||||||
|
|
||||||
|
### 添加测试接口
|
||||||
|
|
||||||
|
* 请求的方法
|
||||||
|
|
||||||
|
```go
|
||||||
|
// 好友申请,参数根据实际业务添加
|
||||||
|
func (r *Robot) FriendApply(friendIds []string) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
* 响应的方法
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 添加subType,调用响应方法
|
||||||
|
|
||||||
|
```go
|
||||||
|
//根据实际情况添加subtype
|
||||||
|
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
||||||
|
switch msg.SubType {
|
||||||
|
case "apply":
|
||||||
|
//调用响应
|
||||||
|
r.handleFriendApply(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 修改请求方法调用
|
||||||
|
|
||||||
|
```go
|
||||||
|
func (r *Robot) onUserLoaded() {
|
||||||
|
switch msg.MainType {
|
||||||
|
case "user":
|
||||||
|
r.handleUserMsg(msg)
|
||||||
|
case "friend":
|
||||||
|
r.handleFriendMsg(msg)
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
@ -82,8 +82,11 @@ func (r *Robot) onUserLoaded() {
|
|||||||
r.CreateUser("user671")
|
r.CreateUser("user671")
|
||||||
|
|
||||||
//friend
|
//friend
|
||||||
// r.FriendAdd()
|
r.FriendApply("629f147e3d276120561bfa18")
|
||||||
|
|
||||||
|
//pack
|
||||||
r.QueryUserPack()
|
r.QueryUserPack()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error {
|
func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error {
|
||||||
|
@ -3,12 +3,28 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/cache"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
Friend_SubType_Apply = "apply"
|
||||||
|
Friend_SubType_ApplyList = "applylist"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FriendComp struct {
|
type FriendComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MComp_GateComp
|
||||||
|
module *Friend
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *FriendComp) 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
|
||||||
}
|
}
|
||||||
|
|
||||||
//搜索
|
//搜索
|
||||||
@ -16,16 +32,133 @@ func (this *FriendComp) Search(ctx context.Context, session comm.IUserSession, r
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加好友
|
//好友申请
|
||||||
func (this *FriendComp) Apply(ctx context.Context, session comm.IUserSession, req *pb.FriendAddReq) error {
|
func (this *FriendComp) Apply(ctx context.Context, session comm.IUserSession, req *pb.FriendApplyReq) (err error) {
|
||||||
//判断是否超过最大好友数量
|
var (
|
||||||
//判断对方是否也超过最大好友数量
|
code pb.ErrorCode
|
||||||
//判断是否是自己
|
self *pb.Cache_FriendData
|
||||||
//判断是否是好友
|
target *pb.Cache_FriendData
|
||||||
//判断是否已经申请
|
rsp *pb.FriendApplyRsp
|
||||||
//判断是否在黑名单中
|
)
|
||||||
//判断是否在对方的黑名单中
|
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), Friend_SubType_Apply, req, rsp)
|
||||||
|
}()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if code == pb.ErrorCode_Success {
|
||||||
|
rsp = &pb.FriendApplyRsp{
|
||||||
|
UserId: session.GetUserId(),
|
||||||
|
FriendId: req.FriendId,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_Apply, code, rsp)
|
||||||
|
}()
|
||||||
|
|
||||||
|
self, err = cache.Defsys.Friend_Get(session.GetUserId())
|
||||||
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
target, err = cache.Defsys.Friend_Get(req.FriendId)
|
||||||
|
if target == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendTargetNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否是自己
|
||||||
|
if req.FriendId == session.GetUserId() {
|
||||||
|
code = pb.ErrorCode_FriendNotSelf
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否超过最大好友数量
|
||||||
|
//TODO 最大数从全局配置中获取
|
||||||
|
var max int32 = 50
|
||||||
|
total := cache.Defsys.Friend_Total(session.GetUserId())
|
||||||
|
if total >= max {
|
||||||
|
code = pb.ErrorCode_FriendSelfMax
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断对方是否也超过最大好友数量
|
||||||
|
ttotal := cache.Defsys.Friend_Total(req.FriendId)
|
||||||
|
if ttotal >= max {
|
||||||
|
code = pb.ErrorCode_FriendTargetMax
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否是好友
|
||||||
|
if _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
|
||||||
|
code = pb.ErrorCode_FriendYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断自己是否在目标用户的申请列表中
|
||||||
|
if _, ok := utils.Find(target.ApplyIds, self.UserId); ok {
|
||||||
|
code = pb.ErrorCode_FriendApplyYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断目标用户是否在黑名单中
|
||||||
|
if _, ok := utils.Find(self.BlackIds, req.FriendId); ok {
|
||||||
|
code = pb.ErrorCode_FriendSelfBlackYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//判断是否在对方的黑名单中
|
||||||
|
if _, ok := utils.Find(target.BlackIds, self.UserId); ok {
|
||||||
|
code = pb.ErrorCode_FriendTargetBlackYet
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//将自己加入到目标用户的申请列表中
|
||||||
|
target.ApplyIds = append(target.ApplyIds, self.UserId)
|
||||||
|
err = cache.Defsys.Friend_Apply(&pb.Cache_FriendData{
|
||||||
|
UserId: req.FriendId,
|
||||||
|
ApplyIds: target.ApplyIds,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("firend Apply err:%v", err)
|
||||||
|
code = pb.ErrorCode_FriendApplyError
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//申请列表
|
||||||
|
func (this *FriendComp) ApplyList(ctx context.Context, session comm.IUserSession, req *pb.FriendApplyListReq) (err error) {
|
||||||
|
var (
|
||||||
|
code pb.ErrorCode
|
||||||
|
self *pb.Cache_FriendData
|
||||||
|
rsp *pb.FriendApplyListRsp
|
||||||
|
list []*pb.FriendBase
|
||||||
|
)
|
||||||
|
|
||||||
|
self, err = cache.Defsys.Friend_Get(session.GetUserId())
|
||||||
|
if self == nil || err != nil {
|
||||||
|
code = pb.ErrorCode_FriendSelfNoData
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if code == pb.ErrorCode_Success {
|
||||||
|
rsp = &pb.FriendApplyListRsp{
|
||||||
|
List: list,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
session.SendMsg(string(this.module.GetType()), Friend_SubType_ApplyList, code, rsp)
|
||||||
|
}()
|
||||||
|
|
||||||
|
for _, userId := range self.ApplyIds {
|
||||||
|
//TODO 组装FriendBase明细数据
|
||||||
|
list = append(list, &pb.FriendBase{
|
||||||
|
UserId: userId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -40,13 +173,14 @@ func (this *FriendComp) List(ctx context.Context, session comm.IUserSession, req
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//同意或拒绝
|
//单个/批量同意
|
||||||
func (this *FriendComp) Check(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error {
|
func (this *FriendComp) Agree(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//批量同意或拒绝
|
//单个/批量拒绝
|
||||||
func (this *FriendComp) CheckAll(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error {
|
func (this *FriendComp) Refuse(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ type LoginComp struct {
|
|||||||
modules.MComp_GateComp
|
modules.MComp_GateComp
|
||||||
}
|
}
|
||||||
|
|
||||||
func DecodeUserData(base64Str string) *pb.DB_UserData {
|
|
||||||
//解码
|
//解码
|
||||||
|
func decodeUserData(base64Str string) *pb.DB_UserData {
|
||||||
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
|
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("base64 decode err %v", err)
|
log.Errorf("base64 decode err %v", err)
|
||||||
@ -44,17 +44,30 @@ func DecodeUserData(base64Str string) *pb.DB_UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//登录
|
//登录
|
||||||
func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error {
|
func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) (err error) {
|
||||||
log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req)
|
var (
|
||||||
var code pb.ErrorCode = pb.ErrorCode_Success
|
code pb.ErrorCode
|
||||||
|
db_user *pb.DB_UserData
|
||||||
|
)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
session.SendMsg("user", "login", code, &pb.UserLoginResp{
|
||||||
|
Data: &pb.Cache_UserData{
|
||||||
|
UserData: db_user,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
event.TriggerEvent(comm.Event_UserLogin, db_user.UserId)
|
||||||
|
}()
|
||||||
|
|
||||||
if !utils.ValidSecretKey(req.Sec) {
|
if !utils.ValidSecretKey(req.Sec) {
|
||||||
session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, nil)
|
code = pb.ErrorCode_SecKeyInvalid
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user := DecodeUserData(req.Sec)
|
user := decodeUserData(req.Sec)
|
||||||
|
|
||||||
db_user, err := db.Defsys.User_FindUserByAccount(user)
|
db_user, err = db.Defsys.User_FindByAccount(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
return err
|
return err
|
||||||
@ -63,10 +76,10 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
|||||||
|
|
||||||
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
|
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
|
||||||
if db_user == nil {
|
if db_user == nil {
|
||||||
err = db.Defsys.User_CreateUser(user)
|
err = db.Defsys.User_Create(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("User_CreateUser err %v", err)
|
log.Errorf("User_CreateUser err %v", err)
|
||||||
return err
|
return
|
||||||
}
|
}
|
||||||
session.Build(user.UserId)
|
session.Build(user.UserId)
|
||||||
} else {
|
} else {
|
||||||
@ -84,16 +97,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = session.SendMsg("user", "login", code, &pb.UserLoginResp{
|
return
|
||||||
Data: &pb.Cache_UserData{
|
|
||||||
UserData: db_user,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
event.TriggerEvent(comm.Event_UserLogin, db_user.UserId)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//注销
|
//注销
|
||||||
|
@ -25,21 +25,24 @@ func (this *UserComp) Init(service core.IService, module core.IModule, comp core
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创角
|
//创角
|
||||||
func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) error {
|
func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) (err error) {
|
||||||
defer utils.TraceFunc(session.GetUserId(), "user", "create", req, nil)
|
defer utils.TraceFunc(session.GetUserId(), "user", "create", req, nil)
|
||||||
user := cache.Defsys.Get(session.GetUserId())
|
user := cache.Defsys.Get(session.GetUserId())
|
||||||
|
var code pb.ErrorCode
|
||||||
|
defer func() {
|
||||||
|
session.SendMsg("user", "create", code, &pb.UserCreateRsp{})
|
||||||
|
}()
|
||||||
if user == nil {
|
if user == nil {
|
||||||
log.Errorf("user no exist")
|
log.Errorf("user no exist")
|
||||||
session.SendMsg("user", "create", pb.ErrorCode_UserSessionNobeing, nil)
|
code = pb.ErrorCode_UserSessionNobeing
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user.UserData.NiceName = req.NickName
|
user.UserData.NiceName = req.NickName
|
||||||
err := cache.Defsys.Update(user)
|
err = cache.Defsys.Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("cache update err")
|
log.Errorf("cache update err")
|
||||||
}
|
}
|
||||||
event.RegisterGO(comm.Event_CreateUser, session.GetUserId())
|
event.RegisterGO(comm.Event_CreateUser, session.GetUserId())
|
||||||
session.SendMsg("user", "create", pb.ErrorCode_Success, &pb.UserCreateRsp{})
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func (this *Api_Comp) Register(c *engine.Context) {
|
|||||||
rsp := &pb.UserRegisterRsp{}
|
rsp := &pb.UserRegisterRsp{}
|
||||||
err := c.BindJSON(&req)
|
err := c.BindJSON(&req)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err := db.Defsys.User_CreateUser(&pb.DB_UserData{
|
err := db.Defsys.User_Create(&pb.DB_UserData{
|
||||||
Account: req.Account,
|
Account: req.Account,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
29
pb.bat
29
pb.bat
@ -1,18 +1,27 @@
|
|||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
|
set PROJECT_ROOT=.\
|
||||||
|
|
||||||
set PROJECT_ROOT=.
|
set PROJECT_ROOT=.
|
||||||
|
|
||||||
set SRC=%PROJECT_ROOT%\pb\proto
|
set SRC=%PROJECT_ROOT%\pb\proto
|
||||||
set TAR=%PROJECT_ROOT%\pb
|
set TAR=%PROJECT_ROOT%\pb
|
||||||
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/comm.proto
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/errorcode.proto
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/friend/friend_db.proto
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/friend/friend_msg.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\*.proto
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/mail/mail_db.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\friend\*.proto
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/mail/mail_msg.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\pack\*.proto
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/pack/pack_db.proto
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/pack/pack_msg.proto
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/user/user_db.proto
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import ./pb/proto/user/user_msg.proto
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=source_relative %SRC%\*.proto
|
||||||
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=source_relative %SRC%\*.proto
|
||||||
|
|
||||||
pause
|
pause
|
@ -33,11 +33,23 @@ const (
|
|||||||
ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足
|
ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足
|
||||||
ErrorCode_NoLogin ErrorCode = 17 //未登录
|
ErrorCode_NoLogin ErrorCode = 17 //未登录
|
||||||
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
||||||
ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误
|
|
||||||
ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效
|
|
||||||
ErrorCode_StateInvalid ErrorCode = 21 //无效状态
|
ErrorCode_StateInvalid ErrorCode = 21 //无效状态
|
||||||
ErrorCode_DBError ErrorCode = 22 // 数据库操作失败
|
ErrorCode_DBError ErrorCode = 22 // 数据库操作失败
|
||||||
ErrorCode_SystemError ErrorCode = 23 // 通用错误
|
ErrorCode_SystemError ErrorCode = 23 // 通用错误
|
||||||
|
//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 //申请失败
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for ErrorCode.
|
// Enum value maps for ErrorCode.
|
||||||
@ -53,11 +65,21 @@ var (
|
|||||||
16: "InsufficientPermissions",
|
16: "InsufficientPermissions",
|
||||||
17: "NoLogin",
|
17: "NoLogin",
|
||||||
18: "UserSessionNobeing",
|
18: "UserSessionNobeing",
|
||||||
19: "SecKey",
|
|
||||||
20: "SecKeyInvalid",
|
|
||||||
21: "StateInvalid",
|
21: "StateInvalid",
|
||||||
22: "DBError",
|
22: "DBError",
|
||||||
23: "SystemError",
|
23: "SystemError",
|
||||||
|
1000: "SecKeyInvalid",
|
||||||
|
1001: "SecKey",
|
||||||
|
1100: "FriendNotSelf",
|
||||||
|
1101: "FriendSelfMax",
|
||||||
|
1102: "FriendTargetMax",
|
||||||
|
1103: "FriendSelfNoData",
|
||||||
|
1104: "FriendTargetNoData",
|
||||||
|
1105: "FriendYet",
|
||||||
|
1106: "FriendApplyYet",
|
||||||
|
1107: "FriendSelfBlackYet",
|
||||||
|
1108: "FriendTargetBlackYet",
|
||||||
|
1109: "FriendApplyError",
|
||||||
}
|
}
|
||||||
ErrorCode_value = map[string]int32{
|
ErrorCode_value = map[string]int32{
|
||||||
"Success": 0,
|
"Success": 0,
|
||||||
@ -70,11 +92,21 @@ var (
|
|||||||
"InsufficientPermissions": 16,
|
"InsufficientPermissions": 16,
|
||||||
"NoLogin": 17,
|
"NoLogin": 17,
|
||||||
"UserSessionNobeing": 18,
|
"UserSessionNobeing": 18,
|
||||||
"SecKey": 19,
|
|
||||||
"SecKeyInvalid": 20,
|
|
||||||
"StateInvalid": 21,
|
"StateInvalid": 21,
|
||||||
"DBError": 22,
|
"DBError": 22,
|
||||||
"SystemError": 23,
|
"SystemError": 23,
|
||||||
|
"SecKeyInvalid": 1000,
|
||||||
|
"SecKey": 1001,
|
||||||
|
"FriendNotSelf": 1100,
|
||||||
|
"FriendSelfMax": 1101,
|
||||||
|
"FriendTargetMax": 1102,
|
||||||
|
"FriendSelfNoData": 1103,
|
||||||
|
"FriendTargetNoData": 1104,
|
||||||
|
"FriendYet": 1105,
|
||||||
|
"FriendApplyYet": 1106,
|
||||||
|
"FriendSelfBlackYet": 1107,
|
||||||
|
"FriendTargetBlackYet": 1108,
|
||||||
|
"FriendApplyError": 1109,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -109,7 +141,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_errorcode_proto_rawDesc = []byte{
|
var file_errorcode_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x6f, 0x2a, 0xa8, 0x02, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
0x6f, 0x2a, 0x88, 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,
|
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,
|
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
||||||
0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
|
0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
|
||||||
@ -122,12 +154,26 @@ var file_errorcode_proto_rawDesc = []byte{
|
|||||||
0x6e, 0x73, 0x75, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69,
|
0x6e, 0x73, 0x75, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69,
|
||||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x10, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x6f, 0x4c, 0x6f,
|
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x10, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x6f, 0x4c, 0x6f,
|
||||||
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||||
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a,
|
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x10, 0x0a,
|
||||||
0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x63,
|
0x0c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x15, 0x12,
|
||||||
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c,
|
0x0b, 0x0a, 0x07, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0f, 0x0a, 0x0b,
|
||||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x15, 0x12, 0x0b,
|
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x17, 0x12, 0x12, 0x0a,
|
||||||
0x0a, 0x07, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0f, 0x0a, 0x0b, 0x53,
|
0x0d, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8,
|
||||||
0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x17, 0x42, 0x06, 0x5a, 0x04,
|
0x07, 0x12, 0x0b, 0x0a, 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x12,
|
||||||
|
0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10,
|
||||||
|
0xcc, 0x08, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66,
|
||||||
|
0x4d, 0x61, 0x78, 0x10, 0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
|
0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10,
|
||||||
|
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61,
|
||||||
|
0x10, 0xcf, 0x08, 0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72,
|
||||||
|
0x67, 0x65, 0x74, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09,
|
||||||
|
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e,
|
||||||
|
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2,
|
||||||
|
0x08, 0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42,
|
||||||
|
0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72,
|
||||||
|
0x69, 0x65, 0x6e, 0x64, 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, 0x42, 0x06, 0x5a, 0x04,
|
||||||
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,12 @@ type Cache_FriendData struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` //tags:{bson:"_id"}用户Id
|
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id
|
||||||
FriendId []string `protobuf:"bytes,2,rep,name=friendId,proto3" json:"friendId,omitempty"`
|
FriendId []string `protobuf:"bytes,2,rep,name=friendId,proto3" json:"friendId,omitempty"`
|
||||||
|
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty" bson:"_id"` // ID
|
||||||
|
FriendIds []string `protobuf:"bytes,2,rep,name=friendIds,proto3" json:"friendIds,omitempty"` //好友ID
|
||||||
|
ApplyIds []string `protobuf:"bytes,3,rep,name=applyIds,proto3" json:"applyIds,omitempty"` //申请用户ID
|
||||||
|
BlackIds []string `protobuf:"bytes,4,rep,name=blackIds,proto3" json:"blackIds,omitempty"` //黑名单ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Cache_FriendData) Reset() {
|
func (x *Cache_FriendData) Reset() {
|
||||||
@ -69,8 +73,24 @@ func (x *Cache_FriendData) GetUserId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *Cache_FriendData) GetFriendId() []string {
|
func (x *Cache_FriendData) GetFriendId() []string {
|
||||||
|
func (x *Cache_FriendData) GetFriendIds() []string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.FriendId
|
return x.FriendId
|
||||||
|
return x.FriendIds
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Cache_FriendData) GetApplyIds() []string {
|
||||||
|
if x != nil {
|
||||||
|
return x.ApplyIds
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *Cache_FriendData) GetBlackIds() []string {
|
||||||
|
if x != nil {
|
||||||
|
return x.BlackIds
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -85,6 +105,16 @@ var file_friend_friend_db_proto_rawDesc = []byte{
|
|||||||
0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64,
|
0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64,
|
||||||
0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64,
|
0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64,
|
||||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
|
0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x10, 0x43, 0x61, 0x63,
|
||||||
|
0x68, 0x65, 0x5f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a,
|
||||||
|
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75,
|
||||||
|
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49,
|
||||||
|
0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
|
0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x64, 0x73, 0x18,
|
||||||
|
0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x64, 0x73, 0x12,
|
||||||
|
0x1a, 0x0a, 0x08, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28,
|
||||||
|
0x09, 0x52, 0x08, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||||
|
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -201,8 +201,8 @@ func (x *FriendListRsp) GetList() []*Cache_FriendData {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加好友
|
//申请好友
|
||||||
type FriendAddReq struct {
|
type FriendApplyReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
@ -210,8 +210,8 @@ type FriendAddReq struct {
|
|||||||
FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` //好友ID
|
FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` //好友ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendAddReq) Reset() {
|
func (x *FriendApplyReq) Reset() {
|
||||||
*x = FriendAddReq{}
|
*x = FriendApplyReq{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_friend_friend_msg_proto_msgTypes[3]
|
mi := &file_friend_friend_msg_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -219,13 +219,13 @@ func (x *FriendAddReq) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendAddReq) String() string {
|
func (x *FriendApplyReq) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*FriendAddReq) ProtoMessage() {}
|
func (*FriendApplyReq) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *FriendAddReq) ProtoReflect() protoreflect.Message {
|
func (x *FriendApplyReq) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_friend_friend_msg_proto_msgTypes[3]
|
mi := &file_friend_friend_msg_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -237,28 +237,29 @@ func (x *FriendAddReq) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use FriendAddReq.ProtoReflect.Descriptor instead.
|
// Deprecated: Use FriendApplyReq.ProtoReflect.Descriptor instead.
|
||||||
func (*FriendAddReq) Descriptor() ([]byte, []int) {
|
func (*FriendApplyReq) Descriptor() ([]byte, []int) {
|
||||||
return file_friend_friend_msg_proto_rawDescGZIP(), []int{3}
|
return file_friend_friend_msg_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendAddReq) GetFriendId() string {
|
func (x *FriendApplyReq) GetFriendId() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.FriendId
|
return x.FriendId
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
type FriendAddRsp struct {
|
type FriendApplyRsp struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` //用户ID
|
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` //用户ID
|
||||||
|
FriendId string `protobuf:"bytes,2,opt,name=friendId,proto3" json:"friendId,omitempty"` //好友ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendAddRsp) Reset() {
|
func (x *FriendApplyRsp) Reset() {
|
||||||
*x = FriendAddRsp{}
|
*x = FriendApplyRsp{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_friend_friend_msg_proto_msgTypes[4]
|
mi := &file_friend_friend_msg_proto_msgTypes[4]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -266,13 +267,13 @@ func (x *FriendAddRsp) Reset() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendAddRsp) String() string {
|
func (x *FriendApplyRsp) String() string {
|
||||||
return protoimpl.X.MessageStringOf(x)
|
return protoimpl.X.MessageStringOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*FriendAddRsp) ProtoMessage() {}
|
func (*FriendApplyRsp) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *FriendAddRsp) ProtoReflect() protoreflect.Message {
|
func (x *FriendApplyRsp) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_friend_friend_msg_proto_msgTypes[4]
|
mi := &file_friend_friend_msg_proto_msgTypes[4]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
@ -284,18 +285,25 @@ func (x *FriendAddRsp) ProtoReflect() protoreflect.Message {
|
|||||||
return mi.MessageOf(x)
|
return mi.MessageOf(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated: Use FriendAddRsp.ProtoReflect.Descriptor instead.
|
// Deprecated: Use FriendApplyRsp.ProtoReflect.Descriptor instead.
|
||||||
func (*FriendAddRsp) Descriptor() ([]byte, []int) {
|
func (*FriendApplyRsp) Descriptor() ([]byte, []int) {
|
||||||
return file_friend_friend_msg_proto_rawDescGZIP(), []int{4}
|
return file_friend_friend_msg_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendAddRsp) GetUserId() string {
|
func (x *FriendApplyRsp) GetUserId() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.UserId
|
return x.UserId
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *FriendApplyRsp) GetFriendId() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.FriendId
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
//删除好友
|
//删除好友
|
||||||
type FriendDelReq struct {
|
type FriendDelReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -553,6 +561,8 @@ type FriendApplyListRsp struct {
|
|||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
List []*FriendBase `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FriendApplyListRsp) Reset() {
|
func (x *FriendApplyListRsp) Reset() {
|
||||||
@ -587,6 +597,13 @@ func (*FriendApplyListRsp) Descriptor() ([]byte, []int) {
|
|||||||
return file_friend_friend_msg_proto_rawDescGZIP(), []int{10}
|
return file_friend_friend_msg_proto_rawDescGZIP(), []int{10}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *FriendApplyListRsp) GetList() []*FriendBase {
|
||||||
|
if x != nil {
|
||||||
|
return x.List
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
//好友搜索
|
//好友搜索
|
||||||
type FriendSearchReq struct {
|
type FriendSearchReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -1124,12 +1141,14 @@ var file_friend_friend_msg_proto_rawDesc = []byte{
|
|||||||
0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x25,
|
0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x25,
|
||||||
0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x43,
|
0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x43,
|
||||||
0x61, 0x63, 0x68, 0x65, 0x5f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52,
|
0x61, 0x63, 0x68, 0x65, 0x5f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52,
|
||||||
0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2a, 0x0a, 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41,
|
0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2c, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41,
|
||||||
0x64, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49,
|
0x70, 0x70, 0x6c, 0x79, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e,
|
||||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49,
|
0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e,
|
||||||
0x64, 0x22, 0x26, 0x0a, 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x52, 0x73,
|
0x64, 0x49, 0x64, 0x22, 0x44, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70,
|
||||||
0x70, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x6c, 0x79, 0x52, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18,
|
||||||
0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2a, 0x0a, 0x0c, 0x46, 0x72, 0x69,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a,
|
||||||
|
0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
|
0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x2a, 0x0a, 0x0c, 0x46, 0x72, 0x69,
|
||||||
0x65, 0x6e, 0x64, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69,
|
0x65, 0x6e, 0x64, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69,
|
||||||
0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69,
|
0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69,
|
||||||
0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x42, 0x0a, 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44,
|
0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x42, 0x0a, 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44,
|
||||||
@ -1147,49 +1166,52 @@ var file_friend_friend_msg_proto_rawDesc = []byte{
|
|||||||
0x05, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65,
|
0x05, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65,
|
||||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65, 0x65,
|
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65, 0x65,
|
||||||
0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c,
|
0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c,
|
||||||
0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x35, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x22, 0x49, 0x0a, 0x0f,
|
0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x04,
|
||||||
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x12,
|
0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69,
|
||||||
0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x49, 0x0a,
|
||||||
0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e,
|
0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71,
|
||||||
0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e,
|
|
||||||
0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x38, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
|
||||||
0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66, 0x72,
|
|
||||||
0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72,
|
|
||||||
0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
|
||||||
0x73, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b,
|
|
||||||
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x3b, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
|
||||||
0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x25, 0x0a,
|
|
||||||
0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b,
|
|
||||||
0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69,
|
|
||||||
0x65, 0x6e, 0x64, 0x73, 0x22, 0x2f, 0x0a, 0x11, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c,
|
|
||||||
0x61, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69,
|
|
||||||
0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69,
|
|
||||||
0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x11, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42,
|
|
||||||
0x6c, 0x61, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72,
|
|
||||||
0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72,
|
|
||||||
0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
|
|
||||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x52,
|
|
||||||
0x0a, 0x16, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f,
|
|
||||||
0x72, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65,
|
|
||||||
0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65,
|
|
||||||
0x6e, 0x64, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76,
|
|
||||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69,
|
|
||||||
0x76, 0x65, 0x22, 0x6a, 0x0a, 0x16, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x63, 0x65,
|
|
||||||
0x69, 0x76, 0x65, 0x4f, 0x72, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08,
|
|
||||||
0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
|
||||||
0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72,
|
|
||||||
0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
|
|
||||||
0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20,
|
|
||||||
0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x22, 0x2c,
|
|
||||||
0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x71,
|
|
||||||
0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||||
0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x42, 0x0a, 0x0e,
|
0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08,
|
||||||
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x73, 0x70, 0x12, 0x1a,
|
0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||||
0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x38, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65,
|
||||||
0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f,
|
0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66,
|
||||||
0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c,
|
0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46,
|
||||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e,
|
||||||
|
0x64, 0x73, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63,
|
||||||
|
0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x3b, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65,
|
||||||
|
0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x25,
|
||||||
|
0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
|
||||||
|
0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72,
|
||||||
|
0x69, 0x65, 0x6e, 0x64, 0x73, 0x22, 0x2f, 0x0a, 0x11, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42,
|
||||||
|
0x6c, 0x61, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72,
|
||||||
|
0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72,
|
||||||
|
0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x47, 0x0a, 0x11, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
|
0x42, 0x6c, 0x61, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66,
|
||||||
|
0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66,
|
||||||
|
0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49,
|
||||||
|
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22,
|
||||||
|
0x52, 0x0a, 0x16, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
|
||||||
|
0x4f, 0x72, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69,
|
||||||
|
0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69,
|
||||||
|
0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69,
|
||||||
|
0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65,
|
||||||
|
0x69, 0x76, 0x65, 0x22, 0x6a, 0x0a, 0x16, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x63,
|
||||||
|
0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a,
|
||||||
|
0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
|
0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65,
|
||||||
|
0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49,
|
||||||
|
0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x18, 0x03,
|
||||||
|
0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x22,
|
||||||
|
0x2c, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65,
|
||||||
|
0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20,
|
||||||
|
0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x42, 0x0a,
|
||||||
|
0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x73, 0x70, 0x12,
|
||||||
|
0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
|
0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74,
|
||||||
|
0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61,
|
||||||
|
0x6c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
|
0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -1209,8 +1231,8 @@ var file_friend_friend_msg_proto_goTypes = []interface{}{
|
|||||||
(*FriendBase)(nil), // 0: FriendBase
|
(*FriendBase)(nil), // 0: FriendBase
|
||||||
(*FriendListReq)(nil), // 1: FriendListReq
|
(*FriendListReq)(nil), // 1: FriendListReq
|
||||||
(*FriendListRsp)(nil), // 2: FriendListRsp
|
(*FriendListRsp)(nil), // 2: FriendListRsp
|
||||||
(*FriendAddReq)(nil), // 3: FriendAddReq
|
(*FriendApplyReq)(nil), // 3: FriendApplyReq
|
||||||
(*FriendAddRsp)(nil), // 4: FriendAddRsp
|
(*FriendApplyRsp)(nil), // 4: FriendApplyRsp
|
||||||
(*FriendDelReq)(nil), // 5: FriendDelReq
|
(*FriendDelReq)(nil), // 5: FriendDelReq
|
||||||
(*FriendDelRsp)(nil), // 6: FriendDelRsp
|
(*FriendDelRsp)(nil), // 6: FriendDelRsp
|
||||||
(*FriendAgreeOrRefuseReq)(nil), // 7: FriendAgreeOrRefuseReq
|
(*FriendAgreeOrRefuseReq)(nil), // 7: FriendAgreeOrRefuseReq
|
||||||
@ -1231,13 +1253,14 @@ var file_friend_friend_msg_proto_goTypes = []interface{}{
|
|||||||
}
|
}
|
||||||
var file_friend_friend_msg_proto_depIdxs = []int32{
|
var file_friend_friend_msg_proto_depIdxs = []int32{
|
||||||
21, // 0: FriendListRsp.list:type_name -> Cache_FriendData
|
21, // 0: FriendListRsp.list:type_name -> Cache_FriendData
|
||||||
0, // 1: FriendSearchRsp.friends:type_name -> FriendBase
|
0, // 1: FriendApplyListRsp.list:type_name -> FriendBase
|
||||||
0, // 2: FriendBlackListRsp.friends:type_name -> FriendBase
|
0, // 2: FriendSearchRsp.friends:type_name -> FriendBase
|
||||||
3, // [3:3] is the sub-list for method output_type
|
0, // 3: FriendBlackListRsp.friends:type_name -> FriendBase
|
||||||
3, // [3:3] is the sub-list for method input_type
|
4, // [4:4] is the sub-list for method output_type
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
4, // [4:4] is the sub-list for method input_type
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
4, // [4:4] is the sub-list for extension type_name
|
||||||
0, // [0:3] is the sub-list for field type_name
|
4, // [4:4] is the sub-list for extension extendee
|
||||||
|
0, // [0:4] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_friend_friend_msg_proto_init() }
|
func init() { file_friend_friend_msg_proto_init() }
|
||||||
@ -1284,7 +1307,7 @@ func file_friend_friend_msg_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_friend_friend_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
file_friend_friend_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*FriendAddReq); i {
|
switch v := v.(*FriendApplyReq); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
@ -1296,7 +1319,7 @@ func file_friend_friend_msg_proto_init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_friend_friend_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
file_friend_friend_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*FriendAddRsp); i {
|
switch v := v.(*FriendApplyRsp); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -106,7 +106,9 @@ type DB_UserPackData struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty"` //tags:{bson:"_id"}用户Id
|
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id
|
||||||
|
Pack []*DB_GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||||
|
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` // 用户Id
|
||||||
Pack []*DB_GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
Pack []*DB_GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,10 +13,23 @@ enum ErrorCode {
|
|||||||
InsufficientPermissions = 16; //权限不足
|
InsufficientPermissions = 16; //权限不足
|
||||||
NoLogin = 17; //未登录
|
NoLogin = 17; //未登录
|
||||||
UserSessionNobeing = 18; //用户不存在
|
UserSessionNobeing = 18; //用户不存在
|
||||||
SecKey = 19; //秘钥格式错误
|
|
||||||
SecKeyInvalid = 20; //秘钥无效
|
|
||||||
StateInvalid = 21; //无效状态
|
StateInvalid = 21; //无效状态
|
||||||
DBError = 22; // 数据库操作失败
|
DBError = 22; // 数据库操作失败
|
||||||
SystemError = 23; // 通用错误
|
SystemError = 23; // 通用错误
|
||||||
|
|
||||||
|
//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;//申请失败
|
||||||
}
|
}
|
@ -3,6 +3,9 @@ option go_package = ".;pb";
|
|||||||
|
|
||||||
|
|
||||||
message Cache_FriendData {
|
message Cache_FriendData {
|
||||||
string userId = 1; //tags:{bson:"_id"}用户Id
|
string userId = 1;// @go_tags(`json:"userId,omitempty" bson:"_id"`) ID
|
||||||
repeated string friendId = 2;
|
repeated string friendIds = 2; //好友ID
|
||||||
|
repeated string applyIds = 3;//申请用户ID
|
||||||
|
repeated string blackIds = 4;//黑名单ID
|
||||||
|
|
||||||
}
|
}
|
@ -21,12 +21,13 @@ message FriendListRsp{
|
|||||||
repeated Cache_FriendData list = 1;
|
repeated Cache_FriendData list = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加好友
|
//申请好友
|
||||||
message FriendAddReq{
|
message FriendApplyReq{
|
||||||
string friendId = 1; //好友ID
|
string friendId = 1; //好友ID
|
||||||
}
|
}
|
||||||
message FriendAddRsp{
|
message FriendApplyRsp{
|
||||||
string userId = 1; //用户ID
|
string userId = 1; //用户ID
|
||||||
|
string friendId =2;//好友ID
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除好友
|
//删除好友
|
||||||
@ -57,7 +58,7 @@ message FriendApplyListReq{
|
|||||||
|
|
||||||
}
|
}
|
||||||
message FriendApplyListRsp{
|
message FriendApplyListRsp{
|
||||||
|
repeated FriendBase list = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友搜索
|
//好友搜索
|
||||||
|
@ -13,6 +13,6 @@ message DB_GridData {
|
|||||||
|
|
||||||
//用户背包
|
//用户背包
|
||||||
message DB_UserPackData {
|
message DB_UserPackData {
|
||||||
string UserId = 1; //tags:{bson:"_id"}用户Id
|
string UserId = 1; // @go_tags(`bson:"_id"`) 用户Id
|
||||||
repeated DB_GridData Pack = 2; //背包列表
|
repeated DB_GridData Pack = 2; //背包列表
|
||||||
}
|
}
|
42
sys/cache/friend.go
vendored
42
sys/cache/friend.go
vendored
@ -2,35 +2,57 @@ package cache
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go_dreamfactory/lego/sys/redis"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ( //Redis
|
const ( //Redis
|
||||||
Redis_FriendCache string = "friend:%s"
|
Redis_FriendCache string = "friend:%s"
|
||||||
|
Redis_Friend string = "apply:%s"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getRdsUserKey(userId string) string {
|
func getRdsFriendKey(userId string) string {
|
||||||
return fmt.Sprintf(Redis_UserCache, userId)
|
return fmt.Sprintf(Redis_FriendCache, userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
type IFriend interface {
|
type IFriend interface {
|
||||||
FriendAdd(data *pb.Cache_FriendData) (err error)
|
Friend_Apply(data *pb.Cache_FriendData) (err error)
|
||||||
FriendGetTotal(userId string) int32
|
Friend_Total(userId string) int32
|
||||||
|
Friend_Get(userId string) (*pb.Cache_FriendData, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Cache) FriendAdd(data *pb.Cache_FriendData) (err error) {
|
//好友申请
|
||||||
if err = db.Defsys.FriendApply(data); err == nil {
|
func (this *Cache) Friend_Apply(data *pb.Cache_FriendData) (err error) {
|
||||||
err = this.redis.Set(fmt.Sprintf(Redis_FriendCache, data.UserId), data, 0)
|
if err = db.Defsys.Friend_Apply(data); err == nil {
|
||||||
|
err = this.redis.Set(getRdsFriendKey(data.UserId), data, 0)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Cache) FriendGetTotal(userId string) int32 {
|
//好友总数
|
||||||
|
func (this *Cache) Friend_Total(userId string) int32 {
|
||||||
var friend *pb.Cache_FriendData
|
var friend *pb.Cache_FriendData
|
||||||
err := this.redis.Get(getRdsUserKey(userId), &friend)
|
err := this.redis.Get(getRdsFriendKey(userId), &friend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return int32(len(friend.FriendId))
|
return int32(len(friend.FriendIds))
|
||||||
|
}
|
||||||
|
|
||||||
|
//好友获取
|
||||||
|
func (this *Cache) Friend_Get(userId string) (*pb.Cache_FriendData, error) {
|
||||||
|
var d *pb.Cache_FriendData
|
||||||
|
err := this.redis.Get(getRdsFriendKey(userId), &d)
|
||||||
|
if err != nil {
|
||||||
|
if err.Error() == string(redis.RedisNil) {
|
||||||
|
d = &pb.Cache_FriendData{UserId: userId}
|
||||||
|
err = this.Friend_Apply(d)
|
||||||
|
if err != nil {
|
||||||
|
return d, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return d, nil
|
||||||
}
|
}
|
||||||
|
17
sys/cache/friend_test.go
vendored
17
sys/cache/friend_test.go
vendored
@ -9,16 +9,23 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFriendAdd(t *testing.T) {
|
func TestFriendApply(t *testing.T) {
|
||||||
err := cache.Defsys.FriendAdd(&pb.Cache_FriendData{
|
err := cache.Defsys.Friend_Apply(&pb.Cache_FriendData{
|
||||||
UserId: "629f159310d6970846f7ef26",
|
UserId: "629f159310d6970846f7ef26",
|
||||||
FriendId: []string{"629f147e3d276120561bfa18", "629eb3f4132dc4bb26139659"},
|
FriendIds: []string{"629f147e3d276120561bfa18"},
|
||||||
|
ApplyIds: []string{"629eb3f4132dc4bb26139659"},
|
||||||
})
|
})
|
||||||
|
|
||||||
require.Nil(t, err, nil)
|
require.Nil(t, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFriendGetTotal(t *testing.T) {
|
func TestFriendGetTotal(t *testing.T) {
|
||||||
total := cache.Defsys.FriendGetTotal("629f159310d6970846f7ef26")
|
total := cache.Defsys.Friend_Total("629f159310d6970846f7ef26")
|
||||||
assert.Equal(t, total, int32(1))
|
assert.Equal(t, total, int32(2))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFriendGet(t *testing.T) {
|
||||||
|
data, err := cache.Defsys.Friend_Get("629f159310d6970846f7ef26")
|
||||||
|
require.NotNil(t, err, nil)
|
||||||
|
assert.Equal(t, data.UserId, "629f159310d6970846f7ef26")
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,13 +14,21 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type IFriend interface {
|
type IFriend interface {
|
||||||
FriendApply(data *pb.Cache_FriendData) error
|
Friend_Apply(data *pb.Cache_FriendData) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DB) FriendApply(data *pb.Cache_FriendData) error {
|
//好友申请
|
||||||
err := this.mgo.FindOneAndUpdate(DB_FriendTable,
|
func (this *DB) Friend_Apply(data *pb.Cache_FriendData) (err error) {
|
||||||
|
err = this.mgo.FindOneAndUpdate(DB_FriendTable,
|
||||||
bson.M{"_id": data.UserId},
|
bson.M{"_id": data.UserId},
|
||||||
bson.M{"$set": bson.M{"friendid": data.FriendId}},
|
bson.M{"$set": bson.M{
|
||||||
|
"friendids": data.FriendIds,
|
||||||
|
"applyids": data.ApplyIds}},
|
||||||
options.FindOneAndUpdate().SetUpsert(true)).Err()
|
options.FindOneAndUpdate().SetUpsert(true)).Err()
|
||||||
return err
|
if err != nil {
|
||||||
|
if err == mongo.ErrNoDocuments {
|
||||||
|
_, err = this.mgo.InsertOne(DB_FriendTable, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestFriendAdd(t *testing.T) {
|
func TestFriendAdd(t *testing.T) {
|
||||||
err := db.FriendApply(&pb.Cache_FriendData{
|
err := db.Friend_Apply(&pb.Cache_FriendData{
|
||||||
UserId: "629f159310d6970846f7ef26",
|
UserId: "629f159310d6970846f7ef26",
|
||||||
FriendId: []string{
|
FriendIds: []string{
|
||||||
"629f147e3d276120561bfa18",
|
"629f147e3d276120561bfa18",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -15,16 +15,17 @@ const ( //Redis
|
|||||||
)
|
)
|
||||||
|
|
||||||
type IUser interface {
|
type IUser interface {
|
||||||
User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error)
|
User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error)
|
||||||
User_FindUserById(id string) (*pb.DB_UserData, error)
|
User_FindById(id string) (*pb.DB_UserData, error)
|
||||||
User_CreateUser(user *pb.DB_UserData) error
|
User_Create(user *pb.DB_UserData) error
|
||||||
User_UpdateUser(data *pb.DB_UserData) (err error)
|
User_Update(data *pb.DB_UserData) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DB) User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) {
|
//
|
||||||
filter := bson.D{
|
func (this *DB) User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) {
|
||||||
{"serverid", user.ServerId},
|
filter := bson.M{
|
||||||
{"account", user.Account},
|
"serverid": user.ServerId,
|
||||||
|
"account": user.Account,
|
||||||
}
|
}
|
||||||
sr := this.mgo.FindOne(DB_UserTable, filter)
|
sr := this.mgo.FindOne(DB_UserTable, filter)
|
||||||
var nd *pb.DB_UserData
|
var nd *pb.DB_UserData
|
||||||
@ -32,9 +33,9 @@ func (this *DB) User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, e
|
|||||||
return nd, err
|
return nd, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) {
|
func (this *DB) User_FindById(id string) (*pb.DB_UserData, error) {
|
||||||
filter := bson.D{
|
filter := bson.M{
|
||||||
{"_id", id},
|
"_id": id,
|
||||||
}
|
}
|
||||||
sr := this.mgo.FindOne(DB_UserTable, filter)
|
sr := this.mgo.FindOne(DB_UserTable, filter)
|
||||||
user := &pb.DB_UserData{}
|
user := &pb.DB_UserData{}
|
||||||
@ -42,14 +43,14 @@ func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) {
|
|||||||
return user, err
|
return user, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *DB) User_CreateUser(user *pb.DB_UserData) (err error) {
|
func (this *DB) User_Create(user *pb.DB_UserData) (err error) {
|
||||||
user.UserId = primitive.NewObjectID().Hex()
|
user.UserId = primitive.NewObjectID().Hex()
|
||||||
_, err = this.mgo.InsertOne(DB_UserTable, user)
|
_, err = this.mgo.InsertOne(DB_UserTable, user)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//更新用户数据到DB
|
//更新用户数据到DB
|
||||||
func (this *DB) User_UpdateUser(data *pb.DB_UserData) (err error) {
|
func (this *DB) User_Update(data *pb.DB_UserData) (err error) {
|
||||||
err = this.mgo.FindOneAndUpdate(
|
err = this.mgo.FindOneAndUpdate(
|
||||||
DB_UserTable,
|
DB_UserTable,
|
||||||
bson.M{"_id": data.UserId},
|
bson.M{"_id": data.UserId},
|
||||||
|
@ -16,17 +16,17 @@ func TestCreate(t *testing.T) {
|
|||||||
ServerId: 1,
|
ServerId: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.User_CreateUser(user)
|
err := db.User_Create(user)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindOne(t *testing.T) {
|
func TestFindOne(t *testing.T) {
|
||||||
user, err := db.User_FindUserById("629eb3f4132dc4bb26139659")
|
user, err := db.User_FindById("629eb3f4132dc4bb26139659")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, "legu3", user.Account)
|
assert.Equal(t, "legu3", user.Account)
|
||||||
|
|
||||||
// user.ServerId = 2
|
// user.ServerId = 2
|
||||||
user2, err := db.User_FindUserByAccount(user)
|
user2, err := db.User_FindByAccount(user)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, "legu3", user2.Account)
|
assert.Equal(t, "legu3", user2.Account)
|
||||||
assert.Equal(t, int32(1), user2.ServerId)
|
assert.Equal(t, int32(1), user2.ServerId)
|
||||||
@ -36,7 +36,7 @@ func TestUpdate(t *testing.T) {
|
|||||||
user := &pb.DB_UserData{
|
user := &pb.DB_UserData{
|
||||||
UserId: primitive.NewObjectID().Hex(),
|
UserId: primitive.NewObjectID().Hex(),
|
||||||
}
|
}
|
||||||
err := db.User_UpdateUser(user)
|
err := db.User_Update(user)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "NiceName", "")
|
assert.Equal(t, "NiceName", "")
|
||||||
|
@ -20,6 +20,7 @@ func Base64Decode(data string) string {
|
|||||||
return string(b)
|
return string(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//校验加密串
|
||||||
func ValidSecretKey(secStr string) bool {
|
func ValidSecretKey(secStr string) bool {
|
||||||
if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 {
|
if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 {
|
||||||
return false
|
return false
|
||||||
@ -29,7 +30,6 @@ func ValidSecretKey(secStr string) bool {
|
|||||||
rawmsg := secStr[35:]
|
rawmsg := secStr[35:]
|
||||||
log.Debugf("data base: %s", rawmsg)
|
log.Debugf("data base: %s", rawmsg)
|
||||||
serverMd5Key := MD5Str(rawmsg)
|
serverMd5Key := MD5Str(rawmsg)
|
||||||
// s := fmt.Sprintf("%x", serverMd5Key)
|
|
||||||
if !strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) {
|
if !strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -15,3 +15,13 @@ func ParseP(p string) (string, string, bool) {
|
|||||||
|
|
||||||
return s[0], s[1], true
|
return s[0], s[1], true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func Find(slice []string, val string) (int, bool) {
|
||||||
|
for i, item := range slice {
|
||||||
|
if item == val {
|
||||||
|
return i, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1, false
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user