This commit is contained in:
liwei1dao 2022-06-13 10:19:19 +08:00
commit a309fe9a47
44 changed files with 1986 additions and 721 deletions

View File

@ -2,21 +2,36 @@ package robot
import (
"go_dreamfactory/comm"
"go_dreamfactory/modules/friend"
"go_dreamfactory/pb"
"log"
)
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
switch msg.SubType {
case "add":
r.handleFriendAdd(msg)
case friend.Friend_SubType_Apply:
r.handleFriendApply(msg)
case friend.Friend_SubType_ApplyList:
r.handleFriendApplyList(msg)
case friend.Friend_SubType_Agree:
r.handleFriendAgree(msg)
case friend.Friend_SubType_Refuse:
r.handleFriendRefuse(msg)
case friend.Friend_SubType_Blacklist:
r.handleFriendBlacklist(msg)
case friend.Friend_SubType_AddBlack:
r.handleFriendAddBlack(msg)
case friend.Friend_SubType_DelBlack:
r.handleFriendDelBlack(msg)
case friend.Friend_SubType_Search:
r.handleFriendSearch(msg)
}
}
//添加好友
func (r *Robot) FriendAdd() {
req := &pb.FriendAddReq{}
head := &pb.UserMessage{MainType: "friend", SubType: "add"}
//好友列表
func (r *Robot) FriendList() {
req := &pb.FriendListReq{}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_List}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
@ -24,8 +39,170 @@ func (r *Robot) FriendAdd() {
}
}
func (r *Robot) handleFriendAdd(msg *pb.UserMessage) {
rsp := &pb.FriendAddRsp{}
func (r *Robot) handleFriendList(msg *pb.UserMessage) {
rsp := &pb.FriendListRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//好友搜索
func (r *Robot) FriendSearch(nickName string) {
req := &pb.FriendSearchReq{
NickName: nickName,
}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Search}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendSearch(msg *pb.UserMessage) {
rsp := &pb.FriendSearchRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//好友申请
func (r *Robot) FriendApply(friendId string) {
req := &pb.FriendApplyReq{
FriendId: friendId,
}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
rsp := &pb.FriendApplyRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//申请列表
func (r *Robot) FriendApplyList() {
req := &pb.FriendApplyListReq{}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendApplyList(msg *pb.UserMessage) {
rsp := &pb.FriendApplyListRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//同意
func (r *Robot) FriendAgree(friendIds []string) {
req := &pb.FriendAgreeReq{
FriendIds: friendIds,
}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendAgree(msg *pb.UserMessage) {
rsp := &pb.FriendAgreeRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//拒绝
func (r *Robot) FriendRefuse(friendIds []string) {
req := &pb.FriendRefuseReq{
FriendIds: friendIds,
}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Refuse}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendRefuse(msg *pb.UserMessage) {
rsp := &pb.FriendRefuseRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//黑名单列表
func (r *Robot) FriendBlacklist() {
req := &pb.FriendBlackListReq{}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Blacklist}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendBlacklist(msg *pb.UserMessage) {
rsp := &pb.FriendBlackListRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//添加黑名单
func (r *Robot) FriendAddBlack() {
req := &pb.FriendBlackAddReq{}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_AddBlack}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendAddBlack(msg *pb.UserMessage) {
rsp := &pb.FriendBlackAddRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}
printReply(msg, rsp)
}
//删除黑名单
func (r *Robot) FriendDelBlack(friendId string) {
req := &pb.FriendDelBlackReq{
FriendId: friendId,
}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_DelBlack}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
err := r.SendToClient(head, req)
if err != nil {
log.Fatal(err)
}
}
func (r *Robot) handleFriendDelBlack(msg *pb.UserMessage) {
rsp := &pb.FriendDelBlackRsp{}
if !comm.ProtoDecode(msg, rsp) {
return
}

View File

@ -9,7 +9,7 @@ import (
func (r *Robot) handlePackMsg(msg *pb.UserMessage) {
switch msg.SubType {
case "queryuserpackresp":
r.handleFriendAdd(msg)
r.handleQueryUserPack(msg)
}
}

View File

@ -10,3 +10,51 @@ go run cmd.go run --account yourAccount
#使用新账号测试接口
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)
...
}
```

View File

@ -9,9 +9,9 @@ import (
"log"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/gorilla/websocket"
jsoniter "github.com/json-iterator/go"
"google.golang.org/protobuf/proto"
)
type Robot struct {
@ -79,11 +79,22 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
//在这里添加玩家成功登录以后的测试方法
func (r *Robot) onUserLoaded() {
//user
r.CreateUser("user671")
// r.CreateUser("乐谷4")
//friend
// r.FriendAdd()
r.QueryUserPack()
// r.FriendApply("629f147e3d276120561bfa18")
// r.FriendAgree([]string{})
// r.FriendRefuse([]string{})
// r.FriendApplyList()
// r.FriendList()
// r.FriendBlacklist()
// r.FriendAddBlack()
// r.FriendDelBlack("")
r.FriendSearch("乐谷5")
//pack
// r.QueryUserPack()
}
func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error {
@ -134,10 +145,12 @@ func (r *Robot) AccountRegister() {
}
}
//打印响应
func printReply(msg *pb.UserMessage, rsp interface{}) {
log.Printf("rsp [%s.%s] [%d] [%v]", msg.MainType, msg.SubType, msg.Code, rsp)
}
//方法参数跟踪
func traceFunc(module string, funcName string, uid string, funcArgs interface{}) {
log.Printf("req [%s.%s] [%s] [%v]", module, funcName, uid, funcArgs)
}

View File

@ -2,6 +2,7 @@ package robot
import (
"go_dreamfactory/comm"
"go_dreamfactory/modules/user"
"go_dreamfactory/pb"
"log"
)
@ -40,8 +41,8 @@ func (r *Robot) CreateUser(NickName string) {
}
head := &pb.UserMessage{
MainType: "user",
SubType: "create",
MainType: string(comm.SM_UserModule),
SubType: user.User_SubType_Create,
}
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)

View File

@ -7,7 +7,8 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"google.golang.org/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
)
const (
@ -68,7 +69,7 @@ type IUserSession interface {
}
func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
err := proto.Unmarshal(msg.Data, req)
err := ptypes.UnmarshalAny(msg.Data, req)
if err != nil {
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
return
@ -77,7 +78,7 @@ func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
}
func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
data, err := proto.Marshal(rsp)
data, err := ptypes.MarshalAny(rsp)
if err != nil {
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
return

View File

@ -8,7 +8,8 @@ import (
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/sys/log"
"google.golang.org/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
)
/*
@ -86,7 +87,7 @@ func (this *UserSession) UnBind() (err error) {
//向用户发送消息
func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) {
reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg)
data, _ := ptypes.MarshalAny(msg)
log.Debugf("SendMsg to SessionId:[%s] UserId:[%s] Code:%d Data: %v", this.UserId, code, msg)
if err := this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{
UserSessionId: this.SessionId,

1
go.mod
View File

@ -7,6 +7,7 @@ require (
github.com/go-playground/validator/v10 v10.10.1
github.com/go-redis/redis/v8 v8.11.5
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/golang/protobuf v1.5.2
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/consul/api v1.12.0
github.com/json-iterator/go v1.1.12

View File

@ -3,30 +3,192 @@ package friend
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db"
"go_dreamfactory/utils"
)
const (
Friend_SubType_List = "list"
Friend_SubType_Apply = "apply"
Friend_SubType_ApplyList = "applylist"
Friend_SubType_AddBlack = "addblack"
Friend_SubType_DelBlack = "delblack"
Friend_SubType_Blacklist = "blacklist"
Friend_SubType_Agree = "agree"
Friend_SubType_Refuse = "refuse"
Friend_SubType_Search = "search"
)
type FriendComp struct {
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
}
//搜索
func (this *FriendComp) Search(ctx context.Context, session comm.IUserSession, req *pb.FriendSearchReq) error {
var (
code pb.ErrorCode
rsp *pb.FriendSearchRsp
friend *pb.FriendBase
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendSearchRsp{
Friend: friend,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_Search, code, rsp)
}()
user := db.Defsys.Frined_FindCond(req.NickName)
if user != nil {
friend = &pb.FriendBase{
UserId: user.UserId,
NickName: user.NiceName,
}
}
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_Update(&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
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendApplyListRsp{
List: list,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_ApplyList, code, rsp)
}()
self, err = cache.Defsys.Friend_Get(session.GetUserId())
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
for _, userId := range self.ApplyIds {
//TODO 组装FriendBase明细数据
list = append(list, &pb.FriendBase{
UserId: userId,
})
}
return nil
}
@ -36,27 +198,142 @@ func (this *FriendComp) Del(ctx context.Context, session comm.IUserSession, req
}
//好友列表
func (this *FriendComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) error {
func (this *FriendComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) (err error) {
var (
code pb.ErrorCode
self *pb.Cache_FriendData
rsp *pb.FriendListRsp
list []*pb.FriendBase
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendListRsp{
List: list,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_List, code, rsp)
}()
self, err = cache.Defsys.Friend_Get(session.GetUserId())
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
for _, userId := range self.FriendIds {
list = append(list, &pb.FriendBase{
UserId: userId,
})
}
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.FriendAgreeReq) (err error) {
var (
code pb.ErrorCode
self *pb.Cache_FriendData
rsp *pb.FriendAgreeRsp
optNum int32
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendAgreeRsp{
Num: optNum,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_Agree, code, rsp)
}()
self, err = cache.Defsys.Friend_Get(session.GetUserId())
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
//将申请人加入到自己的好友列表中
for _, userId := range req.FriendIds {
if _, ok := utils.Find(self.FriendIds, userId); !ok {
self.FriendIds = append(self.FriendIds, userId)
}
}
//将自己加入到申请人的好友列表中
for _, userId := range req.FriendIds {
target, err2 := cache.Defsys.Friend_Get(userId)
if target == nil || err2 != nil {
code = pb.ErrorCode_FriendTargetNoData
continue
}
if _, ok := utils.Find(target.FriendIds, self.UserId); !ok {
target.FriendIds = append(target.FriendIds, self.UserId)
}
err = cache.Defsys.Friend_Update(target)
if err != nil {
code = pb.ErrorCode_DBError
return
}
}
//将申请人从申请列表中删除
for _, userId := range req.FriendIds {
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
optNum++
}
//更新
err = cache.Defsys.Friend_Update(self)
if err != nil {
code = pb.ErrorCode_DBError
return
}
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.FriendRefuseReq) (err error) {
//将申请人从申请列表中删除
var (
code pb.ErrorCode
self *pb.Cache_FriendData
rsp *pb.FriendAgreeRsp
optNum int32
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendAgreeRsp{
Num: optNum,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_Refuse, code, rsp)
}()
self, err = cache.Defsys.Friend_Get(session.GetUserId())
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
//将申请人从申请列表中删除
for _, userId := range req.FriendIds {
self.ApplyIds = utils.DeleteString(self.ApplyIds, userId)
optNum++
}
//更新
err = cache.Defsys.Friend_Update(self)
if err != nil {
code = pb.ErrorCode_DBError
return
}
return nil
}
//赠送或接收
func (this *FriendComp) ReceSend(ctx context.Context, session comm.IUserSession, req *pb.FriendReceiveOrSendReq) error {
return nil
}
//好友数量
func (this *FriendComp) Total(ctx context.Context, session comm.IUserSession, req *pb.FriendTotalReq) error {
func (this *FriendComp) ReceSend(ctx context.Context, session comm.IUserSession, req *pb.FriendReceiveReq) error {
return nil
}
@ -66,11 +343,129 @@ func (this *FriendComp) Detail(ctx context.Context, session comm.IUserSession, r
}
//黑名单
func (this *FriendComp) Blacklist(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackListReq) error {
func (this *FriendComp) Blacklist(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackListReq) (err error) {
var (
code pb.ErrorCode
self *pb.Cache_FriendData
rsp *pb.FriendBlackListRsp
list []*pb.FriendBase
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendBlackListRsp{
Friends: list,
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_Blacklist, code, rsp)
}()
self, err = cache.Defsys.Friend_Get(session.GetUserId())
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
for _, userId := range self.BlackIds {
//TODO 完善FriendBase信息
list = append(list, &pb.FriendBase{
UserId: userId,
})
}
return nil
}
//加入黑名单
func (this *FriendComp) Addblack(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackAddReq) error {
func (this *FriendComp) Addblack(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackAddReq) (err error) {
var (
code pb.ErrorCode
self *pb.Cache_FriendData
target *pb.Cache_FriendData
rsp *pb.FriendBlackAddRsp
blackNumMax = 50 //TODO 从配置中读取
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendBlackAddRsp{
FriendId: req.FriendId,
UserId: session.GetUserId(),
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, 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 _, ok := utils.Find(self.FriendIds, req.FriendId); ok {
code = pb.ErrorCode_FriendSelfBlackYet
return
}
// 判断自己是否在对方的黑名单中
if _, ok := utils.Find(target.BlackIds, self.UserId); ok {
code = pb.ErrorCode_FriendTargetBlackYet
return
}
// 判断是否黑名单人数已满
if len(self.BlackIds) >= blackNumMax {
code = pb.ErrorCode_FriendBlackMax
return
}
//将目标加入黑名单
self.BlackIds = append(self.BlackIds, req.FriendId)
//更新黑名单
err = cache.Defsys.Friend_Update(self)
if err != nil {
code = pb.ErrorCode_DBError
return
}
return nil
}
//删除黑名单
func (this *FriendComp) delblack(ctx context.Context, session comm.IUserSession, req *pb.FriendDelBlackReq) (err error) {
var (
code pb.ErrorCode
self *pb.Cache_FriendData
rsp *pb.FriendDelBlackRsp
)
defer func() {
if code == pb.ErrorCode_Success {
rsp = &pb.FriendDelBlackRsp{
FriendId: req.FriendId,
UserId: session.GetUserId(),
}
}
session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, code, rsp)
}()
self, err = cache.Defsys.Friend_Get(session.GetUserId())
if self == nil || err != nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
//从黑名单列表中删除目标
self.BlackIds = utils.DeleteString(self.BlackIds, req.FriendId)
//更新黑名单
err = cache.Defsys.Friend_Update(self)
if err != nil {
code = pb.ErrorCode_DBError
return
}
return nil
}

42
modules/mail/api.go Normal file
View File

@ -0,0 +1,42 @@
package mail
import (
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/lego/core"
)
const (
QueryUserMailResp = "queryusermailresp"
ReadUserMailResp = "readusermailresp"
GetUserMailAttachmentResp = "getusermailattachmentresp"
DelUserMailResp = "delusermailresp"
GetNewEMailResp = "getnewEmailresp"
)
type Api_Comp struct {
modules.MComp_GateComp
service core.IService
module *Mail
pack comm.IPack
}
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MComp_GateComp.Init(service, module, comp, options)
this.service = service
this.module = module.(*Mail)
return
}
func (this *Api_Comp) Start() (err error) {
err = this.MComp_GateComp.Start()
var module core.IModule
if module, err = this.service.GetModule(comm.SM_PackModule); err != nil {
return
}
this.pack = module.(comm.IPack)
return
}

View File

@ -1,157 +0,0 @@
package mail
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
)
const (
QueryUserMailResp = "queryusermailresp"
ReadUserMailResp = "readusermailresp"
GetUserMailAttachmentResp = "getusermailattachmentresp"
DelUserMailResp = "delusermailresp"
GetNewEMailResp = "getnewEmailresp"
)
type Api_Comp struct {
modules.MComp_GateComp
service core.IService
module *Mail
pack comm.IPack
}
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MComp_GateComp.Init(service, module, comp, options)
this.service = service
this.module = module.(*Mail)
return
}
func (this *Api_Comp) Start() (err error) {
err = this.MComp_GateComp.Start()
var module core.IModule
if module, err = this.service.GetModule(comm.SM_PackModule); err != nil {
return
}
this.pack = module.(comm.IPack)
return
}
// 查看所有邮件信息
func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailReq) (err error) {
code := pb.ErrorCode_Success
mailinfo := make([]*pb.DB_MailData, 0)
defer func() {
session.SendMsg(string(this.module.GetType()), QueryUserMailResp, code, &pb.QueryUserMailResp{Mails: mailinfo})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
if mailinfo, err = cache.Defsys.QueryUserMail(session.GetUserId()); err != nil {
log.Errorf("QueryUserMailResp err:%v", err)
code = pb.ErrorCode_CacheReadError
return
}
return
}
// 查看某一封邮件
func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailReq) (err error) {
var (
code pb.ErrorCode
mail *pb.DB_MailData
)
defer func() {
session.SendMsg(string(this.module.GetType()), ReadUserMailResp, code, &pb.ReadUserMailResp{Mail: mail})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
mail, err = db.Defsys.Mail_ReadOneMail(req.ObjID)
if err != nil {
code = pb.ErrorCode_ReqParameterError
}
return
}
// 领取附件
func (this *Api_Comp) GetUserMailAttachmentReq(ctx context.Context, session comm.IUserSession, req *pb.GetUserMailAttachmentReq) (err error) {
var (
code pb.ErrorCode
mail *pb.DB_MailData
)
defer func() {
session.SendMsg(string(this.module.GetType()), GetUserMailAttachmentResp, code, &pb.GetUserMailAttachmentResp{Mail: mail})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
_bGet := db.Defsys.Mail_GetMailAttachmentState(req.ObjID)
if !_bGet {
code = pb.ErrorCode_StateInvalid
return
}
_data, err := db.Defsys.Mail_GetMailAttachment(req.ObjID)
if err != nil {
if len(_data) > 0 {
// todo 领取附件
_items := make(map[uint32]uint32, 0)
for _, v := range _data {
_items[v.ItemId] += v.ItemCount
}
// bRet := this.pack.GetRewaredItems(mail.UserId, _items)
// if bRet {
// // 修改状态
// db.Defsys.Mail_UpdateMailAttachmentState(req.ObjID)
// mail.Reward = true
// return
// }
}
code = pb.ErrorCode_SystemError
}
return
}
// 删除邮件
func (this *Api_Comp) DelUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.DelUserMailReq) (err error) {
code := pb.ErrorCode_Success
mailinfo := make([]*pb.DB_MailData, 0)
defer func() {
session.SendMsg(string(this.module.GetType()), DelUserMailResp, code, &pb.DelUserMailResp{Mail: mailinfo})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
bRet := db.Defsys.Mail_DelUserMail(req.ObjID)
if !bRet {
code = pb.ErrorCode_DBError
return
}
if mailinfo, err = cache.Defsys.QueryUserMail(session.GetUserId()); err != nil {
log.Errorf("QueryUserMailResp err:%v", err)
code = pb.ErrorCode_CacheReadError
return
}
return
}

View File

@ -0,0 +1,35 @@
package mail
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
// 删除邮件
func (this *Api_Comp) DelUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.DelUserMailReq) (err error) {
code := pb.ErrorCode_Success
mailinfo := make([]*pb.DB_MailData, 0)
defer func() {
session.SendMsg(string(this.module.GetType()), DelUserMailResp, code, &pb.DelUserMailResp{Mail: mailinfo})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
bRet := db.Defsys.Mail_DelUserMail(req.ObjID)
if !bRet {
code = pb.ErrorCode_DBError
return
}
if mailinfo, err = db.Defsys.Mail_QueryUserMail(session.GetUserId()); err != nil {
log.Errorf("QueryUserMailResp err:%v", err)
code = pb.ErrorCode_CacheReadError
return
}
return
}

View File

@ -0,0 +1,49 @@
package mail
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
// 领取附件
func (this *Api_Comp) GetUserMailAttachmentReq(ctx context.Context, session comm.IUserSession, req *pb.GetUserMailAttachmentReq) (err error) {
var (
code pb.ErrorCode
mail *pb.DB_MailData
)
defer func() {
session.SendMsg(string(this.module.GetType()), GetUserMailAttachmentResp, code, &pb.GetUserMailAttachmentResp{Mail: mail})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
_bGet := db.Defsys.Mail_GetMailAttachmentState(req.ObjID)
if !_bGet {
code = pb.ErrorCode_StateInvalid
return
}
_data, err := db.Defsys.Mail_GetMailAttachment(req.ObjID)
if err != nil {
if len(_data) > 0 {
// todo 领取附件
_items := make(map[int32]int32, 0)
for _, v := range _data {
_items[int32(v.ItemId)] += int32(v.ItemCount)
}
bRet := this.pack.AddItemsToUserPack(mail.UserId, _items)
if bRet != nil {
// 修改状态
db.Defsys.Mail_UpdateMailAttachmentState(req.ObjID)
mail.Reward = true
return
}
}
code = pb.ErrorCode_SystemError
}
return
}

View File

@ -0,0 +1,30 @@
package mail
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
// 查看所有邮件信息
func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailReq) (err error) {
code := pb.ErrorCode_Success
mailinfo := make([]*pb.DB_MailData, 0)
defer func() {
session.SendMsg(string(this.module.GetType()), QueryUserMailResp, code, &pb.QueryUserMailResp{Mails: mailinfo})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
if mailinfo, err = db.Defsys.Mail_QueryUserMail(session.GetUserId()); err != nil {
log.Errorf("QueryUserMailResp err:%v", err)
code = pb.ErrorCode_CacheReadError
return
}
return
}

View File

@ -0,0 +1,30 @@
package mail
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
// 查看某一封邮件
func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailReq) (err error) {
var (
code pb.ErrorCode
mail *pb.DB_MailData
)
defer func() {
session.SendMsg(string(this.module.GetType()), ReadUserMailResp, code, &pb.ReadUserMailResp{Mail: mail})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
mail, err = db.Defsys.Mail_ReadOneMail(req.ObjID)
if err != nil {
code = pb.ErrorCode_ReqParameterError
}
return
}

View File

@ -11,7 +11,8 @@ import (
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"google.golang.org/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
)
/*
@ -32,7 +33,7 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options
//向指定用户发送消息
func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) {
reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg)
data, _ := ptypes.MarshalAny(msg)
if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Gateway, user.GatewayServiceId), string(comm.Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{
UserSessionId: user.SessionId,
MainType: mainType,
@ -59,7 +60,7 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa
gateway = append(gateway, v.SessionId)
}
reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg)
data, _ := ptypes.MarshalAny(msg)
for k, v := range gateways {
if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Gateway, k), string(comm.Rpc_GatewayAgentSendMsg), &pb.BatchMessageReq{
UserSessionIds: v,

View File

@ -22,8 +22,8 @@ type LoginComp struct {
modules.MComp_GateComp
}
func DecodeUserData(base64Str string) *pb.DB_UserData {
//解码
//解码
func decodeUserData(base64Str string) *pb.DB_UserData {
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
if err != nil {
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 {
log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req)
var code pb.ErrorCode = pb.ErrorCode_Success
func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) (err error) {
var (
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) {
session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, nil)
return nil
code = pb.ErrorCode_SecKeyInvalid
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 != mongo.ErrNoDocuments {
return err
@ -63,10 +76,10 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
if db_user == nil {
err = db.Defsys.User_CreateUser(user)
err = db.Defsys.User_Create(user)
if err != nil {
log.Errorf("User_CreateUser err %v", err)
return err
return
}
session.Bind(user.UserId, this.S.GetId())
} else {
@ -84,16 +97,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
return err
}
err = session.SendMsg("user", "login", code, &pb.UserLoginResp{
Data: &pb.Cache_UserData{
UserData: db_user,
},
})
if err != nil {
return err
}
event.TriggerEvent(comm.Event_UserLogin, db_user.UserId)
return nil
return
}
//注销

View File

@ -13,6 +13,10 @@ import (
"go_dreamfactory/lego/sys/log"
)
const (
User_SubType_Create = "create"
)
type UserComp struct {
modules.MComp_GateComp
module *User
@ -25,21 +29,26 @@ 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 {
defer utils.TraceFunc(session.GetUserId(), "user", "create", req, nil)
func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) (err error) {
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
user := cache.Defsys.Get(session.GetUserId())
var code pb.ErrorCode
defer func() {
session.SendMsg(string(this.module.GetType()), User_SubType_Create, code, &pb.UserCreateRsp{})
}()
if user == nil {
log.Errorf("user no exist")
session.SendMsg("user", "create", pb.ErrorCode_UserSessionNobeing, nil)
return nil
code = pb.ErrorCode_UserSessionNobeing
return
}
user.UserData.NiceName = req.NickName
err := cache.Defsys.Update(user)
err = cache.Defsys.Update(user)
if err != nil {
log.Errorf("cache update err")
code = pb.ErrorCode_DBError
return
}
event.RegisterGO(comm.Event_CreateUser, session.GetUserId())
session.SendMsg("user", "create", pb.ErrorCode_Success, &pb.UserCreateRsp{})
return nil
}

View File

@ -37,7 +37,7 @@ func (this *Api_Comp) Register(c *engine.Context) {
rsp := &pb.UserRegisterRsp{}
err := c.BindJSON(&req)
if err == nil {
err := db.Defsys.User_CreateUser(&pb.DB_UserData{
err := db.Defsys.User_Create(&pb.DB_UserData{
Account: req.Account,
})
if err != nil {

8
pb.bat
View File

@ -2,11 +2,15 @@
set PROJECT_ROOT=.\
set PROJECT_ROOT=.
set SRC=%PROJECT_ROOT%\pb\proto
set TAR=%PROJECT_ROOT%\pb
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\*.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 %SRC%\pack\*.proto
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\mail\*.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

View File

@ -9,6 +9,7 @@ package pb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
anypb "google.golang.org/protobuf/types/known/anypb"
reflect "reflect"
sync "sync"
)
@ -26,10 +27,10 @@ type UserMessage struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
Data *anypb.Any `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
}
func (x *UserMessage) Reset() {
@ -85,7 +86,7 @@ func (x *UserMessage) GetCode() ErrorCode {
return ErrorCode_Success
}
func (x *UserMessage) GetData() []byte {
func (x *UserMessage) GetData() *anypb.Any {
if x != nil {
return x.Data
}
@ -98,12 +99,12 @@ type AgentMessage struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ip string `protobuf:"bytes,1,opt,name=Ip,proto3" json:"Ip,omitempty"`
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId,omitempty"`
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId,omitempty"`
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method,omitempty"`
Message []byte `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message,omitempty"`
Ip string `protobuf:"bytes,1,opt,name=Ip,proto3" json:"Ip,omitempty"`
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId,omitempty"`
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId,omitempty"`
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method,omitempty"`
Message *anypb.Any `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message,omitempty"`
}
func (x *AgentMessage) Reset() {
@ -173,7 +174,7 @@ func (x *AgentMessage) GetMethod() string {
return ""
}
func (x *AgentMessage) GetMessage() []byte {
func (x *AgentMessage) GetMessage() *anypb.Any {
if x != nil {
return x.Message
}
@ -346,11 +347,11 @@ type AgentSendMessageReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
Code ErrorCode `protobuf:"varint,4,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
Data []byte `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data,omitempty"`
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
Code ErrorCode `protobuf:"varint,4,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
Data *anypb.Any `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *AgentSendMessageReq) Reset() {
@ -413,7 +414,7 @@ func (x *AgentSendMessageReq) GetCode() ErrorCode {
return ErrorCode_Success
}
func (x *AgentSendMessageReq) GetData() []byte {
func (x *AgentSendMessageReq) GetData() *anypb.Any {
if x != nil {
return x.Data
}
@ -426,10 +427,10 @@ type BatchMessageReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"`
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"`
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data *anypb.Any `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *BatchMessageReq) Reset() {
@ -485,7 +486,7 @@ func (x *BatchMessageReq) GetSubType() string {
return ""
}
func (x *BatchMessageReq) GetData() []byte {
func (x *BatchMessageReq) GetData() *anypb.Any {
if x != nil {
return x.Data
}
@ -498,9 +499,9 @@ type BroadCastMessageReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
Data *anypb.Any `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
}
func (x *BroadCastMessageReq) Reset() {
@ -549,7 +550,7 @@ func (x *BroadCastMessageReq) GetSubType() string {
return ""
}
func (x *BroadCastMessageReq) GetData() []byte {
func (x *BroadCastMessageReq) GetData() *anypb.Any {
if x != nil {
return x.Data
}
@ -608,69 +609,78 @@ var File_comm_proto protoreflect.FileDescriptor
var file_comm_proto_rawDesc = []byte{
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72,
0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a,
0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54,
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e,
0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f,
0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a,
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55,
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49,
0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28,
0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e,
0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61,
0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x55, 0x73, 0x65,
0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e,
0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e,
0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e,
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x28,
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41,
0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65,
0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74,
0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
0x22, 0xa5, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65,
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72,
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a,
0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75,
0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62,
0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74,
0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65,
0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61,
0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x5f,
0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70,
0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44,
0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22,
0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65,
0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77,
0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20,
0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67,
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41,
0x6e, 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52,
0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e,
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10,
0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67,
0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65,
0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22,
0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52,
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0xbb, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65,
0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71,
0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79,
0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79,
0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04,
0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72,
0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x28, 0x0a, 0x04,
0x44, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79,
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, 0x68,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, 0x73,
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03,
0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61,
0x74, 0x61, 0x22, 0x75, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69,
0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69,
0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12,
0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65,
0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55,
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49,
0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
@ -697,16 +707,22 @@ var file_comm_proto_goTypes = []interface{}{
(*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq
(*AgentCloseeReq)(nil), // 8: AgentCloseeReq
(ErrorCode)(0), // 9: ErrorCode
(*anypb.Any)(nil), // 10: google.protobuf.Any
}
var file_comm_proto_depIdxs = []int32{
9, // 0: UserMessage.Code:type_name -> ErrorCode
9, // 1: RPCMessageReply.Code:type_name -> ErrorCode
9, // 2: AgentSendMessageReq.Code:type_name -> ErrorCode
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
9, // 0: UserMessage.Code:type_name -> ErrorCode
10, // 1: UserMessage.data:type_name -> google.protobuf.Any
10, // 2: AgentMessage.Message:type_name -> google.protobuf.Any
9, // 3: RPCMessageReply.Code:type_name -> ErrorCode
9, // 4: AgentSendMessageReq.Code:type_name -> ErrorCode
10, // 5: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
10, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any
10, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_comm_proto_init() }

View File

@ -33,31 +33,55 @@ const (
ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足
ErrorCode_NoLogin ErrorCode = 17 //未登录
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误
ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效
ErrorCode_StateInvalid ErrorCode = 21 //无效状态
ErrorCode_DBError ErrorCode = 22 // 数据库操作失败
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 //申请失败
ErrorCode_FriendBlackMax ErrorCode = 1110 //黑名单最大数量
)
// Enum value maps for ErrorCode.
var (
ErrorCode_name = map[int32]string{
0: "Success",
10: "NoFindService",
11: "RpcFuncExecutionError",
12: "CacheReadError",
13: "SqlExecutionError",
14: "ReqParameterError",
15: "SignError",
16: "InsufficientPermissions",
17: "NoLogin",
18: "UserSessionNobeing",
19: "SecKey",
20: "SecKeyInvalid",
21: "StateInvalid",
22: "DBError",
23: "SystemError",
0: "Success",
10: "NoFindService",
11: "RpcFuncExecutionError",
12: "CacheReadError",
13: "SqlExecutionError",
14: "ReqParameterError",
15: "SignError",
16: "InsufficientPermissions",
17: "NoLogin",
18: "UserSessionNobeing",
21: "StateInvalid",
22: "DBError",
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",
1110: "FriendBlackMax",
}
ErrorCode_value = map[string]int32{
"Success": 0,
@ -70,11 +94,22 @@ var (
"InsufficientPermissions": 16,
"NoLogin": 17,
"UserSessionNobeing": 18,
"SecKey": 19,
"SecKeyInvalid": 20,
"StateInvalid": 21,
"DBError": 22,
"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,
"FriendBlackMax": 1110,
}
)
@ -109,7 +144,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, 0xa8, 0x02, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x6f, 0x2a, 0x9d, 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,
0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
@ -122,13 +157,29 @@ var file_errorcode_proto_rawDesc = []byte{
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,
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,
0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x63,
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c,
0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x15, 0x12, 0x0b,
0x0a, 0x07, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0f, 0x0a, 0x0b, 0x53,
0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x17, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x10, 0x0a,
0x0c, 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x15, 0x12,
0x0b, 0x0a, 0x07, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0f, 0x0a, 0x0b,
0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x17, 0x12, 0x12, 0x0a,
0x0d, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8,
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, 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,
}
var (

View File

@ -25,8 +25,10 @@ type Cache_FriendData struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
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"`
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() {
@ -68,9 +70,23 @@ func (x *Cache_FriendData) GetUserId() string {
return ""
}
func (x *Cache_FriendData) GetFriendId() []string {
func (x *Cache_FriendData) GetFriendIds() []string {
if x != nil {
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
}
@ -79,12 +95,16 @@ var File_friend_friend_db_proto protoreflect.FileDescriptor
var file_friend_friend_db_proto_rawDesc = []byte{
0x0a, 0x16, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f,
0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x46, 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, 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,
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 (

File diff suppressed because it is too large Load Diff

View File

@ -80,7 +80,7 @@ type DB_MailData struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId,omitempty" bson:"_id"` // tags:{bson:"_id"}
ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId,omitempty" bson:"_id"` // ID
UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title,omitempty"` // 邮件标题
Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容

View File

@ -122,8 +122,8 @@ type DB_UserPackData struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
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"` //背包列表
}
func (x *DB_UserPackData) Reset() {

View File

@ -1,13 +1,14 @@
syntax = "proto3";
option go_package = ".;pb";
import "errorcode.proto";
import "google/protobuf/any.proto";
//
message UserMessage {
string MainType =1;
string SubType = 2;
ErrorCode Code = 3;
bytes Data = 4;
google.protobuf.Any data = 4;
}
//
@ -17,7 +18,7 @@ message AgentMessage {
string UserId = 3;
string GatewayServiceId = 4;
string Method = 5;
bytes Message = 6;
google.protobuf.Any Message = 6;
}
//RPC
@ -42,7 +43,7 @@ message AgentSendMessageReq {
string MainType = 2;
string SubType = 3;
ErrorCode Code = 4;
bytes Data = 5;
google.protobuf.Any Data = 5;
}
//
@ -50,14 +51,14 @@ message BatchMessageReq {
repeated string UserSessionIds = 1;
string MainType = 2;
string SubType = 3;
bytes Data = 4;
google.protobuf.Any Data = 4;
}
//广
message BroadCastMessageReq {
string MainType = 1; //
string SubType = 2;
bytes Data = 3;
google.protobuf.Any Data = 3;
}
//

View File

@ -13,10 +13,24 @@ enum ErrorCode {
InsufficientPermissions = 16; //
NoLogin = 17; //
UserSessionNobeing = 18; //
SecKey = 19; //
SecKeyInvalid = 20; //
StateInvalid = 21; //
DBError = 22; //
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;//
FriendBlackMax = 1110; //
}

View File

@ -3,6 +3,9 @@ option go_package = ".;pb";
message Cache_FriendData {
string userId = 1; //tags:{bson:"_id"}Id
repeated string friendId = 2;
string userId = 1;// @go_tags(`bson:"_id"`) ID
repeated string friendIds = 2; //ID
repeated string applyIds = 3;//ID
repeated string blackIds = 4;//ID
}

View File

@ -1,6 +1,5 @@
syntax = "proto3";
option go_package = ".;pb";
import "friend/friend_db.proto";
message FriendBase {
string userId = 1; //ID
@ -18,15 +17,16 @@ message FriendListReq{
}
message FriendListRsp{
repeated Cache_FriendData list = 1;
repeated FriendBase list = 1;
}
//
message FriendAddReq{
//
message FriendApplyReq{
string friendId = 1; //ID
}
message FriendAddRsp{
message FriendApplyRsp{
string userId = 1; //ID
string friendId =2;//ID
}
//
@ -40,15 +40,20 @@ message FriendDelRsp{
string userId = 2; //ID
}
//
message FriendAgreeOrRefuseReq{
string friendId = 1; //
bool isAgree = 2;
//
message FriendAgreeReq{
repeated string friendIds = 1; //
}
message FriendAgressOrRefuseRsp{
message FriendAgreeRsp{
int32 Num = 1;//
}
//
message FriendRefuseReq{
repeated string friendIds = 1; //
}
message FriendRefuseRsp{
int32 Num = 1;//
bool isAgree = 2;
}
@ -57,17 +62,16 @@ message FriendApplyListReq{
}
message FriendApplyListRsp{
repeated FriendBase list = 1;
}
//
message FriendSearchReq{
string friendId = 1;
string nickName = 2; //
string nickName = 1; //
}
message FriendSearchRsp{
repeated FriendBase friends = 1;
FriendBase friend = 1;
}
//
@ -89,18 +93,37 @@ message FriendBlackAddRsp{
string userId = 2;
}
//
message FriendReceiveOrSendReq{
//
message FriendDelBlackReq{
string friendId = 1;
bool isReceive = 2;
}
message FriendReceiveOrSendRsp{
message FriendDelBlackRsp{
string friendId = 1;
string userId = 2;
bool isReceive = 3;
}
//
message FriendReceiveReq{
string friendId = 1;
}
message FriendReceiveRsp{
string friendId = 1;
string userId = 2;
}
//
message FriendGiveReq{
string friendId = 1;
}
message FriendGiveRsp{
string friendId = 1;
string userId = 2;
}
//
message FriendTotalReq{
string friendId = 1;

View File

@ -12,7 +12,7 @@ message MailAttachment { // 附件
}
message DB_MailData {
string ObjId = 1; // tags:{bson:"_id"}
string ObjId = 1; // @go_tags(`bson:"_id"`) ID
string UserId = 2;
string Title = 3; //
string Contex = 4; //

View File

@ -15,6 +15,6 @@ message DB_GridData {
//
message DB_UserPackData {
string UserId = 1; //tags:{bson:"_id"}Id
string UserId = 1; // @go_tags(`bson:"_id"`) Id
repeated DB_GridData Pack = 2; //
}

View File

@ -8,7 +8,7 @@ message Cache_UserData {
}
message DB_UserData {
string UserId = 1; //tags:{bson:"_id"}Id
string UserId = 1; // @go_tags(`bson:"_id"`) ID
string Account = 2;
string NiceName = 3;
int32 ServerId = 4;

View File

@ -88,7 +88,7 @@ type DB_UserData struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty"` //tags:{bson:"_id"}动态Id
Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"`
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"`

View File

@ -13,7 +13,8 @@ import (
"go_dreamfactory/lego/core/cbase"
"go_dreamfactory/lego/sys/log"
"google.golang.org/protobuf/proto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/ptypes"
)
/*
@ -118,7 +119,7 @@ func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentM
if ok {
session := comm.NewUserSession(this.service, args.Ip, args.UserSessionId, args.GatewayServiceId, args.UserId)
msg := reflect.New(msghandle.msgType.Elem()).Interface()
if err := proto.Unmarshal(args.Message, msg.(proto.Message)); err != nil {
if err := ptypes.UnmarshalAny(args.Message, msg.(proto.Message)); err != nil {
log.Errorf("UserMessage:%s Unmarshal err:%v", args.Method, err)
return err
}

43
sys/cache/friend.go vendored
View File

@ -2,35 +2,58 @@ package cache
import (
"fmt"
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
const ( //Redis
Redis_FriendCache string = "friend:%s"
Redis_Friend string = "apply:%s"
)
func getRdsUserKey(userId string) string {
return fmt.Sprintf(Redis_UserCache, userId)
func getRdsFriendKey(userId string) string {
return fmt.Sprintf(Redis_FriendCache, userId)
}
type IFriend interface {
FriendAdd(data *pb.Cache_FriendData) (err error)
FriendGetTotal(userId string) int32
Friend_Update(data *pb.Cache_FriendData) (err error)
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 {
err = this.redis.Set(fmt.Sprintf(Redis_FriendCache, data.UserId), data, 0)
//更新
func (this *Cache) Friend_Update(data *pb.Cache_FriendData) (err error) {
if err = db.Defsys.Friend_SaveOrUpdate(data); err == nil {
//更新缓存
err = this.redis.Set(getRdsFriendKey(data.UserId), data, 0)
}
return
}
func (this *Cache) FriendGetTotal(userId string) int32 {
//好友总数
func (this *Cache) Friend_Total(userId string) int32 {
var friend *pb.Cache_FriendData
err := this.redis.Get(getRdsUserKey(userId), &friend)
err := this.redis.Get(getRdsFriendKey(userId), &friend)
if err != nil {
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_Update(d)
if err != nil {
return d, nil
}
}
return nil, err
}
return d, nil
}

View File

@ -9,16 +9,23 @@ import (
"github.com/stretchr/testify/require"
)
func TestFriendAdd(t *testing.T) {
err := cache.Defsys.FriendAdd(&pb.Cache_FriendData{
UserId: "629f159310d6970846f7ef26",
FriendId: []string{"629f147e3d276120561bfa18", "629eb3f4132dc4bb26139659"},
func TestFriendApply(t *testing.T) {
err := cache.Defsys.Friend_Update(&pb.Cache_FriendData{
UserId: "629f159310d6970846f7ef26",
FriendIds: []string{"629f147e3d276120561bfa18"},
ApplyIds: []string{"629eb3f4132dc4bb26139659"},
})
require.Nil(t, err, nil)
}
func TestFriendGetTotal(t *testing.T) {
total := cache.Defsys.FriendGetTotal("629f159310d6970846f7ef26")
assert.Equal(t, total, int32(1))
total := cache.Defsys.Friend_Total("629f159310d6970846f7ef26")
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")
}

6
sys/cache/user.go vendored
View File

@ -3,6 +3,7 @@ package cache
import (
"fmt"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"go_dreamfactory/lego/sys/log"
)
@ -17,7 +18,10 @@ type IUser interface {
}
func (this *Cache) Update(data *pb.Cache_UserData) (err error) {
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1)
err = db.Defsys.User_Update(data.UserData)
if err == nil {
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1)
}
return
}

View File

@ -2,9 +2,11 @@ package db
import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
@ -13,13 +15,34 @@ const (
)
type IFriend interface {
FriendApply(data *pb.Cache_FriendData) error
Friend_SaveOrUpdate(data *pb.Cache_FriendData) (err error)
Frined_FindCond(nickName string) *pb.DB_UserData
}
func (this *DB) FriendApply(data *pb.Cache_FriendData) error {
err := this.mgo.FindOneAndUpdate(DB_FriendTable,
//好友
func (this *DB) Friend_SaveOrUpdate(data *pb.Cache_FriendData) (err error) {
err = this.mgo.FindOneAndUpdate(DB_FriendTable,
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()
return err
if err != nil {
if err == mongo.ErrNoDocuments {
_, err = this.mgo.InsertOne(DB_FriendTable, data)
}
}
return
}
func (this *DB) Frined_FindCond(nickName string) *pb.DB_UserData {
var user *pb.DB_UserData
err := this.mgo.FindOne(DB_UserTable, bson.M{
"nicename": nickName,
}).Decode(&user)
if err != nil {
log.Errorf("findCond err:%v", err)
return nil
}
return user
}

View File

@ -1,6 +1,7 @@
package db
import (
"fmt"
"go_dreamfactory/pb"
"testing"
@ -8,12 +9,19 @@ import (
)
func TestFriendAdd(t *testing.T) {
err := db.FriendApply(&pb.Cache_FriendData{
err := db.Friend_SaveOrUpdate(&pb.Cache_FriendData{
UserId: "629f159310d6970846f7ef26",
FriendId: []string{
FriendIds: []string{
"629f147e3d276120561bfa18",
},
})
require.Nil(t, err, nil)
}
func TestFriendFindCond(t *testing.T) {
user := db.Frined_FindCond("乐谷5")
require.NotNil(t, user, nil)
fmt.Printf("%v", user)
}

View File

@ -15,16 +15,17 @@ const ( //Redis
)
type IUser interface {
User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error)
User_FindUserById(id string) (*pb.DB_UserData, error)
User_CreateUser(user *pb.DB_UserData) error
User_UpdateUser(data *pb.DB_UserData) (err error)
User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error)
User_FindById(id string) (*pb.DB_UserData, error)
User_Create(user *pb.DB_UserData) 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{
{"serverid", user.ServerId},
{"account", user.Account},
//
func (this *DB) User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) {
filter := bson.M{
"serverid": user.ServerId,
"account": user.Account,
}
sr := this.mgo.FindOne(DB_UserTable, filter)
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
}
func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) {
filter := bson.D{
{"_id", id},
func (this *DB) User_FindById(id string) (*pb.DB_UserData, error) {
filter := bson.M{
"userid": id,
}
sr := this.mgo.FindOne(DB_UserTable, filter)
user := &pb.DB_UserData{}
@ -42,21 +43,21 @@ func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) {
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()
_, err = this.mgo.InsertOne(DB_UserTable, user)
return err
}
//更新用户数据到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(
DB_UserTable,
bson.M{"_id": data.UserId},
bson.M{"userid": data.UserId},
bson.M{"$set": bson.M{
"niceName": data.NiceName,
"nicename": data.NiceName,
}},
options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After),
).Decode(data)
options.FindOneAndUpdate().SetUpsert(true),
).Err()
return err
}

View File

@ -16,17 +16,17 @@ func TestCreate(t *testing.T) {
ServerId: 1,
}
err := db.User_CreateUser(user)
err := db.User_Create(user)
require.Nil(t, err)
}
func TestFindOne(t *testing.T) {
user, err := db.User_FindUserById("629eb3f4132dc4bb26139659")
user, err := db.User_FindById("629eb3f4132dc4bb26139659")
require.Nil(t, err)
assert.Equal(t, "legu3", user.Account)
// user.ServerId = 2
user2, err := db.User_FindUserByAccount(user)
user2, err := db.User_FindByAccount(user)
require.Nil(t, err)
assert.Equal(t, "legu3", user2.Account)
assert.Equal(t, int32(1), user2.ServerId)
@ -36,7 +36,7 @@ func TestUpdate(t *testing.T) {
user := &pb.DB_UserData{
UserId: primitive.NewObjectID().Hex(),
}
err := db.User_UpdateUser(user)
err := db.User_Update(user)
require.Nil(t, err)
assert.Equal(t, "NiceName", "")

View File

@ -20,6 +20,7 @@ func Base64Decode(data string) string {
return string(b)
}
//校验加密串
func ValidSecretKey(secStr string) bool {
if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 {
return false
@ -29,7 +30,6 @@ func ValidSecretKey(secStr string) bool {
rawmsg := secStr[35:]
log.Debugf("data base: %s", rawmsg)
serverMd5Key := MD5Str(rawmsg)
// s := fmt.Sprintf("%x", serverMd5Key)
if !strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) {
return false
}

View File

@ -15,3 +15,22 @@ func ParseP(p string) (string, string, bool) {
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
}
func DeleteString(list []string, ele string) []string {
result := make([]string, 0)
for _, v := range list {
if v != ele {
result = append(result, v)
}
}
return result
}