getEnterpriseBalance.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_m_api/consts"
  6. "youngee_m_api/db"
  7. "youngee_m_api/model/http_model"
  8. "youngee_m_api/util"
  9. )
  10. func WrapGetEnterpriseBalanceHandler(ctx *gin.Context) {
  11. handler := newGetEnterpriseBalanceHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type GetEnterpriseBalanceHandler struct {
  15. ctx *gin.Context
  16. req *http_model.GetEnterPriseBalanceRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (g GetEnterpriseBalanceHandler) getContext() *gin.Context {
  20. return g.ctx
  21. }
  22. func (g GetEnterpriseBalanceHandler) getResponse() interface{} {
  23. return g.resp
  24. }
  25. func (g GetEnterpriseBalanceHandler) getRequest() interface{} {
  26. return g.req
  27. }
  28. func (g GetEnterpriseBalanceHandler) run() {
  29. data, err := db.GetEnterpriseBalance(g.ctx, g.req.EnterPriseId)
  30. if err != nil {
  31. logrus.Errorf("[GetEnterpriseBalanceHandler] call Show err:%+v\n", err)
  32. util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, "")
  33. logrus.Info("GetEnterpriseBalanceHandler fail,req:%+v", g.req)
  34. return
  35. }
  36. g.resp.Data = data
  37. }
  38. func (g GetEnterpriseBalanceHandler) checkParam() error {
  39. return nil
  40. }
  41. func newGetEnterpriseBalanceHandler(ctx *gin.Context) *GetEnterpriseBalanceHandler {
  42. return &GetEnterpriseBalanceHandler{
  43. ctx: ctx,
  44. req: http_model.NewEnterpriseBalanceRequest(),
  45. resp: http_model.NewGetEnterpriseBalanceResponse(),
  46. }
  47. }