Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into liwei
This commit is contained in:
commit
28c99a8893
552
bin/json/tbhero.json
Normal file
552
bin/json/tbhero.json
Normal file
@ -0,0 +1,552 @@
|
||||
[
|
||||
{
|
||||
"id": "11001",
|
||||
"name": "阿宝",
|
||||
"star": 4,
|
||||
"color": 3,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "Person/11001.prefab",
|
||||
"icon": "11001",
|
||||
"sound": "121323",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "57.4",
|
||||
"atkgrow": "7.2",
|
||||
"defgrow": "5.6",
|
||||
"speedgrow": "2",
|
||||
"hp": "576",
|
||||
"atk": "73",
|
||||
"def": "57",
|
||||
"speed": "174",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11001.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11002",
|
||||
"name": "原始人",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "Person/11002.prefab",
|
||||
"icon": "11002",
|
||||
"sound": "11002",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "82.9",
|
||||
"atkgrow": "9.4",
|
||||
"defgrow": "5.8",
|
||||
"speedgrow": "2",
|
||||
"hp": "830",
|
||||
"atk": "95",
|
||||
"def": "59",
|
||||
"speed": "193",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11002.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11003",
|
||||
"name": "波比",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "Person/11003.prefab",
|
||||
"icon": "11003",
|
||||
"sound": "11003",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "82.9",
|
||||
"atkgrow": "9.4",
|
||||
"defgrow": "5.8",
|
||||
"speedgrow": "2",
|
||||
"hp": "830",
|
||||
"atk": "95",
|
||||
"def": "59",
|
||||
"speed": "193",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11003.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11004",
|
||||
"name": "布兰",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "11004",
|
||||
"icon": "11004",
|
||||
"sound": "11004",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "82.9",
|
||||
"atkgrow": "9.4",
|
||||
"defgrow": "5.8",
|
||||
"speedgrow": "2",
|
||||
"hp": "830",
|
||||
"atk": "95",
|
||||
"def": "59",
|
||||
"speed": "193",
|
||||
"intr": "",
|
||||
"events": "hero_2011",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11005",
|
||||
"name": "无牙仔",
|
||||
"star": 4,
|
||||
"color": 3,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "Person/11001.prefab",
|
||||
"icon": "11005",
|
||||
"sound": "121323",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "57.4",
|
||||
"atkgrow": "7.2",
|
||||
"defgrow": "5.6",
|
||||
"speedgrow": "2",
|
||||
"hp": "576",
|
||||
"atk": "73",
|
||||
"def": "57",
|
||||
"speed": "174",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11001.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11006",
|
||||
"name": "亚丝翠",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "11006",
|
||||
"icon": "11006",
|
||||
"sound": "11006",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "82.9",
|
||||
"atkgrow": "9.4",
|
||||
"defgrow": "5.8",
|
||||
"speedgrow": "2",
|
||||
"hp": "830",
|
||||
"atk": "95",
|
||||
"def": "59",
|
||||
"speed": "193",
|
||||
"intr": "",
|
||||
"events": "hero_2011",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11009",
|
||||
"name": "希卡普",
|
||||
"star": 4,
|
||||
"color": 3,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11009",
|
||||
"icon": "11009",
|
||||
"sound": "11009",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "38.6",
|
||||
"atkgrow": "10.5",
|
||||
"defgrow": "5.7",
|
||||
"speedgrow": "2",
|
||||
"hp": "389",
|
||||
"atk": "106",
|
||||
"def": "58",
|
||||
"speed": "165",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11009.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "22002",
|
||||
"name": "沈王爷青春版",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "22002",
|
||||
"icon": "22002",
|
||||
"sound": "22002",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "hero_2011",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "90001",
|
||||
"name": "邪恶阿宝",
|
||||
"star": 4,
|
||||
"color": 3,
|
||||
"chengwei": 3,
|
||||
"zhongzu": 1,
|
||||
"job": 1,
|
||||
"type": 1,
|
||||
"prefab": "Person/90001.prefab",
|
||||
"icon": "90001",
|
||||
"sound": "90001",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "57.4",
|
||||
"atkgrow": "7.2",
|
||||
"defgrow": "5.6",
|
||||
"speedgrow": "2",
|
||||
"hp": "576",
|
||||
"atk": "73",
|
||||
"def": "57",
|
||||
"speed": "174",
|
||||
"intr": "",
|
||||
"events": "hero_90001",
|
||||
"cite": "11001"
|
||||
},
|
||||
{
|
||||
"id": "11011",
|
||||
"name": "浣熊",
|
||||
"star": 4,
|
||||
"color": 3,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11011",
|
||||
"icon": "11011",
|
||||
"sound": "11011",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "38.6",
|
||||
"atkgrow": "10.5",
|
||||
"defgrow": "5.7",
|
||||
"speedgrow": "2",
|
||||
"hp": "389",
|
||||
"atk": "106",
|
||||
"def": "58",
|
||||
"speed": "165",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11011.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11008",
|
||||
"name": "悍娇虎",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11008",
|
||||
"icon": "11008",
|
||||
"sound": "11008",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "hero_2011",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11017",
|
||||
"name": "冰霜杰克",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11017",
|
||||
"icon": "11017",
|
||||
"sound": "11017",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11017.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11018",
|
||||
"name": "睡神",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11018",
|
||||
"icon": "11018",
|
||||
"sound": "11018",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11018.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11019",
|
||||
"name": "莫甘娜",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11019",
|
||||
"icon": "11019",
|
||||
"sound": "11019",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11019.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11020",
|
||||
"name": "莫甘娜二阶段",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11020",
|
||||
"icon": "11020",
|
||||
"sound": "11020",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11020.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11021",
|
||||
"name": "莫甘娜巨怪",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11021",
|
||||
"icon": "11021",
|
||||
"sound": "11021",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11021.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "11099",
|
||||
"name": "触手",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "11099",
|
||||
"icon": "11099",
|
||||
"sound": "11099",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11099.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "12001",
|
||||
"name": "黑化阿宝",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "Person/12001.prefab",
|
||||
"icon": "12001",
|
||||
"sound": "121323",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "57.4",
|
||||
"atkgrow": "7.2",
|
||||
"defgrow": "5.6",
|
||||
"speedgrow": "2",
|
||||
"hp": "576",
|
||||
"atk": "73",
|
||||
"def": "57",
|
||||
"speed": "174",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_12001.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "12003",
|
||||
"name": "黑化包比",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "Person/11003.prefab",
|
||||
"icon": "12003",
|
||||
"sound": "12003",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "82.9",
|
||||
"atkgrow": "9.4",
|
||||
"defgrow": "5.8",
|
||||
"speedgrow": "2",
|
||||
"hp": "830",
|
||||
"atk": "95",
|
||||
"def": "59",
|
||||
"speed": "193",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11003.asset",
|
||||
"cite": "11003"
|
||||
},
|
||||
{
|
||||
"id": "12009",
|
||||
"name": "黑化希卡普",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "12009",
|
||||
"icon": "11009",
|
||||
"sound": "11009",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "38.6",
|
||||
"atkgrow": "10.5",
|
||||
"defgrow": "5.7",
|
||||
"speedgrow": "2",
|
||||
"hp": "389",
|
||||
"atk": "106",
|
||||
"def": "58",
|
||||
"speed": "165",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11009.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "12017",
|
||||
"name": "黑化杰克",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "12017",
|
||||
"icon": "12017",
|
||||
"sound": "12017",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11017.asset",
|
||||
"cite": ""
|
||||
},
|
||||
{
|
||||
"id": "12018",
|
||||
"name": "黑化睡神",
|
||||
"star": 5,
|
||||
"color": 4,
|
||||
"chengwei": 4,
|
||||
"zhongzu": 2,
|
||||
"job": 2,
|
||||
"type": 1,
|
||||
"prefab": "12018",
|
||||
"icon": "12018",
|
||||
"sound": "12018",
|
||||
"tujing": "[1]",
|
||||
"hpgrow": "55.6",
|
||||
"atkgrow": "13.6",
|
||||
"defgrow": "5.9",
|
||||
"speedgrow": "2",
|
||||
"hp": "561",
|
||||
"atk": "137",
|
||||
"def": "60",
|
||||
"speed": "183",
|
||||
"intr": "",
|
||||
"events": "EventDataSet/Hero_11018.asset",
|
||||
"cite": "11018"
|
||||
}
|
||||
]
|
@ -1,47 +1,55 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/nacos-group/nacos-sdk-go/util"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (r *Robot) handleLogin(msg *pb.UserMessage) {
|
||||
switch msg.SubType {
|
||||
case "login":
|
||||
handleLogin(r, msg)
|
||||
default:
|
||||
log.Fatal("methodName no exist")
|
||||
}
|
||||
type LoginParam struct {
|
||||
Account string `json:"account"`
|
||||
ServerId int `json:"serverId"`
|
||||
TimeStamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
//处理接口响应数据
|
||||
func handleLogin(r *Robot, msg *pb.UserMessage) {
|
||||
rsp := &pb.UserLoginResp{}
|
||||
if !comm.ProtoDecode(msg, rsp) {
|
||||
return
|
||||
}
|
||||
log.Printf("to client: %v", rsp.Data)
|
||||
func (r *Robot) BuildSecStr() string {
|
||||
jsonByte, _ := jsoniter.Marshal(&LoginParam{
|
||||
Account: r.Opts.Account,
|
||||
ServerId: r.Opts.ServerId,
|
||||
TimeStamp: time.Now().Unix(),
|
||||
})
|
||||
jsonBase64 := utils.Base64Encode(jsonByte)
|
||||
log.Printf("client base64:%s", jsonBase64)
|
||||
clientMd5key := util.Md5(jsonBase64)
|
||||
log.Printf("client md5:%s", clientMd5key)
|
||||
return fmt.Sprintf("CE:%s%s", clientMd5key, jsonBase64)
|
||||
}
|
||||
|
||||
//处理登录请求
|
||||
func (r *Robot) AccountLogin() {
|
||||
//登录
|
||||
sec := r.BuildSecStr()
|
||||
log.Printf("client secret key:%s", sec)
|
||||
loginReg := &pb.UserLoginReq{
|
||||
Name: r.Opts.Account,
|
||||
Sec: sec,
|
||||
}
|
||||
|
||||
head := &pb.UserMessage{
|
||||
MainType: "login",
|
||||
MainType: "user",
|
||||
SubType: "login",
|
||||
}
|
||||
if comm.ProtoEncode(loginReg, head) {
|
||||
data, _ := proto.Marshal(head)
|
||||
err := r.SendToClient(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Fatalf("send err:%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ type Options struct {
|
||||
RegUrl string //账号注册接口地址
|
||||
Account string //玩家账号
|
||||
Create bool
|
||||
Secretkey string //秘钥串
|
||||
ServerId int
|
||||
}
|
||||
|
||||
func DefaultOpts() *Options {
|
||||
@ -12,6 +14,7 @@ func DefaultOpts() *Options {
|
||||
WsUrl: "ws://localhost:7891/gateway",
|
||||
RegUrl: "http://localhost:8000/register",
|
||||
Create: false,
|
||||
ServerId: 1,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ func (r *Robot) Run() {
|
||||
if r.Opts.Create { //创建新用户
|
||||
r.AccountRegister()
|
||||
} else {
|
||||
//login user
|
||||
r.AccountLogin()
|
||||
}
|
||||
|
||||
@ -62,10 +61,10 @@ func (r *Robot) Run() {
|
||||
select {}
|
||||
}
|
||||
|
||||
//模块处理
|
||||
func (r *Robot) handleMsg(msg *pb.UserMessage) {
|
||||
log.Printf("route: %s.%s", msg.MainType, msg.SubType)
|
||||
switch msg.MainType {
|
||||
case "login":
|
||||
r.handleLogin(msg)
|
||||
case "user":
|
||||
r.handleUserMsg(msg)
|
||||
default:
|
||||
@ -73,7 +72,10 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
//在这里添加玩家成功登录以后的测试方法
|
||||
func (r *Robot) onUserLoaded() {
|
||||
//user
|
||||
r.CreateUser("user671")
|
||||
|
||||
}
|
||||
|
||||
@ -103,13 +105,14 @@ func (r *Robot) AccountRegister() {
|
||||
err = jsoniter.Unmarshal(body, regRsp)
|
||||
|
||||
if regRsp.Code == pb.ErrorCode_Success { //注册成功
|
||||
|
||||
//登录
|
||||
loginReg := &pb.UserLoginReq{
|
||||
Name: regReq.Account,
|
||||
Sec: r.BuildSecStr(),
|
||||
}
|
||||
|
||||
head := &pb.UserMessage{
|
||||
MainType: "login",
|
||||
MainType: "user",
|
||||
SubType: "login",
|
||||
}
|
||||
if comm.ProtoEncode(loginReg, head) {
|
||||
|
@ -3,37 +3,62 @@ package robot
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"log"
|
||||
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (r *Robot) handleUserMsg(msg *pb.UserMessage) {
|
||||
|
||||
switch msg.SubType {
|
||||
//创建账号
|
||||
case "login":
|
||||
handleLogin(r, msg)
|
||||
case "create":
|
||||
case "load":
|
||||
handleCreateUser(r, msg)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//加载玩家数据
|
||||
if msg.SubType == "load" {
|
||||
rsp := &pb.UserLoadRsp{}
|
||||
//处理登录响应数据
|
||||
func handleLogin(r *Robot, msg *pb.UserMessage) {
|
||||
rsp := &pb.UserLoginResp{}
|
||||
if !comm.ProtoDecode(msg, rsp) {
|
||||
log.Fatal("load user err")
|
||||
return
|
||||
}
|
||||
log.Printf("登录返回: %v", rsp)
|
||||
|
||||
if rsp.Data.UserData.UserId != "" {
|
||||
//是否有登录数据返回
|
||||
if rsp != nil {
|
||||
r.onUserLoaded()
|
||||
} else {
|
||||
log.Debugf("%s不存在", r.Opts.Account)
|
||||
//创建
|
||||
|
||||
}
|
||||
|
||||
r.AccountRegister() //请求Http接口,模拟创建新账号
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Robot) CreateUser() {
|
||||
func handleCreateUser(r *Robot, msg *pb.UserMessage) {
|
||||
rsp := &pb.UserCreateRsp{}
|
||||
if !comm.ProtoDecode(msg, rsp) {
|
||||
return
|
||||
}
|
||||
log.Printf("创角返回: %v", rsp)
|
||||
}
|
||||
|
||||
//创角色
|
||||
func (r *Robot) CreateUser(NickName string) {
|
||||
req := &pb.UserCreateReq{
|
||||
NickName: NickName,
|
||||
}
|
||||
|
||||
head := &pb.UserMessage{
|
||||
MainType: "user",
|
||||
SubType: "create",
|
||||
}
|
||||
|
||||
if comm.ProtoEncode(req, head) {
|
||||
data, _ := proto.Marshal(head)
|
||||
err := r.SendToClient(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,9 +17,10 @@ const (
|
||||
const (
|
||||
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块
|
||||
SM_WebModule core.M_Modules = "web" //web模块
|
||||
SM_LoginModule core.M_Modules = "user" //用户模块
|
||||
SM_UserModule core.M_Modules = "user" //用户模块
|
||||
SM_PackModule core.M_Modules = "pack" //背包模块
|
||||
SM_MailModule core.M_Modules = "mail" //邮件模块
|
||||
SM_FriendModule core.M_Modules = "friend" //好友模块
|
||||
)
|
||||
|
||||
const ( //Rpc
|
||||
@ -32,6 +33,10 @@ const ( //Rpc
|
||||
Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接
|
||||
)
|
||||
|
||||
const (
|
||||
Event_UserLogin core.Event_Key = "Event_UserLogin" //登录事件
|
||||
)
|
||||
|
||||
type ISC_GateRouteComp interface {
|
||||
core.IServiceComp
|
||||
RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method)
|
||||
|
@ -53,7 +53,7 @@ func (this *UserSession) Build(uid string) (err error) {
|
||||
UserSessionId: this.SessionId,
|
||||
UserId: uid,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("UserSession:%s UserId:%d Build:%s err:%v", this.SessionId, this.UserId, err)
|
||||
log.Errorf("UserSession:%s UserId:%s Build:%s err:%v", this.SessionId, this.UserId, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -63,7 +63,7 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e
|
||||
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentUnBuild), context.Background(), &pb.AgentUnBuildReq{
|
||||
UserSessionId: this.SessionId,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("UserSession:%s UserId:%d UnBuild err:%v", this.SessionId, this.UserId, err)
|
||||
log.Errorf("UserSession:%s UserId:%s UnBuild err:%v", this.SessionId, this.UserId, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -79,7 +79,7 @@ func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, ms
|
||||
Code: code,
|
||||
Data: data,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err)
|
||||
log.Errorf("UserSession:%s UserId:%s SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -94,5 +94,5 @@ func (this *UserSession) Close() (err error) {
|
||||
}
|
||||
|
||||
func (this *UserSession) ToString() string {
|
||||
return fmt.Sprintf("SessionId:%s UserId:%d GatewayServiceId:%s", this.SessionId, this.UserId, this.GatewayServiceId)
|
||||
return fmt.Sprintf("SessionId:%s UserId:%s GatewayServiceId:%s", this.SessionId, this.UserId, this.GatewayServiceId)
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@ -21,6 +21,7 @@ require (
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.7.1
|
||||
github.com/tidwall/gjson v1.14.1
|
||||
github.com/ugorji/go/codec v1.2.7
|
||||
go.mongodb.org/mongo-driver v1.5.1
|
||||
go.uber.org/zap v1.21.0
|
||||
@ -102,6 +103,8 @@ require (
|
||||
github.com/soheilhy/cmux v0.1.5 // indirect
|
||||
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect
|
||||
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tinylib/msgp v1.1.6 // indirect
|
||||
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||
github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect
|
||||
|
7
go.sum
7
go.sum
@ -647,8 +647,13 @@ github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 h1:89CEmDvlq/F7S
|
||||
github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU=
|
||||
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b h1:fj5tQ8acgNUr6O8LEplsxDhUIe2573iLkJc+PqnzZTI=
|
||||
github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
|
||||
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
|
||||
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
|
||||
github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho=
|
||||
|
67
modules/friend/friend_comp.go
Normal file
67
modules/friend/friend_comp.go
Normal file
@ -0,0 +1,67 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
type FriendComp struct {
|
||||
modules.MComp_GateComp
|
||||
}
|
||||
|
||||
//搜索
|
||||
func (this *FriendComp) Search(ctx context.Context, session comm.IUserSession, req *pb.FriendSearchReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//添加好友
|
||||
func (this *FriendComp) Add(ctx context.Context, session comm.IUserSession, req *pb.FriendAddReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//删除好友
|
||||
func (this *FriendComp) Del(ctx context.Context, session comm.IUserSession, req *pb.FriendDelReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//好友列表
|
||||
func (this *FriendComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//同意或拒绝
|
||||
func (this *FriendComp) Check(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//批量同意或拒绝
|
||||
func (this *FriendComp) CheckAll(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//赠送或接收
|
||||
func (this *FriendComp) ReceSend(ctx context.Context, session comm.IUserSession, req *pb.FriendReceiveOrSendReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//好友数量
|
||||
func (this *FriendComp) Total(ctx context.Context, session comm.IUserSession, req *pb.FriendTotalReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//好友详情
|
||||
func (this *FriendComp) Detail(ctx context.Context, session comm.IUserSession, req *pb.FriendTotalReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//黑名单
|
||||
func (this *FriendComp) Blacklist(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackListReq) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
//加入黑名单
|
||||
func (this *FriendComp) Addblack(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackAddReq) error {
|
||||
return nil
|
||||
}
|
32
modules/friend/module.go
Normal file
32
modules/friend/module.go
Normal file
@ -0,0 +1,32 @@
|
||||
package friend
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
)
|
||||
|
||||
func NewModule() core.IModule {
|
||||
m := new(Friend)
|
||||
return m
|
||||
}
|
||||
|
||||
type Friend struct {
|
||||
modules.ModuleBase
|
||||
}
|
||||
|
||||
func (this *Friend) GetType() core.M_Modules {
|
||||
return comm.SM_UserModule
|
||||
}
|
||||
|
||||
func (this *Friend) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Friend) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
|
||||
}
|
@ -53,19 +53,19 @@ func (this *Agent) readLoop() {
|
||||
locp:
|
||||
for {
|
||||
if _, data, err = this.wsConn.ReadMessage(); err != nil {
|
||||
log.Errorf("agent:%s uId:%d ReadMessage err:%v", this.sessionId, this.uId, err)
|
||||
log.Errorf("agent:%s uId:%s ReadMessage err:%v", this.sessionId, this.uId, err)
|
||||
go this.Close()
|
||||
break locp
|
||||
}
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
log.Errorf("agent:%s uId:%d Unmarshal err:%v", this.sessionId, this.uId, err)
|
||||
log.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
|
||||
go this.Close()
|
||||
break locp
|
||||
} else {
|
||||
this.messageDistribution(msg)
|
||||
}
|
||||
}
|
||||
log.Debugf("agent:%s uId:%d readLoop end!", this.sessionId, this.uId)
|
||||
log.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId)
|
||||
}
|
||||
|
||||
func (this *Agent) writeLoop() {
|
||||
@ -91,7 +91,7 @@ locp:
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Debugf("agent:%s uId:%d writeLoop end!", this.sessionId, this.uId)
|
||||
log.Debugf("agent:%s uId:%s writeLoop end!", this.sessionId, this.uId)
|
||||
}
|
||||
|
||||
func (this *Agent) SessionId() string {
|
||||
@ -136,7 +136,7 @@ func (this *Agent) Close() {
|
||||
//分发用户消息
|
||||
func (this *Agent) messageDistribution(msg *pb.UserMessage) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
log.Debugf("agent:%s uId:%d MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{
|
||||
Ip: this.IP(),
|
||||
UserSessionId: this.sessionId,
|
||||
@ -145,8 +145,8 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) {
|
||||
Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
|
||||
Message: msg.Data,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||
log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||
} else {
|
||||
log.Debugf("agent:%s uId:%d MessageDistribution reply:%v", this.sessionId, this.uId, reply)
|
||||
log.Debugf("agent:%s uId:%s MessageDistribution reply:%v", this.sessionId, this.uId, reply)
|
||||
}
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
package gateway_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func Test_WebSocket(t *testing.T) {
|
||||
url := "ws://localhost:7891/gateway" //服务器地址
|
||||
ws, _, err := websocket.DefaultDialer.Dial(url, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("err:%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||
for {
|
||||
_, data, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
fmt.Printf("err:%v\n", err)
|
||||
}
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
fmt.Printf("err:%v\n", err)
|
||||
} else {
|
||||
fmt.Printf("ReadMessage msg:%v\n", msg)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
loginreq := &pb.UserLoginReq{
|
||||
Name: "aaa",
|
||||
}
|
||||
logindata, _ := proto.Marshal(loginreq)
|
||||
message := &pb.UserMessage{
|
||||
MainType: "login",
|
||||
SubType: "login",
|
||||
Data: logindata,
|
||||
}
|
||||
data, _ := proto.Marshal(message)
|
||||
err = ws.WriteMessage(websocket.BinaryMessage, data)
|
||||
if err != nil {
|
||||
fmt.Printf("err:%v\n", err)
|
||||
}
|
||||
|
||||
sigterm := make(chan os.Signal, 1)
|
||||
signal.Notify(sigterm, syscall.SIGINT, syscall.SIGTERM)
|
||||
select {
|
||||
case <-sigterm:
|
||||
fmt.Printf("terminating: via signal\n")
|
||||
}
|
||||
}
|
@ -64,6 +64,6 @@ func (this *Gateway) Connect(a IAgent) {
|
||||
|
||||
//有新的连接对象进入
|
||||
func (this *Gateway) DisConnect(a IAgent) {
|
||||
log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%d]", a.IP(), a.SessionId(), a.UserId())
|
||||
log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%s]", a.IP(), a.SessionId(), a.UserId())
|
||||
this.agentmgr_comp.DisConnect(a)
|
||||
}
|
||||
|
@ -1,14 +1,26 @@
|
||||
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 (
|
||||
QueryUserMailReq = "mail.queryusermailreq"
|
||||
QueryUserMailResp = "mail.queryusermailresp"
|
||||
ReadUserMailReq = "mail.readusermailreq"
|
||||
ReadUserMailResp = "mail.readusermailresp"
|
||||
GetUserMailAttachmentReq = "mail.getusermailattachmentreq"
|
||||
GetUserMailAttachmentResp = "mail.getusermailattachmentresp"
|
||||
DelUserMailReq = "mail.delusermailreq"
|
||||
DelUserMailResp = "mail.delusermailresp"
|
||||
)
|
||||
|
||||
type Api_Comp struct {
|
||||
@ -21,3 +33,101 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core
|
||||
this.module = module.(*Mail)
|
||||
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("mail", "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.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.GetMailAttachmentState(req.ObjID)
|
||||
if !_bGet {
|
||||
code = pb.ErrorCode_StateInvalid
|
||||
return
|
||||
}
|
||||
_data, err := db.Defsys.GetMailAttachment(req.ObjID)
|
||||
if err != nil {
|
||||
if len(_data) > 0 {
|
||||
// todo 领取附件
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
// 修改状态
|
||||
db.Defsys.UpdateMailAttachmentState(req.ObjID)
|
||||
mail.Reward = true
|
||||
|
||||
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.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
|
||||
}
|
||||
|
@ -2,16 +2,19 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/cache"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/sys/db"
|
||||
"go_dreamfactory/utils"
|
||||
"time"
|
||||
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
@ -19,53 +22,77 @@ type LoginComp struct {
|
||||
modules.MComp_GateComp
|
||||
}
|
||||
|
||||
func DecodeUserData(base64Str string) *pb.DB_UserData {
|
||||
//解码
|
||||
dec, err := base64.StdEncoding.DecodeString(base64Str[35:])
|
||||
if err != nil {
|
||||
log.Errorf("base64 decode err %v", err)
|
||||
return nil
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
jsonRet := gjson.Parse(string(dec))
|
||||
serverId := jsonRet.Get("serverId").Int()
|
||||
timestamp := jsonRet.Get("timestamp").Int()
|
||||
if now-time.Unix(timestamp, 0).Unix() > 100 {
|
||||
return nil
|
||||
}
|
||||
account := jsonRet.Get("account").String()
|
||||
return &pb.DB_UserData{
|
||||
ServerId: int32(serverId),
|
||||
Account: account,
|
||||
}
|
||||
}
|
||||
|
||||
//登录
|
||||
func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error {
|
||||
log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req)
|
||||
var code pb.ErrorCode = pb.ErrorCode_Success
|
||||
if !utils.ValidSecretKey(req.Sec) {
|
||||
session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
db_user, err := db.Defsys.User_FindUserByAccount(req.Name)
|
||||
user := DecodeUserData(req.Sec)
|
||||
|
||||
db_user, err := db.Defsys.User_FindUserByAccount(user)
|
||||
if err != nil {
|
||||
if err != mongo.ErrNoDocuments {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if db_user.UserId == "" {
|
||||
db_user.Account = req.Name
|
||||
err = db.Defsys.User_CreateUser(db_user)
|
||||
//如果是新玩家,创建一条基础的数据,页面会引导进入创角页面
|
||||
if db_user == nil {
|
||||
err = db.Defsys.User_CreateUser(user)
|
||||
if err != nil {
|
||||
log.Errorf("User_CreateUser err %v", err)
|
||||
return err
|
||||
}
|
||||
session.Build(user.UserId)
|
||||
} else {
|
||||
session.Build(db_user.UserId)
|
||||
}
|
||||
|
||||
session.Build(db_user.UserId)
|
||||
if data, ret := configure.GetConfigure("tbitem.json"); ret == nil {
|
||||
_data := data.(*cfg.TbItem).GetDataMap()
|
||||
for _, v := range _data {
|
||||
if v.Id > 0 {
|
||||
break
|
||||
}
|
||||
log.Debugf(v.Name)
|
||||
}
|
||||
}
|
||||
cache_user := &pb.Cache_UserData{
|
||||
SessionId: session.GetSessionId(),
|
||||
GatewayServiceId: session.GetGatewayServiceId(),
|
||||
UserData: db_user,
|
||||
}
|
||||
err = cache.Defsys.User_UpdateUser(cache_user)
|
||||
err = cache.Defsys.Update(cache_user)
|
||||
if err != nil {
|
||||
log.Errorf("update cache err:%v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
session.SendMsg("login", "login", pb.ErrorCode_Success, &pb.UserLoginResp{
|
||||
err = session.SendMsg("user", "login", code, &pb.UserLoginResp{
|
||||
Data: &pb.Cache_UserData{
|
||||
UserData: &pb.DB_UserData{
|
||||
UserId: db_user.UserId,
|
||||
},
|
||||
UserData: db_user,
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
event.TriggerEvent(comm.Event_UserLogin, db_user.UserId)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,21 @@ func NewModule() core.IModule {
|
||||
type User struct {
|
||||
modules.ModuleBase
|
||||
login_comp *LoginComp
|
||||
user_comp *UserComp
|
||||
}
|
||||
|
||||
func (this *User) GetType() core.M_Modules {
|
||||
return comm.SM_LoginModule
|
||||
return comm.SM_UserModule
|
||||
}
|
||||
|
||||
func (this *User) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *User) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.login_comp = this.RegisterComp(new(LoginComp)).(*LoginComp)
|
||||
this.user_comp = this.RegisterComp(new(UserComp)).(*UserComp)
|
||||
}
|
||||
|
@ -5,13 +5,39 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/cache"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
)
|
||||
|
||||
type UserComp struct {
|
||||
modules.MComp_GateComp
|
||||
module *User
|
||||
}
|
||||
|
||||
func (this *UserComp) 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.(*User)
|
||||
return
|
||||
}
|
||||
|
||||
//创角
|
||||
func (this *UserComp) CreateUser(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error {
|
||||
func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) error {
|
||||
defer utils.TraceFunc(session.GetUserId(), "user", "create", req, nil)
|
||||
user := cache.Defsys.Get(session.GetUserId())
|
||||
if user == nil {
|
||||
log.Errorf("user no exist")
|
||||
session.SendMsg("user", "create", pb.ErrorCode_UserSessionNobeing, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
user.UserData.NiceName = req.NickName
|
||||
err := cache.Defsys.Update(user)
|
||||
if err != nil {
|
||||
log.Errorf("cache update err")
|
||||
}
|
||||
session.SendMsg("user", "create", pb.ErrorCode_Success, &pb.UserCreateRsp{})
|
||||
return nil
|
||||
}
|
||||
|
@ -33,6 +33,10 @@ const (
|
||||
ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足
|
||||
ErrorCode_NoLogin ErrorCode = 17 //未登录
|
||||
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
||||
ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误
|
||||
ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效
|
||||
ErrorCode_StateInvalid ErrorCode = 21 //无效状态
|
||||
ErrorCode_DBError ErrorCode = 22 // 数据库操作失败
|
||||
)
|
||||
|
||||
// Enum value maps for ErrorCode.
|
||||
@ -48,6 +52,10 @@ var (
|
||||
16: "InsufficientPermissions",
|
||||
17: "NoLogin",
|
||||
18: "UserSessionNobeing",
|
||||
19: "SecKey",
|
||||
20: "SecKeyInvalid",
|
||||
21: "StateInvalid",
|
||||
22: "DBError",
|
||||
}
|
||||
ErrorCode_value = map[string]int32{
|
||||
"Success": 0,
|
||||
@ -60,6 +68,10 @@ var (
|
||||
"InsufficientPermissions": 16,
|
||||
"NoLogin": 17,
|
||||
"UserSessionNobeing": 18,
|
||||
"SecKey": 19,
|
||||
"SecKeyInvalid": 20,
|
||||
"StateInvalid": 21,
|
||||
"DBError": 22,
|
||||
}
|
||||
)
|
||||
|
||||
@ -94,7 +106,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_errorcode_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x2a, 0xd9, 0x01, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x6f, 0x2a, 0x97, 0x02, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
|
||||
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
||||
0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
|
||||
@ -107,8 +119,12 @@ var file_errorcode_proto_rawDesc = []byte{
|
||||
0x6e, 0x73, 0x75, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x10, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x6f, 0x4c, 0x6f,
|
||||
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a,
|
||||
0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x63,
|
||||
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c,
|
||||
0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x15, 0x12, 0x0b,
|
||||
0x0a, 0x07, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
146
pb/friend_db.pb.go
Normal file
146
pb/friend_db.pb.go
Normal file
@ -0,0 +1,146 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v3.20.0
|
||||
// source: friend_db.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Friend struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserData *DB_UserData `protobuf:"bytes,1,opt,name=UserData,proto3" json:"UserData,omitempty"` //用户
|
||||
}
|
||||
|
||||
func (x *Friend) Reset() {
|
||||
*x = Friend{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_friend_db_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Friend) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Friend) ProtoMessage() {}
|
||||
|
||||
func (x *Friend) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_friend_db_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Friend.ProtoReflect.Descriptor instead.
|
||||
func (*Friend) Descriptor() ([]byte, []int) {
|
||||
return file_friend_db_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Friend) GetUserData() *DB_UserData {
|
||||
if x != nil {
|
||||
return x.UserData
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_friend_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_friend_db_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x22, 0x32, 0x0a, 0x06, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44,
|
||||
0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72,
|
||||
0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_friend_db_proto_rawDescOnce sync.Once
|
||||
file_friend_db_proto_rawDescData = file_friend_db_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_friend_db_proto_rawDescGZIP() []byte {
|
||||
file_friend_db_proto_rawDescOnce.Do(func() {
|
||||
file_friend_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_friend_db_proto_rawDescData)
|
||||
})
|
||||
return file_friend_db_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_friend_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_friend_db_proto_goTypes = []interface{}{
|
||||
(*Friend)(nil), // 0: Friend
|
||||
(*DB_UserData)(nil), // 1: DB_UserData
|
||||
}
|
||||
var file_friend_db_proto_depIdxs = []int32{
|
||||
1, // 0: Friend.UserData:type_name -> DB_UserData
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_friend_db_proto_init() }
|
||||
func file_friend_db_proto_init() {
|
||||
if File_friend_db_proto != nil {
|
||||
return
|
||||
}
|
||||
file_user_db_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_friend_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Friend); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_friend_db_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_friend_db_proto_goTypes,
|
||||
DependencyIndexes: file_friend_db_proto_depIdxs,
|
||||
MessageInfos: file_friend_db_proto_msgTypes,
|
||||
}.Build()
|
||||
File_friend_db_proto = out.File
|
||||
file_friend_db_proto_rawDesc = nil
|
||||
file_friend_db_proto_goTypes = nil
|
||||
file_friend_db_proto_depIdxs = nil
|
||||
}
|
1520
pb/friend_msg.pb.go
Normal file
1520
pb/friend_msg.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
292
pb/mail_db.pb.go
Normal file
292
pb/mail_db.pb.go
Normal file
@ -0,0 +1,292 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v3.20.0
|
||||
// source: mail_db.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type MailAttachment struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ItemId uint32 `protobuf:"varint,1,opt,name=ItemId,proto3" json:"ItemId,omitempty"` // 道具iD
|
||||
ItemCount uint32 `protobuf:"varint,2,opt,name=ItemCount,proto3" json:"ItemCount,omitempty"` // 数量
|
||||
}
|
||||
|
||||
func (x *MailAttachment) Reset() {
|
||||
*x = MailAttachment{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_db_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *MailAttachment) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MailAttachment) ProtoMessage() {}
|
||||
|
||||
func (x *MailAttachment) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_db_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MailAttachment.ProtoReflect.Descriptor instead.
|
||||
func (*MailAttachment) Descriptor() ([]byte, []int) {
|
||||
return file_mail_db_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *MailAttachment) GetItemId() uint32 {
|
||||
if x != nil {
|
||||
return x.ItemId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MailAttachment) GetItemCount() uint32 {
|
||||
if x != nil {
|
||||
return x.ItemCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type DB_MailData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId,omitempty" bson:"_id"` // tags:{bson:"_id"}
|
||||
UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
|
||||
Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title,omitempty"` // 邮件标题
|
||||
Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容
|
||||
CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"` // 发送时间
|
||||
DueTime uint64 `protobuf:"varint,6,opt,name=DueTime,proto3" json:"DueTime,omitempty"` // 过期时间
|
||||
Check bool `protobuf:"varint,7,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看
|
||||
Reward bool `protobuf:"varint,8,opt,name=Reward,proto3" json:"Reward,omitempty"` // 附件领取状态
|
||||
Items []*MailAttachment `protobuf:"bytes,9,rep,name=Items,proto3" json:"Items,omitempty"` // 附件
|
||||
}
|
||||
|
||||
func (x *DB_MailData) Reset() {
|
||||
*x = DB_MailData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_db_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DB_MailData) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DB_MailData) ProtoMessage() {}
|
||||
|
||||
func (x *DB_MailData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_db_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DB_MailData.ProtoReflect.Descriptor instead.
|
||||
func (*DB_MailData) Descriptor() ([]byte, []int) {
|
||||
return file_mail_db_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetObjId() string {
|
||||
if x != nil {
|
||||
return x.ObjId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetContex() string {
|
||||
if x != nil {
|
||||
return x.Contex
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetCreateTime() uint64 {
|
||||
if x != nil {
|
||||
return x.CreateTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetDueTime() uint64 {
|
||||
if x != nil {
|
||||
return x.DueTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetCheck() bool {
|
||||
if x != nil {
|
||||
return x.Check
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetReward() bool {
|
||||
if x != nil {
|
||||
return x.Reward
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *DB_MailData) GetItems() []*MailAttachment {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_mail_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_mail_db_proto_rawDesc = []byte{
|
||||
0x0a, 0x0d, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x46, 0x0a, 0x0e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e,
|
||||
0x74, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x74, 0x65,
|
||||
0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x49, 0x74,
|
||||
0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xf8, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d,
|
||||
0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55,
|
||||
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43,
|
||||
0x6f, 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6e,
|
||||
0x74, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d,
|
||||
0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54,
|
||||
0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06,
|
||||
0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68,
|
||||
0x65, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69,
|
||||
0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65,
|
||||
0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_mail_db_proto_rawDescOnce sync.Once
|
||||
file_mail_db_proto_rawDescData = file_mail_db_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_mail_db_proto_rawDescGZIP() []byte {
|
||||
file_mail_db_proto_rawDescOnce.Do(func() {
|
||||
file_mail_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_mail_db_proto_rawDescData)
|
||||
})
|
||||
return file_mail_db_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_mail_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_mail_db_proto_goTypes = []interface{}{
|
||||
(*MailAttachment)(nil), // 0: MailAttachment
|
||||
(*DB_MailData)(nil), // 1: DB_MailData
|
||||
}
|
||||
var file_mail_db_proto_depIdxs = []int32{
|
||||
0, // 0: DB_MailData.Items:type_name -> MailAttachment
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_mail_db_proto_init() }
|
||||
func file_mail_db_proto_init() {
|
||||
if File_mail_db_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_mail_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*MailAttachment); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DB_MailData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_mail_db_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_mail_db_proto_goTypes,
|
||||
DependencyIndexes: file_mail_db_proto_depIdxs,
|
||||
MessageInfos: file_mail_db_proto_msgTypes,
|
||||
}.Build()
|
||||
File_mail_db_proto = out.File
|
||||
file_mail_db_proto_rawDesc = nil
|
||||
file_mail_db_proto_goTypes = nil
|
||||
file_mail_db_proto_depIdxs = nil
|
||||
}
|
584
pb/mail_msg.pb.go
Normal file
584
pb/mail_msg.pb.go
Normal file
@ -0,0 +1,584 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v3.20.0
|
||||
// source: mail_msg.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type QueryUserMailReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *QueryUserMailReq) Reset() {
|
||||
*x = QueryUserMailReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *QueryUserMailReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*QueryUserMailReq) ProtoMessage() {}
|
||||
|
||||
func (x *QueryUserMailReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use QueryUserMailReq.ProtoReflect.Descriptor instead.
|
||||
func (*QueryUserMailReq) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
// 查询邮件信息
|
||||
type QueryUserMailResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Mails []*DB_MailData `protobuf:"bytes,1,rep,name=Mails,proto3" json:"Mails,omitempty"`
|
||||
}
|
||||
|
||||
func (x *QueryUserMailResp) Reset() {
|
||||
*x = QueryUserMailResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *QueryUserMailResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*QueryUserMailResp) ProtoMessage() {}
|
||||
|
||||
func (x *QueryUserMailResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use QueryUserMailResp.ProtoReflect.Descriptor instead.
|
||||
func (*QueryUserMailResp) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *QueryUserMailResp) GetMails() []*DB_MailData {
|
||||
if x != nil {
|
||||
return x.Mails
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 查看邮件
|
||||
type ReadUserMailReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ObjID string `protobuf:"bytes,1,opt,name=ObjID,proto3" json:"ObjID,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReadUserMailReq) Reset() {
|
||||
*x = ReadUserMailReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReadUserMailReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadUserMailReq) ProtoMessage() {}
|
||||
|
||||
func (x *ReadUserMailReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadUserMailReq.ProtoReflect.Descriptor instead.
|
||||
func (*ReadUserMailReq) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ReadUserMailReq) GetObjID() string {
|
||||
if x != nil {
|
||||
return x.ObjID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ReadUserMailResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Mail *DB_MailData `protobuf:"bytes,1,opt,name=Mail,proto3" json:"Mail,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReadUserMailResp) Reset() {
|
||||
*x = ReadUserMailResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ReadUserMailResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadUserMailResp) ProtoMessage() {}
|
||||
|
||||
func (x *ReadUserMailResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ReadUserMailResp.ProtoReflect.Descriptor instead.
|
||||
func (*ReadUserMailResp) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ReadUserMailResp) GetMail() *DB_MailData {
|
||||
if x != nil {
|
||||
return x.Mail
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 领取附件
|
||||
type GetUserMailAttachmentReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ObjID string `protobuf:"bytes,1,opt,name=ObjID,proto3" json:"ObjID,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetUserMailAttachmentReq) Reset() {
|
||||
*x = GetUserMailAttachmentReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetUserMailAttachmentReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserMailAttachmentReq) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserMailAttachmentReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserMailAttachmentReq.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserMailAttachmentReq) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *GetUserMailAttachmentReq) GetObjID() string {
|
||||
if x != nil {
|
||||
return x.ObjID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUserMailAttachmentResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Mail *DB_MailData `protobuf:"bytes,1,opt,name=Mail,proto3" json:"Mail,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetUserMailAttachmentResp) Reset() {
|
||||
*x = GetUserMailAttachmentResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetUserMailAttachmentResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserMailAttachmentResp) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserMailAttachmentResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserMailAttachmentResp.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserMailAttachmentResp) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *GetUserMailAttachmentResp) GetMail() *DB_MailData {
|
||||
if x != nil {
|
||||
return x.Mail
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 删除某个邮件
|
||||
type DelUserMailReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ObjID string `protobuf:"bytes,1,opt,name=ObjID,proto3" json:"ObjID,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DelUserMailReq) Reset() {
|
||||
*x = DelUserMailReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DelUserMailReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DelUserMailReq) ProtoMessage() {}
|
||||
|
||||
func (x *DelUserMailReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DelUserMailReq.ProtoReflect.Descriptor instead.
|
||||
func (*DelUserMailReq) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *DelUserMailReq) GetObjID() string {
|
||||
if x != nil {
|
||||
return x.ObjID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DelUserMailResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Mail []*DB_MailData `protobuf:"bytes,1,rep,name=Mail,proto3" json:"Mail,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DelUserMailResp) Reset() {
|
||||
*x = DelUserMailResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_msg_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DelUserMailResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DelUserMailResp) ProtoMessage() {}
|
||||
|
||||
func (x *DelUserMailResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_msg_proto_msgTypes[7]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DelUserMailResp.ProtoReflect.Descriptor instead.
|
||||
func (*DelUserMailResp) Descriptor() ([]byte, []int) {
|
||||
return file_mail_msg_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *DelUserMailResp) GetMail() []*DB_MailData {
|
||||
if x != nil {
|
||||
return x.Mail
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_mail_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_mail_msg_proto_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x0d, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x12, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c,
|
||||
0x52, 0x65, 0x71, 0x22, 0x37, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72,
|
||||
0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x05, 0x4d, 0x61, 0x69, 0x6c,
|
||||
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69,
|
||||
0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x4d, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x27, 0x0a, 0x0f,
|
||||
0x52, 0x65, 0x61, 0x64, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12,
|
||||
0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
|
||||
0x4f, 0x62, 0x6a, 0x49, 0x44, 0x22, 0x34, 0x0a, 0x10, 0x52, 0x65, 0x61, 0x64, 0x55, 0x73, 0x65,
|
||||
0x72, 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x4d, 0x61, 0x69,
|
||||
0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69,
|
||||
0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x22, 0x30, 0x0a, 0x18, 0x47,
|
||||
0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68,
|
||||
0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x22, 0x3d, 0x0a,
|
||||
0x19, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61,
|
||||
0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x4d, 0x61,
|
||||
0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61,
|
||||
0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x22, 0x26, 0x0a, 0x0e,
|
||||
0x44, 0x65, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f,
|
||||
0x62, 0x6a, 0x49, 0x44, 0x22, 0x33, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x4d,
|
||||
0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x18,
|
||||
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, 0x6c, 0x44,
|
||||
0x61, 0x74, 0x61, 0x52, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_mail_msg_proto_rawDescOnce sync.Once
|
||||
file_mail_msg_proto_rawDescData = file_mail_msg_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_mail_msg_proto_rawDescGZIP() []byte {
|
||||
file_mail_msg_proto_rawDescOnce.Do(func() {
|
||||
file_mail_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_mail_msg_proto_rawDescData)
|
||||
})
|
||||
return file_mail_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_mail_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_mail_msg_proto_goTypes = []interface{}{
|
||||
(*QueryUserMailReq)(nil), // 0: QueryUserMailReq
|
||||
(*QueryUserMailResp)(nil), // 1: QueryUserMailResp
|
||||
(*ReadUserMailReq)(nil), // 2: ReadUserMailReq
|
||||
(*ReadUserMailResp)(nil), // 3: ReadUserMailResp
|
||||
(*GetUserMailAttachmentReq)(nil), // 4: GetUserMailAttachmentReq
|
||||
(*GetUserMailAttachmentResp)(nil), // 5: GetUserMailAttachmentResp
|
||||
(*DelUserMailReq)(nil), // 6: DelUserMailReq
|
||||
(*DelUserMailResp)(nil), // 7: DelUserMailResp
|
||||
(*DB_MailData)(nil), // 8: DB_MailData
|
||||
}
|
||||
var file_mail_msg_proto_depIdxs = []int32{
|
||||
8, // 0: QueryUserMailResp.Mails:type_name -> DB_MailData
|
||||
8, // 1: ReadUserMailResp.Mail:type_name -> DB_MailData
|
||||
8, // 2: GetUserMailAttachmentResp.Mail:type_name -> DB_MailData
|
||||
8, // 3: DelUserMailResp.Mail:type_name -> DB_MailData
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_mail_msg_proto_init() }
|
||||
func file_mail_msg_proto_init() {
|
||||
if File_mail_msg_proto != nil {
|
||||
return
|
||||
}
|
||||
file_mail_db_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_mail_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*QueryUserMailReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*QueryUserMailResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ReadUserMailReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ReadUserMailResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetUserMailAttachmentReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetUserMailAttachmentResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DelUserMailReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DelUserMailResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_mail_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_mail_msg_proto_goTypes,
|
||||
DependencyIndexes: file_mail_msg_proto_depIdxs,
|
||||
MessageInfos: file_mail_msg_proto_msgTypes,
|
||||
}.Build()
|
||||
File_mail_msg_proto = out.File
|
||||
file_mail_msg_proto_rawDesc = nil
|
||||
file_mail_msg_proto_goTypes = nil
|
||||
file_mail_msg_proto_depIdxs = nil
|
||||
}
|
@ -107,7 +107,7 @@ type DB_UserPackData struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id
|
||||
Pack []*DB_GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||
Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||
}
|
||||
|
||||
func (x *DB_UserPackData) Reset() {
|
||||
|
@ -13,4 +13,8 @@ enum ErrorCode {
|
||||
InsufficientPermissions = 16; //权限不足
|
||||
NoLogin = 17; //未登录
|
||||
UserSessionNobeing = 18; //用户不存在
|
||||
SecKey = 19; //秘钥格式错误
|
||||
SecKeyInvalid = 20; //秘钥无效
|
||||
StateInvalid = 21; //无效状态
|
||||
DBError = 22; // 数据库操作失败
|
||||
}
|
8
pb/proto/friend_db.proto
Normal file
8
pb/proto/friend_db.proto
Normal file
@ -0,0 +1,8 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "user_db.proto";
|
||||
|
||||
message Friend {
|
||||
DB_UserData UserData = 1;//用户
|
||||
//工会
|
||||
}
|
111
pb/proto/friend_msg.proto
Normal file
111
pb/proto/friend_msg.proto
Normal file
@ -0,0 +1,111 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "friend_db.proto";
|
||||
|
||||
message FriendBase {
|
||||
string userId = 1; //ID
|
||||
string NickName = 2; //昵称
|
||||
int32 level = 3; //等级
|
||||
int32 avatar = 4; //头像
|
||||
int64 strength = 5; //战力
|
||||
int32 serverId = 6;//服务编号
|
||||
int64 offlineTime =7;//最近一次下线时间 0在线
|
||||
}
|
||||
|
||||
//好友列表
|
||||
message FriendListReq{
|
||||
|
||||
}
|
||||
message FriendListRsp{
|
||||
repeated Friend list = 1;
|
||||
}
|
||||
|
||||
//添加好友
|
||||
message FriendAddReq{
|
||||
string friendId = 1; //好友ID
|
||||
}
|
||||
message FriendAddRsp{
|
||||
string userId = 1; //用户ID
|
||||
}
|
||||
|
||||
//删除好友
|
||||
message FriendDelReq{
|
||||
string friendId = 1;//好友ID
|
||||
|
||||
}
|
||||
|
||||
message FriendDelRsp{
|
||||
string friendId = 1;//好友ID
|
||||
string userId = 2; //用户ID
|
||||
}
|
||||
|
||||
//同意或拒绝
|
||||
message FriendAgreeOrRefuseReq{
|
||||
string friendId = 1; //被同意或拒绝的用户
|
||||
bool isAgree = 2;
|
||||
|
||||
}
|
||||
message FriendAgressOrRefuseRsp{
|
||||
int32 Num = 1;//操作的数量
|
||||
bool isAgree = 2;
|
||||
}
|
||||
|
||||
|
||||
//好友申请列表
|
||||
message FriendApplyListReq{
|
||||
|
||||
}
|
||||
message FriendApplyListRsp{
|
||||
|
||||
}
|
||||
|
||||
//好友搜索
|
||||
message FriendSearchReq{
|
||||
string friendId = 1;
|
||||
string nickName = 2; //好友昵称
|
||||
}
|
||||
|
||||
message FriendSearchRsp{
|
||||
repeated FriendBase friends = 1;
|
||||
}
|
||||
|
||||
//黑名单
|
||||
message FriendBlackListReq{
|
||||
|
||||
}
|
||||
|
||||
message FriendBlackListRsp{
|
||||
repeated FriendBase friends = 1;
|
||||
}
|
||||
|
||||
//添加黑名单
|
||||
message FriendBlackAddReq{
|
||||
string friendId = 1;
|
||||
}
|
||||
|
||||
message FriendBlackAddRsp{
|
||||
string friendId = 1;
|
||||
string userId = 2;
|
||||
}
|
||||
|
||||
//赠送或接收
|
||||
message FriendReceiveOrSendReq{
|
||||
string friendId = 1;
|
||||
bool isReceive = 2;
|
||||
}
|
||||
|
||||
message FriendReceiveOrSendRsp{
|
||||
string friendId = 1;
|
||||
string userId = 2;
|
||||
bool isReceive = 3;
|
||||
}
|
||||
|
||||
//好友数量
|
||||
message FriendTotalReq{
|
||||
string friendId = 1;
|
||||
}
|
||||
|
||||
message FriendTotalRsp{
|
||||
string friendId = 1;
|
||||
int32 total = 2; //好友数量
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
|
||||
message MailAttachment { // 附件
|
||||
uint32 Itemid = 1; // 道具iD
|
||||
uint32 ItemCount = 2; // 数量
|
||||
}
|
||||
|
||||
message MailData {
|
||||
string Title = 1; // 邮件标题
|
||||
string Contex = 2; // 邮件内容
|
||||
uint64 CreateTime = 3; // 发送时间
|
||||
uint64 DueTime = 4; // 过期时间
|
||||
bool Check = 5; // 是否查看
|
||||
repeated MailAttachment Items = 6; // 附件
|
||||
}
|
||||
|
||||
message DB_UserMailData {
|
||||
string UserId = 1; //tags:{bson:"_id"}用户Id
|
||||
repeated MailData mails = 2; // 邮件列表
|
||||
}
|
24
pb/proto/mail_db.proto
Normal file
24
pb/proto/mail_db.proto
Normal file
@ -0,0 +1,24 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
|
||||
// message Cache_mailData {
|
||||
// string UserID = 1;
|
||||
// repeated DB_MailData MailData = 2;
|
||||
// }
|
||||
|
||||
message MailAttachment { // 附件
|
||||
uint32 ItemId = 1; // 道具iD
|
||||
uint32 ItemCount = 2; // 数量
|
||||
}
|
||||
|
||||
message DB_MailData {
|
||||
string ObjId = 1; // tags:{bson:"_id"}
|
||||
string UserId = 2;
|
||||
string Title = 3; // 邮件标题
|
||||
string Contex = 4; // 邮件内容
|
||||
uint64 CreateTime = 5; // 发送时间
|
||||
uint64 DueTime = 6; // 过期时间
|
||||
bool Check = 7; // 是否查看
|
||||
bool Reward = 8; // 附件领取状态
|
||||
repeated MailAttachment Items = 9; // 附件
|
||||
}
|
39
pb/proto/mail_msg.proto
Normal file
39
pb/proto/mail_msg.proto
Normal file
@ -0,0 +1,39 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "mail_db.proto";
|
||||
|
||||
message QueryUserMailReq {
|
||||
|
||||
}
|
||||
|
||||
// 查询邮件信息
|
||||
message QueryUserMailResp {
|
||||
repeated DB_MailData Mails = 1;
|
||||
}
|
||||
|
||||
// 查看邮件
|
||||
message ReadUserMailReq {
|
||||
string ObjID = 1;
|
||||
}
|
||||
|
||||
message ReadUserMailResp {
|
||||
DB_MailData Mail = 1;
|
||||
}
|
||||
|
||||
// 领取附件
|
||||
message GetUserMailAttachmentReq {
|
||||
string ObjID = 1;
|
||||
}
|
||||
|
||||
message GetUserMailAttachmentResp {
|
||||
DB_MailData Mail = 1;
|
||||
}
|
||||
|
||||
// 删除某个邮件
|
||||
message DelUserMailReq {
|
||||
string ObjID = 1;
|
||||
}
|
||||
|
||||
message DelUserMailResp {
|
||||
repeated DB_MailData Mail = 1;
|
||||
}
|
@ -11,6 +11,7 @@ message DB_UserData {
|
||||
string UserId = 1; //tags:{bson:"_id"}动态Id
|
||||
string Account = 2;
|
||||
string NiceName = 3;
|
||||
string Email = 4;
|
||||
string Password = 5;
|
||||
int32 ServerId = 4;
|
||||
int32 FriendPoint = 5;//友情点
|
||||
int32 avatar = 6;//头像
|
||||
}
|
@ -3,13 +3,13 @@ option go_package = ".;pb";
|
||||
import "errorcode.proto";
|
||||
import "user_db.proto";
|
||||
|
||||
//用户登录
|
||||
message UserLoginReq {
|
||||
string Name = 1;
|
||||
string sec= 1;//密文
|
||||
}
|
||||
|
||||
message UserLoginResp {
|
||||
ErrorCode Code = 1;
|
||||
Cache_UserData data = 2;
|
||||
Cache_UserData data = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -25,9 +25,9 @@ message UserLoadRsp {
|
||||
Cache_UserData data = 1;
|
||||
}
|
||||
|
||||
//创角
|
||||
message UserCreateReq{
|
||||
string NickName = 1;//昵称
|
||||
int32 gender = 2; //性别
|
||||
}
|
||||
|
||||
message UserCreateRsp{
|
||||
|
@ -91,8 +91,9 @@ type DB_UserData struct {
|
||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id
|
||||
Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"`
|
||||
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
|
||||
Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"`
|
||||
Password string `protobuf:"bytes,5,opt,name=Password,proto3" json:"Password,omitempty"`
|
||||
ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"`
|
||||
FriendPoint int32 `protobuf:"varint,5,opt,name=FriendPoint,proto3" json:"FriendPoint,omitempty"` //友情点
|
||||
Avatar int32 `protobuf:"varint,6,opt,name=avatar,proto3" json:"avatar,omitempty"` //头像
|
||||
}
|
||||
|
||||
func (x *DB_UserData) Reset() {
|
||||
@ -148,18 +149,25 @@ func (x *DB_UserData) GetNiceName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetEmail() string {
|
||||
func (x *DB_UserData) GetServerId() int32 {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
return x.ServerId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetPassword() string {
|
||||
func (x *DB_UserData) GetFriendPoint() int32 {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
return x.FriendPoint
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetAvatar() int32 {
|
||||
if x != nil {
|
||||
return x.Avatar
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_user_db_proto protoreflect.FileDescriptor
|
||||
@ -174,17 +182,19 @@ var file_user_db_proto_rawDesc = []byte{
|
||||
0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x08,
|
||||
0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c,
|
||||
0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18,
|
||||
0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61,
|
||||
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61,
|
||||
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64,
|
||||
0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64,
|
||||
0x12, 0x20, 0x0a, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18,
|
||||
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69,
|
||||
0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -20,12 +20,13 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
//用户登录
|
||||
type UserLoginReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
|
||||
Sec string `protobuf:"bytes,1,opt,name=sec,proto3" json:"sec,omitempty"` //密文
|
||||
}
|
||||
|
||||
func (x *UserLoginReq) Reset() {
|
||||
@ -60,9 +61,9 @@ func (*UserLoginReq) Descriptor() ([]byte, []int) {
|
||||
return file_user_msg_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *UserLoginReq) GetName() string {
|
||||
func (x *UserLoginReq) GetSec() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
return x.Sec
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -72,8 +73,7 @@ type UserLoginResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
|
||||
Data *Cache_UserData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Data *Cache_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UserLoginResp) Reset() {
|
||||
@ -108,13 +108,6 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) {
|
||||
return file_user_msg_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *UserLoginResp) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *UserLoginResp) GetData() *Cache_UserData {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
@ -263,13 +256,13 @@ func (x *UserLoadRsp) GetData() *Cache_UserData {
|
||||
return nil
|
||||
}
|
||||
|
||||
//创角
|
||||
type UserCreateReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
NickName string `protobuf:"bytes,1,opt,name=NickName,proto3" json:"NickName,omitempty"` //昵称
|
||||
Gender int32 `protobuf:"varint,2,opt,name=gender,proto3" json:"gender,omitempty"` //性别
|
||||
}
|
||||
|
||||
func (x *UserCreateReq) Reset() {
|
||||
@ -311,13 +304,6 @@ func (x *UserCreateReq) GetNickName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserCreateReq) GetGender() int32 {
|
||||
if x != nil {
|
||||
return x.Gender
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type UserCreateRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -362,30 +348,26 @@ var file_user_msg_proto_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x22, 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x54, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 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, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72,
|
||||
0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73,
|
||||
0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52,
|
||||
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 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, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73,
|
||||
0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74,
|
||||
0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f,
|
||||
0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43,
|
||||
0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67,
|
||||
0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e,
|
||||
0x64, 0x65, 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74,
|
||||
0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x22, 0x20, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73,
|
||||
0x65, 0x63, 0x22, 0x34, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52,
|
||||
0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61,
|
||||
0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72,
|
||||
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67,
|
||||
0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 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, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72,
|
||||
0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0d,
|
||||
0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65,
|
||||
0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -409,19 +391,18 @@ var file_user_msg_proto_goTypes = []interface{}{
|
||||
(*UserLoadRsp)(nil), // 4: UserLoadRsp
|
||||
(*UserCreateReq)(nil), // 5: UserCreateReq
|
||||
(*UserCreateRsp)(nil), // 6: UserCreateRsp
|
||||
(ErrorCode)(0), // 7: ErrorCode
|
||||
(*Cache_UserData)(nil), // 8: Cache_UserData
|
||||
(*Cache_UserData)(nil), // 7: Cache_UserData
|
||||
(ErrorCode)(0), // 8: ErrorCode
|
||||
}
|
||||
var file_user_msg_proto_depIdxs = []int32{
|
||||
7, // 0: UserLoginResp.Code:type_name -> ErrorCode
|
||||
8, // 1: UserLoginResp.data:type_name -> Cache_UserData
|
||||
7, // 2: UserRegisterRsp.Code:type_name -> ErrorCode
|
||||
8, // 3: UserLoadRsp.data:type_name -> Cache_UserData
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
7, // 0: UserLoginResp.data:type_name -> Cache_UserData
|
||||
8, // 1: UserRegisterRsp.Code:type_name -> ErrorCode
|
||||
7, // 2: UserLoadRsp.data:type_name -> Cache_UserData
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_user_msg_proto_init() }
|
||||
|
@ -31,4 +31,7 @@ buildProto('./pb/proto','./pb','user_db')
|
||||
buildProto('./pb/proto','./pb','user_msg')
|
||||
buildProto('./pb/proto','./pb','pack_db')
|
||||
buildProto('./pb/proto','./pb','pack_msg')
|
||||
buildProto('./pb/proto','./pb','mail')
|
||||
buildProto('./pb/proto','./pb','mail_db')
|
||||
buildProto('./pb/proto','./pb','mail_msg')
|
||||
buildProto('./pb/proto','./pb','friend_db')
|
||||
buildProto('./pb/proto','./pb','friend_msg')
|
52
sys/cache/mail.go
vendored
52
sys/cache/mail.go
vendored
@ -1,12 +1,8 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"go_dreamfactory/lego/sys/redis"
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
@ -14,22 +10,42 @@ const ( //Redis
|
||||
)
|
||||
|
||||
type IMail interface {
|
||||
QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error)
|
||||
QueryUserMail(uId string) (mail []*pb.DB_MailData, err error)
|
||||
InsertUserMail(uId string) (mail []*pb.DB_MailData, err error)
|
||||
ReadOneMail(uId string, ObjId string) (mail *pb.DB_MailData, err error)
|
||||
}
|
||||
|
||||
// 查询玩家邮件数据
|
||||
func (this *Cache) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) {
|
||||
mail = &pb.DB_UserMailData{
|
||||
UserId: uId,
|
||||
}
|
||||
if err = this.redis.Get(fmt.Sprintf(Redis_MailCache, uId), mail); err == nil {
|
||||
return
|
||||
} else if err == redis.RedisNil {
|
||||
if mail, err = db.Defsys.QueryUserMail(uId); err == nil {
|
||||
this.redis.Set(fmt.Sprintf(Redis_MailCache, uId), mail, -1)
|
||||
} else if err == mgo.MongodbNil {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
func (this *Cache) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
||||
// var result []interface{}
|
||||
// if result, err = this.redis.HGetAll(fmt.Sprintf(Redis_MailCache, uId), reflect.TypeOf(&pb.DB_MailData{})); err != nil {
|
||||
// return
|
||||
// } else {
|
||||
// mail = make([]*pb.DB_MailData, len(result))
|
||||
// for i, v := range result {
|
||||
// mail[i] = v.(*pb.DB_MailData)
|
||||
// }
|
||||
// }
|
||||
// 邮件暂时不写redis
|
||||
mail, _ = db.Defsys.QueryUserMail(uId)
|
||||
|
||||
// } else if err == redis.RedisNil {
|
||||
// if mail, err = db.Defsys.QueryUserMail(uId); err == nil {
|
||||
// this.redis.Set(fmt.Sprintf(Redis_MailCache, uId), mail, -1)
|
||||
// } else if err == mgo.MongodbNil {
|
||||
// err = nil
|
||||
// }
|
||||
// }
|
||||
return
|
||||
}
|
||||
|
||||
// 创建新的邮件
|
||||
func (this *Cache) ReadOneMail(uId string, ObjId string) (mail *pb.DB_MailData, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Cache) InsertUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
17
sys/cache/user.go
vendored
17
sys/cache/user.go
vendored
@ -3,6 +3,8 @@ package cache
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
@ -10,10 +12,21 @@ const ( //Redis
|
||||
)
|
||||
|
||||
type IUser interface {
|
||||
User_UpdateUser(data *pb.Cache_UserData) (err error)
|
||||
Update(data *pb.Cache_UserData) (err error)
|
||||
Get(userId string) *pb.Cache_UserData
|
||||
}
|
||||
|
||||
func (this *Cache) User_UpdateUser(data *pb.Cache_UserData) (err error) {
|
||||
func (this *Cache) Update(data *pb.Cache_UserData) (err error) {
|
||||
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Cache) Get(userId string) *pb.Cache_UserData {
|
||||
var user *pb.Cache_UserData
|
||||
err := this.redis.Get(fmt.Sprintf(Redis_UserCache, userId), &user)
|
||||
if err != nil {
|
||||
log.Errorf("get user cache err:%v", err)
|
||||
return nil
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
8
sys/cache/user_test.go
vendored
8
sys/cache/user_test.go
vendored
@ -1,6 +1,7 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"log"
|
||||
"testing"
|
||||
@ -34,6 +35,11 @@ func TestUpdateUser(t *testing.T) {
|
||||
Account: "aaa",
|
||||
},
|
||||
}
|
||||
err := cache.User_UpdateUser(user)
|
||||
err := cache.Update(user)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestGetUser(t *testing.T) {
|
||||
c := cache.Get("62157")
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
79
sys/configure/structs/MyBean.Hero.go
Normal file
79
sys/configure/structs/MyBean.Hero.go
Normal file
@ -0,0 +1,79 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg
|
||||
|
||||
import "errors"
|
||||
|
||||
type MyBeanHero struct {
|
||||
Id string
|
||||
Name string
|
||||
Star int32
|
||||
Color int32
|
||||
Chengwei int32
|
||||
Zhongzu int32
|
||||
Job int32
|
||||
Type int32
|
||||
Prefab string
|
||||
Icon string
|
||||
Sound string
|
||||
Tujing string
|
||||
Hpgrow string
|
||||
Atkgrow string
|
||||
Defgrow string
|
||||
Speedgrow string
|
||||
Hp string
|
||||
Atk string
|
||||
Def string
|
||||
Speed string
|
||||
Intr string
|
||||
Events string
|
||||
Cite string
|
||||
}
|
||||
|
||||
const TypeId_MyBeanHero = 1050121004
|
||||
|
||||
func (*MyBeanHero) GetTypeId() int32 {
|
||||
return 1050121004
|
||||
}
|
||||
|
||||
func (_v *MyBeanHero)Deserialize(_buf map[string]interface{}) (err error) {
|
||||
{ var _ok_ bool; if _v.Id, _ok_ = _buf["id"].(string); !_ok_ { err = errors.New("id error"); return } }
|
||||
{ var _ok_ bool; if _v.Name, _ok_ = _buf["name"].(string); !_ok_ { err = errors.New("name error"); return } }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["color"].(float64); !_ok_ { err = errors.New("color error"); return }; _v.Color = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["chengwei"].(float64); !_ok_ { err = errors.New("chengwei error"); return }; _v.Chengwei = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["zhongzu"].(float64); !_ok_ { err = errors.New("zhongzu error"); return }; _v.Zhongzu = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["job"].(float64); !_ok_ { err = errors.New("job error"); return }; _v.Job = int32(_tempNum_) }
|
||||
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) }
|
||||
{ var _ok_ bool; if _v.Prefab, _ok_ = _buf["prefab"].(string); !_ok_ { err = errors.New("prefab error"); return } }
|
||||
{ var _ok_ bool; if _v.Icon, _ok_ = _buf["icon"].(string); !_ok_ { err = errors.New("icon error"); return } }
|
||||
{ var _ok_ bool; if _v.Sound, _ok_ = _buf["sound"].(string); !_ok_ { err = errors.New("sound error"); return } }
|
||||
{ var _ok_ bool; if _v.Tujing, _ok_ = _buf["tujing"].(string); !_ok_ { err = errors.New("tujing error"); return } }
|
||||
{ var _ok_ bool; if _v.Hpgrow, _ok_ = _buf["hpgrow"].(string); !_ok_ { err = errors.New("hpgrow error"); return } }
|
||||
{ var _ok_ bool; if _v.Atkgrow, _ok_ = _buf["atkgrow"].(string); !_ok_ { err = errors.New("atkgrow error"); return } }
|
||||
{ var _ok_ bool; if _v.Defgrow, _ok_ = _buf["defgrow"].(string); !_ok_ { err = errors.New("defgrow error"); return } }
|
||||
{ var _ok_ bool; if _v.Speedgrow, _ok_ = _buf["speedgrow"].(string); !_ok_ { err = errors.New("speedgrow error"); return } }
|
||||
{ var _ok_ bool; if _v.Hp, _ok_ = _buf["hp"].(string); !_ok_ { err = errors.New("hp error"); return } }
|
||||
{ var _ok_ bool; if _v.Atk, _ok_ = _buf["atk"].(string); !_ok_ { err = errors.New("atk error"); return } }
|
||||
{ var _ok_ bool; if _v.Def, _ok_ = _buf["def"].(string); !_ok_ { err = errors.New("def error"); return } }
|
||||
{ var _ok_ bool; if _v.Speed, _ok_ = _buf["speed"].(string); !_ok_ { err = errors.New("speed error"); return } }
|
||||
{ var _ok_ bool; if _v.Intr, _ok_ = _buf["intr"].(string); !_ok_ { err = errors.New("intr error"); return } }
|
||||
{ var _ok_ bool; if _v.Events, _ok_ = _buf["events"].(string); !_ok_ { err = errors.New("events error"); return } }
|
||||
{ var _ok_ bool; if _v.Cite, _ok_ = _buf["cite"].(string); !_ok_ { err = errors.New("cite error"); return } }
|
||||
return
|
||||
}
|
||||
|
||||
func DeserializeMyBeanHero(_buf map[string]interface{}) (*MyBeanHero, error) {
|
||||
v := &MyBeanHero{}
|
||||
if err := v.Deserialize(_buf); err == nil {
|
||||
return v, nil
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ type JsonLoader func(string) ([]map[string]interface{}, error)
|
||||
type Tables struct {
|
||||
TbRewards *TbRewards
|
||||
TbItem *TbItem
|
||||
TbHero *TbHero
|
||||
}
|
||||
|
||||
func NewTables(loader JsonLoader) (*Tables, error) {
|
||||
@ -32,5 +33,11 @@ func NewTables(loader JsonLoader) (*Tables, error) {
|
||||
if tables.TbItem, err = NewTbItem(buf) ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if buf, err = loader("tbhero") ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tables.TbHero, err = NewTbHero(buf) ; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tables, nil
|
||||
}
|
||||
|
42
sys/configure/structs/TbHero.go
Normal file
42
sys/configure/structs/TbHero.go
Normal file
@ -0,0 +1,42 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
package cfg
|
||||
|
||||
type TbHero struct {
|
||||
_dataMap map[string]*MyBeanHero
|
||||
_dataList []*MyBeanHero
|
||||
}
|
||||
|
||||
func NewTbHero(_buf []map[string]interface{}) (*TbHero, error) {
|
||||
_dataList := make([]*MyBeanHero, 0, len(_buf))
|
||||
dataMap := make(map[string]*MyBeanHero)
|
||||
for _, _ele_ := range _buf {
|
||||
if _v, err2 := DeserializeMyBeanHero(_ele_); err2 != nil {
|
||||
return nil, err2
|
||||
} else {
|
||||
_dataList = append(_dataList, _v)
|
||||
dataMap[_v.Id] = _v
|
||||
}
|
||||
}
|
||||
return &TbHero{_dataList:_dataList, _dataMap:dataMap}, nil
|
||||
}
|
||||
|
||||
func (table *TbHero) GetDataMap() map[string]*MyBeanHero {
|
||||
return table._dataMap
|
||||
}
|
||||
|
||||
func (table *TbHero) GetDataList() []*MyBeanHero {
|
||||
return table._dataList
|
||||
}
|
||||
|
||||
func (table *TbHero) Get(key string) *MyBeanHero {
|
||||
return table._dataMap[key]
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,108 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
const (
|
||||
DB_MailTable core.SqlTable = "mail"
|
||||
)
|
||||
|
||||
type IMail interface {
|
||||
QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error)
|
||||
QueryUserMail(uId string) (mail []*pb.DB_MailData, err error)
|
||||
InsertUserMail(mail *pb.DB_MailData) (err error)
|
||||
ReadOneMail(objId string) (mail *pb.DB_MailData, err error)
|
||||
GetMailAttachment(objId string) (itmes []*pb.MailAttachment, err error)
|
||||
GetMailAttachmentState(objId string) bool
|
||||
UpdateMailAttachmentState(objId string) bool
|
||||
DelUserMail(objId string) bool
|
||||
}
|
||||
|
||||
func (this *DB) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) {
|
||||
mail = &pb.DB_UserMailData{}
|
||||
err = this.mgo.FindOne(DB_MailTable, bson.M{"_id": uId}).Decode(mail)
|
||||
func (this *DB) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
||||
|
||||
if _data, err := this.mgo.Find(DB_MailTable, bson.M{"userid": uId}); err == nil {
|
||||
for _data.Next(context.TODO()) {
|
||||
temp := &pb.DB_MailData{}
|
||||
if err = _data.Decode(temp); err == nil {
|
||||
mail = append(mail, temp)
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *DB) InsertUserMail(mail *pb.DB_MailData) (err error) {
|
||||
|
||||
mail.ObjId = primitive.NewObjectID().Hex()
|
||||
mail.Check = false
|
||||
_, err = this.mgo.InsertOne(DB_MailTable, mail)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *DB) ReadOneMail(objId string) (mail *pb.DB_MailData, err error) {
|
||||
|
||||
err = this.mgo.FindOneAndUpdate(
|
||||
DB_MailTable,
|
||||
bson.M{"_id": objId},
|
||||
bson.M{"$set": bson.M{
|
||||
"check": false,
|
||||
}},
|
||||
options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After),
|
||||
).Decode(mail)
|
||||
|
||||
return mail, err
|
||||
}
|
||||
|
||||
// 查询附件信息
|
||||
func (this *DB) GetMailAttachment(objId string) (itmes []*pb.MailAttachment, err error) {
|
||||
|
||||
obj := this.mgo.FindOne(DB_MailTable, bson.M{"_id": objId})
|
||||
var nd *pb.DB_MailData
|
||||
err = obj.Decode(&nd)
|
||||
itmes = nd.GetItems()
|
||||
|
||||
return itmes, err
|
||||
}
|
||||
|
||||
// 查看领取附件状态
|
||||
func (this *DB) GetMailAttachmentState(objId string) bool {
|
||||
var nd *pb.DB_MailData
|
||||
err := this.mgo.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(nd)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return nd.Reward && len(nd.GetItems()) > 0
|
||||
}
|
||||
|
||||
// 更新领取附件状态
|
||||
func (this *DB) UpdateMailAttachmentState(objId string) bool {
|
||||
this.mgo.FindOneAndUpdate(
|
||||
DB_MailTable,
|
||||
bson.M{"_id": objId},
|
||||
bson.M{"$set": bson.M{
|
||||
"reward": true,
|
||||
}},
|
||||
options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After),
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *DB) DelUserMail(objId string) bool {
|
||||
var obj *pb.DB_MailData
|
||||
err := this.mgo.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(obj)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
this.mgo.DeleteOne(DB_MailTable, bson.M{"_id": objId})
|
||||
|
||||
return true
|
||||
}
|
||||
|
@ -15,20 +15,21 @@ const ( //Redis
|
||||
)
|
||||
|
||||
type IUser interface {
|
||||
User_FindUserByAccount(account string) (*pb.DB_UserData, error)
|
||||
User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error)
|
||||
User_FindUserById(id string) (*pb.DB_UserData, error)
|
||||
User_CreateUser(user *pb.DB_UserData) error
|
||||
User_UpdateUser(data *pb.DB_UserData) (err error)
|
||||
}
|
||||
|
||||
func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error) {
|
||||
func (this *DB) User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) {
|
||||
filter := bson.D{
|
||||
{"account", account},
|
||||
{"serverid", user.ServerId},
|
||||
{"account", user.Account},
|
||||
}
|
||||
sr := this.mgo.FindOne(DB_UserTable, filter)
|
||||
user := &pb.DB_UserData{}
|
||||
err := sr.Decode(user)
|
||||
return user, err
|
||||
var nd *pb.DB_UserData
|
||||
err := sr.Decode(&nd)
|
||||
return nd, err
|
||||
}
|
||||
|
||||
func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) {
|
||||
@ -54,7 +55,6 @@ func (this *DB) User_UpdateUser(data *pb.DB_UserData) (err error) {
|
||||
bson.M{"_id": data.UserId},
|
||||
bson.M{"$set": bson.M{
|
||||
"niceName": data.NiceName,
|
||||
"email": data.Email,
|
||||
}},
|
||||
options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After),
|
||||
).Decode(data)
|
||||
|
@ -31,7 +31,7 @@ func TestCreate(t *testing.T) {
|
||||
user := &pb.DB_UserData{
|
||||
Account: "legu3",
|
||||
NiceName: "乐谷3",
|
||||
Email: "1111@legu.com",
|
||||
ServerId: 1,
|
||||
}
|
||||
|
||||
err := db.User_CreateUser(user)
|
||||
@ -39,23 +39,23 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFindOne(t *testing.T) {
|
||||
user, err := db.User_FindUserById("")
|
||||
user, err := db.User_FindUserById("629eb3f4132dc4bb26139659")
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, "legu1", user.Account)
|
||||
assert.Equal(t, "legu3", user.Account)
|
||||
|
||||
user2, err := db.User_FindUserByAccount("legu1")
|
||||
// user.ServerId = 2
|
||||
user2, err := db.User_FindUserByAccount(user)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, "legu1", user2.Account)
|
||||
|
||||
assert.Equal(t, "legu3", user2.Account)
|
||||
assert.Equal(t, int32(1), user2.ServerId)
|
||||
}
|
||||
|
||||
func TestUpdate(t *testing.T) {
|
||||
user := &pb.DB_UserData{
|
||||
UserId: primitive.NewObjectID().String(),
|
||||
Email: "new@qq.com",
|
||||
UserId: primitive.NewObjectID().Hex(),
|
||||
}
|
||||
err := db.User_UpdateUser(user)
|
||||
require.Nil(t, err)
|
||||
|
||||
assert.Equal(t, "new@qq.com", user.Email)
|
||||
assert.Equal(t, "NiceName", "")
|
||||
}
|
||||
|
37
utils/base64.go
Normal file
37
utils/base64.go
Normal file
@ -0,0 +1,37 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
)
|
||||
|
||||
func Base64Encode(data []byte) string {
|
||||
return base64.StdEncoding.EncodeToString(data)
|
||||
}
|
||||
|
||||
func Base64Decode(data string) string {
|
||||
b, err := base64.StdEncoding.DecodeString(data)
|
||||
if err != nil {
|
||||
log.Errorf("base64 decode", err)
|
||||
return ""
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func ValidSecretKey(secStr string) bool {
|
||||
if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 {
|
||||
return false
|
||||
}
|
||||
|
||||
clientMd5Key := secStr[3:35]
|
||||
rawmsg := secStr[35:]
|
||||
log.Debugf("data base: %s", rawmsg)
|
||||
serverMd5Key := MD5Str(rawmsg)
|
||||
// s := fmt.Sprintf("%x", serverMd5Key)
|
||||
if !strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
17
utils/md5.go
Normal file
17
utils/md5.go
Normal file
@ -0,0 +1,17 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func MD5Str(s string) string {
|
||||
return MD5Bytes([]byte(s))
|
||||
}
|
||||
|
||||
func MD5Bytes(s []byte) string {
|
||||
md5Ctx := md5.New()
|
||||
md5Ctx.Write(s)
|
||||
cipherStr := md5Ctx.Sum(nil)
|
||||
return hex.EncodeToString(cipherStr)
|
||||
}
|
47
utils/trace.go
Normal file
47
utils/trace.go
Normal file
@ -0,0 +1,47 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
)
|
||||
|
||||
const (
|
||||
UID = "uid"
|
||||
Module = "module"
|
||||
FuncName = "funcName"
|
||||
FuncArgs = "funcArgs"
|
||||
FuncRsp = "response"
|
||||
TimeCost = "timeCost"
|
||||
)
|
||||
|
||||
//打印函数处理信息
|
||||
func TraceFunc(uid string, module string, funcName string, funcArgs interface{}, rsp interface{}) {
|
||||
log.Debugf("traceFunc uid:%s module:%s funcName:%s funcArgs:%v", uid, module, funcName, funcArgs)
|
||||
}
|
||||
|
||||
//打印函数处理时间
|
||||
func TraceTimeCost(funcName string, invocation time.Time) {
|
||||
elapsed := time.Since(invocation)
|
||||
cost := elapsed.Milliseconds()
|
||||
lg := fmt.Sprintf("funcName:%s timeCost:%v", funcName, cost)
|
||||
|
||||
if cost < 20 {
|
||||
log.Debugf(lg)
|
||||
return
|
||||
}
|
||||
log.Warnf(lg)
|
||||
}
|
||||
|
||||
//打印异常
|
||||
func TraceError(err error) (b bool) {
|
||||
if err != nil {
|
||||
pc, fn, line, _ := runtime.Caller(1)
|
||||
|
||||
log.Errorf("[error] in %s[%s:%d] %v", runtime.FuncForPC(pc).Name(), fn, line, err)
|
||||
b = true
|
||||
}
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user