PassproTaskCoop.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/model/http_model"
  7. "youngee_b_api/service"
  8. "youngee_b_api/util"
  9. )
  10. func WrapPassproTaskCoopHandler(ctx *gin.Context) {
  11. handler := newPassproTaskCoopHandler(ctx)
  12. baseRun(handler)
  13. }
  14. type PassproTaskCoop struct {
  15. ctx *gin.Context
  16. req *http_model.PassproTaskCoopRequest
  17. resp *http_model.CommonResponse
  18. }
  19. func (c PassproTaskCoop) getContext() *gin.Context {
  20. return c.ctx
  21. }
  22. func (c PassproTaskCoop) getResponse() interface{} {
  23. return c.resp
  24. }
  25. func (c PassproTaskCoop) getRequest() interface{} {
  26. return c.req
  27. }
  28. func (c PassproTaskCoop) run() {
  29. data := http_model.PassproTaskCoopRequest{}
  30. data = *c.req
  31. //auth := middleware.GetSessionAuth(c.ctx)
  32. //enterpriseID := auth.EnterpriseID
  33. res, err := service.Task.PassCoop(c.ctx, data)
  34. if err != nil {
  35. logrus.Errorf("[PassproTaskCoop] call PassproTaskCoop err:%+v\n", err)
  36. util.HandlerPackErrorResp(c.resp, consts.ErrorParamCheck, "")
  37. logrus.Info("PassproTaskCoop fail,req:%+v", c.req)
  38. return
  39. }
  40. c.resp.Message = "成功合作种草任务"
  41. c.resp.Data = res
  42. c.resp.Status = consts.ErrorSuccess
  43. }
  44. func (c PassproTaskCoop) checkParam() error {
  45. return nil
  46. }
  47. func newPassproTaskCoopHandler(ctx *gin.Context) *PassproTaskCoop {
  48. return &PassproTaskCoop{
  49. ctx: ctx,
  50. req: http_model.NewPassproTaskCoopRequest(),
  51. resp: http_model.NewPassproTaskCoopResponse(),
  52. }
  53. }