roomNotice.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package v1
  2. import (
  3. "context"
  4. v1pb "go-common/app/interface/live/app-room/api/http/v1"
  5. "go-common/app/interface/live/app-room/conf"
  6. "go-common/app/interface/live/app-room/dao"
  7. "go-common/app/service/live/xuserex/api/grpc/v1"
  8. "go-common/library/ecode"
  9. )
  10. // RoomNoticeService struct
  11. type RoomNoticeService struct {
  12. conf *conf.Config
  13. // optionally add other properties here, such as dao
  14. dao *dao.Dao
  15. }
  16. //NewRoomNoticeService init
  17. func NewRoomNoticeService(c *conf.Config) (s *RoomNoticeService) {
  18. s = &RoomNoticeService{
  19. conf: c,
  20. dao: dao.New(c),
  21. }
  22. return s
  23. }
  24. // 房间提示 相关服务
  25. // BuyGuard implementation
  26. // 是否弹出大航海购买提示
  27. func (s *RoomNoticeService) BuyGuard(ctx context.Context, req *v1pb.RoomNoticeBuyGuardReq) (resp *v1pb.RoomNoticeBuyGuardResp, err error) {
  28. resp = &v1pb.RoomNoticeBuyGuardResp{}
  29. UID := req.GetUid()
  30. targetID := req.GetTargetId()
  31. if UID <= 0 || targetID <= 0 {
  32. err = ecode.ParamInvalid
  33. return
  34. }
  35. ret, err := s.dao.XuserexAPI.BuyGuard(ctx, &v1.RoomNoticeBuyGuardReq{
  36. Uid: UID,
  37. TargetId: targetID,
  38. })
  39. if err != nil {
  40. return
  41. }
  42. if ret == nil {
  43. return
  44. }
  45. resp = &v1pb.RoomNoticeBuyGuardResp{
  46. ShouldNotice: ret.GetShouldNotice(),
  47. Begin: ret.GetBegin(),
  48. End: ret.GetEnd(),
  49. Now: ret.GetNow(),
  50. Title: ret.GetTitle(),
  51. Content: ret.GetContent(),
  52. Button: ret.GetButton(),
  53. }
  54. return
  55. }