Add validate CMA API
This commit is contained in:
parent
f61e06b49b
commit
1107ab18cc
|
|
@ -17,5 +17,5 @@
|
|||
| 11 | POST | `/api/reports/{id}/submit` | 用户确认提交 | `src/api/report.js` | ✅ 已修正 | OCR 通过后将状态置为 `pending` 并记录历史 |
|
||||
| 12 | POST | `/api/reports/{id}/audit` | 审核提交 | `src/api/report.js` | ✅ 已修正 | 支持 `status/opinion/files`,保存附件并记录历史 |
|
||||
| 13 | DELETE | `/api/reports/{id}` | 删除报告 | `src/api/report.js` | ✅ 已修正 | 删除任务并清理 pdf/预览/附件目录 |
|
||||
| 14 | POST | `/api/validate-cma` | CMA 校验 | `src/api/report.js` | | |
|
||||
| 14 | POST | `/api/validate-cma` | CMA 校验 | `src/api/report.js` | ✅ 已修正 | 返回 `{valid, cma_number, institution}` |
|
||||
| 15 | GET | `/api/reports/{id}/pdf` | PDF 预览 | `src/views/shibieneirong/shenhe/index.vue` | | |
|
||||
|
|
|
|||
|
|
@ -6,4 +6,6 @@ import java.util.Optional;
|
|||
|
||||
public interface InstitutionRepository extends JpaRepository<Institution, Long> {
|
||||
Optional<Institution> findByName(String name);
|
||||
|
||||
Optional<Institution> findByCmaNumber(String cmaNumber);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.chinaweal.youfool.reportdetect.modules.task.controller;
|
|||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.chinaweal.youfool.reportdetect.modules.sys.repository.InstitutionRepository;
|
||||
import com.chinaweal.youfool.reportdetect.modules.sys.service.SysUserService;
|
||||
import com.chinaweal.youfool.reportdetect.modules.task.entity.Task;
|
||||
import com.chinaweal.youfool.reportdetect.modules.task.service.TaskService;
|
||||
|
|
@ -31,6 +32,9 @@ public class TaskController {
|
|||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private InstitutionRepository institutionRepository;
|
||||
|
||||
@PostMapping("/login")
|
||||
public ResponseEntity<?> login(@RequestBody Map<String, String> creds) {
|
||||
String username = creds.get("username");
|
||||
|
|
@ -253,6 +257,39 @@ public class TaskController {
|
|||
}
|
||||
}
|
||||
|
||||
@PostMapping("/validate-cma")
|
||||
public ResponseEntity<?> validateCma(@RequestBody Map<String, String> payload) {
|
||||
String cmaNumber = payload.get("cma_number");
|
||||
String institution = payload.get("institution");
|
||||
if (cmaNumber == null || cmaNumber.isBlank()) {
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 1);
|
||||
resp.put("msg", "cma_number is required");
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(resp);
|
||||
}
|
||||
|
||||
com.chinaweal.youfool.reportdetect.modules.sys.entity.Institution inst = null;
|
||||
boolean valid;
|
||||
if (institution != null && !institution.isBlank()) {
|
||||
inst = institutionRepository.findByName(institution).orElse(null);
|
||||
valid = inst != null && cmaNumber.equals(inst.getCmaNumber());
|
||||
} else {
|
||||
inst = institutionRepository.findByCmaNumber(cmaNumber).orElse(null);
|
||||
valid = inst != null;
|
||||
}
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("valid", valid);
|
||||
data.put("cma_number", cmaNumber);
|
||||
data.put("institution", inst != null ? inst.getName() : null);
|
||||
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
resp.put("code", 0);
|
||||
resp.put("data", data);
|
||||
resp.put("msg", "Success");
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
@GetMapping("/statistics")
|
||||
@SaCheckRole(value = { "ADMIN", "AUDITOR", "USER" }, mode = SaMode.OR)
|
||||
public ResponseEntity<?> getStatistics() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue