邮件协议完善
This commit is contained in:
parent
1fda87e83d
commit
35a1353df5
@ -6,6 +6,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/cache"
|
"go_dreamfactory/sys/cache"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
|
||||||
"github.com/liwei1dao/lego/core"
|
"github.com/liwei1dao/lego/core"
|
||||||
"github.com/liwei1dao/lego/sys/log"
|
"github.com/liwei1dao/lego/sys/log"
|
||||||
@ -33,7 +34,7 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailResp) (err error) {
|
func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailReq) (err error) {
|
||||||
|
|
||||||
code := pb.ErrorCode_Success
|
code := pb.ErrorCode_Success
|
||||||
mailinfo := make([]*pb.DB_MailData, 0)
|
mailinfo := make([]*pb.DB_MailData, 0)
|
||||||
@ -53,7 +54,7 @@ func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSe
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailResp) (err error) {
|
func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailReq) (err error) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
mail *pb.DB_MailData
|
mail *pb.DB_MailData
|
||||||
@ -61,14 +62,72 @@ func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSes
|
|||||||
defer func() {
|
defer func() {
|
||||||
session.SendMsg(string(this.module.GetType()), "readusermailresp", code, &pb.ReadUserMailResp{Mail: mail})
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Api_Comp) GetUserMailAttachmentReq(ctx context.Context, session comm.IUserSession, req *pb.GetUserMailAttachmentResp) (err error) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Api_Comp) DelUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.DelUserMailResp) (err error) {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ const (
|
|||||||
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在
|
||||||
ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误
|
ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误
|
||||||
ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效
|
ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效
|
||||||
|
ErrorCode_StateInvalid ErrorCode = 21 //无效状态
|
||||||
|
ErrorCode_DBError ErrorCode = 22 // 数据库操作失败
|
||||||
)
|
)
|
||||||
|
|
||||||
// Enum value maps for ErrorCode.
|
// Enum value maps for ErrorCode.
|
||||||
@ -52,6 +54,8 @@ var (
|
|||||||
18: "UserSessionNobeing",
|
18: "UserSessionNobeing",
|
||||||
19: "SecKey",
|
19: "SecKey",
|
||||||
20: "SecKeyInvalid",
|
20: "SecKeyInvalid",
|
||||||
|
21: "StateInvalid",
|
||||||
|
22: "DBError",
|
||||||
}
|
}
|
||||||
ErrorCode_value = map[string]int32{
|
ErrorCode_value = map[string]int32{
|
||||||
"Success": 0,
|
"Success": 0,
|
||||||
@ -66,6 +70,8 @@ var (
|
|||||||
"UserSessionNobeing": 18,
|
"UserSessionNobeing": 18,
|
||||||
"SecKey": 19,
|
"SecKey": 19,
|
||||||
"SecKeyInvalid": 20,
|
"SecKeyInvalid": 20,
|
||||||
|
"StateInvalid": 21,
|
||||||
|
"DBError": 22,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -100,7 +106,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, 0xf8, 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,
|
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,
|
||||||
@ -115,8 +121,10 @@ var file_errorcode_proto_rawDesc = []byte{
|
|||||||
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73,
|
||||||
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a,
|
0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a,
|
||||||
0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x63,
|
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,
|
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c,
|
||||||
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
@ -87,7 +87,8 @@ type DB_MailData struct {
|
|||||||
CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime,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"` // 过期时间
|
DueTime uint64 `protobuf:"varint,6,opt,name=DueTime,proto3" json:"DueTime,omitempty"` // 过期时间
|
||||||
Check bool `protobuf:"varint,7,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看
|
Check bool `protobuf:"varint,7,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看
|
||||||
Items []*MailAttachment `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,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() {
|
func (x *DB_MailData) Reset() {
|
||||||
@ -171,6 +172,13 @@ func (x *DB_MailData) GetCheck() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *DB_MailData) GetReward() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Reward
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (x *DB_MailData) GetItems() []*MailAttachment {
|
func (x *DB_MailData) GetItems() []*MailAttachment {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Items
|
return x.Items
|
||||||
@ -186,7 +194,7 @@ var file_mail_db_proto_rawDesc = []byte{
|
|||||||
0x74, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
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,
|
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,
|
0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x49, 0x74,
|
||||||
0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xe0, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d,
|
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,
|
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,
|
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,
|
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55,
|
||||||
@ -198,10 +206,12 @@ var file_mail_db_proto_rawDesc = []byte{
|
|||||||
0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06,
|
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,
|
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,
|
0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68,
|
||||||
0x65, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x08, 0x20, 0x03,
|
0x65, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20,
|
||||||
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d,
|
0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x49,
|
||||||
0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b,
|
0x74, 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69,
|
||||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
@ -15,4 +15,6 @@ enum ErrorCode {
|
|||||||
UserSessionNobeing = 18; //用户不存在
|
UserSessionNobeing = 18; //用户不存在
|
||||||
SecKey = 19; //秘钥格式错误
|
SecKey = 19; //秘钥格式错误
|
||||||
SecKeyInvalid = 20; //秘钥无效
|
SecKeyInvalid = 20; //秘钥无效
|
||||||
|
StateInvalid = 21; //无效状态
|
||||||
|
DBError = 22; // 数据库操作失败
|
||||||
}
|
}
|
@ -19,5 +19,6 @@ message DB_MailData {
|
|||||||
uint64 CreateTime = 5; // 发送时间
|
uint64 CreateTime = 5; // 发送时间
|
||||||
uint64 DueTime = 6; // 过期时间
|
uint64 DueTime = 6; // 过期时间
|
||||||
bool Check = 7; // 是否查看
|
bool Check = 7; // 是否查看
|
||||||
repeated MailAttachment Items = 8; // 附件
|
bool Reward = 8; // 附件领取状态
|
||||||
|
repeated MailAttachment Items = 9; // 附件
|
||||||
}
|
}
|
||||||
|
@ -91,8 +91,7 @@ type DB_UserData struct {
|
|||||||
UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id
|
UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id
|
||||||
Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"`
|
Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"`
|
||||||
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
|
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
|
||||||
Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"`
|
ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"`
|
||||||
Password string `protobuf:"bytes,5,opt,name=Password,proto3" json:"Password,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) Reset() {
|
func (x *DB_UserData) Reset() {
|
||||||
@ -148,18 +147,11 @@ func (x *DB_UserData) GetNiceName() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) GetEmail() string {
|
func (x *DB_UserData) GetServerId() int32 {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Email
|
return x.ServerId
|
||||||
}
|
}
|
||||||
return ""
|
return 0
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DB_UserData) GetPassword() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Password
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_user_db_proto protoreflect.FileDescriptor
|
var File_user_db_proto protoreflect.FileDescriptor
|
||||||
@ -174,17 +166,15 @@ var file_user_db_proto_rawDesc = []byte{
|
|||||||
0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x08,
|
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,
|
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,
|
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, 0x77, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65,
|
||||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
|
0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a,
|
||||||
0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
||||||
0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65,
|
0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e,
|
||||||
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65,
|
0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e,
|
||||||
0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20,
|
0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61,
|
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x42,
|
||||||
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61,
|
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
|
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/liwei1dao/lego/core"
|
"github.com/liwei1dao/lego/core"
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -16,6 +17,11 @@ const (
|
|||||||
type IMail interface {
|
type IMail interface {
|
||||||
QueryUserMail(uId string) (mail []*pb.DB_MailData, err error)
|
QueryUserMail(uId string) (mail []*pb.DB_MailData, err error)
|
||||||
InsertUserMail(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_MailData, err error) {
|
func (this *DB) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
||||||
@ -32,7 +38,70 @@ func (this *DB) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *DB) InsertUserMail(mail *pb.DB_MailData) (err error) {
|
func (this *DB) InsertUserMail(mail *pb.DB_MailData) (err error) {
|
||||||
|
|
||||||
mail.ObjId = primitive.NewObjectID().Hex()
|
mail.ObjId = primitive.NewObjectID().Hex()
|
||||||
|
mail.Check = false
|
||||||
_, err = this.mgo.InsertOne(DB_MailTable, mail)
|
_, err = this.mgo.InsertOne(DB_MailTable, mail)
|
||||||
|
|
||||||
return err
|
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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user