刘光辉
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
package jnpf.controller;
 
import cn.dev33.satoken.stp.StpUtil;
import jnpf.base.ActionResult;
import jnpf.dms.fonts.DmsWatermarkFonts;
import jnpf.dmsEntity.preview.model.DmsWatermarkSnapshot;
import jnpf.fileStorage.dms.DmsDocxWatermarkService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
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;
 
import java.util.List;
 
@RestController
@RequestMapping("/Dms/Watermark")
@RequiredArgsConstructor
public class DmsWatermarkPreviewController {
    private final DmsDocxWatermarkService renderer;
 
    @GetMapping("/fonts")
    public ActionResult<List<DmsWatermarkFonts.Option>> fonts() {
        StpUtil.checkLogin();
        return ActionResult.success(DmsWatermarkFonts.configured().options());
    }
 
    @PostMapping(value = "/preview", produces = MediaType.IMAGE_PNG_VALUE)
    public byte[] preview(@RequestBody PreviewRequest request) throws Exception {
        StpUtil.checkLogin();
        return renderer.preview(request.paperWidthMm(), request.paperHeightMm(), request.watermark());
    }
 
    public record PreviewRequest(double paperWidthMm, double paperHeightMm, DmsWatermarkSnapshot watermark) {}
}