| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- package com.aijiuyi.admin.controller;
- import com.aijiuyi.admin.common.annotation.Log;
- import com.aijiuyi.admin.common.entity.Result;
- import com.aijiuyi.admin.common.enums.OperationType;
- import com.aijiuyi.admin.controller.dto.PlanQueryDTO;
- import com.aijiuyi.admin.controller.dto.PlanSaveDTO;
- import com.aijiuyi.admin.entity.Plan;
- import com.aijiuyi.admin.service.PlanService;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import javax.validation.Valid;
- import java.util.List;
- /**
- * 方案管理 Controller
- * 提供方案的新增、编辑、发布、下架、删除等接口
- */
- @RestController
- @RequestMapping("/plan")
- public class PlanController {
- @Autowired
- private PlanService planService;
- /**
- * 分页查询方案列表
- *
- * @param queryDTO 查询条件
- * @return 分页结果
- */
- @GetMapping("/page")
- @Log(value = "查询方案列表", module = "方案管理", operationType = OperationType.QUERY)
- public Result<IPage<Plan>> page(PlanQueryDTO queryDTO) {
- return Result.success(planService.pageList(queryDTO));
- }
- /**
- * 获取已有创作人列表(用于筛选下拉框)
- *
- * @return 创作人名称列表
- */
- @GetMapping("/authors")
- @Log(value = "查询方案创作人列表", module = "方案管理", operationType = OperationType.QUERY)
- public Result<List<String>> listAuthors() {
- return Result.success(planService.listAuthors());
- }
- /**
- * 查询方案详情(含步骤列表)
- *
- * @param id 方案ID
- * @return 方案详情
- */
- @GetMapping("/{id}")
- @Log(value = "查询方案详情", module = "方案管理", operationType = OperationType.QUERY)
- public Result<PlanSaveDTO> getById(@PathVariable Long id) {
- return Result.success(planService.getDetail(id));
- }
- /**
- * 新增方案(可保存草稿或直接发布)
- *
- * @param dto 方案信息(含步骤)
- * @return 新增方案ID
- */
- @PostMapping
- @Log(value = "新增方案", module = "方案管理", operationType = OperationType.INSERT)
- public Result<Long> add(@RequestBody @Valid PlanSaveDTO dto) {
- return Result.success(planService.addPlan(dto));
- }
- /**
- * 修改方案信息(含步骤)
- *
- * @param dto 方案信息(含步骤)
- * @return 操作结果
- */
- @PutMapping
- @Log(value = "修改方案信息", module = "方案管理", operationType = OperationType.UPDATE)
- public Result<Void> update(@RequestBody @Valid PlanSaveDTO dto) {
- planService.updatePlan(dto);
- return Result.success();
- }
- /**
- * 删除方案(逻辑删除,草稿或已下架可删)
- *
- * @param id 方案ID
- * @return 操作结果
- */
- @DeleteMapping("/{id}")
- @Log(value = "删除方案", module = "方案管理", operationType = OperationType.DELETE)
- public Result<Void> delete(@PathVariable Long id) {
- planService.deletePlan(id);
- return Result.success();
- }
- /**
- * 批量删除方案(草稿或已下架可删,需二次确认)
- *
- * @param ids 方案ID列表
- * @return 操作结果
- */
- @DeleteMapping("/batch")
- @Log(value = "批量删除方案", module = "方案管理", operationType = OperationType.DELETE)
- public Result<Void> batchDelete(@RequestBody List<Long> ids) {
- planService.batchDeletePlan(ids);
- return Result.success();
- }
- /**
- * 发布方案(草稿 → 已发布)
- *
- * @param id 方案ID
- * @return 操作结果
- */
- @PutMapping("/{id}/publish")
- @Log(value = "发布方案", module = "方案管理", operationType = OperationType.UPDATE)
- public Result<Void> publish(@PathVariable Long id) {
- planService.publishPlan(id);
- return Result.success();
- }
- /**
- * 批量发布方案
- *
- * @param ids 方案ID列表
- * @return 操作结果
- */
- @PutMapping("/batch/publish")
- @Log(value = "批量发布方案", module = "方案管理", operationType = OperationType.UPDATE)
- public Result<Void> batchPublish(@RequestBody List<Long> ids) {
- planService.batchPublishPlan(ids);
- return Result.success();
- }
- /**
- * 下架方案(已发布 → 已下架)
- *
- * @param id 方案ID
- * @return 操作结果
- */
- @PutMapping("/{id}/offshelf")
- @Log(value = "下架方案", module = "方案管理", operationType = OperationType.UPDATE)
- public Result<Void> offshelf(@PathVariable Long id) {
- planService.offshelfPlan(id);
- return Result.success();
- }
- /**
- * 批量下架方案
- *
- * @param ids 方案ID列表
- * @return 操作结果
- */
- @PutMapping("/batch/offshelf")
- @Log(value = "批量下架方案", module = "方案管理", operationType = OperationType.UPDATE)
- public Result<Void> batchOffshelf(@RequestBody List<Long> ids) {
- planService.batchOffshelfPlan(ids);
- return Result.success();
- }
- }
|