Files
his/com/openhis/web/outpatient/controller/LabApplyController.java
2026-05-27 01:07:06 +08:00

49 lines
1.4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
// 其他接口保持不变
}