mirror of
https://github.com/dataease/dataease.git
synced 2026-05-23 13:58:26 +08:00
refactor: 优化代码结构去掉无用的注释
This commit is contained in:
@@ -14,6 +14,7 @@ import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
@@ -24,14 +25,13 @@ import java.util.stream.Collectors;
|
||||
public class DePermissionAnnotationHandler {
|
||||
|
||||
@Around(value = "@annotation(io.dataease.auth.annotation.DePermissions)")
|
||||
public Object PermissionsAround(ProceedingJoinPoint point) throws Throwable{
|
||||
public Object PermissionsAround(ProceedingJoinPoint point) throws Throwable {
|
||||
|
||||
if (AuthUtils.getUser().getIsAdmin()) {
|
||||
return point.proceed(point.getArgs());
|
||||
}
|
||||
Boolean access = false;
|
||||
try {
|
||||
|
||||
MethodSignature ms = (MethodSignature) point.getSignature();
|
||||
Method method = ms.getMethod();
|
||||
DePermissions annotation = method.getAnnotation(DePermissions.class);
|
||||
@@ -66,17 +66,15 @@ public class DePermissionAnnotationHandler {
|
||||
throw exceptions.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
LogUtil.error(throwable.getMessage(), throwable);
|
||||
throw new RuntimeException(throwable.getMessage());
|
||||
}
|
||||
|
||||
return access ? point.proceed(point.getArgs()) : null;
|
||||
}
|
||||
|
||||
@Around(value = "@annotation(io.dataease.auth.annotation.DePermission)")
|
||||
public Object PermissionAround(ProceedingJoinPoint point) throws Throwable{
|
||||
public Object PermissionAround(ProceedingJoinPoint point) throws Throwable {
|
||||
Boolean access = false;
|
||||
try {
|
||||
if (AuthUtils.getUser().getIsAdmin()) {
|
||||
@@ -84,7 +82,6 @@ public class DePermissionAnnotationHandler {
|
||||
}
|
||||
MethodSignature ms = (MethodSignature) point.getSignature();
|
||||
Method method = ms.getMethod();
|
||||
|
||||
DePermission annotation = method.getAnnotation(DePermission.class);
|
||||
Object arg = point.getArgs()[annotation.paramIndex()];
|
||||
if (access(arg, annotation, 0)) {
|
||||
@@ -94,7 +91,6 @@ public class DePermissionAnnotationHandler {
|
||||
LogUtil.error(throwable.getMessage(), throwable);
|
||||
throw new RuntimeException(throwable.getMessage());
|
||||
}
|
||||
|
||||
return access ? point.proceed(point.getArgs()) : null;
|
||||
}
|
||||
|
||||
@@ -104,10 +100,8 @@ public class DePermissionAnnotationHandler {
|
||||
String type = annotation.type().name().toLowerCase();
|
||||
String value = annotation.value();
|
||||
Integer requireLevel = annotation.level().getLevel();
|
||||
|
||||
Set<String> resourceIds = AuthUtils.permissionByType(type).stream().filter(
|
||||
item -> item.getLevel() >= requireLevel).map(AuthItem::getAuthSource).collect(Collectors.toSet());
|
||||
|
||||
Class<?> parameterType = arg.getClass();
|
||||
if (parameterType.isPrimitive() || ReflectUtil.isWrapClass(parameterType) || ReflectUtil.isString(parameterType)) {
|
||||
boolean permissionValid = resourceIds.contains(arg);
|
||||
@@ -122,7 +116,6 @@ public class DePermissionAnnotationHandler {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (ReflectUtil.isCollection(parameterType)) {
|
||||
Object[] array = ((Collection) arg).toArray();
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
@@ -140,14 +133,10 @@ public class DePermissionAnnotationHandler {
|
||||
// 当作自定义类处理
|
||||
String[] values = value.split("\\.");
|
||||
String fieldName = values[layer];
|
||||
|
||||
Object fieldValue = ReflectUtil.getFieldValue(arg, fieldName);
|
||||
return access(fieldValue, annotation, ++layer);
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,21 +35,13 @@ public class DePermissionProxyHandler {
|
||||
Object[] args = point.getArgs();
|
||||
if (null == args || args.length == 0) {
|
||||
return point.proceed(args);
|
||||
|
||||
}
|
||||
Object arg = point.getArgs()[annotation.paramIndex()];
|
||||
/*
|
||||
* if (arg instanceof PermissionProxy) {
|
||||
* PermissionProxy proxy = (PermissionProxy) arg;
|
||||
* AuthUtils.setProxyUser(proxy.getUserId());
|
||||
* }
|
||||
*/
|
||||
PermissionProxy proxy = getProxy(arg, annotation, 0);
|
||||
if (null != proxy && null != proxy.getUserId()) {
|
||||
AuthUtils.setProxyUser(proxy.getUserId());
|
||||
}
|
||||
return point.proceed(args);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
LogUtil.error(throwable.getMessage(), throwable);
|
||||
/* throw new RuntimeException(throwable.getMessage()); */
|
||||
@@ -69,26 +61,8 @@ public class DePermissionProxyHandler {
|
||||
if (arg instanceof PermissionProxy) {
|
||||
return (PermissionProxy) arg;
|
||||
} else if (isArray(parameterType)) {
|
||||
/*
|
||||
* for (int i = 0; i < Array.getLength(arg); i++) {
|
||||
* Object o = Array.get(arg, i);
|
||||
* if ((result = getProxy(o, annotation, layer)) != null) {
|
||||
* return result;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
return null;
|
||||
|
||||
} else if (isCollection(parameterType)) {
|
||||
/*
|
||||
* Object[] array = ((Collection) arg).toArray();
|
||||
* for (int i = 0; i < array.length; i++) {
|
||||
* Object o = array[i];
|
||||
* if ((result = getProxy(o, annotation, layer)) != null) {
|
||||
* return result;
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
return null;
|
||||
} else if (isMap(parameterType)) {
|
||||
Map<String, Object> argMap = (Map) arg;
|
||||
@@ -99,10 +73,8 @@ public class DePermissionProxyHandler {
|
||||
// 当作自定义类处理
|
||||
String[] values = value.split("\\.");
|
||||
String fieldName = values[layer];
|
||||
|
||||
Object fieldValue = getFieldValue(arg, fieldName);
|
||||
return getProxy(fieldValue, annotation, ++layer);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ public class SqlFilter implements Filter {
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,9 +41,7 @@ public class SqlFilter implements Filter {
|
||||
if (xssRequest.checkXSSAndSql(param)) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
// PrintWriter out = response.getWriter();
|
||||
String msg = ThreadLocalContextHolder.getData().toString();
|
||||
// out.write(msg);
|
||||
DEException.throwException(msg);
|
||||
return;
|
||||
}
|
||||
@@ -54,9 +50,7 @@ public class SqlFilter implements Filter {
|
||||
if (xssRequest.checkParameter()) {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
// PrintWriter out = response.getWriter();
|
||||
String msg = ThreadLocalContextHolder.getData().toString();
|
||||
// out.write(msg);
|
||||
DEException.throwException(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -243,22 +243,12 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe
|
||||
ThreadLocalContextHolder.setData("包含SQL注入的参数,请检查参数!");
|
||||
return true;
|
||||
}
|
||||
// NOTE: It's highly recommended to use the ESAPI library and
|
||||
// uncomment the following line to
|
||||
// avoid encoded attacks.
|
||||
// value = ESAPI.encoder().canonicalize(value);
|
||||
// Avoid null characters
|
||||
/** value = value.replaceAll("", ""); ***/
|
||||
// Avoid anything between script tags
|
||||
Pattern scriptPattern = Pattern.compile(
|
||||
"<[\r\n| | ]*script[\r\n| | ]*>(.*?)</[\r\n| | ]*script[\r\n| | ]*>", Pattern.CASE_INSENSITIVE);
|
||||
flag = scriptPattern.matcher(value).find();
|
||||
if (flag) {
|
||||
return flag;
|
||||
}
|
||||
// Avoid anything in a
|
||||
// src="http://www.yihaomen.com/article/java/..." type of
|
||||
// e-xpression
|
||||
scriptPattern = Pattern.compile("src[\r\n| | ]*=[\r\n| | ]*[\\\"|\\\'](.*?)[\\\"|\\\']",
|
||||
Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
flag = scriptPattern.matcher(value).find();
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
package io.dataease.controller.panel;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroup;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroupWithBLOBs;
|
||||
import io.dataease.controller.handler.annotation.I18n;
|
||||
import io.dataease.controller.request.panel.PanelGroupRequest;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import io.dataease.dto.panel.PanelViewTableDTO;
|
||||
import io.dataease.service.panel.PanelGroupService;
|
||||
import io.dataease.service.panel.PanelViewService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
@@ -50,9 +50,4 @@ public class SysPluginController {
|
||||
return pluginService.uninstall(pluginId);
|
||||
}
|
||||
|
||||
// @ApiOperation("切换插件状态")
|
||||
// @PostMapping("/changeStatus")
|
||||
// public Boolean changeStatus(@RequestBody PluginStatus pluginStatus) {
|
||||
// return pluginService.changeStatus(pluginStatus.getPluginId(), pluginStatus.getStatus());
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ import java.util.List;
|
||||
public interface ExtChartViewMapper {
|
||||
List<ChartViewDTO> search(ChartViewRequest request);
|
||||
|
||||
// ChartViewDTO searchOne(ChartViewRequest request);
|
||||
|
||||
void chartCopy(@Param("newChartId")String newChartId,@Param("oldChartId")String oldChartId,@Param("panelId")String panelId);
|
||||
|
||||
@Select("select id from chart_view where table_id = #{tableId}")
|
||||
@@ -35,8 +33,6 @@ public interface ExtChartViewMapper {
|
||||
|
||||
List<ChartViewDTO> searchViewsWithPanelId(@Param("panelId") String panelId);
|
||||
|
||||
// ChartViewDTO searchOneFromCache(@Param("id") String id );
|
||||
|
||||
void copyToCache(@Param("id") String id );
|
||||
|
||||
void deleteCacheWithPanel(@Param("viewIds") List<String> viewIds,@Param("panelId") String panelId );
|
||||
|
||||
@@ -91,9 +91,6 @@
|
||||
<if test="level != null">
|
||||
and panel_group.level = #{level}
|
||||
</if>
|
||||
<!-- <if test="isAdmin != null and !isAdmin">-->
|
||||
<!-- and (panel_group.node_type='folder' or (panel_group.node_type='panel' and panel_group.`status`='publish') or (panel_group.node_type='panel' and panel_group.`status`='unpublished' and authInfo.privileges like '%manage%') )-->
|
||||
<!-- </if>-->
|
||||
</where>
|
||||
ORDER BY CONVERT(panel_group.name using gbk)
|
||||
</select>
|
||||
@@ -170,9 +167,6 @@
|
||||
<if test="level != null">
|
||||
and panel_group.level = #{level}
|
||||
</if>
|
||||
<!-- <if test="isAdmin != null and !isAdmin">-->
|
||||
<!-- and (panel_group.node_type='folder' or (panel_group.node_type='panel' and panel_group.`status`='publish') or (panel_group.node_type='panel' and panel_group.`status`='unpublished' and authInfo.privileges like '%manage%') )-->
|
||||
<!-- </if>-->
|
||||
</where>
|
||||
ORDER BY panel_group.node_type desc, CONVERT(panel_group.name using gbk)
|
||||
</select>
|
||||
|
||||
@@ -222,22 +222,16 @@ public class PanelGroupService {
|
||||
//清理view 和 view cache
|
||||
extPanelGroupMapper.deleteCircleView(id);
|
||||
extPanelGroupMapper.deleteCircleViewCache(id);
|
||||
|
||||
// 同时会删除对应默认仪表盘
|
||||
extPanelGroupMapper.deleteCircle(id);
|
||||
storeService.removeByPanelId(id);
|
||||
shareService.delete(id, null);
|
||||
panelLinkService.deleteByResourceId(id);
|
||||
|
||||
|
||||
//清理跳转信息
|
||||
extPanelLinkJumpMapper.deleteJumpTargetViewInfoWithPanel(id);
|
||||
extPanelLinkJumpMapper.deleteJumpInfoWithPanel(id);
|
||||
extPanelLinkJumpMapper.deleteJumpWithPanel(id);
|
||||
|
||||
DeLogUtils.save(sysLogDTO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -285,7 +279,6 @@ public class PanelGroupService {
|
||||
List<String> panelIds = panelResult.stream().map(VAuthModelDTO::getId).collect(Collectors.toList());
|
||||
VAuthModelRequest viewRequest = new VAuthModelRequest();
|
||||
viewRequest.setPids(panelIds);
|
||||
// Version 1.11 only gets the current panel
|
||||
List<VAuthModelDTO> viewResult = extVAuthModelMapper.queryAuthModelViews(viewRequest);
|
||||
if (CollectionUtils.isNotEmpty(viewResult)) {
|
||||
result.addAll(viewResult);
|
||||
@@ -316,10 +309,6 @@ public class PanelGroupService {
|
||||
VAuthModelRequest viewRequest = new VAuthModelRequest();
|
||||
viewRequest.setPids(panelIds);
|
||||
// Version 1.11 only gets the current panel
|
||||
// List<VAuthModelDTO> viewResult = extVAuthModelMapper.queryAuthModelViews(viewRequest);
|
||||
// if (CollectionUtils.isNotEmpty(viewResult)) {
|
||||
// result.addAll(viewResult);
|
||||
// }
|
||||
result = TreeUtils.mergeTree(result, "panel_list");
|
||||
if (AuthUtils.getUser().getIsAdmin()) {
|
||||
// 原有视图的目录结构
|
||||
|
||||
@@ -125,7 +125,6 @@ public class PanelViewService {
|
||||
extPanelViewMapper.savePanelView(panelViewInsertDTOList);
|
||||
//将视图从cache表中更新到正式表中
|
||||
viewIds = panelViewInsertDTOList.stream().map(panelView -> panelView.getChartViewId()).collect(Collectors.toList());
|
||||
// extChartViewMapper.copyCacheToView(viewIds);
|
||||
}
|
||||
extChartViewMapper.deleteCacheWithPanel(viewIds, panelId);
|
||||
extChartViewMapper.deleteNoUseView(viewIds, panelId);
|
||||
|
||||
@@ -54,7 +54,7 @@ public class ShareService {
|
||||
* 5.批量新增
|
||||
* 6.发送取消分享消息
|
||||
* 7.发送新增分享消息
|
||||
*
|
||||
*
|
||||
* @param panelShareFineDto
|
||||
*/
|
||||
@Transactional
|
||||
@@ -72,12 +72,6 @@ public class ShareService {
|
||||
authURDMap.put(0, authURD.getUserIds());
|
||||
authURDMap.put(1, authURD.getRoleIds());
|
||||
authURDMap.put(2, authURD.getDeptIds());
|
||||
|
||||
/*
|
||||
* PanelShareExample example = new PanelShareExample();
|
||||
* example.createCriteria().andPanelGroupIdEqualTo(panelGroupId);
|
||||
* List<PanelShare> panelShares = mapper.selectByExample(example);
|
||||
*/
|
||||
PanelShareSearchRequest request = new PanelShareSearchRequest();
|
||||
request.setCurrentUserName(AuthUtils.getUser().getUsername());
|
||||
request.setResourceId(panelGroupId);
|
||||
@@ -322,7 +316,7 @@ public class ShareService {
|
||||
|
||||
/**
|
||||
* panel_group_id建了索引 效率不会很差
|
||||
*
|
||||
*
|
||||
* @param panel_group_id
|
||||
*/
|
||||
@Transactional
|
||||
|
||||
@@ -47,11 +47,6 @@ public class LogService {
|
||||
// 驱动文件操作 上传, 删除
|
||||
private static Integer[] driver_file_ope = {11, 3};
|
||||
|
||||
|
||||
// 排除驱动和驱动文件的公共操作的资源类型
|
||||
// 暂时屏蔽视图日志
|
||||
// private static Integer[] COMMON_SOURCE = {1, 2,3,4,6,7,8,9};
|
||||
|
||||
private static Integer[] COMMON_SOURCE = {1, 2, 3, 6, 7, 8, 9};
|
||||
|
||||
// 增 改 删 针对公共资源的操作
|
||||
|
||||
@@ -25,6 +25,5 @@ public class PrincipalHandshakeHandler extends DefaultHandshakeHandler {
|
||||
return new DePrincipal(userId);
|
||||
}
|
||||
return null;
|
||||
//return super.determineUser(request, wsHandler, attributes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,5 @@ public class WsUtil {
|
||||
return ONLINE_USERS.contains(userId);
|
||||
}
|
||||
|
||||
/*public static void releaseMessage(WsMessage wsMessage){
|
||||
if(ObjectUtils.isEmpty(wsMessage) || ObjectUtils.isEmpty(wsMessage.getUserId()) || ObjectUtils.isEmpty(wsMessage.getTopic())) return;
|
||||
CommonBeanFactory.getBean()
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user