viewStatusLogic.go 1.3 KB

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