package handler import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "youngee_b_api/consts" "youngee_b_api/middleware" "youngee_b_api/model/http_model" "youngee_b_api/service/selection_service" "youngee_b_api/util" ) func WrapUpdateSelectionHandler(ctx *gin.Context) { handler := newUpdateSelectionHandler(ctx) baseRun(handler) } type UpdateSelection struct { ctx *gin.Context req *http_model.UpdateSelectionRequest resp *http_model.CommonResponse } func (c UpdateSelection) getContext() *gin.Context { return c.ctx } func (c UpdateSelection) getResponse() interface{} { return c.resp } func (c UpdateSelection) getRequest() interface{} { return c.req } func (c UpdateSelection) run() { data := http_model.UpdateSelectionRequest{} data = *c.req auth := middleware.GetSessionAuth(c.ctx) enterpriseID := auth.EnterpriseID res, err := selection_service.Selection.Update(c.ctx, data, enterpriseID) if err != nil { logrus.Errorf("[UpdateSelection] call UpdateSelection err:%+v\n", err) util.HandlerPackErrorResp(c.resp, consts.ErrorInternal, "") logrus.Info("UpdateSelection fail,req:%+v", c.req) return } c.resp.Message = "选品更新成功" c.resp.Data = res } func (c UpdateSelection) checkParam() error { return nil } func newUpdateSelectionHandler(ctx *gin.Context) *UpdateSelection { return &UpdateSelection{ ctx: ctx, req: http_model.NewUpdateSelectionRequest(), resp: http_model.NewUpdateSelectionResponse(), } }