Merge branch 'meixiongfeng' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
24e4277d05
@ -590,7 +590,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MaxRankList = 50 // 赛季塔 排行榜人数
|
MaxRankList = 50 // 赛季塔 排行榜人数
|
||||||
|
MaxMailCount = 50 // 当前邮件最大数量
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -31,11 +31,16 @@ func (this *modelMail) Init(service core.IService, module core.IModule, comp cor
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *modelMail) MailQueryUserMail(uId string) (mail []*pb.DBMailData, err error) {
|
func (this *modelMail) MailQueryUserMail(uId string) (mail []*pb.DBMailData, err error) {
|
||||||
|
var index int32
|
||||||
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uId}, options.Find().SetSort(bson.M{"createtime": -1})); err == nil {
|
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uId}); err == nil {
|
||||||
for _data.Next(context.TODO()) {
|
for _data.Next(context.TODO()) {
|
||||||
|
index++
|
||||||
temp := &pb.DBMailData{}
|
temp := &pb.DBMailData{}
|
||||||
if err = _data.Decode(temp); err == nil {
|
if err = _data.Decode(temp); err == nil {
|
||||||
|
if index > comm.MaxMailCount { // 删除超标的邮件
|
||||||
|
this.DB.DeleteOne(comm.TableMail, bson.M{"_id": temp.ObjId}, options.Delete())
|
||||||
|
continue
|
||||||
|
}
|
||||||
mail = append(mail, temp)
|
mail = append(mail, temp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,6 +95,29 @@ func (this *modelMail) MailGetMailAttachmentState(objId string) (*pb.DBMailData,
|
|||||||
|
|
||||||
return nd, err
|
return nd, err
|
||||||
}
|
}
|
||||||
|
func (this *modelMail) GetMailCountByUid(uid string) (int32, error) {
|
||||||
|
var count int64
|
||||||
|
count, err := this.DB.CountDocuments(comm.TableMail, bson.M{"uid": uid})
|
||||||
|
|
||||||
|
return int32(count), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除超过最大邮件数量的邮件
|
||||||
|
func (this *modelMail) DelOtherMail(uid string) {
|
||||||
|
if _data, err := this.DB.Find(comm.TableMail, bson.M{"uid": uid}); err == nil {
|
||||||
|
var index int32
|
||||||
|
for _data.Next(context.TODO()) {
|
||||||
|
index++
|
||||||
|
temp := &pb.DBMailData{}
|
||||||
|
if err = _data.Decode(temp); err == nil {
|
||||||
|
if index >= comm.MaxMailCount { // 删除超标的邮件
|
||||||
|
this.DB.DeleteOne(comm.TableMail, bson.M{"_id": temp.ObjId}, options.Delete())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 更新领取附件状态
|
// 更新领取附件状态
|
||||||
func (this *modelMail) MailUpdateMailAttachmentState(objId string) bool {
|
func (this *modelMail) MailUpdateMailAttachmentState(objId string) bool {
|
||||||
|
@ -187,3 +187,12 @@ func (this *Mail) SendMailByCid(session comm.IUserSession, cid string, res []*pb
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 创建邮件之前检测邮件是否达到上限
|
||||||
|
func (this *Mail) CheckMaxMail(session comm.IUserSession) bool {
|
||||||
|
count, err := this.modelMail.GetMailCountByUid(session.GetUserId())
|
||||||
|
if err == nil && count >= comm.MaxMailCount {
|
||||||
|
this.modelMail.DelOtherMail(session.GetUserId())
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
// 公会BOSS 推荐
|
// 公会BOSS 推荐
|
||||||
func (this *apiComp) RecommendCheck(session comm.IUserSession, req *pb.SociatyRecommendReq) (code pb.ErrorCode) {
|
func (this *apiComp) RecommendCheck(session comm.IUserSession, req *pb.SociatyRecommendReq) (code pb.ErrorCode) {
|
||||||
if req.Cate != 1 || req.Cate != 2 {
|
if req.Cate != 1 && req.Cate != 2 {
|
||||||
code = pb.ErrorCode_ReqParameterError
|
code = pb.ErrorCode_ReqParameterError
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user