Fix Bug #571: fallback修复
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.openhis.web.outpatient.controller;
|
||||
|
||||
import com.openhis.web.outpatient.service.impl.LabApplyServiceImpl;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 检验申请(实验室)控制层
|
||||
*
|
||||
* 修复 Bug #571:为撤回接口返回统一的成功/错误结构,并捕获业务异常以返回前端可读的错误信息。
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/lab-apply")
|
||||
public class LabApplyController {
|
||||
|
||||
private final LabApplyServiceImpl labApplyService;
|
||||
|
||||
public LabApplyController(LabApplyServiceImpl labApplyService) {
|
||||
this.labApplyService = labApplyService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 撤回检验申请
|
||||
*
|
||||
* @param applyId 检验申请 ID
|
||||
* @return {code:0, msg:"撤回成功"} 或 {code:1, msg:"错误信息"}
|
||||
*/
|
||||
@PostMapping("/withdraw")
|
||||
public Map<String, Object> withdraw(@RequestParam Long applyId) {
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
try {
|
||||
labApplyService.withdrawApply(applyId);
|
||||
resp.put("code", 0);
|
||||
resp.put("msg", "撤回成功");
|
||||
} catch (RuntimeException ex) {
|
||||
resp.put("code", 1);
|
||||
resp.put("msg", ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
resp.put("code", 1);
|
||||
resp.put("msg", "系统异常,请联系管理员");
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
// 其他接口保持不变
|
||||
}
|
||||
Reference in New Issue
Block a user