刘光辉
13 小时以前 34981c30a78e8bbd7791131059a9210f9928b62c
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package jnpf.controller;
 
import jnpf.base.ActionResult;
import jnpf.dmsEntity.storage.vo.DmsFileUploadVO;
import jnpf.fileStorage.dms.DmsFileStorageService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
 
import java.time.LocalDate;
import java.util.UUID;
 
@RestController
@RequestMapping("/Dms")
@RequiredArgsConstructor
public class DmsFileUploadController {
    private final DmsFileStorageService fileStorageService;
 
    @PostMapping(value = "/Uploader", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ActionResult<DmsFileUploadVO> upload(@RequestParam("folderId") UUID folderId,
                                                @RequestParam("sourceId") String sourceId,
                                                @RequestParam("documentNo") String documentNo,
                                                @RequestParam("documentName") String documentName,
                                                @RequestParam("documentType") String documentType,
                                                @RequestParam("responsibleDeptId") String responsibleDeptId,
                                                @RequestParam("versionLabel") String versionLabel,
                                                @RequestParam("preparedBy") String preparedBy,
                                                @RequestParam("preparedOn")
                                                @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
                                                LocalDate preparedOn,
                                                @RequestPart("file") MultipartFile file) {
        return ActionResult.success(fileStorageService.upload(folderId, sourceId, documentNo,
                documentName, documentType, responsibleDeptId, versionLabel, preparedBy,
                preparedOn, file));
    }
 
    @PostMapping(value = "/Revisions", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public ActionResult<DmsFileUploadVO> revise(
            @RequestParam("documentId") UUID documentId,
            @RequestParam("baseFileVersionId") UUID baseFileVersionId,
            @RequestParam("sourceId") String sourceId,
            @RequestParam("versionLabel") String versionLabel,
            @RequestParam("preparedBy") String preparedBy,
            @RequestParam("preparedOn")
            @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate preparedOn,
            @RequestParam("revisionReason") String revisionReason,
            @RequestPart("file") MultipartFile file) {
        return ActionResult.success(fileStorageService.revise(documentId, baseFileVersionId,
                sourceId, versionLabel, preparedBy, preparedOn, revisionReason, file));
    }
}