account_income.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 WrapTalentInfoHandler(ctx *gin.Context) {
  11. handler := newTalentInfo(ctx)
  12. BaseRun(handler)
  13. }
  14. func newTalentInfo(ctx *gin.Context) *TalentInfo {
  15. return &TalentInfo{
  16. req: http_model.NewTalentInfoRequest(),
  17. resp: http_model.NewTalentInfoResponse(),
  18. ctx: ctx,
  19. }
  20. }
  21. type TalentInfo struct {
  22. req *http_model.TalentInfoRequest
  23. resp *http_model.CommonResponse
  24. ctx *gin.Context
  25. }
  26. func (a TalentInfo) getContext() *gin.Context {
  27. return a.ctx
  28. }
  29. func (a TalentInfo) getResponse() interface{} {
  30. return a.resp
  31. }
  32. func (a TalentInfo) getRequest() interface{} {
  33. return a.req
  34. }
  35. func (a TalentInfo) run() {
  36. data, err := db.AccountIncome(a.ctx, a.req.TalentId)
  37. if err != nil {
  38. // 数据库查询失败,返回5001
  39. logrus.Errorf("[AccountIncomeHandler] call AccountIncome err:%+v\n", err)
  40. util.HandlerPackErrorResp(a.resp, consts.ErrorInternal, "")
  41. logrus.Info("AccountIncomeHandler fail,req:%+v", a.req)
  42. return
  43. }
  44. a.resp.Data = data
  45. }
  46. func (a TalentInfo) checkParam() error {
  47. return nil
  48. }