人生轨迹功能模块补充
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
package com.emotion.controller;
|
||||
|
||||
import com.emotion.common.PageResult;
|
||||
import com.emotion.common.Result;
|
||||
import com.emotion.dto.request.EpicScriptCreateRequest;
|
||||
import com.emotion.dto.request.EpicScriptPageRequest;
|
||||
import com.emotion.dto.request.EpicScriptUpdateRequest;
|
||||
import com.emotion.dto.response.EpicScriptResponse;
|
||||
import com.emotion.service.EpicScriptService;
|
||||
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("/epicScript")
|
||||
public class EpicScriptController {
|
||||
|
||||
@Autowired
|
||||
private EpicScriptService epicScriptService;
|
||||
|
||||
/**
|
||||
* 分页查询当前用户的爽文剧本
|
||||
*/
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<EpicScriptResponse>> getPage(@Validated EpicScriptPageRequest request) {
|
||||
PageResult<EpicScriptResponse> pageResult = epicScriptService.getPageByCurrentUser(request);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的所有爽文剧本列表
|
||||
*/
|
||||
@GetMapping(value = "/listAll")
|
||||
public Result<List<EpicScriptResponse>> getList() {
|
||||
List<EpicScriptResponse> scripts = epicScriptService.getListByCurrentUser();
|
||||
return Result.success(scripts);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取爽文剧本详情
|
||||
*/
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<EpicScriptResponse> getById(@RequestParam String id) {
|
||||
EpicScriptResponse script = epicScriptService.getScriptById(id);
|
||||
if (script == null) {
|
||||
return Result.notFound("爽文剧本不存在");
|
||||
}
|
||||
return Result.success(script);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建爽文剧本
|
||||
*/
|
||||
@PostMapping(value = "/create")
|
||||
public Result<EpicScriptResponse> create(@Valid @RequestBody EpicScriptCreateRequest request) {
|
||||
EpicScriptResponse script = epicScriptService.createScript(request);
|
||||
if (script == null) {
|
||||
return Result.error("创建失败");
|
||||
}
|
||||
return Result.success(script);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新爽文剧本
|
||||
*/
|
||||
@PutMapping(value = "/update")
|
||||
public Result<EpicScriptResponse> update(@Valid @RequestBody EpicScriptUpdateRequest request) {
|
||||
EpicScriptResponse script = epicScriptService.updateScript(request);
|
||||
if (script == null) {
|
||||
return Result.error("更新失败");
|
||||
}
|
||||
return Result.success(script);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中剧本(取消其他选中状态)
|
||||
*/
|
||||
@PutMapping(value = "/select")
|
||||
public Result<EpicScriptResponse> select(@RequestParam String id) {
|
||||
EpicScriptResponse script = epicScriptService.selectScript(id);
|
||||
if (script == null) {
|
||||
return Result.error("选中失败");
|
||||
}
|
||||
return Result.success(script);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除爽文剧本
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
boolean deleted = epicScriptService.deleteScript(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.emotion.controller;
|
||||
|
||||
import com.emotion.common.PageResult;
|
||||
import com.emotion.common.Result;
|
||||
import com.emotion.dto.request.LifeEventCreateRequest;
|
||||
import com.emotion.dto.request.LifeEventPageRequest;
|
||||
import com.emotion.dto.request.LifeEventUpdateRequest;
|
||||
import com.emotion.dto.response.LifeEventResponse;
|
||||
import com.emotion.service.LifeEventService;
|
||||
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("/lifeEvent")
|
||||
public class LifeEventController {
|
||||
|
||||
@Autowired
|
||||
private LifeEventService lifeEventService;
|
||||
|
||||
/**
|
||||
* 分页查询当前用户的生命事件
|
||||
*/
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<LifeEventResponse>> getPage(@Validated LifeEventPageRequest request) {
|
||||
PageResult<LifeEventResponse> pageResult = lifeEventService.getPageByCurrentUser(request);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的所有生命事件列表
|
||||
*/
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<LifeEventResponse>> getList() {
|
||||
List<LifeEventResponse> events = lifeEventService.getListByCurrentUser();
|
||||
return Result.success(events);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取生命事件详情
|
||||
*/
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<LifeEventResponse> getById(@RequestParam String id) {
|
||||
LifeEventResponse event = lifeEventService.getEventById(id);
|
||||
if (event == null) {
|
||||
return Result.notFound("生命事件不存在");
|
||||
}
|
||||
return Result.success(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建生命事件
|
||||
*/
|
||||
@PostMapping(value = "/create")
|
||||
public Result<LifeEventResponse> create(@Valid @RequestBody LifeEventCreateRequest request) {
|
||||
LifeEventResponse event = lifeEventService.createEvent(request);
|
||||
if (event == null) {
|
||||
return Result.error("创建失败");
|
||||
}
|
||||
return Result.success(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新生命事件
|
||||
*/
|
||||
@PutMapping(value = "/update")
|
||||
public Result<LifeEventResponse> update(@Valid @RequestBody LifeEventUpdateRequest request) {
|
||||
LifeEventResponse event = lifeEventService.updateEvent(request);
|
||||
if (event == null) {
|
||||
return Result.error("更新失败");
|
||||
}
|
||||
return Result.success(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除生命事件
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
boolean deleted = lifeEventService.deleteEvent(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
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 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")
|
||||
public class LifePathController {
|
||||
|
||||
@Autowired
|
||||
private LifePathService lifePathService;
|
||||
|
||||
/**
|
||||
* 分页查询当前用户的实现路径
|
||||
*/
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<LifePathResponse>> getPage(@Validated LifePathPageRequest request) {
|
||||
PageResult<LifePathResponse> pageResult = lifePathService.getPageByCurrentUser(request);
|
||||
return Result.success(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户的所有实现路径列表
|
||||
*/
|
||||
@GetMapping(value = "/listAll")
|
||||
public Result<List<LifePathResponse>> getList() {
|
||||
List<LifePathResponse> paths = lifePathService.getListByCurrentUser();
|
||||
return Result.success(paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据剧本ID获取实现路径
|
||||
*/
|
||||
@GetMapping(value = "/byScript")
|
||||
public Result<LifePathResponse> getByScriptId(@RequestParam String scriptId) {
|
||||
LifePathResponse path = lifePathService.getByScriptId(scriptId);
|
||||
if (path == null) {
|
||||
return Result.notFound("实现路径不存在");
|
||||
}
|
||||
return Result.success(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取实现路径详情
|
||||
*/
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<LifePathResponse> getById(@RequestParam String id) {
|
||||
LifePathResponse path = lifePathService.getPathById(id);
|
||||
if (path == null) {
|
||||
return Result.notFound("实现路径不存在");
|
||||
}
|
||||
return Result.success(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建实现路径
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新实现路径
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除实现路径
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
boolean deleted = lifePathService.deletePath(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user