| | |
| | | return |
| | | } |
| | | |
| | | plan.Id = params.Id |
| | | |
| | | errCode = planService.UpdatePlan(&plan) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | |
| | | ctx.Ok() |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags Plan |
| | | // @Summary 获取计划列表 |
| | | // @Produce application/json |
| | | // @Success 200 {object} contextx.Response{data=response.PlanResponse} |
| | | // @Router /api/plan/list [get] |
| | | func (s *PlanApi) List(c *gin.Context) { |
| | | ctx, ok := contextx.NewContext(c, nil) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | list, errCode := planService.GetPlanList() |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.PlanResponse{ |
| | | List: list, |
| | | }) |
| | | } |
| | | |
| | | func checkPlanParams(plan request.Plan) (errCode int, p model.Plan) { |
| | | if plan.Number == "" { |
| | | return ecode.InvalidParams, p |
| | | } |
| | | |
| | | if plan.MemberId == 0 { |
| | | return ecode.InvalidParams, p |
| | | } |
| | | //if plan.Number == "" { |
| | | // return ecode.InvalidParams, p |
| | | //} |
| | | // |
| | | //if plan.MemberId == 0 { |
| | | // return ecode.InvalidParams, p |
| | | //} |
| | | |
| | | t, err := checkTimeFormat(plan.StartTime) |
| | | if err != nil { |
| | |
| | | |
| | | return ecode.OK, p |
| | | } |
| | | |
| | | // List |
| | | // |
| | | // @Tags Plan |
| | | // @Summary 生成计划列表 |
| | | // @Produce application/json |
| | | // @Param object body request.GetPlanList true "参数" |
| | | // @Success 200 {object} contextx.Response{data=response.PlanResponse} |
| | | // @Router /api/plan/list [post] |
| | | func (con *PlanApi) List(c *gin.Context) { |
| | | var params request.GetPlanList |
| | | ctx, ok := contextx.NewContext(c, ¶ms) |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | plans, total, errCode := planService.GetPlanList(params.Page, params.PageSize, params.Keyword) |
| | | if errCode != ecode.OK { |
| | | ctx.Fail(errCode) |
| | | return |
| | | } |
| | | |
| | | ctx.OkWithDetailed(response.PlanResponse{ |
| | | List: plans, |
| | | Count: int(total), |
| | | }) |
| | | } |