命名修改
This commit is contained in:
parent
d32cea4d30
commit
b81ccf78e3
@ -15,14 +15,14 @@ const (
|
||||
GetNewEMailResp = "getnewEmailresp"
|
||||
)
|
||||
|
||||
type Api_Comp struct {
|
||||
type apiComp struct {
|
||||
modules.MComp_GateComp
|
||||
service core.IService
|
||||
module *Mail
|
||||
items comm.IItems
|
||||
}
|
||||
|
||||
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MComp_GateComp.Init(service, module, comp, options)
|
||||
this.service = service
|
||||
this.module = module.(*Mail)
|
||||
@ -30,7 +30,7 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Api_Comp) Start() (err error) {
|
||||
func (this *apiComp) Start() (err error) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
var module core.IModule
|
||||
|
||||
|
@ -7,12 +7,12 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *Api_Comp) DelMail_Check(session comm.IUserSession, req *pb.Mail_DelMail_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) DelMail_Check(session comm.IUserSession, req *pb.Mail_DelMail_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
// 删除邮件
|
||||
func (this *Api_Comp) DelMail(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_DelMail_Req) (code pb.ErrorCode) {
|
||||
func (this *apiComp) DelMail(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_DelMail_Req) (code pb.ErrorCode) {
|
||||
var err error
|
||||
mailinfo := make([]*pb.DB_MailData, 0)
|
||||
defer func() {
|
||||
@ -22,13 +22,13 @@ func (this *Api_Comp) DelMail(session comm.IUserSession, agrs map[string]interfa
|
||||
code = pb.ErrorCode_NoLogin
|
||||
return
|
||||
}
|
||||
bRet := this.module.db_comp.Mail_DelUserMail(req.ObjID)
|
||||
bRet := this.module.modelMail.Mail_DelUserMail(req.ObjID)
|
||||
if !bRet {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
|
||||
if mailinfo, err = this.module.db_comp.Mail_QueryUserMail(session.GetUserId()); err != nil {
|
||||
if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil {
|
||||
log.Errorf("QueryUserMailResp err:%v", err)
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
|
@ -5,12 +5,12 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *Api_Comp) GetUserMailAttachment_Check(session comm.IUserSession, req *pb.Mail_GetUserMailAttachment_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) GetUserMailAttachment_Check(session comm.IUserSession, req *pb.Mail_GetUserMailAttachment_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
// 领取附件
|
||||
func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_GetUserMailAttachment_Req) (code pb.ErrorCode) {
|
||||
func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_GetUserMailAttachment_Req) (code pb.ErrorCode) {
|
||||
|
||||
var (
|
||||
mail *pb.DB_MailData
|
||||
@ -22,12 +22,12 @@ func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[
|
||||
code = pb.ErrorCode_NoLogin
|
||||
return
|
||||
}
|
||||
_bGet := this.module.db_comp.Mail_GetMailAttachmentState(req.ObjID)
|
||||
_bGet := this.module.modelMail.Mail_GetMailAttachmentState(req.ObjID)
|
||||
if !_bGet {
|
||||
code = pb.ErrorCode_StateInvalid
|
||||
return
|
||||
}
|
||||
_data, err := this.module.db_comp.Mail_GetMailAttachment(req.ObjID)
|
||||
_data, err := this.module.modelMail.Mail_GetMailAttachment(req.ObjID)
|
||||
if err == nil {
|
||||
if len(_data) > 0 {
|
||||
// todo 领取附件
|
||||
@ -42,7 +42,7 @@ func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[
|
||||
}, mail.Uid, _items)
|
||||
if code == pb.ErrorCode_Success {
|
||||
// 修改状态
|
||||
this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID)
|
||||
this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID)
|
||||
mail.Reward = true
|
||||
return
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *Api_Comp) GetList_Check(session comm.IUserSession, req *pb.Mail_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) GetList_Check(session comm.IUserSession, req *pb.Mail_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
// 查看所有邮件信息
|
||||
func (this *Api_Comp) GetList(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_GetList_Req) (code pb.ErrorCode) {
|
||||
func (this *apiComp) GetList(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_GetList_Req) (code pb.ErrorCode) {
|
||||
|
||||
var err error
|
||||
mailinfo := make([]*pb.DB_MailData, 0)
|
||||
@ -22,7 +22,7 @@ func (this *Api_Comp) GetList(session comm.IUserSession, agrs map[string]interfa
|
||||
code = pb.ErrorCode_NoLogin
|
||||
return
|
||||
}
|
||||
if mailinfo, err = this.module.db_comp.Mail_QueryUserMail(session.GetUserId()); err != nil {
|
||||
if mailinfo, err = this.module.modelMail.Mail_QueryUserMail(session.GetUserId()); err != nil {
|
||||
log.Errorf("Mail_GetList_Resp err:%v", err)
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
|
@ -5,12 +5,12 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
)
|
||||
|
||||
func (this *Api_Comp) ReadMail_Check(session comm.IUserSession, req *pb.Mail_ReadMail_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) ReadMail_Check(session comm.IUserSession, req *pb.Mail_ReadMail_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
return
|
||||
}
|
||||
|
||||
// 查看某一封邮件
|
||||
func (this *Api_Comp) ReadMail(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_ReadMail_Req) (code pb.ErrorCode) {
|
||||
func (this *apiComp) ReadMail(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_ReadMail_Req) (code pb.ErrorCode) {
|
||||
var (
|
||||
err error
|
||||
mail *pb.DB_MailData
|
||||
@ -23,7 +23,7 @@ func (this *Api_Comp) ReadMail(session comm.IUserSession, agrs map[string]interf
|
||||
return
|
||||
}
|
||||
|
||||
mail, err = this.module.db_comp.Mail_ReadOneMail(req.ObjID)
|
||||
mail, err = this.module.modelMail.Mail_ReadOneMail(req.ObjID)
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ const (
|
||||
DB_MailTable core.SqlTable = "mail"
|
||||
)
|
||||
|
||||
type DB_Comp struct {
|
||||
type ModelMail struct {
|
||||
modules.Model_Comp
|
||||
}
|
||||
|
||||
func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
func (this *ModelMail) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.Model_Comp.Init(service, module, comp, options)
|
||||
this.TableName = "mail"
|
||||
//创建uid索引
|
||||
@ -32,7 +32,7 @@ func (this *DB_Comp) Init(service core.IService, module core.IModule, comp core.
|
||||
return
|
||||
}
|
||||
|
||||
func (this *DB_Comp) Mail_QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
||||
func (this *ModelMail) Mail_QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
|
||||
|
||||
if _data, err := this.DB.Find(DB_MailTable, bson.M{"userid": uId}); err == nil {
|
||||
for _data.Next(context.TODO()) {
|
||||
@ -46,7 +46,7 @@ func (this *DB_Comp) Mail_QueryUserMail(uId string) (mail []*pb.DB_MailData, err
|
||||
}
|
||||
|
||||
// 插入一封新的邮件
|
||||
func (this *DB_Comp) Mail_InsertUserMail(mail *pb.DB_MailData) (err error) {
|
||||
func (this *ModelMail) Mail_InsertUserMail(mail *pb.DB_MailData) (err error) {
|
||||
|
||||
mail.ObjId = primitive.NewObjectID().Hex()
|
||||
mail.Check = false
|
||||
@ -60,7 +60,7 @@ func (this *DB_Comp) Mail_InsertUserMail(mail *pb.DB_MailData) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func (this *DB_Comp) Mail_ReadOneMail(objId string) (mail *pb.DB_MailData, err error) {
|
||||
func (this *ModelMail) Mail_ReadOneMail(objId string) (mail *pb.DB_MailData, err error) {
|
||||
|
||||
err = this.DB.FindOneAndUpdate(
|
||||
DB_MailTable,
|
||||
@ -75,7 +75,7 @@ func (this *DB_Comp) Mail_ReadOneMail(objId string) (mail *pb.DB_MailData, err e
|
||||
}
|
||||
|
||||
// 查询附件信息
|
||||
func (this *DB_Comp) Mail_GetMailAttachment(objId string) (itmes []*pb.MailAttachment, err error) {
|
||||
func (this *ModelMail) Mail_GetMailAttachment(objId string) (itmes []*pb.MailAttachment, err error) {
|
||||
|
||||
obj := this.DB.FindOne(DB_MailTable, bson.M{"_id": objId})
|
||||
var nd *pb.DB_MailData
|
||||
@ -86,7 +86,7 @@ func (this *DB_Comp) Mail_GetMailAttachment(objId string) (itmes []*pb.MailAttac
|
||||
}
|
||||
|
||||
// 查看领取附件状态
|
||||
func (this *DB_Comp) Mail_GetMailAttachmentState(objId string) bool {
|
||||
func (this *ModelMail) Mail_GetMailAttachmentState(objId string) bool {
|
||||
var nd *pb.DB_MailData
|
||||
err := this.DB.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(nd)
|
||||
if err != nil {
|
||||
@ -96,7 +96,7 @@ func (this *DB_Comp) Mail_GetMailAttachmentState(objId string) bool {
|
||||
}
|
||||
|
||||
// 更新领取附件状态
|
||||
func (this *DB_Comp) Mail_UpdateMailAttachmentState(objId string) bool {
|
||||
func (this *ModelMail) Mail_UpdateMailAttachmentState(objId string) bool {
|
||||
this.DB.FindOneAndUpdate(
|
||||
DB_MailTable,
|
||||
bson.M{"_id": objId},
|
||||
@ -110,7 +110,7 @@ func (this *DB_Comp) Mail_UpdateMailAttachmentState(objId string) bool {
|
||||
}
|
||||
|
||||
// 删除一封邮件
|
||||
func (this *DB_Comp) Mail_DelUserMail(objId string) bool {
|
||||
func (this *ModelMail) Mail_DelUserMail(objId string) bool {
|
||||
var obj *pb.DB_MailData
|
||||
err := this.DB.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(obj)
|
||||
if err != nil {
|
@ -24,8 +24,8 @@ func NewModule() core.IModule {
|
||||
|
||||
type Mail struct {
|
||||
modules.ModuleBase
|
||||
api_comp *Api_Comp
|
||||
db_comp *DB_Comp
|
||||
api *apiComp
|
||||
modelMail *ModelMail
|
||||
configure_comp *Configure_Comp
|
||||
}
|
||||
|
||||
@ -35,8 +35,8 @@ func (this *Mail) GetType() core.M_Modules {
|
||||
|
||||
func (this *Mail) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||
this.db_comp = this.RegisterComp(new(DB_Comp)).(*DB_Comp)
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelMail = this.RegisterComp(new(ModelMail)).(*ModelMail)
|
||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||
}
|
||||
|
||||
@ -51,13 +51,13 @@ func (this *Mail) CreateNewMail(uId string) {
|
||||
Check: false,
|
||||
Reward: false,
|
||||
}
|
||||
err := this.db_comp.Mail_InsertUserMail(mail)
|
||||
err := this.modelMail.Mail_InsertUserMail(mail)
|
||||
if err != nil {
|
||||
log.Error("create mail failed")
|
||||
}
|
||||
// 通知玩家
|
||||
var _cache = &pb.Cache_UserData{}
|
||||
err = this.db_comp.Model_Comp.Get(uId, _cache)
|
||||
err = this.modelMail.Model_Comp.Get(uId, _cache)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user