find_all_sub_account.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. log "github.com/sirupsen/logrus"
  6. "youngee_b_api/consts"
  7. "youngee_b_api/model/http_model"
  8. "youngee_b_api/service"
  9. "youngee_b_api/util"
  10. )
  11. func WrapFindAllSubAccountHandler(ctx *gin.Context) {
  12. handler := newFindAllSubAccountHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newFindAllSubAccountHandler(ctx *gin.Context) *FindAllSubAccountHandler {
  16. return &FindAllSubAccountHandler{
  17. req: http_model.NewFindAllSubAccountRequest(),
  18. resp: http_model.NewFindAllSubAccountResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type FindAllSubAccountHandler struct {
  23. req *http_model.FindAllSubAccountRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *FindAllSubAccountHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *FindAllSubAccountHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *FindAllSubAccountHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *FindAllSubAccountHandler) run() {
  37. data, err := service.SubAccount.FindSubAccountBySupplierId(h.ctx, *h.req)
  38. if err != nil {
  39. logrus.Errorf("[FindSubAccountBySupplierId] call SetSession err:%+v\n", err)
  40. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
  41. log.Info("FindSubAccountBySupplierId fail,req:%+v", h.req)
  42. h.resp.Message = err.Error()
  43. h.resp.Status = 40000
  44. return
  45. }
  46. h.resp.Data = data
  47. h.resp.Status = 20000
  48. h.resp.Message = "ok"
  49. }
  50. func (h *FindAllSubAccountHandler) checkParam() error {
  51. return nil
  52. }