getBankInfo.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 WrapGetBankInfoHandler(ctx *gin.Context) {
  11. handler := newGetBankInfoHandler(ctx)
  12. BaseRun(handler)
  13. }
  14. type GetBankInfo struct {
  15. ctx *gin.Context
  16. req *http_model.GetBankInfoRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (g GetBankInfo) getContext() *gin.Context {
  20. return g.ctx
  21. }
  22. func (g GetBankInfo) getResponse() interface{} {
  23. return g.resp
  24. }
  25. func (g GetBankInfo) getRequest() interface{} {
  26. return g.req
  27. }
  28. func (g GetBankInfo) run() {
  29. data, err := db.GetBankInfo(g.ctx, g.req)
  30. if err != nil {
  31. logrus.WithContext(g.ctx).Errorf("[GetBankInfoHandler] error GetBankInfo, err:%+v", err)
  32. util.HandlerPackErrorResp(g.resp, consts.ErrorInternal, consts.DefaultToast)
  33. return
  34. }
  35. g.resp.Data = data
  36. g.resp.Status = consts.ErrorSuccess
  37. }
  38. func (g GetBankInfo) checkParam() error {
  39. return nil
  40. }
  41. func newGetBankInfoHandler(ctx *gin.Context) *GetBankInfo {
  42. return &GetBankInfo{
  43. ctx: ctx,
  44. req: http_model.NewGetBankInfoRequest(),
  45. resp: http_model.NewGetBankInfoResponse(),
  46. }
  47. }