刘光辉
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
package jnpf.bizcommon.onlyoffice.controller;
 
import jakarta.validation.Valid;
import jnpf.bizcommon.onlyoffice.entity.DmsPrintRenderRequest;
import jnpf.bizcommon.onlyoffice.service.impl.DmsOnlyOfficePrintService;
import jnpf.util.UserProvider;
import lombok.RequiredArgsConstructor;
import org.springframework.http.CacheControl;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/onlyoffice/dms-print")
@RequiredArgsConstructor
public class DmsOnlyOfficePrintController {
    private final DmsOnlyOfficePrintService service;
 
    @PostMapping(value = "/render", produces = MediaType.APPLICATION_PDF_VALUE)
    public ResponseEntity<byte[]> render(@RequestBody @Valid DmsPrintRenderRequest request) {
        return ResponseEntity.ok()
                .contentType(MediaType.APPLICATION_PDF)
                .cacheControl(CacheControl.noStore())
                .body(service.render(request, UserProvider.getUser()));
    }
}