From ad65726388fc99ff95db91b4a8a716362cccedd7 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期一, 25 五月 2026 04:32:19 +0800
Subject: [PATCH] feat: 操纵添加LOG注解记录日志

---
 src/main/java/com/ruoyi/ai/controller/XiaozhiController.java |   39 ++++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/ruoyi/ai/controller/XiaozhiController.java b/src/main/java/com/ruoyi/ai/controller/XiaozhiController.java
index 668dd31..7b8ea1c 100644
--- a/src/main/java/com/ruoyi/ai/controller/XiaozhiController.java
+++ b/src/main/java/com/ruoyi/ai/controller/XiaozhiController.java
@@ -10,18 +10,30 @@
 import com.ruoyi.ai.store.MongoChatMemoryStore;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.framework.security.LoginUser;
 import com.ruoyi.framework.web.controller.BaseController;
-import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.framework.web.domain.AjaxResult;
 import dev.langchain4j.data.message.AiMessage;
 import dev.langchain4j.data.message.UserMessage;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import reactor.core.publisher.Flux;
 
 import java.io.IOException;
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.UUID;
@@ -32,6 +44,8 @@
 public class XiaozhiController extends BaseController {
 
     private static final String FILE_ANALYZE_MEMORY_PREFIX = "file-analyze::";
+    private static final DateTimeFormatter CURRENT_DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+    private static final ZoneId CHINA_ZONE_ID = ZoneId.of("Asia/Shanghai");
 
     private final ApproveTodoAgent approveTodoAgent;
     private final ApproveTodoIntentExecutor approveTodoIntentExecutor;
@@ -58,6 +72,7 @@
     }
 
     @Operation(summary = "瀵硅瘽")
+    @Log(title = "鍗忓悓鍔炲叕鍔╂墜瀵硅瘽", businessType = BusinessType.OTHER)
     @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
     public Flux<String> chat(@RequestBody ChatForm chatForm) {
         if (!StringUtils.hasText(chatForm.getMemoryId())) {
@@ -93,12 +108,13 @@
             return Flux.just(noGuessResponse);
         }
 
-        return approveTodoAgent.chat(memoryId, userMessage)
+        return approveTodoAgent.chat(memoryId, userMessage, currentDateForPrompt())
                 .doOnComplete(() -> aiChatSessionService.refreshSessionStats(memoryId, loginUser))
                 .doOnError(ex -> aiChatSessionService.refreshSessionStats(memoryId, loginUser));
     }
 
     @Operation(summary = "涓婁紶鏂囦欢鍒嗘瀽")
+    @Log(title = "涓婁紶鏂囦欢鍒嗘瀽", businessType = BusinessType.OTHER)
     @PostMapping(value = "/analyze-file", consumes = "multipart/form-data", produces = "text/stream;charset=utf-8")
     public Flux<String> analyzeFile(@RequestParam("file") MultipartFile file,
                                     @RequestParam(value = "message", required = false) String message,
@@ -146,21 +162,22 @@
 
     @Operation(summary = "浼氳瘽鍒楄〃")
     @GetMapping("/history/sessions")
-    public R listSessions() {
-        return R.ok(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser()));
+    public AjaxResult listSessions() {
+        return success(aiChatSessionService.listCurrentUserSessions(SecurityUtils.getLoginUser()));
     }
 
     @Operation(summary = "浼氳瘽娑堟伅")
     @GetMapping("/history/messages/{memoryId}")
-    public R listMessages(@PathVariable String memoryId) {
-        return R.ok(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser()));
+    public AjaxResult listMessages(@PathVariable String memoryId) {
+        return success(aiChatSessionService.listCurrentUserMessages(memoryId, SecurityUtils.getLoginUser()));
     }
 
     @Operation(summary = "鍒犻櫎浼氳瘽")
+    @Log(title = "鍒犻櫎鍗忓悓鍔炲叕鍔╂墜浼氳瘽", businessType = BusinessType.DELETE)
     @DeleteMapping("/history/{memoryId}")
-    public R deleteSession(@PathVariable String memoryId) {
+    public AjaxResult deleteSession(@PathVariable String memoryId) {
         aiSessionUserContext.remove(memoryId);
-        return R.ok(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser()));
+        return toAjax(aiChatSessionService.deleteCurrentUserSession(memoryId, SecurityUtils.getLoginUser()));
     }
 
     private boolean isApproveTodoBusinessIntent(String message) {
@@ -183,4 +200,8 @@
         }
         return false;
     }
+
+    private String currentDateForPrompt() {
+        return LocalDate.now(CHINA_ZONE_ID).format(CURRENT_DATE_FMT);
+    }
 }

--
Gitblit v1.9.3