PassSecTaskCoop.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package handler
  2. import (
  3. "fmt"
  4. "github.com/gin-gonic/gin"
  5. "github.com/sirupsen/logrus"
  6. "youngee_m_api/consts"
  7. "youngee_m_api/model/http_model"
  8. "youngee_m_api/service"
  9. "youngee_m_api/util"
  10. )
  11. func WrapPassSecTaskCoopHandler(ctx *gin.Context) {
  12. handler := newPassSecTaskCoopHandler(ctx)
  13. BaseRun(handler)
  14. }
  15. type PassSecTaskCoop struct {
  16. ctx *gin.Context
  17. req *http_model.PassSecTaskCoopRequest
  18. resp *http_model.CommonResponse
  19. }
  20. func (c PassSecTaskCoop) getContext() *gin.Context {
  21. return c.ctx
  22. }
  23. func (c PassSecTaskCoop) getResponse() interface{} {
  24. return c.resp
  25. }
  26. func (c PassSecTaskCoop) getRequest() interface{} {
  27. return c.req
  28. }
  29. func (c PassSecTaskCoop) run() {
  30. data := http_model.PassSecTaskCoopRequest{}
  31. data = *c.req
  32. //println("TaskIds", data.TaskIds)
  33. //auth := middleware.GetSessionAuth(c.ctx)
  34. //enterpriseID := auth.EnterpriseID
  35. res, err := service.SelectionTask.PassCoop(c.ctx, data)
  36. if err != nil {
  37. logrus.Errorf("[PassSecTaskCoop] call PassSecTaskCoop err:%+v\n", err)
  38. util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "")
  39. logrus.Info("PassSecTaskCoop fail,req:%+v", c.req)
  40. return
  41. }
  42. println("开始为每个带货子任务绑定免费领样策略")
  43. err1 := service.SelectionTask.UpdateStrategyId(c.ctx, data.SelectionId)
  44. nerr := service.SelectionTask.UpdateStrategyNumBySelectionId(c.ctx, data.SelectionId)
  45. fmt.Println(nerr, err1)
  46. println("完成为每个带货子任务绑定免费领样策略")
  47. c.resp.Message = "成功合作选品任务"
  48. c.resp.Data = res
  49. }
  50. func (c PassSecTaskCoop) checkParam() error {
  51. return nil
  52. }
  53. func newPassSecTaskCoopHandler(ctx *gin.Context) *PassSecTaskCoop {
  54. return &PassSecTaskCoop{
  55. ctx: ctx,
  56. req: http_model.NewPassSecTaskCoopRequest(),
  57. resp: http_model.NewPassSecTaskCoopResponse(),
  58. }
  59. }