script_opinion.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 WrapScriptOpinionHandler(ctx *gin.Context) {
  12. handler := newScriptOpinionHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newScriptOpinionHandler(ctx *gin.Context) *ScriptOpinionHandler {
  16. return &ScriptOpinionHandler{
  17. req: http_model.NewScriptOpinionRequest(),
  18. resp: http_model.NewScriptOpinionResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type ScriptOpinionHandler struct {
  23. req *http_model.ScriptOpinionRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *ScriptOpinionHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *ScriptOpinionHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *ScriptOpinionHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *ScriptOpinionHandler) run() {
  37. data := http_model.ScriptOpinionRequest{}
  38. data = *h.req
  39. res, err := service.Script.ScriptOpinion(h.ctx, data)
  40. if err != nil {
  41. logrus.Errorf("[ScriptOpinionHandler] call Create err:%+v\n", err)
  42. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  43. log.Info("CreateProject fail,req:%+v", h.req)
  44. return
  45. }
  46. h.resp.Message = "提交脚本修改意见成功"
  47. h.resp.Data = res
  48. h.resp.Data = data
  49. }
  50. /***
  51. func (h *ScriptOpinionHandler) run() {
  52. data := http_model.ScriptOpinionRequest{}
  53. data = *h.req
  54. isRefuse := data.IsRefuse
  55. if isRefuse== 0 {
  56. fmt.Println("Create in")
  57. res, err := service.Project.Create(h.ctx, data)
  58. if err != nil {
  59. logrus.Errorf("[ScriptOpinionHandler] call Create err:%+v\n", err)
  60. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  61. log.Info("CreateProject fail,req:%+v", h.req)
  62. return
  63. }
  64. h.resp.Message = "成功添加修改意见"
  65. h.resp.Data = res
  66. } else {
  67. res, err := service.Logistics.Update(h.ctx, data)
  68. if err != nil {
  69. logrus.Errorf("[ScriptOpinionHandler] call Create err:%+v\n", err)
  70. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  71. log.Info("CreateProject fail,req:%+v", h.req)
  72. return
  73. }
  74. h.resp.Message = "成功修改物流信息"
  75. h.resp.Data = res
  76. }
  77. }
  78. ***/
  79. func (h *ScriptOpinionHandler) checkParam() error {
  80. return nil
  81. }