package cn.huge.module.aidata.controller;
|
|
import cn.huge.module.aidata.domain.po.AiCaseRisk;
|
import cn.huge.module.aidata.service.AiCaseRiskService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.Sort;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 案件风险评估 控制器
|
*/
|
@Slf4j
|
@RestController
|
@RequestMapping("/api/aidata/risk")
|
public class AiCaseRiskController {
|
|
@Autowired
|
private AiCaseRiskService aiCaseRiskService;
|
|
/**
|
* 分页查询案件风险评估列表
|
*/
|
@GetMapping("/list")
|
public Page<AiCaseRisk> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
@RequestParam(value = "caseId", required = false) String caseId) {
|
Map<String, Object> terms = new HashMap<>();
|
if (caseId != null) {
|
terms.put("caseId", caseId);
|
}
|
return aiCaseRiskService.pageQuery(
|
PageRequest.of(pageNum - 1, pageSize, Sort.by(Sort.Direction.DESC, "createTime")),
|
terms
|
);
|
}
|
|
/**
|
* 获取案件风险评估详细信息
|
*/
|
@GetMapping("/{id}")
|
public AiCaseRisk getInfo(@PathVariable String id) {
|
return aiCaseRiskService.getById(id);
|
}
|
|
/**
|
* 新增案件风险评估
|
*/
|
@PostMapping
|
public void add(@RequestBody AiCaseRisk aiCaseRisk) {
|
aiCaseRiskService.saveAiCaseRisk(aiCaseRisk);
|
}
|
|
/**
|
* 修改案件风险评估
|
*/
|
@PutMapping
|
public void edit(@RequestBody AiCaseRisk aiCaseRisk) {
|
aiCaseRiskService.saveAiCaseRisk(aiCaseRisk);
|
}
|
|
/**
|
* 删除案件风险评估
|
*/
|
@DeleteMapping("/{id}")
|
public void remove(@PathVariable String id) {
|
aiCaseRiskService.deleteAiCaseRisk(id);
|
}
|
|
/**
|
* 查询案件风险评估列表
|
*/
|
@GetMapping("/query")
|
public List<AiCaseRisk> query(@RequestParam(required = false) String caseId) {
|
Map<String, Object> terms = new HashMap<>();
|
if (caseId != null) {
|
terms.put("caseId", caseId);
|
}
|
return aiCaseRiskService.listTerms(terms);
|
}
|
|
/**
|
* 根据条件检查案件风险评估
|
* @param risk 包含查询条件的对象
|
* @return 符合条件的案件风险评估列表
|
*/
|
@PostMapping("/check")
|
public List<AiCaseRisk> checkRisks(@RequestBody AiCaseRisk risk) {
|
List<AiCaseRisk> result = aiCaseRiskService.findByConditions(risk);
|
if (result.isEmpty()) {
|
log.info("未找到匹配的案件风险评估记录, 查询条件: {}", risk);
|
}
|
return result;
|
}
|
}
|