From 5e492e5d5a2b743e2e99443220d343f72a633f6d Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 03 三月 2026 16:57:52 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/ai/controller/LlmCallLogController.java |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/zy/ai/controller/LlmCallLogController.java b/src/main/java/com/zy/ai/controller/LlmCallLogController.java
new file mode 100644
index 0000000..20670cb
--- /dev/null
+++ b/src/main/java/com/zy/ai/controller/LlmCallLogController.java
@@ -0,0 +1,65 @@
+package com.zy.ai.controller;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.core.annotations.ManagerAuth;
+import com.core.common.R;
+import com.zy.ai.entity.LlmCallLog;
+import com.zy.ai.service.LlmCallLogService;
+import com.zy.common.web.BaseController;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/ai/llm/log")
+@RequiredArgsConstructor
+public class LlmCallLogController extends BaseController {
+
+    private final LlmCallLogService llmCallLogService;
+
+    @GetMapping("/list/auth")
+    @ManagerAuth
+    public R list(@RequestParam(defaultValue = "1") Integer curr,
+                  @RequestParam(defaultValue = "20") Integer limit,
+                  @RequestParam(required = false) String scene,
+                  @RequestParam(required = false) Integer success,
+                  @RequestParam(required = false) Long routeId,
+                  @RequestParam(required = false) String traceId) {
+        EntityWrapper<LlmCallLog> wrapper = new EntityWrapper<>();
+        if (!isBlank(scene)) {
+            wrapper.eq("scene", scene.trim());
+        }
+        if (success != null) {
+            wrapper.eq("success", success);
+        }
+        if (routeId != null) {
+            wrapper.eq("route_id", routeId);
+        }
+        if (!isBlank(traceId)) {
+            wrapper.eq("trace_id", traceId.trim());
+        }
+        wrapper.orderBy("id", false);
+        return R.ok(llmCallLogService.selectPage(new Page<>(curr, limit), wrapper));
+    }
+
+    @PostMapping("/delete/auth")
+    @ManagerAuth
+    public R delete(@RequestParam("id") Long id) {
+        if (id == null) {
+            return R.error("id涓嶈兘涓虹┖");
+        }
+        llmCallLogService.deleteById(id);
+        return R.ok();
+    }
+
+    @PostMapping("/clear/auth")
+    @ManagerAuth
+    public R clear() {
+        llmCallLogService.delete(new EntityWrapper<LlmCallLog>());
+        return R.ok();
+    }
+
+    private boolean isBlank(String s) {
+        return s == null || s.trim().isEmpty();
+    }
+}

--
Gitblit v1.9.1