刘光辉
4 小时以前 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
package jnpf.controller;
 
import cn.dev33.satoken.same.SaSameUtil;
import jakarta.validation.Valid;
import jnpf.base.ActionResult;
import jnpf.exception.DataException;
import jnpf.fileStorage.dms.FileContentImportService;
import jnpf.model.filecontent.FileContentImportForm;
import jnpf.model.filecontent.FileContentReceipt;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/Internal/file-content")
@RequiredArgsConstructor
public class FileContentController {
    private final FileContentImportService imports;
 
    @PostMapping("/same-content")
    public ActionResult<Boolean> sameContent(@RequestHeader("X-DMS-Service-Id") String serviceId,
            @RequestBody jnpf.model.filecontent.FileContentComparisonForm form) {
        SaSameUtil.checkCurrentRequestToken();
        if (!"jnpf-dms".equals(serviceId)) throw new DataException("文件内容校验调用来源无效");
        return ActionResult.success(imports.sameContent(form));
    }
 
    @PostMapping("/imports")
    public ActionResult<FileContentReceipt> importContent(
            @RequestHeader("X-DMS-Service-Id") String serviceId,
            @RequestBody @Valid FileContentImportForm form) {
        SaSameUtil.checkCurrentRequestToken();
        if (!"jnpf-dms".equals(serviceId)) throw new DataException("物理文件导入调用来源无效");
        return ActionResult.success(imports.importContent(form));
    }
}