viewStatusLogic.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package logic
  2. import (
  3. "context"
  4. "jyBXSubscribe/rpc/type/bxsubscribe"
  5. "time"
  6. "jyBXSubscribe/api/internal/svc"
  7. "jyBXSubscribe/api/internal/types"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type ViewStatusLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewViewStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ViewStatusLogic {
  16. return &ViewStatusLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *ViewStatusLogic) ViewStatus(req *types.ViewStatusReq) (resp *types.CommonResp, err error) {
  23. // todo: add your logic here and delete this line
  24. res, err := l.svcCtx.Suscribe.GetViewStatus(l.ctx, &bxsubscribe.GetViewStatusReq{
  25. AppId: req.AppId,
  26. EntId: req.EntId,
  27. EntUserId: req.EntUserId,
  28. InfoId: req.InfoId,
  29. })
  30. if err != nil {
  31. return &types.CommonResp{
  32. Err_code: res.ErrCode,
  33. Err_msg: res.ErrMsg,
  34. Data: nil,
  35. }, nil
  36. }
  37. var data []map[string]interface{}
  38. for _, v := range res.Items {
  39. _d := make(map[string]interface{})
  40. _d["name"] = v.Name
  41. _d["id"] = v.Id
  42. var visittime string
  43. if v.Visittime > 0 {
  44. visittime = time.Unix(v.Visittime, 0).Format("2006/01/02")
  45. }
  46. _d["visittime"] = visittime
  47. _d["isvisit"] = v.Isvisit
  48. data = append(data, _d)
  49. }
  50. return &types.CommonResp{
  51. Err_code: res.ErrCode,
  52. Err_msg: res.ErrMsg,
  53. Data: data,
  54. }, nil
  55. return
  56. }