selection_update.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package handler
  2. import (
  3. "fmt"
  4. "youngee_m_api/consts"
  5. "youngee_m_api/model/http_model"
  6. "youngee_m_api/service"
  7. "youngee_m_api/util"
  8. "github.com/gin-gonic/gin"
  9. "github.com/sirupsen/logrus"
  10. )
  11. func WrapUpdateSelectionHandler(ctx *gin.Context) {
  12. handler := newUpdateSelectionHandler(ctx)
  13. BaseRun(handler)
  14. }
  15. type UpdateSelection struct {
  16. ctx *gin.Context
  17. req *http_model.UpdateSelectionRequest
  18. resp *http_model.CommonResponse
  19. }
  20. func (c UpdateSelection) getContext() *gin.Context {
  21. return c.ctx
  22. }
  23. func (c UpdateSelection) getResponse() interface{} {
  24. return c.resp
  25. }
  26. func (c UpdateSelection) getRequest() interface{} {
  27. return c.req
  28. }
  29. func (c UpdateSelection) run() {
  30. data := http_model.UpdateSelectionRequest{}
  31. data = *c.req
  32. fmt.Print("data: awdawwa", data)
  33. res, err := service.Selection.Update(c.ctx, data, data.EnterpriseId)
  34. if err != nil {
  35. logrus.Errorf("[UpdateSelection] call UpdateSelection err:%+v\n", err)
  36. util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
  37. logrus.Info("UpdateSelection fail,req:%+v", c.req)
  38. return
  39. }
  40. c.resp.Message = "更新带货任务成功"
  41. c.resp.Data = res
  42. }
  43. func (c UpdateSelection) checkParam() error {
  44. return nil
  45. }
  46. func newUpdateSelectionHandler(ctx *gin.Context) *UpdateSelection {
  47. return &UpdateSelection{
  48. ctx: ctx,
  49. req: http_model.NewUpdateSelectionRequest(),
  50. resp: http_model.NewUpdateSelectionResponse(),
  51. }
  52. }