feat: 支持水印设置

This commit is contained in:
wangjiahao
2022-11-15 11:58:14 +08:00
parent 7cf2f9da02
commit aa4e5689b9
15 changed files with 143 additions and 110 deletions

View File

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -40,20 +41,20 @@ public class PluginCommonServer {
BufferedInputStream bis = null;
InputStream inputStream = null;
OutputStream os = null; //输出流
try{
try {
inputStream = service.vueResource(jsName);
byte[] buffer = new byte[1024];
os = response.getOutputStream();
bis = new BufferedInputStream(inputStream);
int i = bis.read(buffer);
while(i != -1){
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}
os.flush();
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
try {
bis.close();
inputStream.close();
@@ -69,28 +70,28 @@ public class PluginCommonServer {
@GetMapping("/component/{componentName}")
public void componentInfo(@PathVariable String componentName) {
Map<String, PluginComponentService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType(PluginComponentService.class);
beansOfType.values().stream().forEach(service -> {
Map<String, PluginComponentService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType(PluginComponentService.class);
beansOfType.values().stream().forEach(service -> {
List<String> components = service.components();
if (components.contains(componentName)) {
HttpServletResponse response = ServletUtils.response();
BufferedInputStream bis = null;
InputStream inputStream = null;
OutputStream os = null; //输出流
try{
try {
inputStream = service.vueResource(componentName);
byte[] buffer = new byte[1024];
os = response.getOutputStream();
bis = new BufferedInputStream(inputStream);
int i = bis.read(buffer);
while(i != -1){
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}
os.flush();
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
try {
bis.close();
inputStream.close();
@@ -101,7 +102,7 @@ public class PluginCommonServer {
}
return;
}
});
});
}
@GetMapping("/staticInfo/{name}/{suffix}")
@@ -115,22 +116,24 @@ public class PluginCommonServer {
BufferedInputStream bis = null;
InputStream inputStream = null;
OutputStream os = null; //输出流
try{
try {
inputStream = service.vueResource(name, suffix);
byte[] buffer = new byte[1024];
os = response.getOutputStream();
bis = new BufferedInputStream(inputStream);
int i = bis.read(buffer);
while(i != -1){
while (i != -1) {
os.write(buffer, 0, i);
i = bis.read(buffer);
}
if (suffix.indexOf("svg") != -1)
response.setContentType("image/svg+xml");
if (suffix.indexOf("png") != -1)
response.setContentType("image/png");
os.flush();
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
try {
bis.close();
inputStream.close();

View File

@@ -4,10 +4,7 @@ import io.dataease.plugins.config.SpringContextUtil;
import io.dataease.plugins.xpack.watermark.WatermarkService;
import io.dataease.plugins.xpack.watermark.dto.PanelWatermarkDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
/**
@@ -29,7 +26,7 @@ public class XWatermarkServer {
@ApiOperation("保存水印配置")
@PostMapping("/save")
public void save(PanelWatermarkDTO panelWatermark) {
public void save(@RequestBody PanelWatermarkDTO panelWatermark) {
WatermarkService userXpackService = SpringContextUtil.getBean(WatermarkService.class);
userXpackService.saveWatermarkInfo(panelWatermark);
}

View File

@@ -6,26 +6,33 @@ ALTER TABLE `sys_log`
ALTER TABLE `panel_group`
ADD COLUMN `watermark_open` tinyint(1) NULL DEFAULT 1 COMMENT '是否单独打开水印' AFTER `update_time`;
DROP TABLE IF EXISTS `panel_watermark`;
CREATE TABLE `panel_watermark`
(
`id` varchar(50) NOT NULL,
`version` varchar(255) DEFAULT NULL COMMENT '版本号',
`setting_content` longtext COMMENT '设置内容',
`create_by` varchar(255) DEFAULT NULL,
`create_time` bigint(13) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
INSERT INTO `panel_watermark` (`id`, `version`, `setting_content`, `create_by`, `create_time`)
VALUES ('system_default', '1.0',
'{\"enable\":false,\"enablePanelCustom\":true,\"type\":\"custom\",\"content\":\"${time}-${nickName}\",\"watermark_color\":\"#999999\",\"watermark_x_space\":20,\"watermark_y_space\":100,\"watermark_fontsize\":20}',
'admin', NULL);
CREATE TABLE `panel_watermark`
(
`id` varchar(50) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`version` varchar(255) DEFAULT NULL COMMENT '版本',
`type` varchar(255) DEFAULT NULL COMMENT '类型',
`content` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
SET
FOREIGN_KEY_CHECKS = 1;
UPDATE `sys_menu` SET `component` = 'dataset/Form' WHERE (`menu_id` = '800');
UPDATE `sys_menu`
SET `component` = 'dataset/Form'
WHERE (`menu_id` = '800');
UPDATE `sys_menu` SET `component` = 'msg/All' WHERE (`component` = 'msg/all');
UPDATE `sys_menu` SET `component` = 'msg/Setting' WHERE (`component` = 'msg/setting');
UPDATE `sys_menu`
SET `component` = 'msg/All'
WHERE (`component` = 'msg/all');
UPDATE `sys_menu`
SET `component` = 'msg/Setting'
WHERE (`component` = 'msg/setting');