getReceiveInfo.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/db"
  7. "youngee_b_api/middleware"
  8. "youngee_b_api/model/http_model"
  9. "youngee_b_api/util"
  10. )
  11. func WrapGetReceiveInfoHandler(ctx *gin.Context) {
  12. handler := newGetReceiveInfoHandler(ctx)
  13. baseRun(handler)
  14. }
  15. type GetReceiveInfoHandler struct {
  16. ctx *gin.Context
  17. req *http_model.GetReceiveInfoRequest
  18. resp *http_model.CommonResponse
  19. }
  20. func (g GetReceiveInfoHandler) getContext() *gin.Context {
  21. return g.ctx
  22. }
  23. func (g GetReceiveInfoHandler) getResponse() interface{} {
  24. return g.resp
  25. }
  26. func (g GetReceiveInfoHandler) getRequest() interface{} {
  27. return g.req
  28. }
  29. func (g GetReceiveInfoHandler) run() {
  30. auth := middleware.GetSessionAuth(g.ctx)
  31. enterpriseID := auth.EnterpriseID
  32. data, err := db.GetReceiveInfo(g.ctx, enterpriseID)
  33. if err != nil {
  34. // 数据库查询失败,返回5001
  35. logrus.Errorf("[GetReceiveInfoHandler] call GetReceiveInfo err:%+v\n", err)
  36. util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
  37. logrus.Info("GetReceiveInfo fail,req:%+v", g.req)
  38. return
  39. }
  40. g.resp.Data = data
  41. }
  42. func (g GetReceiveInfoHandler) checkParam() error {
  43. return nil
  44. }
  45. func newGetReceiveInfoHandler(ctx *gin.Context) *GetReceiveInfoHandler {
  46. return &GetReceiveInfoHandler{
  47. ctx: ctx,
  48. req: http_model.NewGetReceiveInfoRequest(),
  49. resp: http_model.NewGetReceiveInfoResponse(),
  50. }
  51. }