data_opinion.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package handler
  2. import (
  3. "youngee_b_api/consts"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. "youngee_b_api/util"
  7. "github.com/gin-gonic/gin"
  8. "github.com/sirupsen/logrus"
  9. log "github.com/sirupsen/logrus"
  10. )
  11. func WrapDataOpinionHandler(ctx *gin.Context) {
  12. handler := newDataOpinionHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newDataOpinionHandler(ctx *gin.Context) *DataOpinionHandler {
  16. return &DataOpinionHandler{
  17. req: http_model.NewDataOpinionRequest(),
  18. resp: http_model.NewDataOpinionResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type DataOpinionHandler struct {
  23. req *http_model.DataOpinionRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *DataOpinionHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *DataOpinionHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *DataOpinionHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *DataOpinionHandler) run() {
  37. data := http_model.DataOpinionRequest{}
  38. data = *h.req
  39. res, err := service.Data.DataOpinion(h.ctx, data)
  40. if err != nil {
  41. logrus.Errorf("[DataOpinionHandler] call Create err:%+v\n", err)
  42. util.HandlerPackErrorResp(h.resp, consts.ErrorParamCheck, "")
  43. log.Info("CreateProject fail,req:%+v", h.req)
  44. return
  45. }
  46. h.resp.Message = "提交数据审核修改意见成功"
  47. h.resp.Data = res
  48. h.resp.Status = consts.ErrorSuccess
  49. }
  50. /*
  51. **
  52. func (h *DataOpinionHandler) run() {
  53. data := http_model.DataOpinionRequest{}
  54. data = *h.req
  55. isRefuse := data.IsRefuse
  56. if isRefuse== 0 {
  57. fmt.Println("Create in")
  58. res, err := service.Project.Create(h.ctx, data)
  59. if err != nil {
  60. logrus.Errorf("[DataOpinionHandler] call Create err:%+v\n", err)
  61. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  62. log.Info("CreateProject fail,req:%+v", h.req)
  63. return
  64. }
  65. h.resp.Message = "成功添加修改意见"
  66. h.resp.Data = res
  67. } else {
  68. res, err := service.Logistics.Update(h.ctx, data)
  69. if err != nil {
  70. logrus.Errorf("[DataOpinionHandler] call Create err:%+v\n", err)
  71. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  72. log.Info("CreateProject fail,req:%+v", h.req)
  73. return
  74. }
  75. h.resp.Message = "成功修改物流信息"
  76. h.resp.Data = res
  77. }
  78. }
  79. **
  80. */
  81. func (h *DataOpinionHandler) checkParam() error {
  82. return nil
  83. }