|
|
|
@ -76,10 +76,7 @@ func (c *gameNoticeImpl) GetNoticeList(ctx context.Context, req *game.GetNoticeL
|
|
|
|
|
if req.NoticeType != 0 { |
|
|
|
|
model = model.Where("notice_type=?", req.NoticeType) |
|
|
|
|
} |
|
|
|
|
//if req.Channel != "0" {
|
|
|
|
|
// model = model.Where("channel=? ", req.Channel)
|
|
|
|
|
//}
|
|
|
|
|
err = model.Scan(&res.List) |
|
|
|
|
err = model.Page(req.PageNum, req.PageSize).Scan(&res.List) |
|
|
|
|
res.Total, err = model.Count() |
|
|
|
|
return |
|
|
|
|
}) |
|
|
|
@ -104,15 +101,22 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot
|
|
|
|
|
g.Log().Debugf(ctx, "ipList GetGameNotice ip: "+ip, "NoticeType: "+fmt.Sprint(req.NoticeType), "res: "+fmt.Sprint(res.Status)) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
model = model.Where("channel=? ", req.Channel) |
|
|
|
|
if req.NoticeType == consts.Notice_Type_Pop { |
|
|
|
|
model = model.Where("server=? ", req.ServerId) |
|
|
|
|
} else { |
|
|
|
|
model = model.Where("channel=? ", req.Channel) |
|
|
|
|
} |
|
|
|
|
var noticeList []*entity.GameNotice |
|
|
|
|
var count int |
|
|
|
|
count, err = model.Count() |
|
|
|
|
if count == 0 { |
|
|
|
|
model = dao.GameNotice.Ctx(ctx) |
|
|
|
|
model = model.Where("notice_type = ?", req.NoticeType) |
|
|
|
|
model = model.Where("channel=? ", "") |
|
|
|
|
if req.NoticeType == consts.Notice_Type_Pop { |
|
|
|
|
model = model.Where("server=? ", 0) |
|
|
|
|
} else { |
|
|
|
|
model = model.Where("channel=? ", "") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
err = model.Scan(¬iceList) |
|
|
|
|
if len(noticeList) > 1 { |
|
|
|
@ -133,21 +137,25 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot
|
|
|
|
|
res.Content = "" |
|
|
|
|
res.Status = consts.Notice_Normal |
|
|
|
|
} |
|
|
|
|
//ip := libUtils.GetClientIp(ctx)
|
|
|
|
|
if res.Status == consts.Notice_White_List { |
|
|
|
|
whiteIps, e := internal.GetWhiteList(ctx) |
|
|
|
|
g.Log().Debugf(ctx, "GetGameNotice ip"+ip, len(whiteIps), e) |
|
|
|
|
res.Status = consts.Notice_Maintenance |
|
|
|
|
for _, v := range whiteIps { |
|
|
|
|
if v.Ip == ip { |
|
|
|
|
res.Status = consts.Notice_Normal |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
if req.NoticeType == consts.Notice_Type_Pop { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
if res.Status == consts.Notice_White_List { |
|
|
|
|
whiteIps, e := internal.GetWhiteList(ctx) |
|
|
|
|
g.Log().Debugf(ctx, "GetGameNotice ip"+ip, len(whiteIps), e) |
|
|
|
|
res.Status = consts.Notice_Maintenance |
|
|
|
|
for _, v := range whiteIps { |
|
|
|
|
if v.Ip == ip { |
|
|
|
|
res.Status = consts.Notice_Normal |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if req.NoticeType != consts.Notice_Type_Maintenance { |
|
|
|
|
res.Status = consts.Notice_Normal |
|
|
|
|
if req.NoticeType != consts.Notice_Type_Maintenance { |
|
|
|
|
res.Status = consts.Notice_Normal |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
g.Log().Debugf(ctx, "GetGameNotice ip: "+ip, "NoticeType: "+fmt.Sprint(req.NoticeType), "res: "+fmt.Sprint(res.Status)) |
|
|
|
@ -296,7 +304,7 @@ func (c *gameNoticeImpl) DelNoticeList(ctx context.Context, req *game.DelNoticeL
|
|
|
|
|
|
|
|
|
|
func (c *gameNoticeImpl) PopNotice(ctx context.Context, req *game.PopReq) (res *game.PopRes, err error) { |
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
if req.PopTo == 1 { |
|
|
|
|
if req.PopTo == 1 || req.Type == consts.Notice_Pop_Roll || req.Type == consts.Notice_Pop_Roll_Del { |
|
|
|
|
req.Uids = "" |
|
|
|
|
} |
|
|
|
|
_, e := dao.GameNoticeLog.Ctx(ctx).Insert(&do.GameNoticeLog{ |
|
|
|
@ -305,7 +313,7 @@ func (c *gameNoticeImpl) PopNotice(ctx context.Context, req *game.PopReq) (res *
|
|
|
|
|
Uids: req.Uids, |
|
|
|
|
PopType: req.Type, |
|
|
|
|
Content: req.Content, |
|
|
|
|
NoticeType: 1, |
|
|
|
|
NoticeType: consts.Notice_Type_Pop, |
|
|
|
|
NoticeId: 0, |
|
|
|
|
Channel: "", |
|
|
|
|
SendTime: 0, |
|
|
|
@ -315,6 +323,20 @@ func (c *gameNoticeImpl) PopNotice(ctx context.Context, req *game.PopReq) (res *
|
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
err = internal.BackStageMessage(ctx, req.ServerId, req.Uids, req.Content, req.Type) |
|
|
|
|
if err == nil && req.Type == consts.Notice_Pop_Roll { |
|
|
|
|
dao.GameNotice.Ctx(ctx).Delete(do.GameNotice{NoticeType: consts.Notice_Type_Pop, ServerId: req.ServerId}) |
|
|
|
|
dao.GameNotice.Ctx(ctx).Insert(&do.GameNotice{ |
|
|
|
|
Status: 1, |
|
|
|
|
Content: req.Content, |
|
|
|
|
Channel: "", |
|
|
|
|
NoticeType: consts.Notice_Type_Pop, |
|
|
|
|
ServerId: req.ServerId, |
|
|
|
|
CDate: time.Now().Unix(), |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
if err == nil && req.Type == consts.Notice_Pop_Roll_Del { |
|
|
|
|
dao.GameNotice.Ctx(ctx).Delete(do.GameNotice{NoticeType: consts.Notice_Type_Pop, ServerId: req.ServerId}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|