|
|
|
package org.jeecg.modules.airag.app.controller;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
import org.jeecg.modules.airag.app.entity.AiragLog;
|
|
|
|
import org.jeecg.modules.airag.app.service.IAiragLogService;
|
|
|
|
import org.jeecg.modules.airag.llm.entity.AiragModel;
|
|
|
|
import org.jeecg.modules.airag.llm.service.IAiragModelService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Description: 日志管理
|
|
|
|
* @Author: jeecg-boot
|
|
|
|
* @Date: 2025-06-10
|
|
|
|
* @Version: V1.0
|
|
|
|
*/
|
|
|
|
@Tag(name="日志管理")
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/airaglog/airagLog")
|
|
|
|
@Slf4j
|
|
|
|
public class AiragLogController extends JeecgController<AiragLog, IAiragLogService> {
|
|
|
|
@Autowired
|
|
|
|
private IAiragLogService airagLogService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IAiragModelService airagModelService;
|
|
|
|
/**
|
|
|
|
* 分页列表查询
|
|
|
|
*
|
|
|
|
* @param airagLog
|
|
|
|
* @param pageNo
|
|
|
|
* @param pageSize
|
|
|
|
* @param req
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "日志管理-分页列表查询")
|
|
|
|
@Operation(summary="日志管理-分页列表查询")
|
|
|
|
@GetMapping(value = "/list")
|
|
|
|
public Result<IPage<AiragLog>> queryPageList(AiragLog airagLog,
|
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
|
HttpServletRequest req) {
|
|
|
|
QueryWrapper<AiragLog> queryWrapper = QueryGenerator.initQueryWrapper(airagLog, req.getParameterMap());
|
|
|
|
Page<AiragLog> page = new Page<AiragLog>(pageNo, pageSize);
|
|
|
|
IPage<AiragLog> pageList = airagLogService.page(page, queryWrapper);
|
|
|
|
List<AiragModel> list = airagModelService.list();
|
|
|
|
Map<String,String> nameMap = new HashMap<String,String>();
|
|
|
|
for(AiragModel airagModel : list){
|
|
|
|
nameMap.put(airagModel.getId(), airagModel.getName());
|
|
|
|
}
|
|
|
|
for (AiragLog log : pageList.getRecords()) {
|
|
|
|
String modelId = log.getModelId(); // 获取当前日志的 model_id
|
|
|
|
log.setName(nameMap.get(modelId)); // 从 nameMap 中匹配 name
|
|
|
|
}
|
|
|
|
return Result.OK(pageList);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加
|
|
|
|
*
|
|
|
|
* @param airagLog
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "日志管理-添加")
|
|
|
|
@Operation(summary="日志管理-添加")
|
|
|
|
@RequiresPermissions("airaglog:airag_log:add")
|
|
|
|
@PostMapping(value = "/add")
|
|
|
|
public Result<String> add(@RequestBody AiragLog airagLog) {
|
|
|
|
airagLogService.save(airagLog);
|
|
|
|
return Result.OK("添加成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 添加到知识库
|
|
|
|
*
|
|
|
|
* @param airagLog
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "日志管理-存入问题库")
|
|
|
|
@Operation(summary = "日志管理-存入问题库")
|
|
|
|
@RequiresPermissions("airaglog:airag_log:saveToQuestionLibrary")
|
|
|
|
@PostMapping(value = "/saveToQuestionLibrary")
|
|
|
|
public Result<String> saveToQuestionLibrary(@RequestBody AiragLog airagLog) {
|
|
|
|
airagLogService.saveToQuestionLibrary(airagLog);
|
|
|
|
return Result.OK("存入问题库成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 编辑
|
|
|
|
*
|
|
|
|
* @param airagLog
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "日志管理-编辑")
|
|
|
|
@Operation(summary="日志管理-编辑")
|
|
|
|
@RequiresPermissions("airaglog:airag_log:edit")
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
|
public Result<String> edit(@RequestBody AiragLog airagLog) {
|
|
|
|
airagLogService.updateById(airagLog);
|
|
|
|
return Result.OK("编辑成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id删除
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "日志管理-通过id删除")
|
|
|
|
@Operation(summary="日志管理-通过id删除")
|
|
|
|
@RequiresPermissions("airaglog:airag_log:delete")
|
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
|
airagLogService.removeById(id);
|
|
|
|
return Result.OK("删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 批量删除
|
|
|
|
*
|
|
|
|
* @param ids
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@AutoLog(value = "日志管理-批量删除")
|
|
|
|
@Operation(summary="日志管理-批量删除")
|
|
|
|
@RequiresPermissions("airaglog:airag_log:deleteBatch")
|
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
|
this.airagLogService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
|
return Result.OK("批量删除成功!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过id查询
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
//@AutoLog(value = "日志管理-通过id查询")
|
|
|
|
@Operation(summary="日志管理-通过id查询")
|
|
|
|
@GetMapping(value = "/queryById")
|
|
|
|
public Result<AiragLog> queryById(@RequestParam(name="id",required=true) String id) {
|
|
|
|
AiragLog airagLog = airagLogService.getById(id);
|
|
|
|
if(airagLog==null) {
|
|
|
|
return Result.error("未找到对应数据");
|
|
|
|
}
|
|
|
|
return Result.OK(airagLog);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 导出excel
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param airagLog
|
|
|
|
*/
|
|
|
|
@RequiresPermissions("airaglog:airag_log:exportXls")
|
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
|
public ModelAndView exportXls(HttpServletRequest request, AiragLog airagLog) {
|
|
|
|
return super.exportXls(request, airagLog, AiragLog.class, "日志管理");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过excel导入数据
|
|
|
|
*
|
|
|
|
* @param request
|
|
|
|
* @param response
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@RequiresPermissions("airaglog:airag_log:importExcel")
|
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
return super.importExcel(request, response, AiragLog.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|