|
|
|
1
|
+package org.jeecg.modules.airag.app.controller;
|
|
|
|
2
|
+
|
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
4
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
5
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
6
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
7
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
8
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
9
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
10
|
+import org.jeecg.common.api.vo.Result;
|
|
|
|
11
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
12
|
+import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
|
13
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
14
|
+import org.jeecg.modules.airag.app.entity.AiragLog;
|
|
|
|
15
|
+import org.jeecg.modules.airag.app.service.IAiragLogService;
|
|
|
|
16
|
+import org.jeecg.modules.airag.llm.entity.AiragModel;
|
|
|
|
17
|
+import org.jeecg.modules.airag.llm.service.IAiragModelService;
|
|
|
|
18
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
19
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
20
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
|
21
|
+
|
|
|
|
22
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
23
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
24
|
+import java.util.Arrays;
|
|
|
|
25
|
+import java.util.HashMap;
|
|
|
|
26
|
+import java.util.List;
|
|
|
|
27
|
+import java.util.Map;
|
|
|
|
28
|
+
|
|
|
|
29
|
+/**
|
|
|
|
30
|
+* @Description: 日志管理
|
|
|
|
31
|
+* @Author: jeecg-boot
|
|
|
|
32
|
+* @Date: 2025-06-10
|
|
|
|
33
|
+* @Version: V1.0
|
|
|
|
34
|
+*/
|
|
|
|
35
|
+@Tag(name="日志管理")
|
|
|
|
36
|
+@RestController
|
|
|
|
37
|
+@RequestMapping("/airaglog/airagLog")
|
|
|
|
38
|
+@Slf4j
|
|
|
|
39
|
+public class AiragLogController extends JeecgController<AiragLog, IAiragLogService> {
|
|
|
|
40
|
+ @Autowired
|
|
|
|
41
|
+ private IAiragLogService airagLogService;
|
|
|
|
42
|
+
|
|
|
|
43
|
+ @Autowired
|
|
|
|
44
|
+ private IAiragModelService airagModelService;
|
|
|
|
45
|
+ /**
|
|
|
|
46
|
+ * 分页列表查询
|
|
|
|
47
|
+ *
|
|
|
|
48
|
+ * @param airagLog
|
|
|
|
49
|
+ * @param pageNo
|
|
|
|
50
|
+ * @param pageSize
|
|
|
|
51
|
+ * @param req
|
|
|
|
52
|
+ * @return
|
|
|
|
53
|
+ */
|
|
|
|
54
|
+ //@AutoLog(value = "日志管理-分页列表查询")
|
|
|
|
55
|
+ @Operation(summary="日志管理-分页列表查询")
|
|
|
|
56
|
+ @GetMapping(value = "/list")
|
|
|
|
57
|
+ public Result<IPage<AiragLog>> queryPageList(AiragLog airagLog,
|
|
|
|
58
|
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
59
|
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
60
|
+ HttpServletRequest req) {
|
|
|
|
61
|
+ QueryWrapper<AiragLog> queryWrapper = QueryGenerator.initQueryWrapper(airagLog, req.getParameterMap());
|
|
|
|
62
|
+ Page<AiragLog> page = new Page<AiragLog>(pageNo, pageSize);
|
|
|
|
63
|
+ IPage<AiragLog> pageList = airagLogService.page(page, queryWrapper);
|
|
|
|
64
|
+ List<AiragModel> list = airagModelService.list();
|
|
|
|
65
|
+ Map<String,String> nameMap = new HashMap<String,String>();
|
|
|
|
66
|
+ for(AiragModel airagModel : list){
|
|
|
|
67
|
+ nameMap.put(airagModel.getId(), airagModel.getName());
|
|
|
|
68
|
+ }
|
|
|
|
69
|
+ for (AiragLog log : pageList.getRecords()) {
|
|
|
|
70
|
+ String modelId = log.getModelId(); // 获取当前日志的 model_id
|
|
|
|
71
|
+ log.setName(nameMap.get(modelId)); // 从 nameMap 中匹配 name
|
|
|
|
72
|
+ }
|
|
|
|
73
|
+ return Result.OK(pageList);
|
|
|
|
74
|
+ }
|
|
|
|
75
|
+
|
|
|
|
76
|
+ /**
|
|
|
|
77
|
+ * 添加
|
|
|
|
78
|
+ *
|
|
|
|
79
|
+ * @param airagLog
|
|
|
|
80
|
+ * @return
|
|
|
|
81
|
+ */
|
|
|
|
82
|
+ @AutoLog(value = "日志管理-添加")
|
|
|
|
83
|
+ @Operation(summary="日志管理-添加")
|
|
|
|
84
|
+ @RequiresPermissions("airaglog:airag_log:add")
|
|
|
|
85
|
+ @PostMapping(value = "/add")
|
|
|
|
86
|
+ public Result<String> add(@RequestBody AiragLog airagLog) {
|
|
|
|
87
|
+ airagLogService.save(airagLog);
|
|
|
|
88
|
+ return Result.OK("添加成功!");
|
|
|
|
89
|
+ }
|
|
|
|
90
|
+
|
|
|
|
91
|
+
|
|
|
|
92
|
+ /**
|
|
|
|
93
|
+ * 添加到知识库
|
|
|
|
94
|
+ *
|
|
|
|
95
|
+ * @param airagLog
|
|
|
|
96
|
+ * @return
|
|
|
|
97
|
+ */
|
|
|
|
98
|
+ @AutoLog(value = "日志管理-存入问题库")
|
|
|
|
99
|
+ @Operation(summary = "日志管理-存入问题库")
|
|
|
|
100
|
+ @RequiresPermissions("airaglog:airag_log:saveToQuestionLibrary")
|
|
|
|
101
|
+ @PostMapping(value = "/saveToQuestionLibrary")
|
|
|
|
102
|
+ public Result<String> saveToQuestionLibrary(@RequestBody AiragLog airagLog) {
|
|
|
|
103
|
+ airagLogService.saveToQuestionLibrary(airagLog);
|
|
|
|
104
|
+ return Result.OK("存入问题库成功!");
|
|
|
|
105
|
+ }
|
|
|
|
106
|
+
|
|
|
|
107
|
+ /**
|
|
|
|
108
|
+ * 编辑
|
|
|
|
109
|
+ *
|
|
|
|
110
|
+ * @param airagLog
|
|
|
|
111
|
+ * @return
|
|
|
|
112
|
+ */
|
|
|
|
113
|
+ @AutoLog(value = "日志管理-编辑")
|
|
|
|
114
|
+ @Operation(summary="日志管理-编辑")
|
|
|
|
115
|
+ @RequiresPermissions("airaglog:airag_log:edit")
|
|
|
|
116
|
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
|
117
|
+ public Result<String> edit(@RequestBody AiragLog airagLog) {
|
|
|
|
118
|
+ airagLogService.updateById(airagLog);
|
|
|
|
119
|
+ return Result.OK("编辑成功!");
|
|
|
|
120
|
+ }
|
|
|
|
121
|
+
|
|
|
|
122
|
+ /**
|
|
|
|
123
|
+ * 通过id删除
|
|
|
|
124
|
+ *
|
|
|
|
125
|
+ * @param id
|
|
|
|
126
|
+ * @return
|
|
|
|
127
|
+ */
|
|
|
|
128
|
+ @AutoLog(value = "日志管理-通过id删除")
|
|
|
|
129
|
+ @Operation(summary="日志管理-通过id删除")
|
|
|
|
130
|
+ @RequiresPermissions("airaglog:airag_log:delete")
|
|
|
|
131
|
+ @DeleteMapping(value = "/delete")
|
|
|
|
132
|
+ public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
|
133
|
+ airagLogService.removeById(id);
|
|
|
|
134
|
+ return Result.OK("删除成功!");
|
|
|
|
135
|
+ }
|
|
|
|
136
|
+
|
|
|
|
137
|
+ /**
|
|
|
|
138
|
+ * 批量删除
|
|
|
|
139
|
+ *
|
|
|
|
140
|
+ * @param ids
|
|
|
|
141
|
+ * @return
|
|
|
|
142
|
+ */
|
|
|
|
143
|
+ @AutoLog(value = "日志管理-批量删除")
|
|
|
|
144
|
+ @Operation(summary="日志管理-批量删除")
|
|
|
|
145
|
+ @RequiresPermissions("airaglog:airag_log:deleteBatch")
|
|
|
|
146
|
+ @DeleteMapping(value = "/deleteBatch")
|
|
|
|
147
|
+ public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
|
148
|
+ this.airagLogService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
|
149
|
+ return Result.OK("批量删除成功!");
|
|
|
|
150
|
+ }
|
|
|
|
151
|
+
|
|
|
|
152
|
+ /**
|
|
|
|
153
|
+ * 通过id查询
|
|
|
|
154
|
+ *
|
|
|
|
155
|
+ * @param id
|
|
|
|
156
|
+ * @return
|
|
|
|
157
|
+ */
|
|
|
|
158
|
+ //@AutoLog(value = "日志管理-通过id查询")
|
|
|
|
159
|
+ @Operation(summary="日志管理-通过id查询")
|
|
|
|
160
|
+ @GetMapping(value = "/queryById")
|
|
|
|
161
|
+ public Result<AiragLog> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
|
162
|
+ AiragLog airagLog = airagLogService.getById(id);
|
|
|
|
163
|
+ if(airagLog==null) {
|
|
|
|
164
|
+ return Result.error("未找到对应数据");
|
|
|
|
165
|
+ }
|
|
|
|
166
|
+ return Result.OK(airagLog);
|
|
|
|
167
|
+ }
|
|
|
|
168
|
+
|
|
|
|
169
|
+ /**
|
|
|
|
170
|
+ * 导出excel
|
|
|
|
171
|
+ *
|
|
|
|
172
|
+ * @param request
|
|
|
|
173
|
+ * @param airagLog
|
|
|
|
174
|
+ */
|
|
|
|
175
|
+ @RequiresPermissions("airaglog:airag_log:exportXls")
|
|
|
|
176
|
+ @RequestMapping(value = "/exportXls")
|
|
|
|
177
|
+ public ModelAndView exportXls(HttpServletRequest request, AiragLog airagLog) {
|
|
|
|
178
|
+ return super.exportXls(request, airagLog, AiragLog.class, "日志管理");
|
|
|
|
179
|
+ }
|
|
|
|
180
|
+
|
|
|
|
181
|
+ /**
|
|
|
|
182
|
+ * 通过excel导入数据
|
|
|
|
183
|
+ *
|
|
|
|
184
|
+ * @param request
|
|
|
|
185
|
+ * @param response
|
|
|
|
186
|
+ * @return
|
|
|
|
187
|
+ */
|
|
|
|
188
|
+ @RequiresPermissions("airaglog:airag_log:importExcel")
|
|
|
|
189
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
|
190
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
191
|
+ return super.importExcel(request, response, AiragLog.class);
|
|
|
|
192
|
+ }
|
|
|
|
193
|
+
|
|
|
|
194
|
+} |