notice.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package dao
  2. import (
  3. "context"
  4. notice "go-common/app/service/bbq/notice-service/api/v1"
  5. "go-common/library/log"
  6. )
  7. // NoticeList 获取通知列表
  8. func (d *Dao) NoticeList(ctx context.Context, noticeType int32, mid, cursorID int64) (list []*notice.NoticeBase, err error) {
  9. req := &notice.ListNoticesReq{
  10. Mid: mid,
  11. NoticeType: noticeType,
  12. CursorId: cursorID,
  13. }
  14. res, err := d.noticeClient.ListNotices(ctx, req)
  15. if err != nil {
  16. log.Errorv(ctx, log.KV("log", "notice-service:ListNotices fail"), log.KV("err", err))
  17. return
  18. }
  19. list = res.List
  20. return
  21. }
  22. // GetNoticeUnread 获取未读情况
  23. func (d *Dao) GetNoticeUnread(ctx context.Context, mid int64) (list []*notice.UnreadItem, err error) {
  24. req := &notice.GetUnreadInfoRequest{Mid: mid}
  25. res, err := d.noticeClient.GetUnreadInfo(ctx, req)
  26. if err != nil {
  27. log.Errorv(ctx, log.KV("log", "call notice service get unread info fail: err="+err.Error()))
  28. return
  29. }
  30. list = res.List
  31. log.V(1).Infov(ctx, log.KV("log", "call notice service get unread info: res="+res.String()))
  32. return
  33. }
  34. // CreateNotice 创建通知
  35. func (d *Dao) CreateNotice(ctx context.Context, notice *notice.NoticeBase) (err error) {
  36. _, err = d.noticeClient.CreateNotice(ctx, notice)
  37. if err != nil {
  38. log.Errorv(ctx, log.KV("log", "create notice fail: notice="+notice.String()))
  39. return
  40. }
  41. log.V(1).Infov(ctx, log.KV("log", "create notice: notice="+notice.String()))
  42. return
  43. }