d1a0018d1b
- 39 个 Controller 全部添加 @Tag/@Operation/@Parameter 中文注解(共 278 个 @Operation) - 分 3 批实施:Batch 1 AI+社区(7)、Batch 2 情绪+日记+互动(11)、Batch 3 其他(13) - 已有注解的 8 个 Controller 不重复修改 - 编译验证通过:mvn clean install -DskipTests — BUILD SUCCESS Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
119 lines
4.3 KiB
Java
119 lines
4.3 KiB
Java
package com.emotion.controller;
|
|
|
|
import com.emotion.common.PageResult;
|
|
import com.emotion.common.Result;
|
|
import com.emotion.dto.request.LifePathCreateRequest;
|
|
import com.emotion.dto.request.LifePathPageRequest;
|
|
import com.emotion.dto.request.LifePathUpdateRequest;
|
|
import com.emotion.dto.response.LifePathResponse;
|
|
import com.emotion.service.LifePathService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.validation.Valid;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 实现路径控制器
|
|
*
|
|
* @author huazhongmin
|
|
* @date 2025-12-22
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/lifePath")
|
|
@Tag(name = "实现路径管理", description = "人生剧本实现路径的查询、创建、更新和删除接口")
|
|
public class LifePathController {
|
|
|
|
@Autowired
|
|
private LifePathService lifePathService;
|
|
|
|
/**
|
|
* 分页查询当前用户的实现路径
|
|
*/
|
|
@Operation(summary = "分页查询实现路径", description = "分页查询当前用户的实现路径列表。")
|
|
@GetMapping(value = "/page")
|
|
public Result<PageResult<LifePathResponse>> getPage(@Validated LifePathPageRequest request) {
|
|
PageResult<LifePathResponse> pageResult = lifePathService.getPageByCurrentUser(request);
|
|
return Result.success(pageResult);
|
|
}
|
|
|
|
/**
|
|
* 获取当前用户的所有实现路径列表
|
|
*/
|
|
@Operation(summary = "获取实现路径列表", description = "获取当前用户的所有实现路径列表。")
|
|
@GetMapping(value = "/listAll")
|
|
public Result<List<LifePathResponse>> getList() {
|
|
List<LifePathResponse> paths = lifePathService.getListByCurrentUser();
|
|
return Result.success(paths);
|
|
}
|
|
|
|
/**
|
|
* 根据剧本ID获取实现路径
|
|
*/
|
|
@Operation(summary = "根据剧本ID获取路径", description = "根据剧本 ID 获取对应的实现路径。")
|
|
@GetMapping(value = "/byScript")
|
|
public Result<LifePathResponse> getByScriptId(@Parameter(description = "剧本 ID") @RequestParam String scriptId) {
|
|
LifePathResponse path = lifePathService.getByScriptId(scriptId);
|
|
if (path == null) {
|
|
return Result.notFound("实现路径不存在");
|
|
}
|
|
return Result.success(path);
|
|
}
|
|
|
|
/**
|
|
* 根据ID获取实现路径详情
|
|
*/
|
|
@Operation(summary = "获取路径详情", description = "根据 ID 获取实现路径的详细信息。")
|
|
@GetMapping(value = "/detail")
|
|
public Result<LifePathResponse> getById(@Parameter(description = "路径 ID") @RequestParam String id) {
|
|
LifePathResponse path = lifePathService.getPathById(id);
|
|
if (path == null) {
|
|
return Result.notFound("实现路径不存在");
|
|
}
|
|
return Result.success(path);
|
|
}
|
|
|
|
/**
|
|
* 创建实现路径
|
|
*/
|
|
@Operation(summary = "创建实现路径", description = "创建一条新的实现路径。")
|
|
@PostMapping(value = "/create")
|
|
public Result<LifePathResponse> create(@Valid @RequestBody LifePathCreateRequest request) {
|
|
LifePathResponse path = lifePathService.createPath(request);
|
|
if (path == null) {
|
|
return Result.error("创建失败");
|
|
}
|
|
return Result.success(path);
|
|
}
|
|
|
|
/**
|
|
* 更新实现路径
|
|
*/
|
|
@Operation(summary = "更新实现路径", description = "修改已有实现路径的内容。")
|
|
@PutMapping(value = "/update")
|
|
public Result<LifePathResponse> update(@Valid @RequestBody LifePathUpdateRequest request) {
|
|
LifePathResponse path = lifePathService.updatePath(request);
|
|
if (path == null) {
|
|
return Result.error("更新失败");
|
|
}
|
|
return Result.success(path);
|
|
}
|
|
|
|
/**
|
|
* 删除实现路径
|
|
*/
|
|
@Operation(summary = "删除实现路径", description = "删除指定的实现路径。")
|
|
@DeleteMapping(value = "/delete")
|
|
public Result<Void> delete(@Parameter(description = "路径 ID") @RequestParam String id) {
|
|
boolean deleted = lifePathService.deletePath(id);
|
|
if (!deleted) {
|
|
return Result.error("删除失败");
|
|
}
|
|
return Result.success();
|
|
}
|
|
}
|