Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into liwei
This commit is contained in:
commit
a309fe9a47
@ -2,21 +2,36 @@ package robot
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/modules/friend"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
||||||
switch msg.SubType {
|
switch msg.SubType {
|
||||||
case "add":
|
case friend.Friend_SubType_Apply:
|
||||||
r.handleFriendAdd(msg)
|
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() {
|
func (r *Robot) FriendList() {
|
||||||
req := &pb.FriendAddReq{}
|
req := &pb.FriendListReq{}
|
||||||
head := &pb.UserMessage{MainType: "friend", SubType: "add"}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_List}
|
||||||
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 +39,170 @@ func (r *Robot) FriendAdd() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Robot) handleFriendAdd(msg *pb.UserMessage) {
|
func (r *Robot) handleFriendList(msg *pb.UserMessage) {
|
||||||
rsp := &pb.FriendAddRsp{}
|
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) {
|
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)
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
@ -9,9 +9,9 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Robot struct {
|
type Robot struct {
|
||||||
@ -79,11 +79,22 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
|
|||||||
//在这里添加玩家成功登录以后的测试方法
|
//在这里添加玩家成功登录以后的测试方法
|
||||||
func (r *Robot) onUserLoaded() {
|
func (r *Robot) onUserLoaded() {
|
||||||
//user
|
//user
|
||||||
r.CreateUser("user671")
|
// r.CreateUser("乐谷4")
|
||||||
|
|
||||||
//friend
|
//friend
|
||||||
// r.FriendAdd()
|
// r.FriendApply("629f147e3d276120561bfa18")
|
||||||
r.QueryUserPack()
|
// 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 {
|
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{}) {
|
func printReply(msg *pb.UserMessage, rsp interface{}) {
|
||||||
log.Printf("rsp [%s.%s] [%d] [%v]", msg.MainType, msg.SubType, msg.Code, rsp)
|
log.Printf("rsp [%s.%s] [%d] [%v]", msg.MainType, msg.SubType, msg.Code, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//方法参数跟踪
|
||||||
func traceFunc(module string, funcName string, uid string, funcArgs interface{}) {
|
func traceFunc(module string, funcName string, uid string, funcArgs interface{}) {
|
||||||
log.Printf("req [%s.%s] [%s] [%v]", module, funcName, uid, funcArgs)
|
log.Printf("req [%s.%s] [%s] [%v]", module, funcName, uid, funcArgs)
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package robot
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/modules/user"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
@ -40,8 +41,8 @@ func (r *Robot) CreateUser(NickName string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
head := &pb.UserMessage{
|
head := &pb.UserMessage{
|
||||||
MainType: "user",
|
MainType: string(comm.SM_UserModule),
|
||||||
SubType: "create",
|
SubType: user.User_SubType_Create,
|
||||||
}
|
}
|
||||||
|
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
||||||
|
@ -7,7 +7,8 @@ import (
|
|||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
|
"github.com/golang/protobuf/ptypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -68,7 +69,7 @@ type IUserSession interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
|
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 {
|
if err != nil {
|
||||||
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
||||||
return
|
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) {
|
func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
|
||||||
data, err := proto.Marshal(rsp)
|
data, err := ptypes.MarshalAny(rsp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
||||||
return
|
return
|
||||||
|
@ -8,7 +8,8 @@ import (
|
|||||||
"go_dreamfactory/lego/base"
|
"go_dreamfactory/lego/base"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"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) {
|
func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) {
|
||||||
reply := &pb.RPCMessageReply{}
|
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)
|
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{
|
if err := this.service.RpcCall(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{
|
||||||
UserSessionId: this.SessionId,
|
UserSessionId: this.SessionId,
|
||||||
|
1
go.mod
1
go.mod
@ -7,6 +7,7 @@ require (
|
|||||||
github.com/go-playground/validator/v10 v10.10.1
|
github.com/go-playground/validator/v10 v10.10.1
|
||||||
github.com/go-redis/redis/v8 v8.11.5
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
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/gorilla/websocket v1.4.2
|
||||||
github.com/hashicorp/consul/api v1.12.0
|
github.com/hashicorp/consul/api v1.12.0
|
||||||
github.com/json-iterator/go v1.1.12
|
github.com/json-iterator/go v1.1.12
|
||||||
|
@ -3,29 +3,191 @@ 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/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 {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
//搜索
|
//搜索
|
||||||
func (this *FriendComp) Search(ctx context.Context, session comm.IUserSession, req *pb.FriendSearchReq) error {
|
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
|
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
|
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
|
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
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//赠送或接收
|
//赠送或接收
|
||||||
func (this *FriendComp) ReceSend(ctx context.Context, session comm.IUserSession, req *pb.FriendReceiveOrSendReq) error {
|
func (this *FriendComp) ReceSend(ctx context.Context, session comm.IUserSession, req *pb.FriendReceiveReq) error {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
//好友数量
|
|
||||||
func (this *FriendComp) Total(ctx context.Context, session comm.IUserSession, req *pb.FriendTotalReq) error {
|
|
||||||
return nil
|
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
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
42
modules/mail/api.go
Normal file
42
modules/mail/api.go
Normal 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
|
||||||
|
}
|
@ -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
|
|
||||||
}
|
|
35
modules/mail/api_delmail.go
Normal file
35
modules/mail/api_delmail.go
Normal 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
|
||||||
|
}
|
49
modules/mail/api_getAttachment.go
Normal file
49
modules/mail/api_getAttachment.go
Normal 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
|
||||||
|
}
|
30
modules/mail/api_getmail.go
Normal file
30
modules/mail/api_getmail.go
Normal 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
|
||||||
|
}
|
30
modules/mail/api_readmail.go
Normal file
30
modules/mail/api_readmail.go
Normal 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
|
||||||
|
}
|
@ -11,7 +11,8 @@ import (
|
|||||||
"go_dreamfactory/lego/core/cbase"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"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) {
|
func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) {
|
||||||
reply := &pb.RPCMessageReply{}
|
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{
|
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,
|
UserSessionId: user.SessionId,
|
||||||
MainType: mainType,
|
MainType: mainType,
|
||||||
@ -59,7 +60,7 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa
|
|||||||
gateway = append(gateway, v.SessionId)
|
gateway = append(gateway, v.SessionId)
|
||||||
}
|
}
|
||||||
reply := &pb.RPCMessageReply{}
|
reply := &pb.RPCMessageReply{}
|
||||||
data, _ := proto.Marshal(msg)
|
data, _ := ptypes.MarshalAny(msg)
|
||||||
for k, v := range gateways {
|
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{
|
if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Gateway, k), string(comm.Rpc_GatewayAgentSendMsg), &pb.BatchMessageReq{
|
||||||
UserSessionIds: v,
|
UserSessionIds: v,
|
||||||
|
@ -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.Bind(user.UserId, this.S.GetId())
|
session.Bind(user.UserId, this.S.GetId())
|
||||||
} 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//注销
|
//注销
|
||||||
|
@ -13,6 +13,10 @@ import (
|
|||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
User_SubType_Create = "create"
|
||||||
|
)
|
||||||
|
|
||||||
type UserComp struct {
|
type UserComp struct {
|
||||||
modules.MComp_GateComp
|
modules.MComp_GateComp
|
||||||
module *User
|
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 {
|
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(), string(this.module.GetType()), User_SubType_Create, req, nil)
|
||||||
user := cache.Defsys.Get(session.GetUserId())
|
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 {
|
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")
|
||||||
|
code = pb.ErrorCode_DBError
|
||||||
|
return
|
||||||
}
|
}
|
||||||
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 {
|
||||||
|
8
pb.bat
8
pb.bat
@ -2,11 +2,15 @@
|
|||||||
|
|
||||||
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 %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
|
pause
|
170
pb/comm.pb.go
170
pb/comm.pb.go
@ -9,6 +9,7 @@ package pb
|
|||||||
import (
|
import (
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||||
|
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
sync "sync"
|
sync "sync"
|
||||||
)
|
)
|
||||||
@ -29,7 +30,7 @@ type UserMessage struct {
|
|||||||
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,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"`
|
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"`
|
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"`
|
Data *anypb.Any `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserMessage) Reset() {
|
func (x *UserMessage) Reset() {
|
||||||
@ -85,7 +86,7 @@ func (x *UserMessage) GetCode() ErrorCode {
|
|||||||
return ErrorCode_Success
|
return ErrorCode_Success
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserMessage) GetData() []byte {
|
func (x *UserMessage) GetData() *anypb.Any {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Data
|
return x.Data
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ type AgentMessage struct {
|
|||||||
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId,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"`
|
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId,omitempty"`
|
||||||
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method,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"`
|
Message *anypb.Any `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentMessage) Reset() {
|
func (x *AgentMessage) Reset() {
|
||||||
@ -173,7 +174,7 @@ func (x *AgentMessage) GetMethod() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentMessage) GetMessage() []byte {
|
func (x *AgentMessage) GetMessage() *anypb.Any {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Message
|
return x.Message
|
||||||
}
|
}
|
||||||
@ -350,7 +351,7 @@ type AgentSendMessageReq struct {
|
|||||||
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,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"`
|
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"`
|
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"`
|
Data *anypb.Any `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentSendMessageReq) Reset() {
|
func (x *AgentSendMessageReq) Reset() {
|
||||||
@ -413,7 +414,7 @@ func (x *AgentSendMessageReq) GetCode() ErrorCode {
|
|||||||
return ErrorCode_Success
|
return ErrorCode_Success
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *AgentSendMessageReq) GetData() []byte {
|
func (x *AgentSendMessageReq) GetData() *anypb.Any {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Data
|
return x.Data
|
||||||
}
|
}
|
||||||
@ -429,7 +430,7 @@ type BatchMessageReq struct {
|
|||||||
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,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"`
|
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||||
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,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"`
|
Data *anypb.Any `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BatchMessageReq) Reset() {
|
func (x *BatchMessageReq) Reset() {
|
||||||
@ -485,7 +486,7 @@ func (x *BatchMessageReq) GetSubType() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BatchMessageReq) GetData() []byte {
|
func (x *BatchMessageReq) GetData() *anypb.Any {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Data
|
return x.Data
|
||||||
}
|
}
|
||||||
@ -500,7 +501,7 @@ type BroadCastMessageReq struct {
|
|||||||
|
|
||||||
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,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"`
|
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
|
||||||
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
|
Data *anypb.Any `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BroadCastMessageReq) Reset() {
|
func (x *BroadCastMessageReq) Reset() {
|
||||||
@ -549,7 +550,7 @@ func (x *BroadCastMessageReq) GetSubType() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *BroadCastMessageReq) GetData() []byte {
|
func (x *BroadCastMessageReq) GetData() *anypb.Any {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Data
|
return x.Data
|
||||||
}
|
}
|
||||||
@ -608,69 +609,78 @@ var File_comm_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_comm_proto_rawDesc = []byte{
|
var file_comm_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72,
|
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,
|
0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67,
|
||||||
0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08,
|
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61,
|
||||||
0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x55, 0x73, 0x65,
|
||||||
0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54,
|
0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e,
|
||||||
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
|
0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e,
|
||||||
0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e,
|
0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18,
|
||||||
0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e,
|
||||||
0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c,
|
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
|
||||||
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74,
|
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x28,
|
||||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20,
|
0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
|
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41,
|
||||||
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
|
0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65,
|
||||||
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18,
|
||||||
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
|
||||||
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79,
|
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||||
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,
|
|
||||||
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
|
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,
|
0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74,
|
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77,
|
||||||
0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
|
0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||||
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||||
0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
|
0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20,
|
||||||
0x22, 0xa5, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65,
|
0x01, 0x28, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x4d,
|
||||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72,
|
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67,
|
||||||
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41,
|
||||||
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a,
|
0x6e, 0x79, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52,
|
||||||
0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e,
|
||||||
0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75,
|
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
|
||||||
0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62,
|
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10,
|
||||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01,
|
0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67,
|
||||||
0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
|
0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65,
|
||||||
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,
|
|
||||||
0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
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,
|
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,
|
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
|
||||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
@ -697,16 +707,22 @@ var file_comm_proto_goTypes = []interface{}{
|
|||||||
(*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq
|
(*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq
|
||||||
(*AgentCloseeReq)(nil), // 8: AgentCloseeReq
|
(*AgentCloseeReq)(nil), // 8: AgentCloseeReq
|
||||||
(ErrorCode)(0), // 9: ErrorCode
|
(ErrorCode)(0), // 9: ErrorCode
|
||||||
|
(*anypb.Any)(nil), // 10: google.protobuf.Any
|
||||||
}
|
}
|
||||||
var file_comm_proto_depIdxs = []int32{
|
var file_comm_proto_depIdxs = []int32{
|
||||||
9, // 0: UserMessage.Code:type_name -> ErrorCode
|
9, // 0: UserMessage.Code:type_name -> ErrorCode
|
||||||
9, // 1: RPCMessageReply.Code:type_name -> ErrorCode
|
10, // 1: UserMessage.data:type_name -> google.protobuf.Any
|
||||||
9, // 2: AgentSendMessageReq.Code:type_name -> ErrorCode
|
10, // 2: AgentMessage.Message:type_name -> google.protobuf.Any
|
||||||
3, // [3:3] is the sub-list for method output_type
|
9, // 3: RPCMessageReply.Code:type_name -> ErrorCode
|
||||||
3, // [3:3] is the sub-list for method input_type
|
9, // 4: AgentSendMessageReq.Code:type_name -> ErrorCode
|
||||||
3, // [3:3] is the sub-list for extension type_name
|
10, // 5: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
|
||||||
3, // [3:3] is the sub-list for extension extendee
|
10, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any
|
||||||
0, // [0:3] is the sub-list for field type_name
|
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() }
|
func init() { file_comm_proto_init() }
|
||||||
|
@ -33,11 +33,24 @@ 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 //申请失败
|
||||||
|
ErrorCode_FriendBlackMax ErrorCode = 1110 //黑名单最大数量
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for ErrorCode.
|
// Enum value maps for ErrorCode.
|
||||||
@ -53,11 +66,22 @@ 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",
|
||||||
|
1110: "FriendBlackMax",
|
||||||
}
|
}
|
||||||
ErrorCode_value = map[string]int32{
|
ErrorCode_value = map[string]int32{
|
||||||
"Success": 0,
|
"Success": 0,
|
||||||
@ -70,11 +94,22 @@ 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,
|
||||||
|
"FriendBlackMax": 1110,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -109,7 +144,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, 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,
|
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,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,
|
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,
|
||||||
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
@ -25,8 +25,10 @@ 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" bson:"_id"` //tags:{bson:"_id"}用户Id
|
UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty" bson:"_id"` // ID
|
||||||
FriendId []string `protobuf:"bytes,2,rep,name=friendId,proto3" json:"friendId,omitempty"`
|
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() {
|
||||||
@ -68,9 +70,23 @@ func (x *Cache_FriendData) GetUserId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *Cache_FriendData) GetFriendId() []string {
|
func (x *Cache_FriendData) GetFriendIds() []string {
|
||||||
if x != nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
@ -79,12 +95,16 @@ var File_friend_friend_db_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_friend_friend_db_proto_rawDesc = []byte{
|
var file_friend_friend_db_proto_rawDesc = []byte{
|
||||||
0x0a, 0x16, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f,
|
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,
|
0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x10, 0x43, 0x61, 0x63,
|
||||||
0x65, 0x5f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06,
|
0x68, 0x65, 0x5f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a,
|
||||||
0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73,
|
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75,
|
||||||
0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64,
|
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49,
|
||||||
0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64,
|
0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -80,7 +80,7 @@ type DB_MailData struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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"`
|
UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
|
||||||
Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title,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"` // 邮件内容
|
Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容
|
||||||
|
@ -122,7 +122,7 @@ 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" bson:"_id"` //tags:{bson:"_id"}用户Id
|
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"` //背包列表
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
import "errorcode.proto";
|
import "errorcode.proto";
|
||||||
|
import "google/protobuf/any.proto";
|
||||||
|
|
||||||
//用户消息流结构
|
//用户消息流结构
|
||||||
message UserMessage {
|
message UserMessage {
|
||||||
string MainType =1;
|
string MainType =1;
|
||||||
string SubType = 2;
|
string SubType = 2;
|
||||||
ErrorCode Code = 3;
|
ErrorCode Code = 3;
|
||||||
bytes Data = 4;
|
google.protobuf.Any data = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//代理用户转发消息结构
|
//代理用户转发消息结构
|
||||||
@ -17,7 +18,7 @@ message AgentMessage {
|
|||||||
string UserId = 3;
|
string UserId = 3;
|
||||||
string GatewayServiceId = 4;
|
string GatewayServiceId = 4;
|
||||||
string Method = 5;
|
string Method = 5;
|
||||||
bytes Message = 6;
|
google.protobuf.Any Message = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
//RPC 服务固定回复结构
|
//RPC 服务固定回复结构
|
||||||
@ -42,7 +43,7 @@ message AgentSendMessageReq {
|
|||||||
string MainType = 2;
|
string MainType = 2;
|
||||||
string SubType = 3;
|
string SubType = 3;
|
||||||
ErrorCode Code = 4;
|
ErrorCode Code = 4;
|
||||||
bytes Data = 5;
|
google.protobuf.Any Data = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送批量消息
|
//发送批量消息
|
||||||
@ -50,14 +51,14 @@ message BatchMessageReq {
|
|||||||
repeated string UserSessionIds = 1;
|
repeated string UserSessionIds = 1;
|
||||||
string MainType = 2;
|
string MainType = 2;
|
||||||
string SubType = 3;
|
string SubType = 3;
|
||||||
bytes Data = 4;
|
google.protobuf.Any Data = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
//发送广播消息
|
//发送广播消息
|
||||||
message BroadCastMessageReq {
|
message BroadCastMessageReq {
|
||||||
string MainType = 1; //服务名
|
string MainType = 1; //服务名
|
||||||
string SubType = 2;
|
string SubType = 2;
|
||||||
bytes Data = 3;
|
google.protobuf.Any Data = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
//关闭用户代理
|
//关闭用户代理
|
||||||
|
@ -13,10 +13,24 @@ 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;//申请失败
|
||||||
|
FriendBlackMax = 1110; //黑名单最大数量
|
||||||
}
|
}
|
@ -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(`bson:"_id"`) ID
|
||||||
repeated string friendId = 2;
|
repeated string friendIds = 2; //好友ID
|
||||||
|
repeated string applyIds = 3;//申请用户ID
|
||||||
|
repeated string blackIds = 4;//黑名单ID
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
option go_package = ".;pb";
|
option go_package = ".;pb";
|
||||||
import "friend/friend_db.proto";
|
|
||||||
|
|
||||||
message FriendBase {
|
message FriendBase {
|
||||||
string userId = 1; //ID
|
string userId = 1; //ID
|
||||||
@ -18,15 +17,16 @@ message FriendListReq{
|
|||||||
}
|
}
|
||||||
|
|
||||||
message FriendListRsp{
|
message FriendListRsp{
|
||||||
repeated Cache_FriendData list = 1;
|
repeated FriendBase 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
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除好友
|
//删除好友
|
||||||
@ -40,15 +40,20 @@ message FriendDelRsp{
|
|||||||
string userId = 2; //用户ID
|
string userId = 2; //用户ID
|
||||||
}
|
}
|
||||||
|
|
||||||
//同意或拒绝
|
//同意
|
||||||
message FriendAgreeOrRefuseReq{
|
message FriendAgreeReq{
|
||||||
string friendId = 1; //被同意或拒绝的用户
|
repeated string friendIds = 1; //被同意的用户
|
||||||
bool isAgree = 2;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
message FriendAgressOrRefuseRsp{
|
message FriendAgreeRsp{
|
||||||
|
int32 Num = 1;//操作的数量
|
||||||
|
}
|
||||||
|
|
||||||
|
//拒绝
|
||||||
|
message FriendRefuseReq{
|
||||||
|
repeated string friendIds = 1; //被拒绝的用户
|
||||||
|
}
|
||||||
|
message FriendRefuseRsp{
|
||||||
int32 Num = 1;//操作的数量
|
int32 Num = 1;//操作的数量
|
||||||
bool isAgree = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -57,17 +62,16 @@ message FriendApplyListReq{
|
|||||||
|
|
||||||
}
|
}
|
||||||
message FriendApplyListRsp{
|
message FriendApplyListRsp{
|
||||||
|
repeated FriendBase list = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//好友搜索
|
//好友搜索
|
||||||
message FriendSearchReq{
|
message FriendSearchReq{
|
||||||
string friendId = 1;
|
string nickName = 1; //好友昵称
|
||||||
string nickName = 2; //好友昵称
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message FriendSearchRsp{
|
message FriendSearchRsp{
|
||||||
repeated FriendBase friends = 1;
|
FriendBase friend = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//黑名单
|
//黑名单
|
||||||
@ -89,18 +93,37 @@ message FriendBlackAddRsp{
|
|||||||
string userId = 2;
|
string userId = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
//赠送或接收
|
//删除黑名单
|
||||||
message FriendReceiveOrSendReq{
|
message FriendDelBlackReq{
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
bool isReceive = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message FriendReceiveOrSendRsp{
|
message FriendDelBlackRsp{
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
string userId = 2;
|
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{
|
message FriendTotalReq{
|
||||||
string friendId = 1;
|
string friendId = 1;
|
||||||
|
@ -12,7 +12,7 @@ message MailAttachment { // 附件
|
|||||||
}
|
}
|
||||||
|
|
||||||
message DB_MailData {
|
message DB_MailData {
|
||||||
string ObjId = 1; // tags:{bson:"_id"}
|
string ObjId = 1; // @go_tags(`bson:"_id"`) ID
|
||||||
string UserId = 2;
|
string UserId = 2;
|
||||||
string Title = 3; // 邮件标题
|
string Title = 3; // 邮件标题
|
||||||
string Contex = 4; // 邮件内容
|
string Contex = 4; // 邮件内容
|
||||||
|
@ -15,6 +15,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; //背包列表
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ message Cache_UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message DB_UserData {
|
message DB_UserData {
|
||||||
string UserId = 1; //tags:{bson:"_id"}动态Id
|
string UserId = 1; // @go_tags(`bson:"_id"`) ID
|
||||||
string Account = 2;
|
string Account = 2;
|
||||||
string NiceName = 3;
|
string NiceName = 3;
|
||||||
int32 ServerId = 4;
|
int32 ServerId = 4;
|
||||||
|
@ -88,7 +88,7 @@ type DB_UserData 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" 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"`
|
Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"`
|
||||||
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,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"`
|
ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"`
|
||||||
|
@ -13,7 +13,8 @@ import (
|
|||||||
"go_dreamfactory/lego/core/cbase"
|
"go_dreamfactory/lego/core/cbase"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"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 {
|
if ok {
|
||||||
session := comm.NewUserSession(this.service, args.Ip, args.UserSessionId, args.GatewayServiceId, args.UserId)
|
session := comm.NewUserSession(this.service, args.Ip, args.UserSessionId, args.GatewayServiceId, args.UserId)
|
||||||
msg := reflect.New(msghandle.msgType.Elem()).Interface()
|
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)
|
log.Errorf("UserMessage:%s Unmarshal err:%v", args.Method, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
43
sys/cache/friend.go
vendored
43
sys/cache/friend.go
vendored
@ -2,35 +2,58 @@ 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_Update(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_Update(data *pb.Cache_FriendData) (err error) {
|
||||||
err = this.redis.Set(fmt.Sprintf(Redis_FriendCache, data.UserId), data, 0)
|
if err = db.Defsys.Friend_SaveOrUpdate(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_Update(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_Update(&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")
|
||||||
}
|
}
|
||||||
|
4
sys/cache/user.go
vendored
4
sys/cache/user.go
vendored
@ -3,6 +3,7 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
)
|
)
|
||||||
@ -17,7 +18,10 @@ type IUser interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Cache) Update(data *pb.Cache_UserData) (err error) {
|
func (this *Cache) Update(data *pb.Cache_UserData) (err error) {
|
||||||
|
err = db.Defsys.User_Update(data.UserData)
|
||||||
|
if err == nil {
|
||||||
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1)
|
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,11 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go_dreamfactory/lego/core"
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
"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 +15,34 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type IFriend interface {
|
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{"_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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -8,12 +9,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestFriendAdd(t *testing.T) {
|
func TestFriendAdd(t *testing.T) {
|
||||||
err := db.FriendApply(&pb.Cache_FriendData{
|
err := db.Friend_SaveOrUpdate(&pb.Cache_FriendData{
|
||||||
UserId: "629f159310d6970846f7ef26",
|
UserId: "629f159310d6970846f7ef26",
|
||||||
FriendId: []string{
|
FriendIds: []string{
|
||||||
"629f147e3d276120561bfa18",
|
"629f147e3d276120561bfa18",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
require.Nil(t, err, nil)
|
require.Nil(t, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFriendFindCond(t *testing.T) {
|
||||||
|
user := db.Frined_FindCond("乐谷5")
|
||||||
|
require.NotNil(t, user, nil)
|
||||||
|
|
||||||
|
fmt.Printf("%v", user)
|
||||||
|
}
|
||||||
|
@ -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},
|
"userid": id,
|
||||||
}
|
}
|
||||||
sr := this.mgo.FindOne(DB_UserTable, filter)
|
sr := this.mgo.FindOne(DB_UserTable, filter)
|
||||||
user := &pb.DB_UserData{}
|
user := &pb.DB_UserData{}
|
||||||
@ -42,21 +43,21 @@ 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{"userid": data.UserId},
|
||||||
bson.M{"$set": bson.M{
|
bson.M{"$set": bson.M{
|
||||||
"niceName": data.NiceName,
|
"nicename": data.NiceName,
|
||||||
}},
|
}},
|
||||||
options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After),
|
options.FindOneAndUpdate().SetUpsert(true),
|
||||||
).Decode(data)
|
).Err()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -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,22 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteString(list []string, ele string) []string {
|
||||||
|
result := make([]string, 0)
|
||||||
|
for _, v := range list {
|
||||||
|
if v != ele {
|
||||||
|
result = append(result, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user