accept_sketch.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 WrapAcceptSketchHandler(ctx *gin.Context) {
  12. handler := newAcceptSketchHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newAcceptSketchHandler(ctx *gin.Context) *AcceptSketchHandler {
  16. return &AcceptSketchHandler{
  17. req: http_model.NewAcceptSketchRequest(),
  18. resp: http_model.NewAcceptSketchResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type AcceptSketchHandler struct {
  23. req *http_model.AcceptSketchRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *AcceptSketchHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *AcceptSketchHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *AcceptSketchHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *AcceptSketchHandler) run() {
  37. data := http_model.AcceptSketchRequest{}
  38. data = *h.req
  39. res, err := service.Sketch.AcceptSketch(h.ctx, data)
  40. if err != nil {
  41. logrus.Errorf("[ReviseOpinionHandler] 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 *AcceptSketchHandler) run() {
  53. data := http_model.AcceptSketchRequest{}
  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("[AcceptSketchHandler] 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("[AcceptSketchHandler] 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 *AcceptSketchHandler) checkParam() error {
  82. return nil
  83. }