Skip to content

Commit 66c473e

Browse files
committed
feat: 支持水印设置
1 parent 9019eac commit 66c473e

File tree

30 files changed

+4177
-36
lines changed

30 files changed

+4177
-36
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.dataease.controller.sys;
2+
3+
import io.dataease.dto.UserLoginInfoDTO;
4+
import io.dataease.service.SystemInfoService;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
import springfox.documentation.annotations.ApiIgnore;
9+
10+
import javax.annotation.Resource;
11+
import java.io.IOException;
12+
13+
@ApiIgnore
14+
@RestController
15+
@RequestMapping("systemInfo")
16+
public class SystemInfoController {
17+
@Resource
18+
private SystemInfoService systemInfoService;
19+
20+
@GetMapping("userLoginInfo")
21+
public UserLoginInfoDTO userLoginInfo() throws IOException {
22+
return systemInfoService.getUserLoginInfo();
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.dataease.dto;
2+
3+
import io.dataease.auth.api.dto.CurrentUserDto;
4+
import lombok.Data;
5+
6+
/**
7+
* Author: wangjiahao
8+
* Date: 2022/11/10
9+
* Description:
10+
*/
11+
@Data
12+
public class UserLoginInfoDTO {
13+
14+
private CurrentUserDto userInfo;
15+
16+
private String ip;
17+
18+
public UserLoginInfoDTO() {
19+
}
20+
21+
public UserLoginInfoDTO(CurrentUserDto userInfo, String ip) {
22+
this.userInfo = userInfo;
23+
this.ip = ip;
24+
}
25+
}

backend/src/main/java/io/dataease/dto/panel/PanelGroupDTO.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import io.dataease.dto.chart.ChartViewDTO;
44
import io.dataease.plugins.common.base.domain.PanelGroupWithBLOBs;
5+
import io.dataease.plugins.common.base.domain.PanelWatermark;
56
import io.dataease.plugins.common.model.ITreeBase;
67
import io.swagger.annotations.ApiModelProperty;
78
import lombok.Data;
9+
810
import java.util.List;
911
import java.util.Map;
1012

@@ -43,4 +45,7 @@ public class PanelGroupDTO extends PanelGroupWithBLOBs implements ITreeBase<Pane
4345
private String requestId;
4446
@ApiModelProperty("数据返回来源")
4547
private String responseSource;
48+
@ApiModelProperty("水印信息")
49+
private PanelWatermark watermarkInfo;
50+
4651
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.dataease.plugins.server;
2+
3+
import io.dataease.plugins.config.SpringContextUtil;
4+
import io.dataease.plugins.xpack.watermark.WatermarkService;
5+
import io.dataease.plugins.xpack.watermark.dto.PanelWatermarkDTO;
6+
import io.swagger.annotations.ApiOperation;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PostMapping;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RestController;
11+
import springfox.documentation.annotations.ApiIgnore;
12+
13+
/**
14+
* Author: wangjiahao
15+
* Date: 2022/11/11
16+
* Description:
17+
*/
18+
@ApiIgnore
19+
@RequestMapping("/plugin/watermark")
20+
@RestController
21+
public class XWatermarkServer {
22+
23+
@ApiOperation("查询水印配置")
24+
@GetMapping("/find")
25+
public PanelWatermarkDTO find() {
26+
WatermarkService userXpackService = SpringContextUtil.getBean(WatermarkService.class);
27+
return userXpackService.getWatermarkInfo();
28+
}
29+
30+
@ApiOperation("保存水印配置")
31+
@PostMapping("/save")
32+
public void save(PanelWatermarkDTO panelWatermark) {
33+
WatermarkService userXpackService = SpringContextUtil.getBean(WatermarkService.class);
34+
userXpackService.saveWatermarkInfo(panelWatermark);
35+
}
36+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.dataease.service;
2+
3+
import io.dataease.commons.utils.AuthUtils;
4+
import io.dataease.commons.utils.IPUtils;
5+
import io.dataease.dto.UserLoginInfoDTO;
6+
import org.springframework.stereotype.Service;
7+
8+
9+
@Service
10+
public class SystemInfoService {
11+
12+
public UserLoginInfoDTO getUserLoginInfo() {
13+
return new UserLoginInfoDTO(AuthUtils.getUser(), IPUtils.get());
14+
}
15+
16+
}

backend/src/main/java/io/dataease/service/panel/PanelGroupService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.dataease.plugins.common.base.domain.*;
3030
import io.dataease.plugins.common.base.mapper.*;
3131
import io.dataease.plugins.common.constants.DeTypeConstants;
32+
import io.dataease.service.SystemInfoService;
3233
import io.dataease.service.chart.ChartViewService;
3334
import io.dataease.service.dataset.DataSetGroupService;
3435
import io.dataease.service.dataset.DataSetTableService;
@@ -131,6 +132,10 @@ public class PanelGroupService {
131132
private DataSetGroupService dataSetGroupService;
132133
@Resource
133134
private DatasetGroupMapper datasetGroupMapper;
135+
@Resource
136+
private PanelWatermarkMapper panelWatermarkMapper;
137+
@Resource
138+
private SystemInfoService systemInfoService;
134139

135140
public List<PanelGroupDTO> tree(PanelGroupRequest panelGroupRequest) {
136141
String userId = String.valueOf(AuthUtils.getUser().getUserId());
@@ -304,6 +309,7 @@ public PanelGroupDTO findOne(String panelId) {
304309
panelGroup.setPanelStyle(sourcePanel.getPanelStyle());
305310
panelGroup.setSourcePanelName(sourcePanel.getName());
306311
}
312+
panelGroup.setWatermarkInfo(panelWatermarkMapper.selectByPrimaryKey("system_default"));
307313
return panelGroup;
308314
}
309315

@@ -750,7 +756,9 @@ public PanelGroupDTO findUserPanelCache(String panelId) {
750756
if (cache == null) {
751757
return null;
752758
} else {
753-
return (PanelGroupRequest) cache;
759+
PanelGroupDTO result = (PanelGroupRequest) cache;
760+
result.setWatermarkInfo(panelWatermarkMapper.selectByPrimaryKey("system_default"));
761+
return result;
754762
}
755763
}
756764

backend/src/main/resources/db/migration/V44__1.17.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@ ALTER TABLE `sys_log`
33
CHANGE COLUMN `login_name` `login_name` VARCHAR (255) NULL COMMENT '登录账号',
44
CHANGE COLUMN `nick_name` `nick_name` VARCHAR (255) NULL COMMENT '姓名';
55

6+
ALTER TABLE `panel_group`
7+
ADD COLUMN `watermark_open` tinyint(1) NULL DEFAULT 1 COMMENT '是否单独打开水印' AFTER `update_time`;
8+
9+
INSERT INTO `panel_watermark` (`id`, `version`, `setting_content`, `create_by`, `create_time`)
10+
VALUES ('system_default', '1.0',
11+
'{\"enable\":false,\"enablePanelCustom\":true,\"type\":\"custom\",\"content\":\"${time}-${nickName}\",\"watermark_color\":\"#999999\",\"watermark_x_space\":20,\"watermark_y_space\":100,\"watermark_fontsize\":20}',
12+
'admin', NULL);
13+
14+
CREATE TABLE `panel_watermark`
15+
(
16+
`id` varchar(50) NOT NULL,
17+
`name` varchar(255) DEFAULT NULL,
18+
`version` varchar(255) DEFAULT NULL COMMENT '版本',
19+
`type` varchar(255) DEFAULT NULL COMMENT '类型',
20+
`content` varchar(255) DEFAULT NULL,
21+
PRIMARY KEY (`id`)
22+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
23+
24+
SET
25+
FOREIGN_KEY_CHECKS = 1;
26+
627
UPDATE `sys_menu` SET `component` = 'dataset/Form' WHERE (`menu_id` = '800');
728

829

frontend/src/api/panel/panel.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function viewData(id, panelId, data) {
6666
data
6767
})
6868
}
69+
6970
export function panelSave(data) {
7071
return request({
7172
url: 'panel/group/save',
@@ -174,7 +175,9 @@ export function initPanelData(panelId, useCache = false, callback) {
174175
creatorName: response.data.creatorName,
175176
updateBy: response.data.updateBy,
176177
updateName: response.data.updateName,
177-
updateTime: response.data.updateTime
178+
updateTime: response.data.updateTime,
179+
watermarkOpen: response.data.watermarkOpen,
180+
watermarkInfo: response.data.watermarkInfo
178181
})
179182
// 刷新联动信息
180183
getPanelAllLinkageInfo(panelId).then(rsp => {
@@ -230,6 +233,7 @@ export function initViewCache(panelId) {
230233
loading: false
231234
})
232235
}
236+
233237
export function exportDetails(data) {
234238
// 初始化仪表板视图缓存
235239
return request({
@@ -268,6 +272,7 @@ export function saveCache(data) {
268272
data
269273
})
270274
}
275+
271276
export function findUserCacheRequest(panelId) {
272277
return request({
273278
url: 'panel/group/findUserCache/' + panelId,

frontend/src/api/panel/shareProxy.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export function proxyInitPanelData(panelId, proxy, callback) {
2323
creatorName: response.data.creatorName,
2424
updateBy: response.data.updateBy,
2525
updateName: response.data.updateName,
26-
updateTime: response.data.updateTime
26+
updateTime: response.data.updateTime,
27+
watermarkOpen: response.data.watermarkOpen,
28+
watermarkInfo: response.data.watermarkInfo
2729
})
2830
// 刷新联动信息
2931
getPanelAllLinkageInfo(panelId, proxy).then(rsp => {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import request from '@/utils/request'
2+
3+
export function userLoginInfo() {
4+
return request({
5+
url: '/systemInfo/userLoginInfo',
6+
method: 'get',
7+
loading: false
8+
})
9+
}
10+
11+
export default {
12+
userLoginInfo
13+
}

0 commit comments

Comments
 (0)