Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
a58102ab4c
@ -590,7 +590,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MaxRankList = 50 // 赛季塔 排行榜人数
|
MaxRankList = 50 // 赛季塔 排行榜人数
|
||||||
|
MaxMailCount = 50 // 当前邮件最大数量
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -70,6 +70,7 @@ locp:
|
|||||||
go this.Close()
|
go this.Close()
|
||||||
break locp
|
break locp
|
||||||
}
|
}
|
||||||
|
this.wsConn.SetReadDeadline(time.Now().Add(time.Second * 30))
|
||||||
if err = proto.Unmarshal(data, msg); err != nil {
|
if err = proto.Unmarshal(data, msg); err != nil {
|
||||||
this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
|
this.gateway.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err)
|
||||||
go this.Close()
|
go this.Close()
|
||||||
@ -177,9 +178,14 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (code pb.ErrorCode, err e
|
|||||||
}
|
}
|
||||||
msg.Data = ad
|
msg.Data = ad
|
||||||
} else {
|
} else {
|
||||||
if msg.MainType != string(comm.ModuleNotify) && this.UserId() == "" {
|
switch msg.MainType {
|
||||||
this.gateway.Errorf("[%v.%v] Agent UId empty", msg.MainType, msg.SubType)
|
case string(comm.ModuleNotify), string(comm.ModuleGate):
|
||||||
return pb.ErrorCode_AgentUidEmpty, fmt.Errorf("no login")
|
return pb.ErrorCode_Success, nil
|
||||||
|
default:
|
||||||
|
if this.UserId() == "" {
|
||||||
|
this.gateway.Errorf("[%v.%v] Agent UId empty", msg.MainType, msg.SubType)
|
||||||
|
return pb.ErrorCode_AgentUidEmpty, fmt.Errorf("no login")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pb.ErrorCode_Success, nil
|
return pb.ErrorCode_Success, nil
|
||||||
|
@ -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