wangbin 3 years ago
parent d912b2485d
commit f8868901d5

@ -9,11 +9,11 @@
<version>2.0.2.RELEASE</version> <version>2.0.2.RELEASE</version>
</parent> </parent>
<groupId>com.anjiplus.template.gaea</groupId> <groupId>com.anjiplus.report</groupId>
<artifactId>template-gaea</artifactId> <artifactId>aj-report</artifactId>
<description>anjiplus-template-gaea</description> <description>aj-report</description>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<name>template-gaea</name> <name>aj-report</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<modules> <modules>

@ -3,8 +3,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>com.anjiplus.template.gaea</groupId> <groupId>com.anjiplus.report</groupId>
<artifactId>template-gaea</artifactId> <artifactId>aj-report</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath> <relativePath>../</relativePath>
</parent> </parent>

@ -7,8 +7,8 @@ package com.anjiplus.template.gaea.business.code;
*/ */
public interface ResponseCode { public interface ResponseCode {
String Not_Null = "field.not.null"; String NOT_NULL = "field.not.null";
String Not_Empty = "field.not.empty"; String NOT_EMPTY = "field.not.empty";
String MIN = "field.min"; String MIN = "field.min";
String MAX = "field.max"; String MAX = "field.max";
String DICT_ERROR = "field.dict.error"; String DICT_ERROR = "field.dict.error";

@ -14,7 +14,7 @@ import java.io.IOException;
*/ */
@Component @Component
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
public class CORSFilter implements Filter { public class CorsFilter implements Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

@ -10,9 +10,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; 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 @Component
@Order(Integer.MIN_VALUE + 99) @Order(Integer.MIN_VALUE + 99)
public class TokenFilter implements Filter { 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 @Autowired
private CacheHelper cacheHelper; private CacheHelper cacheHelper;
@Autowired @Autowired
private JwtBean jwtBean; private JwtBean jwtBean;
// 跳过token验证和权限验证的url清单 /** 跳过token验证和权限验证的url清单*/
@Value("#{'${customer.skip-authenticate-urls}'.split(',')}") @Value("#{'${customer.skip-authenticate-urls}'.split(',')}")
private List<String> skipAuthenticateUrls; private List<String> skipAuthenticateUrls;
private Pattern SKIP_AUTHENTICATE_PATTERN; private Pattern skipAuthenticatePattern;
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
// 生成匹配正则跳过token验证和权限验证的url // 生成匹配正则跳过token验证和权限验证的url
SKIP_AUTHENTICATE_PATTERN = fitByList(skipAuthenticateUrls); skipAuthenticatePattern = fitByList(skipAuthenticateUrls);
Filter.super.init(filterConfig); Filter.super.init(filterConfig);
} }
@ -50,13 +56,13 @@ public class TokenFilter implements Filter {
HttpServletResponse response = (HttpServletResponse) servletResponse; HttpServletResponse response = (HttpServletResponse) servletResponse;
String uri = request.getRequestURI(); String uri = request.getRequestURI();
if (uri.equals("/")) { if (SLASH.equals(uri)) {
response.sendRedirect("/index.html"); response.sendRedirect("/index.html");
return; return;
} }
// 不需要token验证和权限验证的url直接放行 // 不需要token验证和权限验证的url直接放行
boolean skipAuthenticate = SKIP_AUTHENTICATE_PATTERN.matcher(uri).matches(); boolean skipAuthenticate = skipAuthenticatePattern.matcher(uri).matches();
if (skipAuthenticate) { if (skipAuthenticate) {
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
return; return;
@ -88,18 +94,19 @@ public class TokenFilter implements Filter {
cacheHelper.stringSetExpire(userKey, gaeaUserJsonStr, 3600); cacheHelper.stringSetExpire(userKey, gaeaUserJsonStr, 3600);
//在线体验版本 //在线体验版本
if (loginName.equals("guest") if (USER_GUEST.equals(loginName)
&& !uri.endsWith("/dataSet/testTransform") && !uri.endsWith("/dataSet/testTransform")
&& !uri.endsWith("/reportDashboard/getData") && !uri.endsWith("/reportDashboard/getData")
&& !uri.startsWith("/dict") && !uri.startsWith("/dict")
) { ) {
//不允许删除 //不允许删除
String method = request.getMethod(); String method = request.getMethod();
if ("post".equalsIgnoreCase(method) if (HttpMethod.POST.name().equalsIgnoreCase(method)
|| "put".equalsIgnoreCase(method) || HttpMethod.PUT.name().equalsIgnoreCase(method)
|| "delete".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)); response.getWriter().print(JSONObject.toJSONString(responseBean));
return; return;
} }
@ -122,7 +129,7 @@ public class TokenFilter implements Filter {
*/ */
private Pattern fitByList(List<String> skipUrlList) { private Pattern fitByList(List<String> skipUrlList) {
if (skipUrlList == null || skipUrlList.size() == 0) { if (skipUrlList == null || skipUrlList.size() == 0) {
return Pattern.compile(".*().*"); return PATTERN;
} }
StringBuffer patternString = new StringBuffer(); StringBuffer patternString = new StringBuffer();
patternString.append(".*("); patternString.append(".*(");

@ -5,7 +5,6 @@ import com.anji.plus.gaea.bean.TreeNode;
import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper; import com.anji.plus.gaea.curd.mapper.GaeaBaseMapper;
import com.anji.plus.gaea.exception.BusinessExceptionBuilder; import com.anji.plus.gaea.exception.BusinessExceptionBuilder;
import com.anjiplus.template.gaea.business.code.ResponseCode; 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.accessauthority.service.AccessAuthorityService;
import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto; import com.anjiplus.template.gaea.business.modules.accessrole.controller.dto.AccessRoleDto;
import com.anjiplus.template.gaea.business.modules.accessrole.dao.AccessRoleAuthorityMapper; 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.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -68,10 +65,10 @@ public class AccessRoleServiceImpl implements AccessRoleService {
String roleCode = accessRoleDto.getRoleCode(); String roleCode = accessRoleDto.getRoleCode();
List<String> authorityList = accessRoleDto.getAuthorityList(); List<String> authorityList = accessRoleDto.getAuthorityList();
if(StringUtils.isBlank(roleCode)){ if(StringUtils.isBlank(roleCode)){
throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, roleCode); throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, roleCode);
} }
if(authorityList == null || authorityList.isEmpty()){ if(authorityList == null || authorityList.isEmpty()){
throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, authorityList); throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, authorityList);
} }
// 先清除该角色已保存的权限 // 先清除该角色已保存的权限

@ -108,10 +108,10 @@ public class AccessUserServiceImpl implements AccessUserService {
String loginName = accessUserDto.getLoginName(); String loginName = accessUserDto.getLoginName();
List<String> roleCodeList = accessUserDto.getRoleCodeList(); List<String> roleCodeList = accessUserDto.getRoleCodeList();
if(StringUtils.isBlank(loginName)){ if(StringUtils.isBlank(loginName)){
throw BusinessExceptionBuilder.build(ResponseCode.Not_Empty, loginName); throw BusinessExceptionBuilder.build(ResponseCode.NOT_EMPTY, loginName);
} }
if(roleCodeList == null || roleCodeList.isEmpty()){ 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: case UPDATE:
//更新用户不允许修改密码 //更新用户不允许修改密码
entity.setPassword(null); entity.setPassword(null);
break;
default:
break; break;
} }

@ -45,10 +45,10 @@ public class JsTransformServiceImpl implements TransformStrategy {
*/ */
@Override @Override
public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) { public List<JSONObject> transform(DataSetTransformDto def, List<JSONObject> data) {
return getValueFromJS(def,data); return getValueFromJs(def,data);
} }
private List<JSONObject> getValueFromJS(DataSetTransformDto def, List<JSONObject> data) { private List<JSONObject> getValueFromJs(DataSetTransformDto def, List<JSONObject> data) {
String js = def.getTransformScript(); String js = def.getTransformScript();
js = js + "\nvar result = dataTransform(eval(" + data.toString() + "));"; js = js + "\nvar result = dataTransform(eval(" + data.toString() + "));";
try { try {

@ -3,6 +3,7 @@ package com.anjiplus.template.gaea.business.modules.dict.controller.dto;
import com.anji.plus.gaea.curd.dto.GaeaBaseDTO; import com.anji.plus.gaea.curd.dto.GaeaBaseDTO;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -53,4 +54,13 @@ public class GaeaDictDTO extends GaeaBaseDTO implements Serializable {
public void setRemark(String remark) { public void setRemark(String remark) {
this.remark = remark; this.remark = remark;
} }
@Override
public String toString() {
return "GaeaDictDTO{" +
"dictName='" + dictName + '\'' +
", dictCode='" + dictCode + '\'' +
", remark='" + remark + '\'' +
'}';
}
} }

@ -116,4 +116,18 @@ public class GaeaDictItemDTO extends GaeaBaseDTO implements Serializable {
public void setLocaleView(String localeView) { public void setLocaleView(String localeView) {
this.localeView = 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 +
'}';
}
} }

@ -116,7 +116,7 @@ public class GaeaFileServiceImpl implements GaeaFileService {
public ResponseEntity<byte[]> download(HttpServletRequest request, HttpServletResponse response, String fileId) { public ResponseEntity<byte[]> download(HttpServletRequest request, HttpServletResponse response, String fileId) {
try { try {
String userAgent = request.getHeader("User-Agent"); String userAgent = request.getHeader("User-Agent");
boolean isIEBrowser = userAgent.indexOf("MSIE") > 0; boolean isIeBrowser = userAgent.indexOf("MSIE") > 0;
//根据fileId从gaea_file中读出filePath //根据fileId从gaea_file中读出filePath
LambdaQueryWrapper<GaeaFile> queryWrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<GaeaFile> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(GaeaFile::getFileId, fileId); queryWrapper.eq(GaeaFile::getFileId, fileId);
@ -136,15 +136,15 @@ public class GaeaFileServiceImpl implements GaeaFileService {
File file = new File(filePath); File file = new File(filePath);
ResponseEntity.BodyBuilder builder = ResponseEntity.ok(); ResponseEntity.BodyBuilder builder = ResponseEntity.ok();
builder.contentLength(file.length()); 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); 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"); builder.header("Content-Type", "video/mp4; charset=UTF-8");
} else { } else {
//application/octet-stream 二进制数据流(最常见的文件下载) //application/octet-stream 二进制数据流(最常见的文件下载)
builder.contentType(MediaType.APPLICATION_OCTET_STREAM); builder.contentType(MediaType.APPLICATION_OCTET_STREAM);
filename = URLEncoder.encode(filename, "UTF-8"); filename = URLEncoder.encode(filename, "UTF-8");
if (isIEBrowser) { if (isIeBrowser) {
builder.header("Content-Disposition", "attachment; filename=" + filename); builder.header("Content-Disposition", "attachment; filename=" + filename);
} else { } else {
builder.header("Content-Disposition", "attacher; filename*=UTF-8''" + filename); builder.header("Content-Disposition", "attacher; filename*=UTF-8''" + filename);

@ -18,7 +18,7 @@ public class StringPatternUtil {
* @param pattern * @param pattern
* @return * @return
*/ */
public static boolean StringMatch(String sourceStr,String pattern){ public static boolean stringMatch(String sourceStr, String pattern){
boolean result=false; boolean result=false;
try{ try{
if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){
@ -38,7 +38,7 @@ public class StringPatternUtil {
return result; return result;
} }
public static boolean StringMatchIgnoreCase(String sourceStr,String pattern){ public static boolean stringMatchIgnoreCase(String sourceStr, String pattern){
boolean result=false; boolean result=false;
try{ try{
if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){
@ -46,7 +46,7 @@ public class StringPatternUtil {
} }
sourceStr=sourceStr.toLowerCase(); sourceStr=sourceStr.toLowerCase();
pattern=pattern.toLowerCase(); pattern=pattern.toLowerCase();
result=StringMatch(sourceStr,pattern); result= stringMatch(sourceStr,pattern);
}catch(Exception e){ }catch(Exception e){
result=false; result=false;
} }
@ -63,7 +63,7 @@ public class StringPatternUtil {
* @param pattern * @param pattern
* @return * @return
*/ */
public static String StringFind(String sourceStr,String pattern){ public static String stringFind(String sourceStr, String pattern){
String result=""; String result="";
try{ try{
if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){ if(StringUtils.isBlank(sourceStr)|| StringUtils.isBlank(pattern)){

Loading…
Cancel
Save