wangbin 3 years ago
parent d912b2485d
commit f8868901d5

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

@ -3,8 +3,8 @@
<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">
<parent>
<groupId>com.anjiplus.template.gaea</groupId>
<artifactId>template-gaea</artifactId>
<groupId>com.anjiplus.report</groupId>
<artifactId>aj-report</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

@ -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";

@ -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)

@ -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<String> 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<String> skipUrlList) {
if (skipUrlList == null || skipUrlList.size() == 0) {
return Pattern.compile(".*().*");
return PATTERN;
}
StringBuffer patternString = new StringBuffer();
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.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<String> 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);
}
// 先清除该角色已保存的权限

@ -108,10 +108,10 @@ public class AccessUserServiceImpl implements AccessUserService {
String loginName = accessUserDto.getLoginName();
List<String> 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;
}

@ -45,10 +45,10 @@ public class JsTransformServiceImpl implements TransformStrategy {
*/
@Override
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();
js = js + "\nvar result = dataTransform(eval(" + data.toString() + "));";
try {

@ -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 + '\'' +
'}';
}
}

@ -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 +
'}';
}
}

@ -116,7 +116,7 @@ public class GaeaFileServiceImpl implements GaeaFileService {
public ResponseEntity<byte[]> 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<GaeaFile> 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);

@ -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)){

Loading…
Cancel
Save