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> 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) {} }