|
|
|
@ -30,6 +30,7 @@ type IGameNotice interface { |
|
|
|
GetNoticeModel(ctx context.Context, req *game.GetNoticeModelReq) (res *game.GetNoticeModelRes, err error) |
|
|
|
GetNoticeModel(ctx context.Context, req *game.GetNoticeModelReq) (res *game.GetNoticeModelRes, err error) |
|
|
|
AddNoticeModel(ctx context.Context, req *game.AddNoticeModelReq) (res *game.AddNoticeModelRes, err error) |
|
|
|
AddNoticeModel(ctx context.Context, req *game.AddNoticeModelReq) (res *game.AddNoticeModelRes, err error) |
|
|
|
DelNoticeModel(ctx context.Context, req *game.DelNoticeModelReq) (res *game.DelNoticeModelRes, err error) |
|
|
|
DelNoticeModel(ctx context.Context, req *game.DelNoticeModelReq) (res *game.DelNoticeModelRes, err error) |
|
|
|
|
|
|
|
NoticeShow(ctx context.Context, req *game.NoticeShowReq) (res *game.NoticeShowRes, err error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type gameNoticeImpl struct { |
|
|
|
type gameNoticeImpl struct { |
|
|
|
@ -96,6 +97,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot |
|
|
|
res.TimeStamp = int32(ipList[0].CDate) |
|
|
|
res.TimeStamp = int32(ipList[0].CDate) |
|
|
|
res.Content = ipList[0].Content |
|
|
|
res.Content = ipList[0].Content |
|
|
|
res.Status = ipList[0].Status |
|
|
|
res.Status = ipList[0].Status |
|
|
|
|
|
|
|
res.IsShow = ipList[0].IsShow |
|
|
|
|
|
|
|
|
|
|
|
g.Log().Debugf(ctx, "ipList GetGameNotice ip: "+ip, "NoticeType: "+fmt.Sprint(req.NoticeType), "res: "+fmt.Sprint(res.Status)) |
|
|
|
g.Log().Debugf(ctx, "ipList GetGameNotice ip: "+ip, "NoticeType: "+fmt.Sprint(req.NoticeType), "res: "+fmt.Sprint(res.Status)) |
|
|
|
return |
|
|
|
return |
|
|
|
@ -124,6 +126,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot |
|
|
|
res.TimeStamp = int32(v.CDate) |
|
|
|
res.TimeStamp = int32(v.CDate) |
|
|
|
res.Content = v.Content |
|
|
|
res.Content = v.Content |
|
|
|
res.Status = v.Status |
|
|
|
res.Status = v.Status |
|
|
|
|
|
|
|
res.IsShow = v.IsShow |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -131,6 +134,7 @@ func (c *gameNoticeImpl) GetGameNotice(ctx context.Context, req *game.GetGameNot |
|
|
|
res.TimeStamp = int32(noticeList[0].CDate) |
|
|
|
res.TimeStamp = int32(noticeList[0].CDate) |
|
|
|
res.Content = noticeList[0].Content |
|
|
|
res.Content = noticeList[0].Content |
|
|
|
res.Status = noticeList[0].Status |
|
|
|
res.Status = noticeList[0].Status |
|
|
|
|
|
|
|
res.IsShow = noticeList[0].IsShow |
|
|
|
} else if len(noticeList) == 0 { |
|
|
|
} else if len(noticeList) == 0 { |
|
|
|
res.TimeStamp = 0 |
|
|
|
res.TimeStamp = 0 |
|
|
|
res.Content = "" |
|
|
|
res.Content = "" |
|
|
|
@ -173,7 +177,11 @@ func (c *gameNoticeImpl) GetGameNoticeList(ctx context.Context, req *game.GetGam |
|
|
|
req1.Channel = req.Channel |
|
|
|
req1.Channel = req.Channel |
|
|
|
res2, _ := c.GetGameNotice(ctx, req1) |
|
|
|
res2, _ := c.GetGameNotice(ctx, req1) |
|
|
|
res.List = append(res.List, game.Notice{Content: res2.Content, Status: res2.Status, TimeStamp: res2.TimeStamp, NoticeType: consts.Notice_Type_Preview}) |
|
|
|
res.List = append(res.List, game.Notice{Content: res2.Content, Status: res2.Status, TimeStamp: res2.TimeStamp, NoticeType: consts.Notice_Type_Preview}) |
|
|
|
//log.Printf("GetGameNotice res: %s", gjson.MustEncodeString(res.List))
|
|
|
|
|
|
|
|
|
|
|
|
req1.NoticeType = consts.Notice_Type_NewServer |
|
|
|
|
|
|
|
req1.Channel = req.Channel |
|
|
|
|
|
|
|
res3, _ := c.GetGameNotice(ctx, req1) |
|
|
|
|
|
|
|
res.List = append(res.List, game.Notice{Content: res3.Content, Status: res3.Status, TimeStamp: res3.TimeStamp, IsShow: res3.IsShow, NoticeType: consts.Notice_Type_NewServer}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
@ -214,10 +222,12 @@ func (c *gameNoticeImpl) AddNotice(ctx context.Context, req *game.AddNoticeReq) |
|
|
|
NoticeType: req.NoticeType, |
|
|
|
NoticeType: req.NoticeType, |
|
|
|
NoticeId: req.NoticeId, |
|
|
|
NoticeId: req.NoticeId, |
|
|
|
Channel: req.Channel, |
|
|
|
Channel: req.Channel, |
|
|
|
|
|
|
|
IsShow: req.IsShow, |
|
|
|
SendTime: SendTime, |
|
|
|
SendTime: SendTime, |
|
|
|
} |
|
|
|
} |
|
|
|
cron := entity.GameNoticeLog{ |
|
|
|
cron := entity.GameNoticeLog{ |
|
|
|
Id: req.Id, |
|
|
|
Id: req.Id, |
|
|
|
|
|
|
|
IsShow: req.IsShow, |
|
|
|
Status: req.Status, |
|
|
|
Status: req.Status, |
|
|
|
Content: req.Content, |
|
|
|
Content: req.Content, |
|
|
|
NoticeType: req.NoticeType, |
|
|
|
NoticeType: req.NoticeType, |
|
|
|
@ -258,12 +268,14 @@ func (c *gameNoticeImpl) AddNotice(ctx context.Context, req *game.AddNoticeReq) |
|
|
|
noticeModel.Where("notice_type=?", req.NoticeType).Where("channel=?", req.Channel).Scan(¬iceList) |
|
|
|
noticeModel.Where("notice_type=?", req.NoticeType).Where("channel=?", req.Channel).Scan(¬iceList) |
|
|
|
if len(noticeList) > 0 { |
|
|
|
if len(noticeList) > 0 { |
|
|
|
_, e = noticeModel.Where("id=?", noticeList[0].Id).Data(&do.GameNotice{ |
|
|
|
_, e = noticeModel.Where("id=?", noticeList[0].Id).Data(&do.GameNotice{ |
|
|
|
|
|
|
|
IsShow: req.IsShow, |
|
|
|
Status: req.Status, |
|
|
|
Status: req.Status, |
|
|
|
Content: req.Content, |
|
|
|
Content: req.Content, |
|
|
|
CDate: time.Now().Unix(), |
|
|
|
CDate: time.Now().Unix(), |
|
|
|
}).Update() |
|
|
|
}).Update() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_, e = noticeModel.Insert(&do.GameNotice{ |
|
|
|
_, e = noticeModel.Insert(&do.GameNotice{ |
|
|
|
|
|
|
|
IsShow: req.IsShow, |
|
|
|
Status: req.Status, |
|
|
|
Status: req.Status, |
|
|
|
Content: req.Content, |
|
|
|
Content: req.Content, |
|
|
|
NoticeType: req.NoticeType, |
|
|
|
NoticeType: req.NoticeType, |
|
|
|
@ -402,3 +414,20 @@ func (c *gameNoticeImpl) DelNoticeModel(ctx context.Context, req *game.DelNotice |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c *gameNoticeImpl) NoticeShow(ctx context.Context, req *game.NoticeShowReq) (res *game.NoticeShowRes, err error) { |
|
|
|
|
|
|
|
if req.Id == 0 { |
|
|
|
|
|
|
|
err = errors.New("错误的id") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = g.Try(ctx, func(ctx context.Context) { |
|
|
|
|
|
|
|
_, e := dao.GameNotice.Ctx(ctx).Where("id=", req.Id).Data(&do.GameNotice{IsShow: req.IsShow}).Update() |
|
|
|
|
|
|
|
if e != nil { |
|
|
|
|
|
|
|
liberr.ErrIsNil(ctx, e, "修改公告失败") |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|