feat: 全量 Controller 接口中文注解补全完成
- 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>
This commit is contained in:
@@ -6,6 +6,7 @@ import com.emotion.dto.request.achievement.*;
|
||||
import com.emotion.dto.response.achievement.AchievementResponse;
|
||||
import com.emotion.service.AchievementService;
|
||||
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;
|
||||
@@ -16,7 +17,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 成就控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-09-08
|
||||
*/
|
||||
@@ -43,7 +44,7 @@ public class AchievementController {
|
||||
*/
|
||||
@Operation(summary = "根据ID获取成就", description = "根据ID获取成就详情")
|
||||
@GetMapping("/detail")
|
||||
public Result<AchievementResponse> getById(@RequestParam String id) {
|
||||
public Result<AchievementResponse> getById(@Parameter(description = "成就 ID") @RequestParam String id) {
|
||||
AchievementResponse response = achievementService.getAchievementResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("成就不存在");
|
||||
@@ -82,7 +83,7 @@ public class AchievementController {
|
||||
*/
|
||||
@Operation(summary = "删除成就", description = "删除指定成就")
|
||||
@DeleteMapping("/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "成就 ID") @RequestParam String id) {
|
||||
boolean deleted = achievementService.removeById(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
@@ -95,7 +96,7 @@ public class AchievementController {
|
||||
*/
|
||||
@Operation(summary = "根据分类查询成就", description = "根据分类查询成就列表")
|
||||
@GetMapping("/byCategory")
|
||||
public Result<List<AchievementResponse>> getByCategory(@RequestParam String category) {
|
||||
public Result<List<AchievementResponse>> getByCategory(@Parameter(description = "分类") @RequestParam String category) {
|
||||
List<AchievementResponse> responses = achievementService.getByCategoryWithResponse(category);
|
||||
return Result.success(responses);
|
||||
}
|
||||
@@ -105,7 +106,7 @@ public class AchievementController {
|
||||
*/
|
||||
@Operation(summary = "根据稀有度查询成就", description = "根据稀有度查询成就列表")
|
||||
@GetMapping("/byRarity")
|
||||
public Result<List<AchievementResponse>> getByRarity(@RequestParam String rarity) {
|
||||
public Result<List<AchievementResponse>> getByRarity(@Parameter(description = "稀有度") @RequestParam String rarity) {
|
||||
List<AchievementResponse> responses = achievementService.getByRarityWithResponse(rarity);
|
||||
return Result.success(responses);
|
||||
}
|
||||
@@ -181,8 +182,8 @@ public class AchievementController {
|
||||
*/
|
||||
@Operation(summary = "查询最近解锁的成就", description = "查询最近解锁的成就列表")
|
||||
@GetMapping("/recent")
|
||||
public Result<List<AchievementResponse>> getRecentlyUnlocked(@RequestParam(defaultValue = "10") Integer limit) {
|
||||
public Result<List<AchievementResponse>> getRecentlyUnlocked(@Parameter(description = "排名数量限制") @RequestParam(defaultValue = "10") Integer limit) {
|
||||
List<AchievementResponse> responses = achievementService.getRecentlyUnlockedWithResponse(limit);
|
||||
return Result.success(responses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.emotion.dto.response.GuestUserInfoResponse;
|
||||
import com.emotion.dto.response.ConversationResponse;
|
||||
import com.emotion.service.AiChatService;
|
||||
import com.emotion.util.UserContextUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -31,6 +33,7 @@ import javax.validation.Valid;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/ai")
|
||||
@Tag(name = "AI 聊天", description = "AI 智能对话聊天接口,支持普通聊天、总结、状态查询、访客模式等")
|
||||
public class AiChatController {
|
||||
|
||||
@Autowired
|
||||
@@ -39,6 +42,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 发送聊天消息
|
||||
*/
|
||||
@Operation(summary = "发送 AI 聊天消息", description = "向 AI 发送聊天消息,返回 AI 回复。支持指定会话 ID 和用户 ID。")
|
||||
@PostMapping("/chat")
|
||||
public Result<AiChatResponse> sendChatMessage(@Valid @RequestBody AiChatRequest request) {
|
||||
log.info("收到AI聊天请求: conversationId={}, userId={}, message={}",
|
||||
@@ -52,6 +56,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 生成对话总结
|
||||
*/
|
||||
@Operation(summary = "获取 AI 聊天总结", description = "获取指定会话的 AI 聊天总结,概括对话要点。")
|
||||
@PostMapping("/summary")
|
||||
public Result<AiSummaryResponse> generateSummary(@Valid @RequestBody AiSummaryRequest request) {
|
||||
log.info("收到对话总结请求: conversationId={}, userId={}", request.getConversationId(), request.getUserId());
|
||||
@@ -64,6 +69,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 获取AI服务状态
|
||||
*/
|
||||
@Operation(summary = "获取 AI 状态", description = "获取当前 AI 服务的运行状态信息。")
|
||||
@GetMapping("/status")
|
||||
public Result<AiStatusResponse> getServiceStatus() {
|
||||
log.info("获取AI服务状态");
|
||||
@@ -75,6 +81,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 获取聊天记录统计
|
||||
*/
|
||||
@Operation(summary = "获取聊天统计数据", description = "获取指定时间范围内的聊天统计数据,包括消息数、Token 消耗等。")
|
||||
@GetMapping("/stats")
|
||||
public Result<ChatStatsResponse> getChatStats(@Valid ChatStatsRequest request) {
|
||||
log.info("获取聊天统计: userId={}, conversationId={}", request.getUserId(), request.getConversationId());
|
||||
@@ -86,6 +93,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 访客聊天(不需要登录)
|
||||
*/
|
||||
@Operation(summary = "访客模式聊天", description = "未登录用户通过访客模式与 AI 进行对话,无需 token 认证。")
|
||||
@PostMapping("/guestChat")
|
||||
public Result<GuestChatResponse> guestChat(@Valid @RequestBody GuestChatRequest request,
|
||||
HttpServletRequest httpRequest) {
|
||||
@@ -99,6 +107,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 获取访客用户信息
|
||||
*/
|
||||
@Operation(summary = "获取访客用户信息", description = "根据访客 ID 获取对应的用户信息。")
|
||||
@GetMapping("/guestUserInfo")
|
||||
public Result<GuestUserInfoResponse> getGuestUserInfo(HttpServletRequest request) {
|
||||
String clientIp = UserContextUtils.getClientIpAddress(request);
|
||||
@@ -111,6 +120,7 @@ public class AiChatController {
|
||||
/**
|
||||
* 创建对话
|
||||
*/
|
||||
@Operation(summary = "创建对话会话", description = "为当前用户创建一个新的 AI 对话会话。")
|
||||
@PostMapping("/createConversation")
|
||||
public Result<ConversationResponse> createConversation(@Valid @RequestBody ConversationCreateRequest request,
|
||||
HttpServletRequest httpRequest) {
|
||||
|
||||
@@ -16,6 +16,9 @@ import com.emotion.service.AiProviderService;
|
||||
import com.emotion.service.AiRuntimeService;
|
||||
import com.emotion.service.AiSceneBindingService;
|
||||
import com.emotion.util.UserContextHolder;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -35,6 +38,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/ai")
|
||||
@Tag(name = "AI 路由管理", description = "AI 服务提供商路由管理接口,包括 Provider/Endpoint/Scene 的 CRUD、调用日志、运行时测试和流式测试")
|
||||
public class AiRoutingController {
|
||||
|
||||
private final AiProviderService providerService;
|
||||
@@ -55,63 +59,75 @@ public class AiRoutingController {
|
||||
this.runtimeService = runtimeService;
|
||||
}
|
||||
|
||||
@Operation(summary = "查询 Provider 列表", description = "查询所有可见的 AI Provider 列表。")
|
||||
@GetMapping("/providers")
|
||||
public Result<List<AiProvider>> providers() {
|
||||
return Result.success(providerService.listVisible());
|
||||
}
|
||||
|
||||
@Operation(summary = "创建 Provider", description = "创建一个新的 AI Provider 配置。")
|
||||
@PostMapping("/providers")
|
||||
public Result<AiProvider> createProvider(@RequestBody AiProvider provider) {
|
||||
return Result.success(providerService.saveProvider(provider));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新 Provider", description = "更新已有的 AI Provider 配置。")
|
||||
@PutMapping("/providers")
|
||||
public Result<AiProvider> updateProvider(@RequestBody AiProvider provider) {
|
||||
return Result.success(providerService.updateProvider(provider));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除 Provider", description = "根据 ID 删除指定的 AI Provider 配置。")
|
||||
@DeleteMapping("/providers")
|
||||
public Result<Void> deleteProvider(@RequestParam String id) {
|
||||
public Result<Void> deleteProvider(@Parameter(description = "Provider ID", required = true) @RequestParam String id) {
|
||||
providerService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询 Endpoint 列表", description = "查询所有可见的 AI Endpoint 配置列表。")
|
||||
@GetMapping("/endpoints")
|
||||
public Result<List<AiEndpointConfig>> endpoints() {
|
||||
return Result.success(endpointConfigService.listVisible());
|
||||
}
|
||||
|
||||
@Operation(summary = "获取 Endpoint 测试模板", description = "根据 Endpoint ID 获取对应的测试模板。")
|
||||
@GetMapping("/endpoints/test-template")
|
||||
public Result<AiTestTemplateResponse> endpointTestTemplate(@RequestParam String id) {
|
||||
public Result<AiTestTemplateResponse> endpointTestTemplate(@Parameter(description = "Endpoint ID", required = true) @RequestParam String id) {
|
||||
return Result.success(runtimeService.buildEndpointTestTemplate(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "创建 Endpoint", description = "创建一个新的 AI Endpoint 配置。")
|
||||
@PostMapping("/endpoints")
|
||||
public Result<AiEndpointConfig> createEndpoint(@RequestBody AiEndpointConfig endpoint) {
|
||||
return Result.success(endpointConfigService.saveEndpoint(endpoint));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新 Endpoint", description = "更新已有的 AI Endpoint 配置。")
|
||||
@PutMapping("/endpoints")
|
||||
public Result<AiEndpointConfig> updateEndpoint(@RequestBody AiEndpointConfig endpoint) {
|
||||
return Result.success(endpointConfigService.updateEndpoint(endpoint));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除 Endpoint", description = "根据 ID 删除指定的 AI Endpoint 配置。")
|
||||
@DeleteMapping("/endpoints")
|
||||
public Result<Void> deleteEndpoint(@RequestParam String id) {
|
||||
public Result<Void> deleteEndpoint(@Parameter(description = "Endpoint ID", required = true) @RequestParam String id) {
|
||||
endpointConfigService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询 Scene 列表", description = "查询所有可见的 AI Scene 绑定配置列表。")
|
||||
@GetMapping("/scenes")
|
||||
public Result<List<AiSceneBinding>> scenes() {
|
||||
return Result.success(sceneBindingService.listVisible());
|
||||
}
|
||||
|
||||
@Operation(summary = "获取 Scene 测试模板", description = "根据场景编码获取对应的测试模板。")
|
||||
@GetMapping("/scenes/test-template")
|
||||
public Result<AiTestTemplateResponse> sceneTestTemplate(@RequestParam String sceneCode) {
|
||||
public Result<AiTestTemplateResponse> sceneTestTemplate(@Parameter(description = "场景编码", required = true) @RequestParam String sceneCode) {
|
||||
return Result.success(runtimeService.buildSceneTestTemplate(sceneCode));
|
||||
}
|
||||
|
||||
@Operation(summary = "创建 Scene", description = "创建一个新的 AI Scene 绑定配置。")
|
||||
@PostMapping("/scenes")
|
||||
public Result<AiSceneBinding> createScene(@RequestBody AiSceneBinding scene) {
|
||||
if (scene.getIsEnabled() == null) {
|
||||
@@ -124,29 +140,34 @@ public class AiRoutingController {
|
||||
return Result.success(scene);
|
||||
}
|
||||
|
||||
@Operation(summary = "更新 Scene", description = "更新已有的 AI Scene 绑定配置。")
|
||||
@PutMapping("/scenes")
|
||||
public Result<AiSceneBinding> updateScene(@RequestBody AiSceneBinding scene) {
|
||||
sceneBindingService.updateById(scene);
|
||||
return Result.success(sceneBindingService.getById(scene.getId()));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除 Scene", description = "根据 ID 删除指定的 AI Scene 绑定配置。")
|
||||
@DeleteMapping("/scenes")
|
||||
public Result<Void> deleteScene(@RequestParam String id) {
|
||||
public Result<Void> deleteScene(@Parameter(description = "Scene ID", required = true) @RequestParam String id) {
|
||||
sceneBindingService.removeById(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询调用日志", description = "查询 AI 调用日志列表,支持限制返回数量。")
|
||||
@GetMapping("/call-logs")
|
||||
public Result<List<AiCallLog>> callLogs(@RequestParam(required = false) Integer limit) {
|
||||
public Result<List<AiCallLog>> callLogs(@Parameter(description = "返回数量限制") @RequestParam(required = false) Integer limit) {
|
||||
return Result.success(callLogService.latest(limit));
|
||||
}
|
||||
|
||||
@Operation(summary = "运行时测试", description = "对指定的 AI 配置进行运行时连通性测试,支持同步和流式模式。")
|
||||
@PostMapping("/runtime/test")
|
||||
public Result<AiRuntimeTestResponse> runtimeTest(@RequestBody JSONObject payload) {
|
||||
AiRuntimeRequest request = withCurrentUser(AiRuntimeRequest.fromPayload(payload));
|
||||
return Result.success(runtimeService.test(request));
|
||||
}
|
||||
|
||||
@Operation(summary = "流式运行时测试", description = "对指定的 AI 配置进行流式运行时连通性测试,以 SSE 事件流返回结果。")
|
||||
@PostMapping("/runtime/stream")
|
||||
public SseEmitter runtimeStream(@RequestBody JSONObject payload) {
|
||||
AiRuntimeRequest request = withCurrentUser(AiRuntimeRequest.fromPayload(payload));
|
||||
@@ -162,6 +183,7 @@ public class AiRoutingController {
|
||||
return emitter;
|
||||
}
|
||||
|
||||
@Operation(summary = "Endpoint 运行时测试", description = "对指定的 Endpoint 进行运行时连通性测试。")
|
||||
@PostMapping("/endpoint/test")
|
||||
public Result<AiRuntimeTestResponse> endpointTest(@RequestBody JSONObject payload) {
|
||||
String endpointId = payload.getString("endpointId");
|
||||
@@ -170,6 +192,7 @@ public class AiRoutingController {
|
||||
return Result.success(runtimeService.testEndpoint(endpointId, inputMap));
|
||||
}
|
||||
|
||||
@Operation(summary = "Endpoint 流式测试", description = "对指定的 Endpoint 进行流式运行时测试,以 SSE 事件流返回结果。")
|
||||
@PostMapping("/endpoint/stream")
|
||||
public SseEmitter endpointStream(@RequestBody JSONObject payload) {
|
||||
String endpointId = payload.getString("endpointId");
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.emotion.dto.response.analytics.AnalyticsBatchResponse;
|
||||
import com.emotion.service.AnalyticsService;
|
||||
import com.emotion.util.JwtUtil;
|
||||
import com.emotion.util.UserContextHolder;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -18,6 +20,7 @@ import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/analytics")
|
||||
@Tag(name = "事件分析", description = "前端行为事件上报和分析接口")
|
||||
public class AnalyticsController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -4,6 +4,9 @@ import com.emotion.common.Result;
|
||||
import com.emotion.dto.response.asr.AsrTranscribeResponse;
|
||||
import com.emotion.service.AsrService;
|
||||
import com.emotion.util.UserContextHolder;
|
||||
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.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
@@ -12,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/asr")
|
||||
@Tag(name = "语音识别(ASR)", description = "语音转文字识别接口")
|
||||
public class AsrController {
|
||||
|
||||
private final AsrService asrService;
|
||||
@@ -20,8 +24,9 @@ public class AsrController {
|
||||
this.asrService = asrService;
|
||||
}
|
||||
|
||||
@Operation(summary = "语音转文字", description = "上传音频文件并将其转换为文字内容。")
|
||||
@PostMapping("/transcribe")
|
||||
public Result<AsrTranscribeResponse> transcribe(@RequestPart("file") MultipartFile file) {
|
||||
public Result<AsrTranscribeResponse> transcribe(@Parameter(description = "音频文件") @RequestPart("file") MultipartFile file) {
|
||||
if (UserContextHolder.getCurrentUserId() == null) {
|
||||
return Result.unauthorized();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.emotion.controller;
|
||||
import com.emotion.dto.request.WebSocketRequest;
|
||||
import com.emotion.dto.websocket.ConnectRequest;
|
||||
import com.emotion.service.WebSocketService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
@@ -16,13 +18,14 @@ import java.security.Principal;
|
||||
/**
|
||||
* WebSocket聊天控制器
|
||||
* 使用规范的请求对象封装参数,符合项目开发规则
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-09-08
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@MessageMapping("/chat")
|
||||
@Tag(name = "WebSocket 聊天", description = "基于 WebSocket 的实时 AI 聊天通信接口")
|
||||
public class ChatWebSocketController {
|
||||
|
||||
@Autowired
|
||||
@@ -30,11 +33,12 @@ public class ChatWebSocketController {
|
||||
|
||||
/**
|
||||
* 处理聊天消息
|
||||
*
|
||||
*
|
||||
* @param webSocketRequest WebSocket请求对象
|
||||
* @param headerAccessor 消息头访问器
|
||||
* @param principal 用户主体
|
||||
*/
|
||||
@Operation(summary = "发送聊天消息", description = "向 AI 发送聊天消息,触发流式响应。")
|
||||
@MessageMapping("/send")
|
||||
public void handleChatMessage(@Valid @Payload WebSocketRequest webSocketRequest,
|
||||
SimpMessageHeaderAccessor headerAccessor,
|
||||
@@ -45,11 +49,12 @@ public class ChatWebSocketController {
|
||||
|
||||
/**
|
||||
* 处理用户连接
|
||||
*
|
||||
*
|
||||
* @param connectRequest 连接请求对象
|
||||
* @param headerAccessor 消息头访问器
|
||||
* @param principal 用户主体
|
||||
*/
|
||||
@Operation(summary = "用户连接", description = "处理用户 WebSocket 连接建立。")
|
||||
@MessageMapping("/connect")
|
||||
public void connectUser(@Payload ConnectRequest connectRequest,
|
||||
SimpMessageHeaderAccessor headerAccessor,
|
||||
@@ -60,10 +65,11 @@ public class ChatWebSocketController {
|
||||
|
||||
/**
|
||||
* 处理用户断开连接
|
||||
*
|
||||
*
|
||||
* @param headerAccessor 消息头访问器
|
||||
* @param principal 用户主体
|
||||
*/
|
||||
@Operation(summary = "用户断开连接", description = "处理用户 WebSocket 连接断开。")
|
||||
@MessageMapping("/disconnect")
|
||||
public void disconnectUser(SimpMessageHeaderAccessor headerAccessor, Principal principal) {
|
||||
String sessionId = headerAccessor.getSessionId();
|
||||
@@ -72,10 +78,11 @@ public class ChatWebSocketController {
|
||||
|
||||
/**
|
||||
* 处理心跳消息
|
||||
*
|
||||
*
|
||||
* @param headerAccessor 消息头访问器
|
||||
* @param principal 用户主体
|
||||
*/
|
||||
@Operation(summary = "心跳检测", description = "处理客户端心跳消息,保持 WebSocket 连接活跃。")
|
||||
@MessageMapping("/heartbeat")
|
||||
public void heartbeat(SimpMessageHeaderAccessor headerAccessor, Principal principal) {
|
||||
String sessionId = headerAccessor.getSessionId();
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.emotion.dto.request.comment.CommentPageRequest;
|
||||
import com.emotion.dto.response.comment.CommentResponse;
|
||||
import com.emotion.service.CommentService;
|
||||
import com.emotion.util.UserContextUtils;
|
||||
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.*;
|
||||
@@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/comment")
|
||||
@Tag(name = "评论管理", description = "评论的查询、创建、更新和删除接口")
|
||||
public class CommentController {
|
||||
|
||||
@Autowired
|
||||
@@ -28,6 +32,7 @@ public class CommentController {
|
||||
/**
|
||||
* 分页查询评论
|
||||
*/
|
||||
@Operation(summary = "分页查询评论", description = "根据条件分页查询评论列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<CommentResponse>> getCommentPage(@Validated CommentPageRequest request) {
|
||||
PageResult<CommentResponse> pageResult = commentService.getPage(request);
|
||||
@@ -37,6 +42,7 @@ public class CommentController {
|
||||
/**
|
||||
* 创建评论
|
||||
*/
|
||||
@Operation(summary = "创建评论", description = "对指定目标发表一条新评论。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<CommentResponse> createComment(@RequestBody @Validated CommentCreateRequest request) {
|
||||
// 从上下文中获取当前用户ID,而不是直接使用请求中的用户ID
|
||||
@@ -51,6 +57,7 @@ public class CommentController {
|
||||
/**
|
||||
* 更新评论
|
||||
*/
|
||||
@Operation(summary = "更新评论", description = "修改已有评论的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<CommentResponse> updateComment(@RequestBody @Validated CommentUpdateRequest request) {
|
||||
CommentResponse response = commentService.update(request);
|
||||
@@ -60,8 +67,9 @@ public class CommentController {
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@Operation(summary = "删除评论", description = "删除指定的评论。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> deleteComment(@RequestParam String id) {
|
||||
public Result<Void> deleteComment(@Parameter(description = "评论 ID", required = true) @RequestParam String id) {
|
||||
boolean deleted = commentService.delete(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
@@ -72,8 +80,9 @@ public class CommentController {
|
||||
/**
|
||||
* 根据ID获取评论
|
||||
*/
|
||||
@Operation(summary = "获取评论详情", description = "根据 ID 获取评论的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<CommentResponse> getCommentById(@RequestParam String id) {
|
||||
public Result<CommentResponse> getCommentById(@Parameter(description = "评论 ID", required = true) @RequestParam String id) {
|
||||
CommentResponse response = commentService.getById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("评论不存在");
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.community.CommunityPostUpdateRequest;
|
||||
import com.emotion.dto.request.community.CommunityPostPageRequest;
|
||||
import com.emotion.dto.response.community.CommunityPostResponse;
|
||||
import com.emotion.service.CommunityPostService;
|
||||
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.*;
|
||||
@@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/communityPost")
|
||||
@Tag(name = "社区帖子管理", description = "社区帖子的查询、创建、更新和删除接口")
|
||||
public class CommunityPostController {
|
||||
|
||||
@Autowired
|
||||
@@ -27,6 +31,7 @@ public class CommunityPostController {
|
||||
/**
|
||||
* 分页查询帖子
|
||||
*/
|
||||
@Operation(summary = "分页查询社区帖子", description = "根据条件分页查询社区帖子列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<CommunityPostResponse>> getPage(@Validated CommunityPostPageRequest request) {
|
||||
PageResult<CommunityPostResponse> pageResult = communityPostService.getPage(request);
|
||||
@@ -36,8 +41,9 @@ public class CommunityPostController {
|
||||
/**
|
||||
* 根据ID获取帖子
|
||||
*/
|
||||
@Operation(summary = "获取帖子详情", description = "根据 ID 获取社区帖子的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<CommunityPostResponse> getById(@RequestParam String id) {
|
||||
public Result<CommunityPostResponse> getById(@Parameter(description = "帖子 ID", required = true) @RequestParam String id) {
|
||||
CommunityPostResponse response = communityPostService.getById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("帖子不存在");
|
||||
@@ -48,6 +54,7 @@ public class CommunityPostController {
|
||||
/**
|
||||
* 创建帖子
|
||||
*/
|
||||
@Operation(summary = "创建社区帖子", description = "发布一篇新的社区帖子。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<CommunityPostResponse> create(@RequestBody @Validated CommunityPostCreateRequest request) {
|
||||
CommunityPostResponse response = communityPostService.create(request);
|
||||
@@ -57,6 +64,7 @@ public class CommunityPostController {
|
||||
/**
|
||||
* 更新帖子
|
||||
*/
|
||||
@Operation(summary = "更新社区帖子", description = "修改已有的社区帖子内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<CommunityPostResponse> update(@RequestBody @Validated CommunityPostUpdateRequest request) {
|
||||
CommunityPostResponse response = communityPostService.update(request);
|
||||
@@ -66,8 +74,9 @@ public class CommunityPostController {
|
||||
/**
|
||||
* 删除帖子
|
||||
*/
|
||||
@Operation(summary = "删除社区帖子", description = "删除指定的社区帖子。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "帖子 ID", required = true) @RequestParam String id) {
|
||||
boolean deleted = communityPostService.delete(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.emotion.dto.request.ConversationCreateRequest;
|
||||
import com.emotion.dto.request.ConversationPageRequest;
|
||||
import com.emotion.dto.response.ConversationResponse;
|
||||
import com.emotion.service.ConversationService;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
@@ -15,12 +18,13 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 对话控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/conversation")
|
||||
@Tag(name = "会话管理", description = "AI 对话会话的查询、创建、更新、删除和状态管理接口")
|
||||
public class ConversationController {
|
||||
|
||||
@Autowired
|
||||
@@ -29,6 +33,7 @@ public class ConversationController {
|
||||
/**
|
||||
* 分页查询对话
|
||||
*/
|
||||
@Operation(summary = "分页查询会话", description = "分页查询当前用户的对话会话列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<ConversationResponse>> getPage(@Valid ConversationPageRequest request) {
|
||||
PageResult<ConversationResponse> pageResult = conversationService.getPageWithResponse(request);
|
||||
@@ -38,8 +43,9 @@ public class ConversationController {
|
||||
/**
|
||||
* 根据ID获取对话
|
||||
*/
|
||||
@Operation(summary = "获取会话详情", description = "根据 ID 获取会话的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<ConversationResponse> getById(@RequestParam String id) {
|
||||
public Result<ConversationResponse> getById(@Parameter(description = "会话 ID") @RequestParam String id) {
|
||||
ConversationResponse response = conversationService.getConversationResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("对话不存在");
|
||||
@@ -50,6 +56,7 @@ public class ConversationController {
|
||||
/**
|
||||
* 创建对话
|
||||
*/
|
||||
@Operation(summary = "创建会话", description = "创建一个新的 AI 对话会话。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<ConversationResponse> create(@Valid @RequestBody ConversationCreateRequest request,
|
||||
HttpServletRequest httpRequest) {
|
||||
@@ -60,6 +67,7 @@ public class ConversationController {
|
||||
/**
|
||||
* 更新对话
|
||||
*/
|
||||
@Operation(summary = "更新会话", description = "修改已有会话的标题等属性。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<ConversationResponse> update(@RequestBody ConversationCreateRequest request) {
|
||||
ConversationResponse response = conversationService.updateConversationWithResponse(request);
|
||||
@@ -69,8 +77,9 @@ public class ConversationController {
|
||||
/**
|
||||
* 删除对话
|
||||
*/
|
||||
@Operation(summary = "删除会话", description = "删除指定的对话会话。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "会话 ID") @RequestParam String id) {
|
||||
boolean deleted = conversationService.removeById(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
@@ -81,6 +90,7 @@ public class ConversationController {
|
||||
/**
|
||||
* 获取活跃对话
|
||||
*/
|
||||
@Operation(summary = "获取活跃会话", description = "获取当前用户最近的活跃会话列表。")
|
||||
@GetMapping(value = "/active")
|
||||
public Result<List<ConversationResponse>> getActiveConversations() {
|
||||
List<ConversationResponse> responses = conversationService.getActiveConversationsWithResponse();
|
||||
@@ -90,6 +100,7 @@ public class ConversationController {
|
||||
/**
|
||||
* 获取归档对话
|
||||
*/
|
||||
@Operation(summary = "获取归档会话", description = "获取当前用户已归档的会话列表。")
|
||||
@GetMapping(value = "/archived")
|
||||
public Result<List<ConversationResponse>> getArchivedConversations() {
|
||||
List<ConversationResponse> responses = conversationService.getArchivedConversationsWithResponse();
|
||||
@@ -99,9 +110,10 @@ public class ConversationController {
|
||||
/**
|
||||
* 更新对话状态
|
||||
*/
|
||||
@Operation(summary = "获取会话状态", description = "获取指定会话的当前状态信息。")
|
||||
@PutMapping(value = "/status")
|
||||
public Result<Void> updateConversationStatus(
|
||||
@RequestParam String id,
|
||||
@Parameter(description = "会话 ID") @RequestParam String id,
|
||||
@RequestParam String status) {
|
||||
boolean updated = conversationService.updateConversationStatus(id, status);
|
||||
if (!updated) {
|
||||
@@ -109,4 +121,4 @@ public class ConversationController {
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.coze.CozeApiCallCreateRequest;
|
||||
import com.emotion.dto.request.coze.CozeApiCallUpdateRequest;
|
||||
import com.emotion.dto.response.coze.CozeApiCallResponse;
|
||||
import com.emotion.service.CozeApiCallService;
|
||||
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.*;
|
||||
@@ -21,6 +24,7 @@ import java.math.BigDecimal;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/coze-api-call")
|
||||
@Tag(name = "Coze API 调用记录", description = "Coze API 调用记录的查询、创建、更新和删除接口")
|
||||
public class CozeApiCallController {
|
||||
|
||||
@Autowired
|
||||
@@ -29,6 +33,7 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 分页查询API调用记录
|
||||
*/
|
||||
@Operation(summary = "分页查询调用记录", description = "根据条件分页查询 Coze API 调用记录。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<CozeApiCallResponse>> getCozeApiCallPage(@Validated CozeApiCallPageRequest request) {
|
||||
PageResult<CozeApiCallResponse> pageResult = cozeApiCallService.getPage(request);
|
||||
@@ -38,8 +43,9 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 根据ID获取API调用记录
|
||||
*/
|
||||
@Operation(summary = "获取调用记录详情", description = "根据 ID 获取单条调用记录的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<CozeApiCallResponse> getCozeApiCallById(@RequestParam String id) {
|
||||
public Result<CozeApiCallResponse> getCozeApiCallById(@Parameter(description = "调用记录 ID", required = true) @RequestParam String id) {
|
||||
CozeApiCallResponse response = cozeApiCallService.getById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("API调用记录不存在");
|
||||
@@ -50,6 +56,7 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 创建API调用记录
|
||||
*/
|
||||
@Operation(summary = "创建调用记录", description = "新增一条 Coze API 调用记录。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<CozeApiCallResponse> createCozeApiCall(@RequestBody @Validated CozeApiCallCreateRequest request) {
|
||||
CozeApiCallResponse response = cozeApiCallService.create(request);
|
||||
@@ -59,6 +66,7 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 更新API调用记录
|
||||
*/
|
||||
@Operation(summary = "更新调用记录", description = "更新已有的 Coze API 调用记录。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<CozeApiCallResponse> updateCozeApiCall(@RequestBody @Validated CozeApiCallUpdateRequest request) {
|
||||
CozeApiCallResponse response = cozeApiCallService.update(request);
|
||||
@@ -71,8 +79,9 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 删除API调用记录
|
||||
*/
|
||||
@Operation(summary = "删除调用记录", description = "删除指定的 Coze API 调用记录。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> deleteCozeApiCall(@RequestParam String id) {
|
||||
public Result<Void> deleteCozeApiCall(@Parameter(description = "调用记录 ID", required = true) @RequestParam String id) {
|
||||
boolean deleted = cozeApiCallService.delete(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
@@ -83,8 +92,9 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 统计用户的API调用次数
|
||||
*/
|
||||
@Operation(summary = "按用户统计调用量", description = "统计指定用户在时间范围内的 Coze API 调用次数。")
|
||||
@GetMapping(value = "/countByUser")
|
||||
public Result<Long> countByUserId(@RequestParam String userId) {
|
||||
public Result<Long> countByUserId(@Parameter(description = "用户 ID", required = true) @RequestParam String userId) {
|
||||
Long count = cozeApiCallService.countByUserId(userId);
|
||||
return Result.success(count);
|
||||
}
|
||||
@@ -92,8 +102,9 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 统计Bot的API调用次数
|
||||
*/
|
||||
@Operation(summary = "按 Bot 统计调用量", description = "统计指定 Bot 的 Coze API 调用次数。")
|
||||
@GetMapping(value = "/countByBot")
|
||||
public Result<Long> countByBotId(@RequestParam String botId) {
|
||||
public Result<Long> countByBotId(@Parameter(description = "Bot ID", required = true) @RequestParam String botId) {
|
||||
Long count = cozeApiCallService.countByBotId(botId);
|
||||
return Result.success(count);
|
||||
}
|
||||
@@ -101,6 +112,7 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 统计指定状态的API调用次数
|
||||
*/
|
||||
@Operation(summary = "按状态统计调用量", description = "按调用状态统计 Coze API 调用次数。")
|
||||
@GetMapping(value = "/countByStatus")
|
||||
public Result<Long> countByStatus(@RequestParam String status) {
|
||||
Long count = cozeApiCallService.countByStatus(status);
|
||||
@@ -110,8 +122,9 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 统计用户的Token使用量
|
||||
*/
|
||||
@Operation(summary = "按用户统计 Token 消耗", description = "统计指定用户的 Token 总消耗量。")
|
||||
@GetMapping(value = "/tokensByUser")
|
||||
public Result<Long> sumTokensByUserId(@RequestParam String userId) {
|
||||
public Result<Long> sumTokensByUserId(@Parameter(description = "用户 ID", required = true) @RequestParam String userId) {
|
||||
Long totalTokens = cozeApiCallService.sumTokensByUserId(userId);
|
||||
return Result.success(totalTokens);
|
||||
}
|
||||
@@ -119,8 +132,9 @@ public class CozeApiCallController {
|
||||
/**
|
||||
* 统计用户的API调用费用
|
||||
*/
|
||||
@Operation(summary = "按用户统计费用", description = "统计指定用户的 API 调用总费用。")
|
||||
@GetMapping(value = "/costByUser")
|
||||
public Result<BigDecimal> sumCostByUserId(@RequestParam String userId) {
|
||||
public Result<BigDecimal> sumCostByUserId(@Parameter(description = "用户 ID", required = true) @RequestParam String userId) {
|
||||
BigDecimal totalCost = cozeApiCallService.sumCostByUserId(userId);
|
||||
return Result.success(totalCost);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.emotion.dto.response.DiaryCommentResponse;
|
||||
import com.emotion.service.DiaryCommentService;
|
||||
import com.emotion.service.DiaryPostService;
|
||||
import com.emotion.util.UserContextUtils;
|
||||
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.*;
|
||||
@@ -23,6 +26,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/diaryComment")
|
||||
@Tag(name = "日记评论管理", description = "日记评论的查询、创建、更新、删除、点赞、置顶等接口")
|
||||
public class DiaryCommentController {
|
||||
|
||||
@Autowired
|
||||
@@ -34,6 +38,7 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 分页查询评论
|
||||
*/
|
||||
@Operation(summary = "分页查询评论", description = "分页查询指定日记的评论列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<DiaryCommentResponse>> getPage(@Validated DiaryCommentPageRequest request) {
|
||||
PageResult<DiaryCommentResponse> pageResult = diaryCommentService.getPageWithResponse(request);
|
||||
@@ -43,8 +48,9 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 获取评论树结构
|
||||
*/
|
||||
@Operation(summary = "获取评论树", description = "以树形结构获取日记的评论及其回复列表。")
|
||||
@GetMapping(value = "/commentTree")
|
||||
public Result<List<DiaryCommentResponse>> getCommentTree(@RequestParam String diaryId) {
|
||||
public Result<List<DiaryCommentResponse>> getCommentTree(@Parameter(description = "日记 ID") @RequestParam String diaryId) {
|
||||
List<DiaryCommentResponse> responses = diaryCommentService.getCommentTreeWithResponse(diaryId);
|
||||
return Result.success(responses);
|
||||
}
|
||||
@@ -52,8 +58,9 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 根据ID获取评论详情
|
||||
*/
|
||||
@Operation(summary = "获取评论详情", description = "根据 ID 获取评论详情。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<DiaryCommentResponse> getById(@RequestParam String id) {
|
||||
public Result<DiaryCommentResponse> getById(@Parameter(description = "评论 ID") @RequestParam String id) {
|
||||
DiaryCommentResponse response = diaryCommentService.getCommentResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("评论不存在");
|
||||
@@ -64,6 +71,7 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 创建评论
|
||||
*/
|
||||
@Operation(summary = "创建评论", description = "对指定日记发表一条新评论或回复。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<DiaryCommentResponse> create(@Valid @RequestBody DiaryCommentCreateRequest request) {
|
||||
// 从上下文中获取当前用户ID,而不是直接使用请求中的用户ID
|
||||
@@ -72,17 +80,18 @@ public class DiaryCommentController {
|
||||
request.setUserId(currentUserId);
|
||||
}
|
||||
DiaryCommentResponse response = diaryCommentService.createCommentWithResponse(request);
|
||||
|
||||
|
||||
// 更新日记的评论数
|
||||
diaryPostService.incrementCommentCount(request.getDiaryId());
|
||||
diaryPostService.updateLastCommentTime(request.getDiaryId());
|
||||
|
||||
|
||||
return Result.success(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新评论
|
||||
*/
|
||||
@Operation(summary = "更新评论", description = "修改已有评论的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<DiaryCommentResponse> update(@Valid @RequestBody DiaryCommentCreateRequest request) {
|
||||
DiaryCommentResponse response = diaryCommentService.updateCommentWithResponse(request);
|
||||
@@ -92,65 +101,69 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 删除评论
|
||||
*/
|
||||
@Operation(summary = "删除评论", description = "永久删除指定评论。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "评论 ID") @RequestParam String id) {
|
||||
boolean deleted = diaryCommentService.deleteComment(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
// 更新日记的评论数
|
||||
DiaryCommentResponse response = diaryCommentService.getCommentResponseById(id);
|
||||
if (response != null) {
|
||||
diaryPostService.decrementCommentCount(response.getDiaryId());
|
||||
}
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 软删除评论
|
||||
*/
|
||||
@Operation(summary = "软删除评论", description = "将评论标记为已删除状态。")
|
||||
@DeleteMapping(value = "/softDelete")
|
||||
public Result<Void> softDelete(@RequestParam String id) {
|
||||
public Result<Void> softDelete(@Parameter(description = "评论 ID") @RequestParam String id) {
|
||||
boolean deleted = diaryCommentService.softDeleteComment(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
|
||||
|
||||
// 更新日记的评论数
|
||||
DiaryCommentResponse response = diaryCommentService.getCommentResponseById(id);
|
||||
if (response != null) {
|
||||
diaryPostService.decrementCommentCount(response.getDiaryId());
|
||||
}
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复评论
|
||||
*/
|
||||
@Operation(summary = "恢复评论", description = "恢复已软删除的评论。")
|
||||
@PutMapping(value = "/restore")
|
||||
public Result<Void> restore(@RequestParam String id) {
|
||||
public Result<Void> restore(@Parameter(description = "评论 ID") @RequestParam String id) {
|
||||
boolean restored = diaryCommentService.restoreComment(id);
|
||||
if (!restored) {
|
||||
return Result.error("恢复失败");
|
||||
}
|
||||
|
||||
|
||||
// 更新日记的评论数
|
||||
DiaryCommentResponse response = diaryCommentService.getCommentResponseById(id);
|
||||
if (response != null) {
|
||||
diaryPostService.incrementCommentCount(response.getDiaryId());
|
||||
}
|
||||
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞评论
|
||||
*/
|
||||
@Operation(summary = "点赞评论", description = "对指定评论进行点赞。")
|
||||
@PostMapping(value = "/like")
|
||||
public Result<Void> like(@RequestParam String id) {
|
||||
public Result<Void> like(@Parameter(description = "评论 ID") @RequestParam String id) {
|
||||
boolean liked = diaryCommentService.incrementLikeCount(id);
|
||||
if (!liked) {
|
||||
return Result.error("点赞失败");
|
||||
@@ -161,8 +174,9 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 取消点赞评论
|
||||
*/
|
||||
@Operation(summary = "取消点赞评论", description = "取消对指定评论的点赞。")
|
||||
@DeleteMapping(value = "/unlike")
|
||||
public Result<Void> unlike(@RequestParam String id) {
|
||||
public Result<Void> unlike(@Parameter(description = "评论 ID") @RequestParam String id) {
|
||||
boolean unliked = diaryCommentService.decrementLikeCount(id);
|
||||
if (!unliked) {
|
||||
return Result.error("取消点赞失败");
|
||||
@@ -173,12 +187,13 @@ public class DiaryCommentController {
|
||||
/**
|
||||
* 设置置顶状态
|
||||
*/
|
||||
@Operation(summary = "置顶评论", description = "将指定评论设为置顶显示。")
|
||||
@PutMapping(value = "/setTop")
|
||||
public Result<Void> setTop(@RequestParam String id, @RequestParam Integer isTop) {
|
||||
public Result<Void> setTop(@Parameter(description = "评论 ID") @RequestParam String id, @RequestParam Integer isTop) {
|
||||
boolean set = diaryCommentService.setTop(id, isTop);
|
||||
if (!set) {
|
||||
return Result.error("设置置顶状态失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.emotion.dto.request.DiaryPostUpdateRequest;
|
||||
import com.emotion.dto.response.DiaryPostResponse;
|
||||
import com.emotion.service.DiaryPostService;
|
||||
import com.emotion.util.UserContextUtils;
|
||||
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.*;
|
||||
@@ -22,6 +25,7 @@ import javax.validation.Valid;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/diaryPost")
|
||||
@Tag(name = "日记管理", description = "用户日记帖子的查询、创建、发布、更新、删除、点赞、分享等接口")
|
||||
public class DiaryPostController {
|
||||
|
||||
@Autowired
|
||||
@@ -30,6 +34,7 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 分页查询日记
|
||||
*/
|
||||
@Operation(summary = "分页查询日记", description = "根据条件分页查询当前用户的日记帖子列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<DiaryPostResponse>> getPage(@Validated DiaryPostPageRequest request) {
|
||||
return Result.success(diaryPostService.getPageWithResponse(request));
|
||||
@@ -38,8 +43,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 根据ID获取日记详情
|
||||
*/
|
||||
@Operation(summary = "获取日记详情", description = "根据 ID 获取日记帖子的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<DiaryPostResponse> getById(@RequestParam String id) {
|
||||
public Result<DiaryPostResponse> getById(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
DiaryPostResponse response = diaryPostService.getDiaryPostResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("日记不存在");
|
||||
@@ -50,6 +56,7 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 创建日记
|
||||
*/
|
||||
@Operation(summary = "创建日记", description = "创建一篇新的日记帖子。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<DiaryPostResponse> create(@Valid @RequestBody DiaryPostCreateRequest request) {
|
||||
// 从上下文中获取当前用户ID,而不是直接使用请求中的用户ID
|
||||
@@ -63,6 +70,7 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 发表日记并生成AI评论
|
||||
*/
|
||||
@Operation(summary = "发布日记", description = "将草稿状态的日记帖子发布为正式内容。")
|
||||
@PostMapping(value = "/publish")
|
||||
public Result<DiaryPostResponse> publish(@Valid @RequestBody DiaryPostCreateRequest request) {
|
||||
// 从上下文中获取当前用户ID,而不是直接使用请求中的用户ID
|
||||
@@ -76,6 +84,7 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 更新日记
|
||||
*/
|
||||
@Operation(summary = "更新日记", description = "修改已有日记帖子的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<DiaryPostResponse> update(@Valid @RequestBody DiaryPostUpdateRequest request) {
|
||||
DiaryPostResponse response = diaryPostService.updateDiaryPostWithResponse(request);
|
||||
@@ -88,8 +97,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 删除日记
|
||||
*/
|
||||
@Operation(summary = "删除日记", description = "永久删除指定的日记帖子。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
boolean deleted = diaryPostService.deleteDiaryPost(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
@@ -100,8 +110,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 软删除日记
|
||||
*/
|
||||
@Operation(summary = "软删除日记", description = "将日记帖子标记为已删除状态(可恢复)。")
|
||||
@DeleteMapping(value = "/softDelete")
|
||||
public Result<Void> softDelete(@RequestParam String id) {
|
||||
public Result<Void> softDelete(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
boolean deleted = diaryPostService.softDeleteDiaryPost(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
@@ -112,8 +123,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 恢复日记
|
||||
*/
|
||||
@Operation(summary = "恢复日记", description = "将已软删除的日记帖子恢复为正常状态。")
|
||||
@PutMapping(value = "/restore")
|
||||
public Result<Void> restore(@RequestParam String id) {
|
||||
public Result<Void> restore(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
boolean restored = diaryPostService.restoreDiaryPost(id);
|
||||
if (!restored) {
|
||||
return Result.error("恢复失败");
|
||||
@@ -124,8 +136,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 点赞日记
|
||||
*/
|
||||
@Operation(summary = "点赞日记", description = "对指定日记帖子进行点赞操作。")
|
||||
@PostMapping(value = "/like")
|
||||
public Result<Void> like(@RequestParam String id) {
|
||||
public Result<Void> like(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
boolean liked = diaryPostService.incrementLikeCount(id);
|
||||
if (!liked) {
|
||||
return Result.error("点赞失败");
|
||||
@@ -136,8 +149,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 取消点赞日记
|
||||
*/
|
||||
@Operation(summary = "取消点赞日记", description = "取消对指定日记帖子的点赞。")
|
||||
@DeleteMapping(value = "/unlike")
|
||||
public Result<Void> unlike(@RequestParam String id) {
|
||||
public Result<Void> unlike(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
boolean unliked = diaryPostService.decrementLikeCount(id);
|
||||
if (!unliked) {
|
||||
return Result.error("取消点赞失败");
|
||||
@@ -148,8 +162,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 分享日记
|
||||
*/
|
||||
@Operation(summary = "分享日记", description = "将指定日记帖子分享给其他用户。")
|
||||
@PostMapping(value = "/share")
|
||||
public Result<Void> share(@RequestParam String id) {
|
||||
public Result<Void> share(@Parameter(description = "日记 ID") @RequestParam String id) {
|
||||
boolean shared = diaryPostService.incrementShareCount(id);
|
||||
if (!shared) {
|
||||
return Result.error("分享失败");
|
||||
@@ -160,8 +175,9 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 设置精选状态
|
||||
*/
|
||||
@Operation(summary = "设置精选日记", description = "将指定日记帖子标记为精选内容。")
|
||||
@PutMapping(value = "/setFeatured")
|
||||
public Result<Void> setFeatured(@RequestParam String id, @RequestParam Integer featured) {
|
||||
public Result<Void> setFeatured(@Parameter(description = "日记 ID") @RequestParam String id, @RequestParam Integer featured) {
|
||||
boolean set = diaryPostService.setFeatured(id, featured);
|
||||
if (!set) {
|
||||
return Result.error("设置精选状态失败");
|
||||
@@ -172,12 +188,13 @@ public class DiaryPostController {
|
||||
/**
|
||||
* 设置置顶优先级
|
||||
*/
|
||||
@Operation(summary = "设置日记优先级", description = "修改指定日记帖子的优先级排序。")
|
||||
@PutMapping(value = "/setPriority")
|
||||
public Result<Void> setPriority(@RequestParam String id, @RequestParam Integer priority) {
|
||||
public Result<Void> setPriority(@Parameter(description = "日记 ID") @RequestParam String id, @RequestParam Integer priority) {
|
||||
boolean set = diaryPostService.setPriority(id, priority);
|
||||
if (!set) {
|
||||
return Result.error("设置优先级失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.dictionary.DictionaryUpdateRequest;
|
||||
import com.emotion.dto.response.dictionary.DictionaryResponse;
|
||||
import com.emotion.common.PageResult;
|
||||
import com.emotion.common.Result;
|
||||
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.*;
|
||||
@@ -15,12 +18,13 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典Controller
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-12-22
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dictionary")
|
||||
@Tag(name = "字典管理", description = "数据字典的查询、创建、更新和删除接口")
|
||||
public class DictionaryController {
|
||||
|
||||
@Autowired
|
||||
@@ -28,10 +32,11 @@ public class DictionaryController {
|
||||
|
||||
/**
|
||||
* 创建字典
|
||||
*
|
||||
*
|
||||
* @param request 创建请求
|
||||
* @return 创建结果
|
||||
*/
|
||||
@Operation(summary = "创建字典项", description = "创建一个新的数据字典项。")
|
||||
@PostMapping
|
||||
public Result<DictionaryResponse> createDictionary(@Validated @RequestBody DictionaryCreateRequest request) {
|
||||
return dictionaryService.createDictionary(request);
|
||||
@@ -39,10 +44,11 @@ public class DictionaryController {
|
||||
|
||||
/**
|
||||
* 更新字典
|
||||
*
|
||||
*
|
||||
* @param request 更新请求
|
||||
* @return 更新结果
|
||||
*/
|
||||
@Operation(summary = "更新字典项", description = "修改已有数据字典项的内容。")
|
||||
@PutMapping
|
||||
public Result<DictionaryResponse> updateDictionary(@Validated @RequestBody DictionaryUpdateRequest request) {
|
||||
return dictionaryService.updateDictionary(request);
|
||||
@@ -50,32 +56,35 @@ public class DictionaryController {
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
*
|
||||
*
|
||||
* @param id 字典ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@Operation(summary = "删除字典项", description = "删除指定的数据字典项。")
|
||||
@DeleteMapping("/delete")
|
||||
public Result<Void> deleteDictionary(@RequestParam String id) {
|
||||
public Result<Void> deleteDictionary(@Parameter(description = "字典 ID") @RequestParam String id) {
|
||||
return dictionaryService.deleteDictionary(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典详情
|
||||
*
|
||||
*
|
||||
* @param id 字典ID
|
||||
* @return 字典详情
|
||||
*/
|
||||
@Operation(summary = "获取字典详情", description = "根据 ID 获取字典项的详细信息。")
|
||||
@GetMapping("/detail")
|
||||
public Result<DictionaryResponse> getDictionary(@RequestParam String id) {
|
||||
public Result<DictionaryResponse> getDictionary(@Parameter(description = "字典 ID") @RequestParam String id) {
|
||||
return dictionaryService.getDictionary(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询字典
|
||||
*
|
||||
*
|
||||
* @param request 分页请求
|
||||
* @return 分页结果
|
||||
*/
|
||||
@Operation(summary = "分页查询字典", description = "分页查询数据字典列表。")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<DictionaryResponse>> listDictionaries(DictionaryPageRequest request) {
|
||||
return dictionaryService.listDictionaries(request);
|
||||
@@ -83,23 +92,25 @@ public class DictionaryController {
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典集合
|
||||
*
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典集合
|
||||
*/
|
||||
@Operation(summary = "根据类型查询字典", description = "根据字典类型查询字典集合。")
|
||||
@GetMapping("/byType")
|
||||
public Result<List<DictionaryResponse>> getDictionariesByType(@RequestParam String dictType) {
|
||||
public Result<List<DictionaryResponse>> getDictionariesByType(@Parameter(description = "字典类型") @RequestParam String dictType) {
|
||||
return dictionaryService.getDictionariesByType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询启用的字典集合
|
||||
*
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 启用的字典集合
|
||||
*/
|
||||
@Operation(summary = "查询启用的字典", description = "根据字典类型查询启用的字典集合。")
|
||||
@GetMapping("/enabledByType")
|
||||
public Result<List<DictionaryResponse>> getEnabledDictionariesByType(@RequestParam String dictType) {
|
||||
public Result<List<DictionaryResponse>> getEnabledDictionariesByType(@Parameter(description = "字典类型") @RequestParam String dictType) {
|
||||
return dictionaryService.getEnabledDictionariesByType(dictType);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.EmotionAnalysisPageRequest;
|
||||
import com.emotion.dto.request.EmotionAnalysisUpdateRequest;
|
||||
import com.emotion.dto.response.EmotionAnalysisResponse;
|
||||
import com.emotion.service.EmotionAnalysisService;
|
||||
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.*;
|
||||
@@ -16,12 +19,13 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 情绪分析控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/emotionAnalysis")
|
||||
@Tag(name = "情绪分析管理", description = "情绪分析记录的查询、创建、更新和删除接口")
|
||||
public class EmotionAnalysisController {
|
||||
|
||||
@Autowired
|
||||
@@ -30,6 +34,7 @@ public class EmotionAnalysisController {
|
||||
/**
|
||||
* 分页查询情绪分析记录
|
||||
*/
|
||||
@Operation(summary = "分页查询情绪分析", description = "根据条件分页查询情绪分析记录列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<EmotionAnalysisResponse>> getPage(@Validated EmotionAnalysisPageRequest request) {
|
||||
return Result.success(emotionAnalysisService.getPageWithResponse(request));
|
||||
@@ -38,8 +43,9 @@ public class EmotionAnalysisController {
|
||||
/**
|
||||
* 根据ID获取情绪分析记录
|
||||
*/
|
||||
@Operation(summary = "获取分析详情", description = "根据 ID 获取情绪分析报告的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<EmotionAnalysisResponse> getById(@RequestParam String id) {
|
||||
public Result<EmotionAnalysisResponse> getById(@Parameter(description = "分析 ID") @RequestParam String id) {
|
||||
EmotionAnalysisResponse response = emotionAnalysisService.getEmotionAnalysisResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("情绪分析记录不存在");
|
||||
@@ -50,6 +56,7 @@ public class EmotionAnalysisController {
|
||||
/**
|
||||
* 创建情绪分析记录
|
||||
*/
|
||||
@Operation(summary = "创建情绪分析", description = "基于情绪记录数据创建一条新的 AI 情绪分析报告。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<EmotionAnalysisResponse> create(@RequestBody @Valid EmotionAnalysisCreateRequest request) {
|
||||
return Result.success(emotionAnalysisService.createEmotionAnalysisWithResponse(request));
|
||||
@@ -58,6 +65,7 @@ public class EmotionAnalysisController {
|
||||
/**
|
||||
* 更新情绪分析记录
|
||||
*/
|
||||
@Operation(summary = "更新情绪分析", description = "修改已有情绪分析报告的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<EmotionAnalysisResponse> update(@RequestBody @Valid EmotionAnalysisUpdateRequest request) {
|
||||
EmotionAnalysisResponse response = emotionAnalysisService.updateEmotionAnalysisWithResponse(request);
|
||||
@@ -70,12 +78,13 @@ public class EmotionAnalysisController {
|
||||
/**
|
||||
* 删除情绪分析记录
|
||||
*/
|
||||
@Operation(summary = "删除情绪分析", description = "删除指定的情绪分析记录。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "分析 ID") @RequestParam String id) {
|
||||
boolean deleted = emotionAnalysisService.deleteEmotionAnalysis(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.emotion.dto.request.EmotionRecordUpdateRequest;
|
||||
import com.emotion.dto.response.EmotionRecordResponse;
|
||||
import com.emotion.service.EmotionRecordService;
|
||||
import com.emotion.util.UserContextUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,6 +29,7 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/emotionRecord")
|
||||
@Tag(name = "情绪记录管理", description = "用户情绪记录的查询、创建、更新、删除和统计接口")
|
||||
public class EmotionRecordController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(EmotionRecordController.class);
|
||||
@@ -36,14 +40,15 @@ public class EmotionRecordController {
|
||||
/**
|
||||
* 创建情绪记录
|
||||
*/
|
||||
@Operation(summary = "创建情绪记录", description = "记录用户当天的情绪数据,包括类型、强度、触发因素等。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<EmotionRecordResponse> createRecord(@RequestBody @Valid EmotionRecordCreateRequest request) {
|
||||
log.info("创建情绪记录: userId={}", request.getUserId());
|
||||
|
||||
|
||||
// 从上下文中获取当前用户ID
|
||||
String userId = UserContextUtils.requireCurrentUserId();
|
||||
request.setUserId(userId);
|
||||
|
||||
|
||||
EmotionRecordResponse response = emotionRecordService.createEmotionRecordWithResponse(request);
|
||||
return Result.success("创建成功", response);
|
||||
}
|
||||
@@ -51,6 +56,7 @@ public class EmotionRecordController {
|
||||
/**
|
||||
* 分页查询情绪记录
|
||||
*/
|
||||
@Operation(summary = "分页查询情绪记录", description = "根据日期范围、情绪类型等条件分页查询情绪记录。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<EmotionRecordResponse>> getPage(@Validated EmotionRecordPageRequest request) {
|
||||
// 从上下文中获取当前用户ID
|
||||
@@ -69,10 +75,11 @@ public class EmotionRecordController {
|
||||
/**
|
||||
* 获取情绪记录详情
|
||||
*/
|
||||
@Operation(summary = "获取记录详情", description = "根据 ID 获取情绪记录的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<EmotionRecordResponse> getRecord(@RequestParam String id) {
|
||||
public Result<EmotionRecordResponse> getRecord(@Parameter(description = "记录 ID") @RequestParam String id) {
|
||||
log.info("获取情绪记录详情: {}", id);
|
||||
|
||||
|
||||
EmotionRecordResponse response = emotionRecordService.getEmotionRecordResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("情绪记录不存在");
|
||||
@@ -83,10 +90,11 @@ public class EmotionRecordController {
|
||||
/**
|
||||
* 更新情绪记录
|
||||
*/
|
||||
@Operation(summary = "更新情绪记录", description = "修改已有情绪记录的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<EmotionRecordResponse> updateRecord(@RequestBody @Valid EmotionRecordUpdateRequest request) {
|
||||
log.info("更新情绪记录: {}", request.getId());
|
||||
|
||||
|
||||
EmotionRecordResponse response = emotionRecordService.updateEmotionRecordWithResponse(request);
|
||||
if (response == null) {
|
||||
return Result.notFound("情绪记录不存在");
|
||||
@@ -97,10 +105,11 @@ public class EmotionRecordController {
|
||||
/**
|
||||
* 删除情绪记录
|
||||
*/
|
||||
@Operation(summary = "删除情绪记录", description = "删除指定的情绪记录。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> deleteRecord(@RequestParam String id) {
|
||||
public Result<String> deleteRecord(@Parameter(description = "记录 ID") @RequestParam String id) {
|
||||
log.info("删除情绪记录: {}", id);
|
||||
|
||||
|
||||
boolean deleted = emotionRecordService.deleteEmotionRecord(id);
|
||||
if (!deleted) {
|
||||
return Result.notFound("情绪记录不存在");
|
||||
@@ -111,18 +120,19 @@ public class EmotionRecordController {
|
||||
/**
|
||||
* 获取情绪统计
|
||||
*/
|
||||
@Operation(summary = "获取情绪统计", description = "统计指定时间范围内的情绪数据分布。")
|
||||
@GetMapping(value = "/stats")
|
||||
public Result<Map<String, Object>> getEmotionStats(
|
||||
@RequestParam(required = false) String startDate,
|
||||
@RequestParam(required = false) String endDate) {
|
||||
|
||||
|
||||
// 从上下文中获取当前用户ID
|
||||
String userId = UserContextUtils.requireCurrentUserId();
|
||||
|
||||
|
||||
log.info("获取情绪统计: userId={}, startDate={}, endDate={}", userId, startDate, endDate);
|
||||
|
||||
|
||||
Map<String, Object> stats = emotionRecordService.getEmotionStats(userId, startDate, endDate);
|
||||
|
||||
|
||||
return Result.success(stats);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EmotionSummaryController {
|
||||
/**
|
||||
* 生成用户当天的情绪记录总结
|
||||
*/
|
||||
@Operation(summary = "生成用户当天的情绪记录总结", description = "基于用户当天的聊天记录生成情绪分析和记录")
|
||||
@Operation(summary = "生成情绪总结", description = "基于指定时间范围的情绪记录数据,生成 AI 情绪总结报告。")
|
||||
@PostMapping(value = "/generate")
|
||||
public Result<EmotionSummaryGenerateResponse> generateEmotionSummary(
|
||||
@RequestBody @Valid EmotionSummaryGenerateRequest request) {
|
||||
@@ -56,7 +56,7 @@ public class EmotionSummaryController {
|
||||
/**
|
||||
* 获取用户情绪记录总结状态
|
||||
*/
|
||||
@Operation(summary = "获取用户情绪记录总结状态", description = "检查用户今天是否已经生成过情绪记录")
|
||||
@Operation(summary = "查询总结状态", description = "查询指定时间段内是否已生成情绪总结及其状态。")
|
||||
@GetMapping(value = "/status")
|
||||
public Result<EmotionSummaryStatusResponse> getEmotionSummaryStatus(
|
||||
@Validated EmotionSummaryStatusRequest request) {
|
||||
@@ -69,4 +69,4 @@ public class EmotionSummaryController {
|
||||
|
||||
return Result.success(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ import com.emotion.dto.response.EpicScriptInspirationResponse;
|
||||
import com.emotion.dto.response.EpicScriptResponse;
|
||||
import com.emotion.dto.response.InspirationSuggestionResponse;
|
||||
import com.emotion.service.EpicScriptService;
|
||||
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.*;
|
||||
@@ -25,6 +28,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/epicScript")
|
||||
@Tag(name = "爽文剧本管理", description = "爽文剧本的查询、创建、更新、删除和灵感推荐接口")
|
||||
public class EpicScriptController {
|
||||
|
||||
@Autowired
|
||||
@@ -33,6 +37,7 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 分页查询当前用户的爽文剧本
|
||||
*/
|
||||
@Operation(summary = "分页查询爽文剧本", description = "分页查询当前用户的爽文剧本列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<EpicScriptResponse>> getPage(@Validated EpicScriptPageRequest request) {
|
||||
PageResult<EpicScriptResponse> pageResult = epicScriptService.getPageByCurrentUser(request);
|
||||
@@ -42,23 +47,27 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 获取当前用户的所有爽文剧本列表
|
||||
*/
|
||||
@Operation(summary = "获取爽文剧本列表", description = "获取当前用户的所有爽文剧本列表。")
|
||||
@GetMapping(value = "/listAll")
|
||||
public Result<List<EpicScriptResponse>> getList() {
|
||||
List<EpicScriptResponse> scripts = epicScriptService.getListByCurrentUser();
|
||||
return Result.success(scripts);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取灵感推荐", description = "获取系统推荐的灵感建议列表。")
|
||||
@GetMapping(value = "/inspiration/recommendations")
|
||||
public Result<List<InspirationSuggestionResponse>> getInspirationRecommendations() {
|
||||
return Result.success(epicScriptService.getInspirationRecommendations());
|
||||
}
|
||||
|
||||
@Operation(summary = "获取随机灵感", description = "随机获取指定数量的灵感建议。")
|
||||
@GetMapping(value = "/inspiration/random")
|
||||
public Result<List<InspirationSuggestionResponse>> getRandomInspirations(
|
||||
@RequestParam(required = false, defaultValue = "3") Integer size) {
|
||||
@Parameter(description = "灵感数量") @RequestParam(required = false, defaultValue = "3") Integer size) {
|
||||
return Result.success(epicScriptService.getRandomInspirations(size));
|
||||
}
|
||||
|
||||
@Operation(summary = "从灵感生成剧本", description = "基于选定的灵感建议生成爽文剧本。")
|
||||
@PostMapping(value = "/inspiration/generate")
|
||||
public Result<EpicScriptInspirationResponse> generateFromInspiration(
|
||||
@Valid @RequestBody EpicScriptInspirationRequest request) {
|
||||
@@ -77,8 +86,9 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 根据ID获取爽文剧本详情
|
||||
*/
|
||||
@Operation(summary = "获取剧本详情", description = "根据 ID 获取爽文剧本的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<EpicScriptResponse> getById(@RequestParam String id) {
|
||||
public Result<EpicScriptResponse> getById(@Parameter(description = "剧本 ID") @RequestParam String id) {
|
||||
EpicScriptResponse script = epicScriptService.getScriptById(id);
|
||||
if (script == null) {
|
||||
return Result.notFound("爽文剧本不存在");
|
||||
@@ -89,6 +99,7 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 创建爽文剧本
|
||||
*/
|
||||
@Operation(summary = "创建爽文剧本", description = "创建一个新的爽文剧本。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<EpicScriptResponse> create(@Valid @RequestBody EpicScriptCreateRequest request) {
|
||||
EpicScriptResponse script = epicScriptService.createScript(request);
|
||||
@@ -101,6 +112,7 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 更新爽文剧本
|
||||
*/
|
||||
@Operation(summary = "更新爽文剧本", description = "修改已有爽文剧本的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<EpicScriptResponse> update(@Valid @RequestBody EpicScriptUpdateRequest request) {
|
||||
EpicScriptResponse script = epicScriptService.updateScript(request);
|
||||
@@ -113,8 +125,9 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 选中剧本(取消其他选中状态)
|
||||
*/
|
||||
@Operation(summary = "选中剧本", description = "选中指定剧本并取消其他剧本的选中状态。")
|
||||
@PutMapping(value = "/select")
|
||||
public Result<EpicScriptResponse> select(@RequestParam String id) {
|
||||
public Result<EpicScriptResponse> select(@Parameter(description = "剧本 ID") @RequestParam String id) {
|
||||
EpicScriptResponse script = epicScriptService.selectScript(id);
|
||||
if (script == null) {
|
||||
return Result.error("选中失败");
|
||||
@@ -125,8 +138,9 @@ public class EpicScriptController {
|
||||
/**
|
||||
* 删除爽文剧本
|
||||
*/
|
||||
@Operation(summary = "删除爽文剧本", description = "删除指定的爽文剧本。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "剧本 ID") @RequestParam String id) {
|
||||
boolean deleted = epicScriptService.deleteScript(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.growth.GrowthTopicPageRequest;
|
||||
import com.emotion.dto.request.growth.GrowthTopicUpdateRequest;
|
||||
import com.emotion.dto.response.growth.GrowthTopicResponse;
|
||||
import com.emotion.service.GrowthTopicService;
|
||||
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.*;
|
||||
@@ -15,12 +18,13 @@ import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 成长话题控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-09-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/growthTopic")
|
||||
@Tag(name = "成长话题管理", description = "成长话题的查询、创建、更新和删除接口")
|
||||
public class GrowthTopicController {
|
||||
|
||||
@Autowired
|
||||
@@ -29,6 +33,7 @@ public class GrowthTopicController {
|
||||
/**
|
||||
* 分页查询成长话题
|
||||
*/
|
||||
@Operation(summary = "分页查询成长话题", description = "分页查询成长话题列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<GrowthTopicResponse>> getPage(@Validated GrowthTopicPageRequest request) {
|
||||
PageResult<GrowthTopicResponse> pageResult = growthTopicService.getPageWithResponse(request);
|
||||
@@ -38,8 +43,9 @@ public class GrowthTopicController {
|
||||
/**
|
||||
* 根据ID获取成长话题
|
||||
*/
|
||||
@Operation(summary = "获取话题详情", description = "根据 ID 获取成长话题的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<GrowthTopicResponse> getById(@RequestParam String id) {
|
||||
public Result<GrowthTopicResponse> getById(@Parameter(description = "话题 ID") @RequestParam String id) {
|
||||
GrowthTopicResponse response = growthTopicService.getGrowthTopicResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("成长话题不存在");
|
||||
@@ -50,6 +56,7 @@ public class GrowthTopicController {
|
||||
/**
|
||||
* 创建成长话题
|
||||
*/
|
||||
@Operation(summary = "创建成长话题", description = "创建一个新的成长话题。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<GrowthTopicResponse> create(@Valid @RequestBody GrowthTopicCreateRequest request) {
|
||||
GrowthTopicResponse response = growthTopicService.createGrowthTopicWithResponse(request);
|
||||
@@ -59,6 +66,7 @@ public class GrowthTopicController {
|
||||
/**
|
||||
* 更新成长话题
|
||||
*/
|
||||
@Operation(summary = "更新成长话题", description = "修改已有成长话题的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<GrowthTopicResponse> update(@Valid @RequestBody GrowthTopicUpdateRequest request) {
|
||||
GrowthTopicResponse response = growthTopicService.updateGrowthTopicWithResponse(request);
|
||||
@@ -71,12 +79,13 @@ public class GrowthTopicController {
|
||||
/**
|
||||
* 删除成长话题
|
||||
*/
|
||||
@Operation(summary = "删除成长话题", description = "删除指定的成长话题。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "话题 ID") @RequestParam String id) {
|
||||
boolean deleted = growthTopicService.deleteGrowthTopic(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.guest.GuestUserPageRequest;
|
||||
import com.emotion.dto.request.guest.GuestUserUpdateRequest;
|
||||
import com.emotion.dto.response.guest.GuestUserResponse;
|
||||
import com.emotion.service.GuestUserService;
|
||||
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.*;
|
||||
@@ -15,12 +18,13 @@ import javax.validation.Valid;
|
||||
|
||||
/**
|
||||
* 访客用户控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-09-08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/guestUser")
|
||||
@Tag(name = "访客用户管理", description = "访客用户的查询、创建、更新和删除接口")
|
||||
public class GuestUserController {
|
||||
|
||||
@Autowired
|
||||
@@ -29,6 +33,7 @@ public class GuestUserController {
|
||||
/**
|
||||
* 分页查询访客用户
|
||||
*/
|
||||
@Operation(summary = "分页查询访客用户", description = "分页查询访客用户列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<GuestUserResponse>> getPage(@Validated GuestUserPageRequest request) {
|
||||
PageResult<GuestUserResponse> pageResult = guestUserService.getPageWithResponse(request);
|
||||
@@ -38,8 +43,9 @@ public class GuestUserController {
|
||||
/**
|
||||
* 根据ID获取访客用户
|
||||
*/
|
||||
@Operation(summary = "获取访客详情", description = "根据 ID 获取访客用户的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<GuestUserResponse> getById(@RequestParam String id) {
|
||||
public Result<GuestUserResponse> getById(@Parameter(description = "访客 ID") @RequestParam String id) {
|
||||
GuestUserResponse response = guestUserService.getGuestUserResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("访客用户不存在");
|
||||
@@ -50,6 +56,7 @@ public class GuestUserController {
|
||||
/**
|
||||
* 创建访客用户
|
||||
*/
|
||||
@Operation(summary = "创建访客用户", description = "创建一个新的访客用户。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<GuestUserResponse> create(@Valid @RequestBody GuestUserCreateRequest request) {
|
||||
GuestUserResponse response = guestUserService.createGuestUserWithResponse(request);
|
||||
@@ -59,6 +66,7 @@ public class GuestUserController {
|
||||
/**
|
||||
* 更新访客用户
|
||||
*/
|
||||
@Operation(summary = "更新访客用户", description = "修改已有访客用户的信息。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<GuestUserResponse> update(@Valid @RequestBody GuestUserUpdateRequest request) {
|
||||
GuestUserResponse response = guestUserService.updateGuestUserWithResponse(request);
|
||||
@@ -71,8 +79,9 @@ public class GuestUserController {
|
||||
/**
|
||||
* 删除访客用户
|
||||
*/
|
||||
@Operation(summary = "删除访客用户", description = "删除指定的访客用户。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "访客 ID") @RequestParam String id) {
|
||||
boolean deleted = guestUserService.deleteGuestUser(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.emotion.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -11,11 +13,12 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 健康检查控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = "健康检查", description = "系统健康状态检查接口")
|
||||
public class HealthController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HealthController.class);
|
||||
@@ -23,6 +26,7 @@ public class HealthController {
|
||||
/**
|
||||
* 健康检查
|
||||
*/
|
||||
@Operation(summary = "系统健康检查", description = "返回系统各组件的健康状态,包括数据库、Redis 等。")
|
||||
@GetMapping("/health")
|
||||
public Map<String, Object> health() {
|
||||
log.info("健康检查请求");
|
||||
@@ -40,6 +44,7 @@ public class HealthController {
|
||||
/**
|
||||
* 服务信息
|
||||
*/
|
||||
@Operation(summary = "获取服务信息", description = "返回服务的基本信息,包括版本号、构建时间等。")
|
||||
@GetMapping("/health/info")
|
||||
public Map<String, Object> info() {
|
||||
log.info("服务信息请求");
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.LifeEventPageRequest;
|
||||
import com.emotion.dto.request.LifeEventUpdateRequest;
|
||||
import com.emotion.dto.response.LifeEventResponse;
|
||||
import com.emotion.service.LifeEventService;
|
||||
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.*;
|
||||
@@ -26,6 +29,7 @@ import java.util.Map;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/lifeEvent")
|
||||
@Tag(name = "生命事件管理", description = "生命事件的查询、创建、更新和删除接口")
|
||||
public class LifeEventController {
|
||||
|
||||
@Autowired
|
||||
@@ -34,6 +38,7 @@ public class LifeEventController {
|
||||
/**
|
||||
* 分页查询当前用户的生命事件
|
||||
*/
|
||||
@Operation(summary = "分页查询生命事件", description = "分页查询生命事件列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<LifeEventResponse>> getPage(@Validated LifeEventPageRequest request) {
|
||||
PageResult<LifeEventResponse> pageResult = lifeEventService.getPageByCurrentUser(request);
|
||||
@@ -43,6 +48,7 @@ public class LifeEventController {
|
||||
/**
|
||||
* 获取当前用户的所有生命事件列表
|
||||
*/
|
||||
@Operation(summary = "获取生命事件列表", description = "获取当前用户的所有生命事件列表。")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<List<LifeEventResponse>> getList() {
|
||||
List<LifeEventResponse> events = lifeEventService.getListByCurrentUser();
|
||||
@@ -52,8 +58,9 @@ public class LifeEventController {
|
||||
/**
|
||||
* 根据ID获取生命事件详情
|
||||
*/
|
||||
@Operation(summary = "获取生命事件详情", description = "根据 ID 获取生命事件的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<LifeEventResponse> getById(@RequestParam String id) {
|
||||
public Result<LifeEventResponse> getById(@Parameter(description = "事件 ID") @RequestParam String id) {
|
||||
LifeEventResponse event = lifeEventService.getEventById(id);
|
||||
if (event == null) {
|
||||
return Result.notFound("生命事件不存在");
|
||||
@@ -64,6 +71,7 @@ public class LifeEventController {
|
||||
/**
|
||||
* 创建生命事件
|
||||
*/
|
||||
@Operation(summary = "创建生命事件", description = "创建一个新的生命事件。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<LifeEventResponse> create(@Valid @RequestBody LifeEventCreateRequest request) {
|
||||
LifeEventResponse event = lifeEventService.createEvent(request);
|
||||
@@ -76,6 +84,7 @@ public class LifeEventController {
|
||||
/**
|
||||
* 更新生命事件
|
||||
*/
|
||||
@Operation(summary = "更新生命事件", description = "修改已有生命事件的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<LifeEventResponse> update(@Valid @RequestBody LifeEventUpdateRequest request) {
|
||||
LifeEventResponse event = lifeEventService.updateEvent(request);
|
||||
@@ -88,14 +97,16 @@ public class LifeEventController {
|
||||
/**
|
||||
* 删除生命事件
|
||||
*/
|
||||
@Operation(summary = "删除生命事件", description = "删除指定的生命事件。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "事件 ID") @RequestParam String id) {
|
||||
boolean deleted = lifeEventService.deleteEvent(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
@Operation(summary = "AI 辅助生成内容", description = "根据标题和内容调用 AI 生成生命事件的解读文本、标签等信息。")
|
||||
@PostMapping(value = "/ai-assist")
|
||||
public Result<Map<String, Object>> aiAssist(@RequestBody Map<String, Object> request) {
|
||||
String title = stringValue(request.get("title"), "这段经历");
|
||||
@@ -116,6 +127,7 @@ public class LifeEventController {
|
||||
return Result.success(data);
|
||||
}
|
||||
|
||||
@Operation(summary = "聊天占位接口", description = "返回聊天功能的占位回复和建议问题。")
|
||||
@PostMapping(value = "/chat-placeholder")
|
||||
public Result<Map<String, Object>> chatPlaceholder(@RequestBody Map<String, Object> request) {
|
||||
String title = stringValue(request.get("title"), "这段经历");
|
||||
@@ -126,6 +138,7 @@ public class LifeEventController {
|
||||
return Result.success(data);
|
||||
}
|
||||
|
||||
@Operation(summary = "分享占位接口", description = "返回分享功能的占位文本和分享信息。")
|
||||
@PostMapping(value = "/share-placeholder")
|
||||
public Result<Map<String, Object>> sharePlaceholder(@RequestBody Map<String, Object> request) {
|
||||
String title = stringValue(request.get("title"), "人生经历");
|
||||
@@ -137,6 +150,7 @@ public class LifeEventController {
|
||||
return Result.success(data);
|
||||
}
|
||||
|
||||
@Operation(summary = "收藏占位接口", description = "返回收藏功能的占位响应。")
|
||||
@PostMapping(value = "/favorite-placeholder")
|
||||
public Result<Map<String, Object>> favoritePlaceholder(@RequestBody Map<String, Object> request) {
|
||||
String id = stringValue(request.get("id"), "");
|
||||
|
||||
@@ -7,6 +7,9 @@ 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.*;
|
||||
@@ -22,6 +25,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/lifePath")
|
||||
@Tag(name = "实现路径管理", description = "人生剧本实现路径的查询、创建、更新和删除接口")
|
||||
public class LifePathController {
|
||||
|
||||
@Autowired
|
||||
@@ -30,6 +34,7 @@ public class LifePathController {
|
||||
/**
|
||||
* 分页查询当前用户的实现路径
|
||||
*/
|
||||
@Operation(summary = "分页查询实现路径", description = "分页查询当前用户的实现路径列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<LifePathResponse>> getPage(@Validated LifePathPageRequest request) {
|
||||
PageResult<LifePathResponse> pageResult = lifePathService.getPageByCurrentUser(request);
|
||||
@@ -39,6 +44,7 @@ public class LifePathController {
|
||||
/**
|
||||
* 获取当前用户的所有实现路径列表
|
||||
*/
|
||||
@Operation(summary = "获取实现路径列表", description = "获取当前用户的所有实现路径列表。")
|
||||
@GetMapping(value = "/listAll")
|
||||
public Result<List<LifePathResponse>> getList() {
|
||||
List<LifePathResponse> paths = lifePathService.getListByCurrentUser();
|
||||
@@ -48,8 +54,9 @@ public class LifePathController {
|
||||
/**
|
||||
* 根据剧本ID获取实现路径
|
||||
*/
|
||||
@Operation(summary = "根据剧本ID获取路径", description = "根据剧本 ID 获取对应的实现路径。")
|
||||
@GetMapping(value = "/byScript")
|
||||
public Result<LifePathResponse> getByScriptId(@RequestParam String scriptId) {
|
||||
public Result<LifePathResponse> getByScriptId(@Parameter(description = "剧本 ID") @RequestParam String scriptId) {
|
||||
LifePathResponse path = lifePathService.getByScriptId(scriptId);
|
||||
if (path == null) {
|
||||
return Result.notFound("实现路径不存在");
|
||||
@@ -60,8 +67,9 @@ public class LifePathController {
|
||||
/**
|
||||
* 根据ID获取实现路径详情
|
||||
*/
|
||||
@Operation(summary = "获取路径详情", description = "根据 ID 获取实现路径的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<LifePathResponse> getById(@RequestParam String id) {
|
||||
public Result<LifePathResponse> getById(@Parameter(description = "路径 ID") @RequestParam String id) {
|
||||
LifePathResponse path = lifePathService.getPathById(id);
|
||||
if (path == null) {
|
||||
return Result.notFound("实现路径不存在");
|
||||
@@ -72,6 +80,7 @@ public class LifePathController {
|
||||
/**
|
||||
* 创建实现路径
|
||||
*/
|
||||
@Operation(summary = "创建实现路径", description = "创建一条新的实现路径。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<LifePathResponse> create(@Valid @RequestBody LifePathCreateRequest request) {
|
||||
LifePathResponse path = lifePathService.createPath(request);
|
||||
@@ -84,6 +93,7 @@ public class LifePathController {
|
||||
/**
|
||||
* 更新实现路径
|
||||
*/
|
||||
@Operation(summary = "更新实现路径", description = "修改已有实现路径的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<LifePathResponse> update(@Valid @RequestBody LifePathUpdateRequest request) {
|
||||
LifePathResponse path = lifePathService.updatePath(request);
|
||||
@@ -96,8 +106,9 @@ public class LifePathController {
|
||||
/**
|
||||
* 删除实现路径
|
||||
*/
|
||||
@Operation(summary = "删除实现路径", description = "删除指定的实现路径。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "路径 ID") @RequestParam String id) {
|
||||
boolean deleted = lifePathService.deletePath(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.emotion.dto.request.MessageSearchRequest;
|
||||
import com.emotion.dto.request.MessageRecentRequest;
|
||||
import com.emotion.dto.response.MessageResponse;
|
||||
import com.emotion.service.MessageService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -24,6 +27,7 @@ import javax.validation.Valid;
|
||||
@RestController
|
||||
@RequestMapping("/message")
|
||||
@Slf4j
|
||||
@Tag(name = "消息管理", description = "会话消息的查询、创建、搜索、更新和删除接口")
|
||||
public class MessageController {
|
||||
|
||||
@Autowired
|
||||
@@ -32,6 +36,7 @@ public class MessageController {
|
||||
/**
|
||||
* 创建消息
|
||||
*/
|
||||
@Operation(summary = "创建消息", description = "在指定会话中创建一条新消息。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<MessageResponse> create(@Valid @RequestBody MessageCreateRequest request) {
|
||||
MessageResponse response = messageService.createMessageFromRequest(request);
|
||||
@@ -41,8 +46,9 @@ public class MessageController {
|
||||
/**
|
||||
* 根据ID获取消息
|
||||
*/
|
||||
@Operation(summary = "获取消息详情", description = "根据 ID 获取消息的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<MessageResponse> getById(@RequestParam String id) {
|
||||
public Result<MessageResponse> getById(@Parameter(description = "消息 ID") @RequestParam String id) {
|
||||
MessageResponse response = messageService.getMessageById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("消息不存在");
|
||||
@@ -53,6 +59,7 @@ public class MessageController {
|
||||
/**
|
||||
* 分页查询消息
|
||||
*/
|
||||
@Operation(summary = "分页查询消息", description = "分页查询指定会话的消息列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<MessageResponse>> getPage(@Validated MessagePageRequest request) {
|
||||
PageResult<MessageResponse> pageResult = messageService.getPageWithResponse(request);
|
||||
@@ -62,6 +69,7 @@ public class MessageController {
|
||||
/**
|
||||
* 搜索消息
|
||||
*/
|
||||
@Operation(summary = "搜索消息", description = "根据关键词在指定会话中搜索消息内容。")
|
||||
@PostMapping(value = "/search")
|
||||
public Result<PageResult<MessageResponse>> search(@Valid @RequestBody MessageSearchRequest request) {
|
||||
PageResult<MessageResponse> pageResult = messageService.searchWithResponse(request);
|
||||
@@ -71,6 +79,7 @@ public class MessageController {
|
||||
/**
|
||||
* 获取最近的消息
|
||||
*/
|
||||
@Operation(summary = "获取最近消息", description = "获取指定会话最近的消息列表。")
|
||||
@PostMapping(value = "/recent")
|
||||
public Result<PageResult<MessageResponse>> getRecentMessages(@Valid @RequestBody MessageRecentRequest request) {
|
||||
PageResult<MessageResponse> pageResult = messageService.getRecentWithResponse(request);
|
||||
@@ -80,6 +89,7 @@ public class MessageController {
|
||||
/**
|
||||
* 更新消息
|
||||
*/
|
||||
@Operation(summary = "更新消息", description = "修改指定消息的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<MessageResponse> update(@RequestParam String id, @RequestParam String content) {
|
||||
MessageResponse response = messageService.updateMessage(id, content);
|
||||
@@ -92,12 +102,13 @@ public class MessageController {
|
||||
/**
|
||||
* 删除消息
|
||||
*/
|
||||
@Operation(summary = "删除消息", description = "删除指定的消息记录。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "消息 ID") @RequestParam String id) {
|
||||
boolean deleted = messageService.deleteMessage(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.reward.RewardPageRequest;
|
||||
import com.emotion.dto.request.reward.RewardUpdateRequest;
|
||||
import com.emotion.dto.response.reward.RewardResponse;
|
||||
import com.emotion.service.RewardService;
|
||||
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.*;
|
||||
@@ -21,6 +24,7 @@ import javax.validation.Valid;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/reward")
|
||||
@Tag(name = "奖励管理", description = "奖励的查询、创建、更新和删除接口")
|
||||
public class RewardController {
|
||||
|
||||
@Autowired
|
||||
@@ -29,6 +33,7 @@ public class RewardController {
|
||||
/**
|
||||
* 分页查询奖励
|
||||
*/
|
||||
@Operation(summary = "分页查询奖励", description = "分页查询奖励列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<RewardResponse>> getPage(@Validated RewardPageRequest request) {
|
||||
PageResult<RewardResponse> pageResult = rewardService.getPageWithResponse(request);
|
||||
@@ -38,8 +43,9 @@ public class RewardController {
|
||||
/**
|
||||
* 根据ID获取奖励
|
||||
*/
|
||||
@Operation(summary = "获取奖励详情", description = "根据 ID 获取奖励的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<RewardResponse> getById(@RequestParam String id) {
|
||||
public Result<RewardResponse> getById(@Parameter(description = "奖励 ID") @RequestParam String id) {
|
||||
RewardResponse response = rewardService.getRewardResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("奖励不存在");
|
||||
@@ -50,6 +56,7 @@ public class RewardController {
|
||||
/**
|
||||
* 创建奖励
|
||||
*/
|
||||
@Operation(summary = "创建奖励", description = "创建一个新的奖励。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<RewardResponse> create(@Valid @RequestBody RewardCreateRequest request) {
|
||||
RewardResponse response = rewardService.createRewardWithResponse(request);
|
||||
@@ -59,6 +66,7 @@ public class RewardController {
|
||||
/**
|
||||
* 更新奖励
|
||||
*/
|
||||
@Operation(summary = "更新奖励", description = "修改已有奖励的信息。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<RewardResponse> update(@Valid @RequestBody RewardUpdateRequest request) {
|
||||
RewardResponse response = rewardService.updateRewardWithResponse(request);
|
||||
@@ -71,8 +79,9 @@ public class RewardController {
|
||||
/**
|
||||
* 删除奖励
|
||||
*/
|
||||
@Operation(summary = "删除奖励", description = "删除指定的奖励。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "奖励 ID") @RequestParam String id) {
|
||||
boolean deleted = rewardService.deleteReward(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
|
||||
@@ -7,6 +7,9 @@ import com.emotion.dto.request.social.SocialContentManualImportRequest;
|
||||
import com.emotion.dto.response.social.SocialContentItemResponse;
|
||||
import com.emotion.service.SocialContentService;
|
||||
import com.emotion.util.UserContextHolder;
|
||||
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.DeleteMapping;
|
||||
@@ -27,11 +30,13 @@ import java.util.List;
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/social/content")
|
||||
@Tag(name = "社交内容管理", description = "社交媒体内容的导入、截图、审核等接口")
|
||||
public class SocialContentController {
|
||||
|
||||
@Autowired
|
||||
private SocialContentService socialContentService;
|
||||
|
||||
@Operation(summary = "手动导入社交内容", description = "通过上传文本内容手动导入社交媒体数据。")
|
||||
@PostMapping("/manual")
|
||||
public Result<SocialContentItemResponse> manualImport(@Valid @RequestBody SocialContentManualImportRequest request) {
|
||||
String userId = currentUserId();
|
||||
@@ -45,6 +50,7 @@ public class SocialContentController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "链接导入社交内容", description = "通过社交媒体链接 URL 导入内容。")
|
||||
@PostMapping("/link")
|
||||
public Result<SocialContentItemResponse> linkImport(@Valid @RequestBody SocialContentLinkImportRequest request) {
|
||||
String userId = currentUserId();
|
||||
@@ -58,8 +64,9 @@ public class SocialContentController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "截图导入社交内容", description = "通过上传截图图片来导入社交媒体内容。")
|
||||
@PostMapping("/screenshot")
|
||||
public Result<SocialContentItemResponse> screenshotImport(@RequestParam String platform,
|
||||
public Result<SocialContentItemResponse> screenshotImport(@Parameter(description = "平台名称", required = true) @RequestParam String platform,
|
||||
@RequestPart("file") MultipartFile file) {
|
||||
String userId = currentUserId();
|
||||
if (userId == null) {
|
||||
@@ -72,6 +79,7 @@ public class SocialContentController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取社交内容列表", description = "查询所有已导入的社交媒体内容列表。")
|
||||
@GetMapping("/list")
|
||||
public Result<List<SocialContentItemResponse>> list() {
|
||||
String userId = currentUserId();
|
||||
@@ -81,8 +89,9 @@ public class SocialContentController {
|
||||
return Result.success(socialContentService.listByUser(userId));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新内容审核状态", description = "修改指定社交内容的审核状态(通过/拒绝)。")
|
||||
@PutMapping("/{id}/approval")
|
||||
public Result<SocialContentItemResponse> updateApproval(@PathVariable String id,
|
||||
public Result<SocialContentItemResponse> updateApproval(@Parameter(description = "内容 ID", required = true) @PathVariable String id,
|
||||
@RequestBody SocialContentApprovalRequest request) {
|
||||
String userId = currentUserId();
|
||||
if (userId == null) {
|
||||
@@ -95,9 +104,10 @@ public class SocialContentController {
|
||||
return Result.success(response);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除社交内容", description = "删除指定的社交媒体内容记录。")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Void> delete(@PathVariable String id,
|
||||
@RequestParam(required = false, defaultValue = "true") Boolean keepConfirmedInsights) {
|
||||
public Result<Void> delete(@Parameter(description = "内容 ID", required = true) @PathVariable String id,
|
||||
@Parameter(description = "是否保留已确认的洞察") @RequestParam(required = false, defaultValue = "true") Boolean keepConfirmedInsights) {
|
||||
String userId = currentUserId();
|
||||
if (userId == null) {
|
||||
return Result.unauthorized();
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.emotion.dto.request.social.SocialInsightUpdateRequest;
|
||||
import com.emotion.dto.response.social.SocialProfileInsightResponse;
|
||||
import com.emotion.service.SocialInsightService;
|
||||
import com.emotion.util.UserContextHolder;
|
||||
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.DeleteMapping;
|
||||
@@ -24,11 +27,13 @@ import java.util.List;
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/social/insight")
|
||||
@Tag(name = "社交洞察管理", description = "社交媒体洞察生成、查询和更新接口")
|
||||
public class SocialInsightController {
|
||||
|
||||
@Autowired
|
||||
private SocialInsightService socialInsightService;
|
||||
|
||||
@Operation(summary = "生成社交洞察", description = "基于用户社交数据生成 AI 分析洞察报告。")
|
||||
@PostMapping("/generate")
|
||||
public Result<List<SocialProfileInsightResponse>> generate(@RequestBody(required = false) SocialInsightGenerateRequest request) {
|
||||
String userId = currentUserId();
|
||||
@@ -38,8 +43,9 @@ public class SocialInsightController {
|
||||
return Result.success(socialInsightService.generateInsights(userId, request));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取洞察列表", description = "查询当前用户的所有社交洞察记录。")
|
||||
@GetMapping("/list")
|
||||
public Result<List<SocialProfileInsightResponse>> list(@RequestParam(required = false) String status) {
|
||||
public Result<List<SocialProfileInsightResponse>> list(@Parameter(description = "洞察状态") @RequestParam(required = false) String status) {
|
||||
String userId = currentUserId();
|
||||
if (userId == null) {
|
||||
return Result.unauthorized();
|
||||
@@ -47,8 +53,9 @@ public class SocialInsightController {
|
||||
return Result.success(socialInsightService.listByUser(userId, status));
|
||||
}
|
||||
|
||||
@Operation(summary = "更新洞察记录", description = "更新已有洞察的状态或备注信息。")
|
||||
@PutMapping("/{id}")
|
||||
public Result<SocialProfileInsightResponse> update(@PathVariable String id,
|
||||
public Result<SocialProfileInsightResponse> update(@Parameter(description = "洞察 ID", required = true) @PathVariable String id,
|
||||
@Valid @RequestBody SocialInsightUpdateRequest request) {
|
||||
String userId = currentUserId();
|
||||
if (userId == null) {
|
||||
@@ -65,8 +72,9 @@ public class SocialInsightController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "删除洞察记录", description = "删除指定的社交洞察记录。")
|
||||
@DeleteMapping("/{id}")
|
||||
public Result<Void> delete(@PathVariable String id) {
|
||||
public Result<Void> delete(@Parameter(description = "洞察 ID", required = true) @PathVariable String id) {
|
||||
String userId = currentUserId();
|
||||
if (userId == null) {
|
||||
return Result.unauthorized();
|
||||
|
||||
+12
-3
@@ -7,6 +7,9 @@ import com.emotion.dto.request.TopicInteractionPageRequest;
|
||||
import com.emotion.dto.request.TopicInteractionUpdateRequest;
|
||||
import com.emotion.dto.response.TopicInteractionResponse;
|
||||
import com.emotion.service.TopicInteractionService;
|
||||
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.*;
|
||||
@@ -21,6 +24,7 @@ import javax.validation.Valid;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/topicInteraction")
|
||||
@Tag(name = "话题互动管理", description = "话题互动记录的查询、创建、更新和删除接口")
|
||||
public class TopicInteractionController {
|
||||
|
||||
@Autowired
|
||||
@@ -29,6 +33,7 @@ public class TopicInteractionController {
|
||||
/**
|
||||
* 分页查询话题互动
|
||||
*/
|
||||
@Operation(summary = "分页查询互动记录", description = "分页查询话题互动记录列表。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<TopicInteractionResponse>> getPage(@Validated TopicInteractionPageRequest request) {
|
||||
PageResult<TopicInteractionResponse> pageResult = topicInteractionService.getPageWithResponse(request);
|
||||
@@ -38,8 +43,9 @@ public class TopicInteractionController {
|
||||
/**
|
||||
* 根据ID获取话题互动
|
||||
*/
|
||||
@Operation(summary = "获取互动详情", description = "根据 ID 获取互动记录的详细信息。")
|
||||
@GetMapping(value = "/detail")
|
||||
public Result<TopicInteractionResponse> getById(@RequestParam String id) {
|
||||
public Result<TopicInteractionResponse> getById(@Parameter(description = "互动 ID") @RequestParam String id) {
|
||||
TopicInteractionResponse response = topicInteractionService.getTopicInteractionResponseById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("话题互动不存在");
|
||||
@@ -50,6 +56,7 @@ public class TopicInteractionController {
|
||||
/**
|
||||
* 创建话题互动
|
||||
*/
|
||||
@Operation(summary = "创建互动记录", description = "创建一条新的话题互动记录。")
|
||||
@PostMapping(value = "/create")
|
||||
public Result<TopicInteractionResponse> create(@Valid @RequestBody TopicInteractionCreateRequest request) {
|
||||
TopicInteractionResponse response = topicInteractionService.createTopicInteractionWithResponse(request);
|
||||
@@ -59,6 +66,7 @@ public class TopicInteractionController {
|
||||
/**
|
||||
* 更新话题互动
|
||||
*/
|
||||
@Operation(summary = "更新互动记录", description = "修改已有话题互动的内容。")
|
||||
@PutMapping(value = "/update")
|
||||
public Result<TopicInteractionResponse> update(@Valid @RequestBody TopicInteractionUpdateRequest request) {
|
||||
TopicInteractionResponse response = topicInteractionService.updateTopicInteractionWithResponse(request);
|
||||
@@ -71,12 +79,13 @@ public class TopicInteractionController {
|
||||
/**
|
||||
* 删除话题互动
|
||||
*/
|
||||
@Operation(summary = "删除互动记录", description = "删除指定的话题互动记录。")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "互动 ID") @RequestParam String id) {
|
||||
boolean deleted = topicInteractionService.deleteTopicInteraction(id);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import com.emotion.common.Result;
|
||||
import com.emotion.dto.request.tts.TtsTaskCreateRequest;
|
||||
import com.emotion.dto.response.tts.TtsTaskResponse;
|
||||
import com.emotion.service.TtsTaskService;
|
||||
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.Value;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
@@ -25,6 +28,7 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/tts")
|
||||
@Tag(name = "语音合成(TTS)", description = "文字转语音任务创建和查询接口")
|
||||
public class TtsController {
|
||||
|
||||
private final TtsTaskService ttsTaskService;
|
||||
@@ -36,6 +40,7 @@ public class TtsController {
|
||||
this.ttsTaskService = ttsTaskService;
|
||||
}
|
||||
|
||||
@Operation(summary = "创建语音合成任务", description = "根据文本内容创建语音合成任务,返回任务信息。")
|
||||
@PostMapping("/tasks")
|
||||
public Result<TtsTaskResponse> create(@Valid @RequestBody TtsTaskCreateRequest request) {
|
||||
try {
|
||||
@@ -45,21 +50,24 @@ public class TtsController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "获取语音合成任务详情", description = "根据任务 ID 获取语音合成任务的详细信息。")
|
||||
@GetMapping("/tasks/{id}")
|
||||
public Result<TtsTaskResponse> detail(@PathVariable String id) {
|
||||
public Result<TtsTaskResponse> detail(@Parameter(description = "任务 ID") @PathVariable String id) {
|
||||
TtsTaskResponse response = ttsTaskService.getTask(id);
|
||||
return response == null ? Result.notFound("TTS task not found") : Result.success(response);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据来源查询语音合成任务", description = "根据来源类型和来源 ID 查询已存在的语音合成任务。")
|
||||
@GetMapping("/tasks/by-source")
|
||||
public Result<TtsTaskResponse> bySource(@RequestParam String sourceType,
|
||||
@RequestParam String sourceId,
|
||||
@RequestParam(required = false) String voice) {
|
||||
public Result<TtsTaskResponse> bySource(@Parameter(description = "来源类型") @RequestParam String sourceType,
|
||||
@Parameter(description = "来源 ID") @RequestParam String sourceId,
|
||||
@Parameter(description = "音色") @RequestParam(required = false) String voice) {
|
||||
return Result.success(ttsTaskService.getBySource(sourceType, sourceId, voice));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取音频文件", description = "返回已合成的音频音频文件(MP3 或 WAV 格式)。")
|
||||
@GetMapping("/audio/{filename:.+}")
|
||||
public ResponseEntity<Resource> audio(@PathVariable String filename) {
|
||||
public ResponseEntity<Resource> audio(@Parameter(description = "音频文件名") @PathVariable String filename) {
|
||||
if (filename.contains("..") || filename.contains("/") || filename.contains("\\")) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user-profile")
|
||||
@Tag(name = "用户档案管理", description = "用户生命档案的增删改查和查询功能")
|
||||
@Tag(name = "用户档案管理", description = "用户档案的查询、创建、更新、删除和 AI 设置管理接口")
|
||||
public class UserProfileController {
|
||||
|
||||
@Autowired
|
||||
@@ -34,6 +34,7 @@ public class UserProfileController {
|
||||
/**
|
||||
* 新增档案
|
||||
*/
|
||||
@Operation(summary = "创建用户档案", description = "为当前用户创建个人档案,包含昵称、MBTI 人格类型、童年经历等。")
|
||||
@PostMapping("/create")
|
||||
public Result<UserProfileResponse> create(@Valid @RequestBody UserProfileCreateRequest request) {
|
||||
UserProfileResponse response = userProfileService.createProfile(request);
|
||||
@@ -43,8 +44,9 @@ public class UserProfileController {
|
||||
/**
|
||||
* 删除档案
|
||||
*/
|
||||
@Operation(summary = "删除用户档案", description = "删除指定的用户档案。")
|
||||
@DeleteMapping("/delete")
|
||||
public Result<Void> delete(@RequestParam String id) {
|
||||
public Result<Void> delete(@Parameter(description = "档案 ID") @RequestParam String id) {
|
||||
boolean success = userProfileService.deleteProfile(id);
|
||||
if (success) {
|
||||
return Result.success();
|
||||
@@ -56,6 +58,7 @@ public class UserProfileController {
|
||||
/**
|
||||
* 修改档案
|
||||
*/
|
||||
@Operation(summary = "更新用户档案", description = "更新当前用户的个人档案信息。")
|
||||
@PutMapping("/update")
|
||||
public Result<UserProfileResponse> update(@Valid @RequestBody UserProfileUpdateRequest request) {
|
||||
UserProfileResponse response = userProfileService.updateProfile(request);
|
||||
@@ -65,8 +68,9 @@ public class UserProfileController {
|
||||
/**
|
||||
* 根据ID查询详情
|
||||
*/
|
||||
@Operation(summary = "获取档案详情", description = "根据 ID 获取用户档案详情。")
|
||||
@GetMapping("/detail")
|
||||
public Result<UserProfileResponse> getById(@RequestParam String id) {
|
||||
public Result<UserProfileResponse> getById(@Parameter(description = "档案 ID") @RequestParam String id) {
|
||||
UserProfileResponse response = userProfileService.getProfileById(id);
|
||||
if (response == null) {
|
||||
return Result.notFound("档案不存在");
|
||||
@@ -77,6 +81,7 @@ public class UserProfileController {
|
||||
/**
|
||||
* 获取当前登录用户的档案
|
||||
*/
|
||||
@Operation(summary = "获取当前用户档案", description = "获取当前登录用户的个人档案信息。")
|
||||
@GetMapping("/me")
|
||||
public Result<UserProfileResponse> getCurrentProfile() {
|
||||
UserProfileResponse response = userProfileService.getCurrentUserProfile();
|
||||
@@ -87,6 +92,7 @@ public class UserProfileController {
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@Operation(summary = "分页查询用户档案", description = "分页查询用户档案列表。")
|
||||
@GetMapping("/page")
|
||||
public Result<PageResult<UserProfileResponse>> getPage(@Validated UserProfilePageRequest request) {
|
||||
PageResult<UserProfileResponse> pageResult = userProfileService.getProfilePage(request);
|
||||
@@ -96,6 +102,7 @@ public class UserProfileController {
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
@Operation(summary = "列表查询用户档案", description = "列表查询用户档案。")
|
||||
@GetMapping("/list")
|
||||
public Result<List<UserProfileResponse>> getList(@Validated UserProfilePageRequest request) {
|
||||
List<UserProfileResponse> list = userProfileService.getProfileList(request);
|
||||
@@ -107,6 +114,7 @@ public class UserProfileController {
|
||||
* 将childhood、peak、valley数据迁移到生命事件表
|
||||
* 注意:此接口为一次性数据迁移接口,迁移完成后可删除
|
||||
*/
|
||||
@Operation(summary = "迁移生活事件", description = "将生活事件模块的数据迁移到用户档案中。")
|
||||
@PostMapping("/migrateLifeEvents")
|
||||
public Result<Integer> migrateLifeEvents() {
|
||||
int count = userProfileService.migrateLifeEventsFromProfiles();
|
||||
|
||||
@@ -8,6 +8,9 @@ import com.emotion.dto.request.UserStatsPageRequest;
|
||||
import com.emotion.dto.request.UserStatsUpdateValueRequest;
|
||||
import com.emotion.dto.response.UserStatsResponse;
|
||||
import com.emotion.service.UserStatsService;
|
||||
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.*;
|
||||
@@ -18,13 +21,14 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户统计控制器
|
||||
*
|
||||
*
|
||||
* @author huazhongmin
|
||||
* @date 2025-07-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/userStats")
|
||||
@Validated
|
||||
@Tag(name = "用户统计管理", description = "用户统计数据的查询、创建、更新、增量操作和重新计算接口")
|
||||
public class UserStatsController {
|
||||
|
||||
@Autowired
|
||||
@@ -33,6 +37,7 @@ public class UserStatsController {
|
||||
/**
|
||||
* 分页查询用户统计
|
||||
*/
|
||||
@Operation(summary = "分页查询用户统计", description = "分页查询用户统计数据。")
|
||||
@GetMapping(value = "/page")
|
||||
public Result<PageResult<UserStatsResponse>> getPage(@Validated UserStatsPageRequest request) {
|
||||
PageResult<UserStatsResponse> pageResult = userStatsService.getPageWithResponse(request);
|
||||
@@ -42,6 +47,7 @@ public class UserStatsController {
|
||||
/**
|
||||
* 创建或更新用户统计
|
||||
*/
|
||||
@Operation(summary = "创建或更新用户统计", description = "创建新用户统计数据或更新已有数据。")
|
||||
@PostMapping(value = "/createOrUpdate")
|
||||
public Result<UserStatsResponse> createOrUpdate(@Valid @RequestBody UserStatsCreateRequest request) {
|
||||
UserStatsResponse stats = userStatsService.createOrUpdateUserStatsWithResponse(request);
|
||||
@@ -51,6 +57,7 @@ public class UserStatsController {
|
||||
/**
|
||||
* 更新用户统计值
|
||||
*/
|
||||
@Operation(summary = "更新用户统计值", description = "直接更新指定统计项的值。")
|
||||
@PutMapping(value = "/updateStatsValue")
|
||||
public Result<Void> updateStatsValue(@Valid @RequestBody UserStatsUpdateValueRequest request) {
|
||||
boolean updated = userStatsService.updateStatsValue(request);
|
||||
@@ -63,6 +70,7 @@ public class UserStatsController {
|
||||
/**
|
||||
* 增加用户统计值
|
||||
*/
|
||||
@Operation(summary = "增加用户统计值", description = "对指定统计项进行增量累加操作。")
|
||||
@PutMapping(value = "/incrementStatsValue")
|
||||
public Result<Void> incrementStatsValue(@Valid @RequestBody UserStatsIncrementRequest request) {
|
||||
boolean updated = userStatsService.incrementStatsValue(request);
|
||||
@@ -75,8 +83,9 @@ public class UserStatsController {
|
||||
/**
|
||||
* 重新计算用户统计
|
||||
*/
|
||||
@Operation(summary = "重新计算用户统计", description = "基于原始数据重新计算用户的统计值。")
|
||||
@PutMapping(value = "/recalculateUserStats")
|
||||
public Result<Void> recalculateUserStats(@RequestParam String userId) {
|
||||
public Result<Void> recalculateUserStats(@Parameter(description = "用户 ID") @RequestParam String userId) {
|
||||
boolean recalculated = userStatsService.recalculateUserStats(userId);
|
||||
if (!recalculated) {
|
||||
return Result.error("重新计算失败");
|
||||
@@ -87,6 +96,7 @@ public class UserStatsController {
|
||||
/**
|
||||
* 重新计算所有用户统计
|
||||
*/
|
||||
@Operation(summary = "重新计算所有用户统计", description = "重新计算所有用户的统计值(管理员操作)。")
|
||||
@PutMapping(value = "/recalculateAll")
|
||||
public Result<Void> recalculateAllUserStats() {
|
||||
boolean recalculated = userStatsService.recalculateAllUserStats();
|
||||
@@ -99,8 +109,9 @@ public class UserStatsController {
|
||||
/**
|
||||
* 删除过期的统计数据
|
||||
*/
|
||||
@Operation(summary = "删除过期统计数据", description = "清理超过指定天数的过期统计数据。")
|
||||
@DeleteMapping(value = "/deleteExpired")
|
||||
public Result<Void> deleteExpiredStats(@RequestParam(defaultValue = "30") Integer days) {
|
||||
public Result<Void> deleteExpiredStats(@Parameter(description = "过期天数阈值") @RequestParam(defaultValue = "30") Integer days) {
|
||||
boolean deleted = userStatsService.deleteExpiredStats(days);
|
||||
if (!deleted) {
|
||||
return Result.error("删除失败");
|
||||
|
||||
+2
@@ -11,7 +11,9 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class AnalyticsPreferenceItem {
|
||||
private String dimension;
|
||||
private String dimensionLabel;
|
||||
private String value;
|
||||
private String valueLabel;
|
||||
private long count;
|
||||
private long users;
|
||||
}
|
||||
|
||||
+6
@@ -11,7 +11,13 @@ import lombok.NoArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public class AnalyticsTopEventItem {
|
||||
private String eventName;
|
||||
private String eventLabel;
|
||||
private String eventType;
|
||||
private String eventTypeLabel;
|
||||
private String pagePath;
|
||||
private String pageLabel;
|
||||
private String apiPath;
|
||||
private String apiLabel;
|
||||
private long count;
|
||||
private long users;
|
||||
}
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ import lombok.NoArgsConstructor;
|
||||
public class AnalyticsTrendItem {
|
||||
private String bucket;
|
||||
private String eventName;
|
||||
private String eventLabel;
|
||||
private long count;
|
||||
private long users;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user