diff --git a/pom.xml b/pom.xml index 921c59d2..01093def 100644 --- a/pom.xml +++ b/pom.xml @@ -9,11 +9,11 @@ 2.0.2.RELEASE - com.anjiplus.template.gaea - template-gaea - anjiplus-template-gaea + com.anjiplus.report + aj-report + aj-report 1.0.0-SNAPSHOT - template-gaea + aj-report pom diff --git a/report-core/pom.xml b/report-core/pom.xml index 67613b35..33fcf25d 100644 --- a/report-core/pom.xml +++ b/report-core/pom.xml @@ -3,8 +3,8 @@ - com.anjiplus.template.gaea - template-gaea + com.anjiplus.report + aj-report 1.0.0-SNAPSHOT ../ diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java index eadf6f4c..8359a3fa 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/code/ResponseCode.java @@ -7,8 +7,8 @@ package com.anjiplus.template.gaea.business.code; */ public interface ResponseCode { - String Not_Null = "field.not.null"; - String Not_Empty = "field.not.empty"; + String NOT_NULL = "field.not.null"; + String NOT_EMPTY = "field.not.empty"; String MIN = "field.min"; String MAX = "field.max"; String DICT_ERROR = "field.dict.error"; diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/CORSFilter.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/CorsFilter.java similarity index 97% rename from report-core/src/main/java/com/anjiplus/template/gaea/business/filter/CORSFilter.java rename to report-core/src/main/java/com/anjiplus/template/gaea/business/filter/CorsFilter.java index e5eea41f..243a7fd0 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/CORSFilter.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/CorsFilter.java @@ -14,7 +14,7 @@ import java.io.IOException; */ @Component @Order(Ordered.HIGHEST_PRECEDENCE) -public class CORSFilter implements Filter { +public class CorsFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java index a7016b43..a21eff4f 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java @@ -10,9 +10,9 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.annotation.Order; +import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; -import javax.annotation.PostConstruct; import javax.servlet.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -22,25 +22,31 @@ import java.util.regex.Pattern; /** * 简单的鉴权 - * Created by raodeming on 2021/6/24. + * @author raodeming + * @date 2021/6/24. */ @Component @Order(Integer.MIN_VALUE + 99) public class TokenFilter implements Filter { + private static final Pattern PATTERN = Pattern.compile(".*().*"); + private static final String USER_GUEST = "guest"; + private static final String SLASH = "/"; + @Autowired private CacheHelper cacheHelper; @Autowired private JwtBean jwtBean; - // 跳过token验证和权限验证的url清单 + /** 跳过token验证和权限验证的url清单*/ @Value("#{'${customer.skip-authenticate-urls}'.split(',')}") private List skipAuthenticateUrls; - private Pattern SKIP_AUTHENTICATE_PATTERN; + private Pattern skipAuthenticatePattern; + @Override public void init(FilterConfig filterConfig) throws ServletException { // 生成匹配正则,跳过token验证和权限验证的url - SKIP_AUTHENTICATE_PATTERN = fitByList(skipAuthenticateUrls); + skipAuthenticatePattern = fitByList(skipAuthenticateUrls); Filter.super.init(filterConfig); } @@ -50,13 +56,13 @@ public class TokenFilter implements Filter { HttpServletResponse response = (HttpServletResponse) servletResponse; String uri = request.getRequestURI(); - if (uri.equals("/")) { + if (SLASH.equals(uri)) { response.sendRedirect("/index.html"); return; } // 不需要token验证和权限验证的url,直接放行 - boolean skipAuthenticate = SKIP_AUTHENTICATE_PATTERN.matcher(uri).matches(); + boolean skipAuthenticate = skipAuthenticatePattern.matcher(uri).matches(); if (skipAuthenticate) { filterChain.doFilter(request, response); return; @@ -88,18 +94,19 @@ public class TokenFilter implements Filter { cacheHelper.stringSetExpire(userKey, gaeaUserJsonStr, 3600); //在线体验版本 - if (loginName.equals("guest") + if (USER_GUEST.equals(loginName) && !uri.endsWith("/dataSet/testTransform") && !uri.endsWith("/reportDashboard/getData") && !uri.startsWith("/dict") ) { //不允许删除 String method = request.getMethod(); - if ("post".equalsIgnoreCase(method) - || "put".equalsIgnoreCase(method) - || "delete".equalsIgnoreCase(method) + if (HttpMethod.POST.name().equalsIgnoreCase(method) + || HttpMethod.PUT.name().equalsIgnoreCase(method) + || HttpMethod.DELETE.name().equalsIgnoreCase(method) ) { - ResponseBean responseBean = ResponseBean.builder().code("50001").message("在线体验版本,不允许此操作。请自行下载本地运行").build(); + ResponseBean responseBean = ResponseBean.builder().code("50001") + .message("在线体验版本,不允许此操作。请自行下载本地运行").build(); response.getWriter().print(JSONObject.toJSONString(responseBean)); return; } @@ -122,7 +129,7 @@ public class TokenFilter implements Filter { */ private Pattern fitByList(List skipUrlList) { if (skipUrlList == null || skipUrlList.size() == 0) { - return Pattern.compile(".*().*"); + return PATTERN; } StringBuffer patternString = new StringBuffer(); patternString.append(".*("); diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java index 16411774..0d93b0ec 100755 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessrole/service/impl/AccessRoleServiceImpl.java @@ -5,7 +5,6 @@ import com.anji.plus.gaea.bean.TreeNode; import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; import com.anji.plus.gaea.exception.BusinessExceptionBuilder; import com.anjiplus.template.gaea.business.code.ResponseCode; -import com.anjiplus.template.gaea.business.modules.accessauthority.dao.entity.AccessAuthority; import com.anjiplus.template.gaea.business.modules.accessauthority.service.AccessAuthorityService; import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto; import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleAuthorityMapper; @@ -16,11 +15,9 @@ import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleMapp import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.apache.commons.lang3.StringUtils; -import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -68,10 +65,10 @@ public class AccessRoleServiceImpl implements AccessRoleService { String roleCode = accessRoleDto.getRoleCode(); List authorityList = accessRoleDto.getAuthorityList(); if(StringUtils.isBlank(roleCode)){ - throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, roleCode); + throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCode); } if(authorityList == null || authorityList.isEmpty()){ - throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, authorityList); + throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, authorityList); } // 先清除该角色已保存的权限 diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java index 444ec39a..d066a3a5 100755 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/accessuser/service/impl/AccessUserServiceImpl.java @@ -108,10 +108,10 @@ public class AccessUserServiceImpl implements AccessUserService { String loginName = accessUserDto.getLoginName(); List roleCodeList = accessUserDto.getRoleCodeList(); if(StringUtils.isBlank(loginName)){ - throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, loginName); + throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, loginName); } if(roleCodeList == null || roleCodeList.isEmpty()){ - throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, roleCodeList); + throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCodeList); } // 先清除该用户已保存的角色 @@ -230,6 +230,9 @@ public class AccessUserServiceImpl implements AccessUserService { case UPDATE: //更新用户不允许修改密码 entity.setPassword(null); + break; + default: + break; } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSetTransform/service/impl/JsTransformServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSetTransform/service/impl/JsTransformServiceImpl.java index 4adaa2dc..5744457c 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSetTransform/service/impl/JsTransformServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dataSetTransform/service/impl/JsTransformServiceImpl.java @@ -45,10 +45,10 @@ public class JsTransformServiceImpl implements TransformStrategy { */ @Override public List transform(DataSetTransformDto def, List data) { - return getValueFromJS(def,data); + return getValueFromJs(def,data); } - private List getValueFromJS(DataSetTransformDto def, List data) { + private List getValueFromJs(DataSetTransformDto def, List data) { String js = def.getTransformScript(); js = js + "\nvar result = dataTransform(eval(" + data.toString() + "));"; try { diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictDTO.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictDTO.java index f26f75eb..48aca456 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictDTO.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictDTO.java @@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.modules.dict.controller.dto; import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import java.io.Serializable; @@ -53,4 +54,13 @@ public class GaeaDictDTO extends GaeaBaseDTO implements Serializable { public void setRemark(String remark) { this.remark = remark; } + + @Override + public String toString() { + return "GaeaDictDTO{" + + "dictName='" + dictName + '\'' + + ", dictCode='" + dictCode + '\'' + + ", remark='" + remark + '\'' + + '}'; + } } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictItemDTO.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictItemDTO.java index 3978d8f7..b16a7a54 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictItemDTO.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/dict/controller/dto/GaeaDictItemDTO.java @@ -116,4 +116,18 @@ public class GaeaDictItemDTO extends GaeaBaseDTO implements Serializable { public void setLocaleView(String localeView) { this.localeView = localeView; } + + @Override + public String toString() { + return "GaeaDictItemDTO{" + + "dictCode='" + dictCode + '\'' + + ", itemName='" + itemName + '\'' + + ", itemValue='" + itemValue + '\'' + + ", itemExtend='" + itemExtend + '\'' + + ", locale='" + locale + '\'' + + ", localeView='" + localeView + '\'' + + ", remark='" + remark + '\'' + + ", sort=" + sort + + '}'; + } } diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/impl/GaeaFileServiceImpl.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/impl/GaeaFileServiceImpl.java index 7c4e9196..2465f8da 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/impl/GaeaFileServiceImpl.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/service/impl/GaeaFileServiceImpl.java @@ -116,7 +116,7 @@ public class GaeaFileServiceImpl implements GaeaFileService { public ResponseEntity download(HttpServletRequest request, HttpServletResponse response, String fileId) { try { String userAgent = request.getHeader("User-Agent"); - boolean isIEBrowser = userAgent.indexOf("MSIE") > 0; + boolean isIeBrowser = userAgent.indexOf("MSIE") > 0; //根据fileId,从gaea_file中读出filePath LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(GaeaFile::getFileId, fileId); @@ -136,15 +136,15 @@ public class GaeaFileServiceImpl implements GaeaFileService { File file = new File(filePath); ResponseEntity.BodyBuilder builder = ResponseEntity.ok(); builder.contentLength(file.length()); - if (StringPatternUtil.StringMatchIgnoreCase(fileSuffix, "(.png|.jpg|.jpeg|.bmp|.gif|.icon)")) { + if (StringPatternUtil.stringMatchIgnoreCase(fileSuffix, "(.png|.jpg|.jpeg|.bmp|.gif|.icon)")) { builder.cacheControl(CacheControl.noCache()).contentType(MediaType.IMAGE_PNG); - } else if (StringPatternUtil.StringMatchIgnoreCase(fileSuffix, "(.flv|.swf|.mkv|.avi|.rm|.rmvb|.mpeg|.mpg|.ogg|.ogv|.mov|.wmv|.mp4|.webm|.wav|.mid|.mp3|.aac)")) { + } else if (StringPatternUtil.stringMatchIgnoreCase(fileSuffix, "(.flv|.swf|.mkv|.avi|.rm|.rmvb|.mpeg|.mpg|.ogg|.ogv|.mov|.wmv|.mp4|.webm|.wav|.mid|.mp3|.aac)")) { builder.header("Content-Type", "video/mp4; charset=UTF-8"); } else { //application/octet-stream 二进制数据流(最常见的文件下载) builder.contentType(MediaType.APPLICATION_OCTET_STREAM); filename = URLEncoder.encode(filename, "UTF-8"); - if (isIEBrowser) { + if (isIeBrowser) { builder.header("Content-Disposition", "attachment; filename=" + filename); } else { builder.header("Content-Disposition", "attacher; filename*=UTF-8''" + filename); diff --git a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java index e8d45e20..5741f5e8 100644 --- a/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java +++ b/report-core/src/main/java/com/anjiplus/template/gaea/business/modules/file/util/StringPatternUtil.java @@ -18,7 +18,7 @@ public class StringPatternUtil { * @param pattern * @return */ - public static boolean StringMatch(String sourceStr,String pattern){ + public static boolean stringMatch(String sourceStr, String pattern){ boolean result=false; try{ if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ @@ -38,7 +38,7 @@ public class StringPatternUtil { return result; } - public static boolean StringMatchIgnoreCase(String sourceStr,String pattern){ + public static boolean stringMatchIgnoreCase(String sourceStr, String pattern){ boolean result=false; try{ if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ @@ -46,7 +46,7 @@ public class StringPatternUtil { } sourceStr=sourceStr.toLowerCase(); pattern=pattern.toLowerCase(); - result=StringMatch(sourceStr,pattern); + result= stringMatch(sourceStr,pattern); }catch(Exception e){ result=false; } @@ -63,7 +63,7 @@ public class StringPatternUtil { * @param pattern * @return */ - public static String StringFind(String sourceStr,String pattern){ + public static String stringFind(String sourceStr, String pattern){ String result=""; try{ if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){