刘光辉
5 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package jnpf.elnController;
 
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.elnEntity.ElnDocumentFileVo;
import jnpf.elnService.ElnTemplateFileQueryService;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@Tag(name = "ELN电子记录模板")
@RestController
@RequestMapping("/dianzi_jilu_muban")
@RequiredArgsConstructor
public class ElnTemplateFileController {
 
    private final ElnTemplateFileQueryService templateFileQueryService;
 
    @Operation(summary = "按检验项目查询模板文件")
    @GetMapping("/file")
    public ActionResult<ElnDocumentFileVo> file(
            @RequestParam(value = "jianyan_xiangmu", required = false) String jianyanXiangmu,
            @RequestParam(value = "jianyan_xiangmu_bianma", required = false)
            String jianyanXiangmuBianma) {
        boolean hasId = StringUtils.hasText(jianyanXiangmu);
        boolean hasCode = StringUtils.hasText(jianyanXiangmuBianma);
        if (!hasId && !hasCode) {
            return ActionResult.fail("检验项目 ID 或编码不能为空");
        }
        if (hasId && hasCode) {
            return ActionResult.fail("检验项目 ID 与编码只能传一个");
        }
        return ActionResult.success(templateFileQueryService.getFile(
                hasId ? jianyanXiangmu.trim() : null,
                hasCode ? jianyanXiangmuBianma.trim() : null));
    }
}