feat(仪表板): 仪表板编辑时定时缓存未完成的仪表板,如果异常退出重新进入可以选择是否打开未保存的仪表板

This commit is contained in:
wangjiahao
2022-08-15 17:17:04 +08:00
parent 0ca33a5c79
commit 4b4a12969c
35 changed files with 235 additions and 63 deletions

View File

@@ -3,4 +3,6 @@ package io.dataease.commons.constants;
public class JdbcConstants {
public final static String VIEW_CACHE_KEY = "view_cache";
public final static String PANEL_CACHE_KEY="panel_cache-";
}

View File

@@ -145,5 +145,31 @@ public class PanelGroupController {
public void updatePanelStatus(@PathVariable String panelId, @RequestBody PanelGroupBaseInfoRequest request) {
panelGroupService.updatePanelStatus(panelId, request);
}
@ApiOperation("自动缓存")
@PostMapping("/autoCache")
@DePermissions(value = {
@DePermission(type = DePermissionType.PANEL, value = "id"),
@DePermission(type = DePermissionType.PANEL, value = "pid", level = ResourceAuthLevel.PANNEL_LEVEL_MANAGE)
}, logical = Logical.AND)
public void autoCache(@RequestBody PanelGroupRequest request){
panelGroupService.autoCache(request);
}
@ApiOperation("查找缓存")
@GetMapping("/findUserCache/{panelId}")
public PanelGroupDTO findUserCache(@PathVariable String panelId){
return panelGroupService.findUserPanelCache(panelId);
}
@ApiOperation("检查缓存")
@GetMapping("/checkUserCache/{panelId}")
public Boolean checkUserCache(@PathVariable String panelId){
return panelGroupService.checkUserCache(panelId);
}
@ApiOperation("删除缓存")
@DeleteMapping("/removePanelCache/{panelId}")
public void removePanelCache(@PathVariable String panelId){
panelGroupService.removePanelCache(panelId);
}
}

View File

@@ -130,6 +130,7 @@ public class PanelGroupService {
clearPermissionCache();
sysAuthService.copyAuth(panelId, SysAuthConstants.AUTH_SOURCE_TYPE_PANEL);
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.CREATE, sourceType, panelId, request.getPid(), null, null);
this.removePanelAllCache(panelId);
return panelId;
}
@@ -201,6 +202,7 @@ public class PanelGroupService {
}
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.MODIFY, sourceType, request.getId(), request.getPid(), null, sourceType);
}
this.removePanelAllCache(panelId);
return panelId;
}
@@ -627,4 +629,44 @@ public class PanelGroupService {
return null;
}
}
/**
* @Description: Automatically save panel data to cache when editing
* */
public void autoCache(PanelGroupRequest request){
String cacheName = JdbcConstants.PANEL_CACHE_KEY+request.getId();
String cacheId = AuthUtils.getUser().getUserId()+"&"+request.getId();
CacheUtils.put(cacheName, cacheId, request, null, null);
}
/**
* @Description: Remove panel cache for specific user
* */
public void removePanelCache(String panelId){
String cacheName = JdbcConstants.PANEL_CACHE_KEY+panelId;
String cacheId = AuthUtils.getUser().getUserId()+"&"+panelId;
CacheUtils.remove(cacheName,cacheId);
}
public void removePanelAllCache(String panelId){
String cacheName = JdbcConstants.PANEL_CACHE_KEY+panelId;
CacheUtils.removeAll(cacheName);
}
public PanelGroupDTO findUserPanelCache(String panelId){
String cacheName = JdbcConstants.PANEL_CACHE_KEY+panelId;
String cacheId = AuthUtils.getUser().getUserId()+"&"+panelId;
Object cache = CacheUtils.get(cacheName,cacheId);
if(cache==null){
return null;
}else{
return (PanelGroupRequest)cache;
}
}
public Boolean checkUserCache(String panelId){
String cacheName = JdbcConstants.PANEL_CACHE_KEY+panelId;
String cacheId = AuthUtils.getUser().getUserId()+"&"+panelId;
Object cache = CacheUtils.get(cacheName,cacheId);
return cache!=null;
}
}