package handler import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "youngee_b_api/consts" "youngee_b_api/model/http_model" "youngee_b_api/service" "youngee_b_api/util" ) func WrapLocalChangeTaskStatusHandler(ctx *gin.Context) { handler := newLocalChangeTaskStatusHandler(ctx) baseRun(handler) } func newLocalChangeTaskStatusHandler(ctx *gin.Context) *LocalChangeTaskStatusHandler { return &LocalChangeTaskStatusHandler{ req: http_model.NewLocalChangeSupplierStatusRequst(), resp: http_model.NewLocalChangeSupplierStatusResponse(), ctx: ctx, } } type LocalChangeTaskStatusHandler struct { req *http_model.LocalChangeSupplierStatusRequest resp *http_model.CommonResponse ctx *gin.Context } func (p *LocalChangeTaskStatusHandler) getContext() *gin.Context { return p.ctx } func (p *LocalChangeTaskStatusHandler) getResponse() interface{} { return p.resp } func (p *LocalChangeTaskStatusHandler) getRequest() interface{} { return p.req } func (p *LocalChangeTaskStatusHandler) run() { // 1. 同意或拒绝 err := service.SLocalLife.ChangeTaskSupplierStatus(p.ctx, p.req) if err != nil { logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v\n", err) util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "") logrus.Info("ChangeTaskStatus fail,req:%+v", p.req) p.resp.Message = "状态变更失败" p.resp.Status = 40000 return } // 变更达人和服务商合作次数 if p.req.SupplierStatus == 2 { cooperateErr := service.STCooperate.CreateSTCooperate(p.ctx, p.req.SupplierId, p.req.TaskIds) if cooperateErr != nil { logrus.Errorf("[ChangeTaskStatusHandler] call Create err:%+v", cooperateErr) util.HandlerPackErrorResp(p.resp, consts.ErrorInternal, "") logrus.Info("ChangeTaskStatus fail,req:%+v", p.req) p.resp.Message = "合作次数修改失败" p.resp.Status = 40000 return } } p.resp.Message = "任务状态更换成功" } func (p *LocalChangeTaskStatusHandler) checkParam() error { return nil }