update
This commit is contained in:
parent
7a13637dd3
commit
e122abaa4b
@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,11 +2,14 @@ package user
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/cache"
|
"go_dreamfactory/sys/cache"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/liwei1dao/lego/sys/log"
|
"github.com/liwei1dao/lego/sys/log"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
@ -20,15 +23,33 @@ type LoginComp struct {
|
|||||||
func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error {
|
func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error {
|
||||||
log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req)
|
log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req)
|
||||||
|
|
||||||
db_user, err := db.Defsys.User_FindUserByAccount(req.Name)
|
var code pb.ErrorCode = pb.ErrorCode_Success
|
||||||
|
rsp := &pb.UserLoginResp{}
|
||||||
|
secStr := req.Sec
|
||||||
|
|
||||||
|
if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 {
|
||||||
|
session.SendMsg("user", "login", pb.ErrorCode_SecKey, rsp)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
clientMd5Key := strings.TrimPrefix(secStr, "CE:")
|
||||||
|
rawmsg := secStr[35:]
|
||||||
|
serverMd5Key := utils.MD5Str(rawmsg)
|
||||||
|
s := fmt.Sprintf("%x", serverMd5Key)
|
||||||
|
if !strings.EqualFold(strings.ToLower(s), strings.ToLower(clientMd5Key)) {
|
||||||
|
session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, rsp)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
account := ""
|
||||||
|
db_user, err := db.Defsys.User_FindUserByAccount(account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != mongo.ErrNoDocuments {
|
if err != mongo.ErrNoDocuments {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if db_user.UserId == 0 {
|
if db_user.UserId == "" {
|
||||||
db_user.Account = req.Name
|
db_user.Account = account
|
||||||
err = db.Defsys.User_CreateUser(db_user)
|
err = db.Defsys.User_CreateUser(db_user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -47,7 +68,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
session.SendMsg("login", "login", pb.ErrorCode_Success, &pb.UserLoginResp{
|
session.SendMsg("user", "login", code, &pb.UserLoginResp{
|
||||||
Data: &pb.Cache_UserData{
|
Data: &pb.Cache_UserData{
|
||||||
UserData: &pb.DB_UserData{
|
UserData: &pb.DB_UserData{
|
||||||
UserId: db_user.UserId,
|
UserId: db_user.UserId,
|
||||||
|
@ -33,6 +33,8 @@ const (
|
|||||||
ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足
|
ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足
|
||||||
ErrorCode_NoLogin ErrorCode = 17 //未登录
|
ErrorCode_NoLogin ErrorCode = 17 //未登录
|
||||||
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
||||||
|
ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误
|
||||||
|
ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for ErrorCode.
|
// Enum value maps for ErrorCode.
|
||||||
@ -48,6 +50,8 @@ var (
|
|||||||
16: "InsufficientPermissions",
|
16: "InsufficientPermissions",
|
||||||
17: "NoLogin",
|
17: "NoLogin",
|
||||||
18: "UserSessionNobeing",
|
18: "UserSessionNobeing",
|
||||||
|
19: "SecKey",
|
||||||
|
20: "SecKeyInvalid",
|
||||||
}
|
}
|
||||||
ErrorCode_value = map[string]int32{
|
ErrorCode_value = map[string]int32{
|
||||||
"Success": 0,
|
"Success": 0,
|
||||||
@ -60,6 +64,8 @@ var (
|
|||||||
"InsufficientPermissions": 16,
|
"InsufficientPermissions": 16,
|
||||||
"NoLogin": 17,
|
"NoLogin": 17,
|
||||||
"UserSessionNobeing": 18,
|
"UserSessionNobeing": 18,
|
||||||
|
"SecKey": 19,
|
||||||
|
"SecKeyInvalid": 20,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,7 +100,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_errorcode_proto_rawDesc = []byte{
|
var file_errorcode_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x6f, 0x2a, 0xd9, 0x01, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
0x6f, 0x2a, 0xf8, 0x01, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||||
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
|
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
|
||||||
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
||||||
0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
|
0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74,
|
||||||
@ -107,8 +113,10 @@ var file_errorcode_proto_rawDesc = []byte{
|
|||||||
0x6e, 0x73, 0x75, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69,
|
0x6e, 0x73, 0x75, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69,
|
||||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x10, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x6f, 0x4c, 0x6f,
|
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x10, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x6f, 0x4c, 0x6f,
|
||||||
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||||
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x42, 0x06, 0x5a,
|
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a,
|
||||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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, 0x42, 0x06, 0x5a, 0x04,
|
||||||
|
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -13,4 +13,6 @@ enum ErrorCode {
|
|||||||
InsufficientPermissions = 16; //权限不足
|
InsufficientPermissions = 16; //权限不足
|
||||||
NoLogin = 17; //未登录
|
NoLogin = 17; //未登录
|
||||||
UserSessionNobeing = 18; //用户不存在
|
UserSessionNobeing = 18; //用户不存在
|
||||||
|
SecKey = 19; //秘钥格式错误
|
||||||
|
SecKeyInvalid = 20; //秘钥无效
|
||||||
}
|
}
|
@ -3,13 +3,13 @@ option go_package = ".;pb";
|
|||||||
import "errorcode.proto";
|
import "errorcode.proto";
|
||||||
import "user_db.proto";
|
import "user_db.proto";
|
||||||
|
|
||||||
|
//用户登录
|
||||||
message UserLoginReq {
|
message UserLoginReq {
|
||||||
string Name = 1;
|
string sec= 1;//密文
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserLoginResp {
|
message UserLoginResp {
|
||||||
ErrorCode Code = 1;
|
Cache_UserData data = 1;
|
||||||
Cache_UserData data = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ message UserLoadRsp {
|
|||||||
Cache_UserData data = 1;
|
Cache_UserData data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//创角
|
||||||
message UserCreateReq{
|
message UserCreateReq{
|
||||||
string NickName = 1;//昵称
|
string NickName = 1;//昵称
|
||||||
int32 gender = 2; //性别
|
int32 gender = 2; //性别
|
||||||
|
@ -20,12 +20,13 @@ const (
|
|||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//用户登录
|
||||||
type UserLoginReq struct {
|
type UserLoginReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
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() {
|
func (x *UserLoginReq) Reset() {
|
||||||
@ -60,9 +61,9 @@ func (*UserLoginReq) Descriptor() ([]byte, []int) {
|
|||||||
return file_user_msg_proto_rawDescGZIP(), []int{0}
|
return file_user_msg_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserLoginReq) GetName() string {
|
func (x *UserLoginReq) GetSec() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Name
|
return x.Sec
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -72,8 +73,7 @@ type UserLoginResp struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
|
Data *Cache_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||||
Data *Cache_UserData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserLoginResp) Reset() {
|
func (x *UserLoginResp) Reset() {
|
||||||
@ -108,13 +108,6 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) {
|
|||||||
return file_user_msg_proto_rawDescGZIP(), []int{1}
|
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 {
|
func (x *UserLoginResp) GetData() *Cache_UserData {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Data
|
return x.Data
|
||||||
@ -263,6 +256,7 @@ func (x *UserLoadRsp) GetData() *Cache_UserData {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//创角
|
||||||
type UserCreateReq struct {
|
type UserCreateReq struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@ -362,30 +356,28 @@ var file_user_msg_proto_rawDesc = []byte{
|
|||||||
0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
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,
|
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,
|
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,
|
0x22, 0x20, 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,
|
0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73,
|
||||||
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x54, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69,
|
0x65, 0x63, 0x22, 0x34, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52,
|
||||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
|
0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52,
|
0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61,
|
||||||
0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20,
|
0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72,
|
||||||
0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72,
|
0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
||||||
0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73,
|
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
||||||
0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a,
|
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67,
|
||||||
0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65,
|
||||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f,
|
||||||
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f,
|
0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72,
|
||||||
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
|
0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
|
||||||
0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73,
|
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73,
|
||||||
0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74,
|
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, 0x0a, 0x0d,
|
||||||
0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f,
|
0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a,
|
||||||
0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43,
|
0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12,
|
0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e,
|
||||||
0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65,
|
||||||
0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67,
|
0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52,
|
||||||
0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e,
|
0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x64, 0x65, 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74,
|
0x6f, 0x33,
|
||||||
0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
|
||||||
0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -409,19 +401,18 @@ var file_user_msg_proto_goTypes = []interface{}{
|
|||||||
(*UserLoadRsp)(nil), // 4: UserLoadRsp
|
(*UserLoadRsp)(nil), // 4: UserLoadRsp
|
||||||
(*UserCreateReq)(nil), // 5: UserCreateReq
|
(*UserCreateReq)(nil), // 5: UserCreateReq
|
||||||
(*UserCreateRsp)(nil), // 6: UserCreateRsp
|
(*UserCreateRsp)(nil), // 6: UserCreateRsp
|
||||||
(ErrorCode)(0), // 7: ErrorCode
|
(*Cache_UserData)(nil), // 7: Cache_UserData
|
||||||
(*Cache_UserData)(nil), // 8: Cache_UserData
|
(ErrorCode)(0), // 8: ErrorCode
|
||||||
}
|
}
|
||||||
var file_user_msg_proto_depIdxs = []int32{
|
var file_user_msg_proto_depIdxs = []int32{
|
||||||
7, // 0: UserLoginResp.Code:type_name -> ErrorCode
|
7, // 0: UserLoginResp.data:type_name -> Cache_UserData
|
||||||
8, // 1: UserLoginResp.data:type_name -> Cache_UserData
|
8, // 1: UserRegisterRsp.Code:type_name -> ErrorCode
|
||||||
7, // 2: UserRegisterRsp.Code:type_name -> ErrorCode
|
7, // 2: UserLoadRsp.data:type_name -> Cache_UserData
|
||||||
8, // 3: UserLoadRsp.data:type_name -> Cache_UserData
|
3, // [3:3] is the sub-list for method output_type
|
||||||
4, // [4:4] is the sub-list for method output_type
|
3, // [3:3] is the sub-list for method input_type
|
||||||
4, // [4:4] is the sub-list for method input_type
|
3, // [3:3] is the sub-list for extension type_name
|
||||||
4, // [4:4] is the sub-list for extension type_name
|
3, // [3:3] is the sub-list for extension extendee
|
||||||
4, // [4:4] is the sub-list for extension extendee
|
0, // [0:3] is the sub-list for field type_name
|
||||||
0, // [0:4] is the sub-list for field type_name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_user_msg_proto_init() }
|
func init() { file_user_msg_proto_init() }
|
||||||
|
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)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user