Conflicts:
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/constant/GenConstants.java
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ExceptionUtil.java
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/ImageUtils.java
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/sql/SqlUtil.java
	ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java
	ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/DictUtils.java
	ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/BlackListUrlFilter.java
	ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java
	ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/XssFilter.java
	ruoyi-gateway/src/main/java/com/ruoyi/gateway/handler/ValidateCodeHandler.java
	ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/ValidateCodeService.java
	ruoyi-gateway/src/main/java/com/ruoyi/gateway/service/impl/ValidateCodeServiceImpl.java
	ruoyi-modules/ruoyi-file/src/main/java/com/ruoyi/file/utils/FileUploadUtils.java
	ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java
	ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/util/VelocityUtils.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
	ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml
	ruoyi-ui/src/components/FileUpload/index.vue
	ruoyi-ui/src/router/index.js
2.X
疯狂的狮子li 2022-02-14 14:55:55 +08:00
commit 4827f9217b
36 changed files with 477 additions and 473 deletions

3
.gitignore vendored
View File

@ -25,6 +25,8 @@ target/
*.iml *.iml
*.ipr *.ipr
### JRebel ###
rebel.xml
### NetBeans ### ### NetBeans ###
nbproject/private/ nbproject/private/
build/* build/*
@ -36,6 +38,7 @@ nbdist/
# Others # Others
*.log *.log
*.xml.versionsBackup *.xml.versionsBackup
*.swp
!*/build/*.java !*/build/*.java
!*/build/*.html !*/build/*.html

View File

@ -1,181 +1,186 @@
package com.ruoyi.common.core.constant; package com.ruoyi.common.core.constant;
/** /**
* *
* *
* @author Lion Li * @author Lion Li
*/ */
public interface GenConstants { public interface GenConstants {
/** /**
* *
*/ */
String TPL_CRUD = "crud"; String TPL_CRUD = "crud";
/** /**
* *
*/ */
String TPL_TREE = "tree"; String TPL_TREE = "tree";
/** /**
* *
*/ */
String TPL_SUB = "sub"; String TPL_SUB = "sub";
/** /**
* *
*/ */
String TREE_CODE = "treeCode"; String TREE_CODE = "treeCode";
/** /**
* *
*/ */
String TREE_PARENT_CODE = "treeParentCode"; String TREE_PARENT_CODE = "treeParentCode";
/** /**
* *
*/ */
String TREE_NAME = "treeName"; String TREE_NAME = "treeName";
/** /**
* ID * ID
*/ */
String PARENT_MENU_ID = "parentMenuId"; String PARENT_MENU_ID = "parentMenuId";
/** /**
* *
*/ */
String PARENT_MENU_NAME = "parentMenuName"; String PARENT_MENU_NAME = "parentMenuName";
/** /**
* *
*/ */
String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"}; String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"};
/** /**
* *
*/ */
String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"}; String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
/** /**
* *
*/ */
String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"}; String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
/** /**
* *
*/ */
String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer", String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
"bigint", "float", "double", "decimal"}; "bigint", "float", "double", "decimal"};
/** /**
* *
*/ */
String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"}; String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"};
/** /**
* *
*/ */
String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by", String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by",
"update_time"}; "update_time"};
/** /**
* *
*/ */
String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by", String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
"update_time", "remark"}; "update_time", "remark"};
/** /**
* Entity * Entity
*/ */
String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"}; String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"};
/** /**
* Tree * Tree
*/ */
String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors"}; String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors"};
/** /**
* *
*/ */
String HTML_INPUT = "input"; String HTML_INPUT = "input";
/** /**
* *
*/ */
String HTML_TEXTAREA = "textarea"; String HTML_TEXTAREA = "textarea";
/** /**
* *
*/ */
String HTML_SELECT = "select"; String HTML_SELECT = "select";
/** /**
* *
*/ */
String HTML_RADIO = "radio"; String HTML_RADIO = "radio";
/** /**
* *
*/ */
String HTML_CHECKBOX = "checkbox"; String HTML_CHECKBOX = "checkbox";
/** /**
* *
*/ */
String HTML_DATETIME = "datetime"; String HTML_DATETIME = "datetime";
/** /**
* *
*/ */
String HTML_IMAGE_UPLOAD = "imageUpload"; String HTML_IMAGE_UPLOAD = "imageUpload";
/** /**
* *
*/ */
String HTML_FILE_UPLOAD = "fileUpload"; String HTML_FILE_UPLOAD = "fileUpload";
/** /**
* *
*/ */
String HTML_EDITOR = "editor"; String HTML_EDITOR = "editor";
/** /**
* *
*/ */
String TYPE_STRING = "String"; String TYPE_STRING = "String";
/** /**
* *
*/ */
String TYPE_INTEGER = "Integer"; String TYPE_INTEGER = "Integer";
/** /**
* *
*/ */
String TYPE_LONG = "Long"; String TYPE_LONG = "Long";
/** /**
* *
*/ */
String TYPE_DOUBLE = "Double"; String TYPE_DOUBLE = "Double";
/** /**
* *
*/ */
String TYPE_BIGDECIMAL = "BigDecimal"; String TYPE_BIGDECIMAL = "BigDecimal";
/** /**
* *
*/ */
String TYPE_DATE = "Date"; String TYPE_DATE = "Date";
/** /**
* *
*/ */
String QUERY_LIKE = "LIKE"; String QUERY_LIKE = "LIKE";
/** /**
* *
*/ */
String REQUIRE = "1"; String QUERY_EQ = "EQ";
}
/**
*
*/
String REQUIRE = "1";
}

View File

@ -137,9 +137,8 @@ public class ServletUtils extends ServletUtil {
* *
* @param response * @param response
* @param string * @param string
* @return null
*/ */
public static String renderString(HttpServletResponse response, String string) { public static void renderString(HttpServletResponse response, String string) {
try { try {
response.setStatus(HttpStatus.HTTP_OK); response.setStatus(HttpStatus.HTTP_OK);
response.setContentType(MediaType.APPLICATION_JSON_VALUE); response.setContentType(MediaType.APPLICATION_JSON_VALUE);
@ -148,7 +147,6 @@ public class ServletUtils extends ServletUtil {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null;
} }
/** /**
@ -159,12 +157,12 @@ public class ServletUtils extends ServletUtil {
public static boolean isAjaxRequest(HttpServletRequest request) { public static boolean isAjaxRequest(HttpServletRequest request) {
String accept = request.getHeader("accept"); String accept = request.getHeader("accept");
if (accept != null && accept.indexOf("application/json") != -1) { if (accept != null && accept.contains("application/json")) {
return true; return true;
} }
String xRequestedWith = request.getHeader("X-Requested-With"); String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) { if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) {
return true; return true;
} }
@ -174,10 +172,7 @@ public class ServletUtils extends ServletUtil {
} }
String ajax = request.getParameter("__ajax"); String ajax = request.getParameter("__ajax");
if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) { return StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml");
return true;
}
return false;
} }
public static String getClientIP() { public static String getClientIP() {

View File

@ -1,58 +1,58 @@
package com.ruoyi.gateway.filter; package com.ruoyi.gateway.filter;
import com.ruoyi.gateway.utils.WebFluxUtils; import com.ruoyi.gateway.utils.WebFluxUtils;
import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUrlFilter.Config> { public class BlackListUrlFilter extends AbstractGatewayFilterFactory<BlackListUrlFilter.Config> {
@Override @Override
public GatewayFilter apply(Config config) { public GatewayFilter apply(Config config) {
return (exchange, chain) -> { return (exchange, chain) -> {
String url = exchange.getRequest().getURI().getPath(); String url = exchange.getRequest().getURI().getPath();
if (config.matchBlacklist(url)) { if (config.matchBlacklist(url)) {
return WebFluxUtils.webFluxResponseWriter(exchange.getResponse(), "请求地址不允许访问"); return WebFluxUtils.webFluxResponseWriter(exchange.getResponse(), "请求地址不允许访问");
} }
return chain.filter(exchange); return chain.filter(exchange);
}; };
} }
public BlackListUrlFilter() { public BlackListUrlFilter() {
super(Config.class); super(Config.class);
} }
public static class Config { public static class Config {
private List<String> blacklistUrl; private List<String> blacklistUrl;
private List<Pattern> blacklistUrlPattern = new ArrayList<>(); private List<Pattern> blacklistUrlPattern = new ArrayList<>();
public boolean matchBlacklist(String url) { public boolean matchBlacklist(String url) {
return blacklistUrlPattern.isEmpty() ? false : blacklistUrlPattern.stream().filter(p -> p.matcher(url).find()).findAny().isPresent(); return !blacklistUrlPattern.isEmpty() && blacklistUrlPattern.stream().anyMatch(p -> p.matcher(url).find());
} }
public List<String> getBlacklistUrl() { public List<String> getBlacklistUrl() {
return blacklistUrl; return blacklistUrl;
} }
public void setBlacklistUrl(List<String> blacklistUrl) { public void setBlacklistUrl(List<String> blacklistUrl) {
this.blacklistUrl = blacklistUrl; this.blacklistUrl = blacklistUrl;
this.blacklistUrlPattern.clear(); this.blacklistUrlPattern.clear();
this.blacklistUrl.forEach(url -> { this.blacklistUrl.forEach(url -> {
this.blacklistUrlPattern.add(Pattern.compile(url.replaceAll("\\*\\*", "(.*?)"), Pattern.CASE_INSENSITIVE)); this.blacklistUrlPattern.add(Pattern.compile(url.replaceAll("\\*\\*", "(.*?)"), Pattern.CASE_INSENSITIVE));
}); });
} }
} }
} }

View File

@ -1,73 +1,73 @@
package com.ruoyi.gateway.filter; package com.ruoyi.gateway.filter;
import com.ruoyi.common.core.utils.JsonUtils; import com.ruoyi.common.core.utils.JsonUtils;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.gateway.config.properties.CaptchaProperties; import com.ruoyi.gateway.config.properties.CaptchaProperties;
import com.ruoyi.gateway.service.ValidateCodeService; import com.ruoyi.gateway.service.ValidateCodeService;
import com.ruoyi.gateway.utils.WebFluxUtils; import com.ruoyi.gateway.utils.WebFluxUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils; import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import java.nio.CharBuffer; import java.nio.CharBuffer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> { public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"}; private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
@Autowired @Autowired
private ValidateCodeService validateCodeService; private ValidateCodeService validateCodeService;
@Autowired @Autowired
private CaptchaProperties captchaProperties; private CaptchaProperties captchaProperties;
private static final String CODE = "code"; private static final String CODE = "code";
private static final String UUID = "uuid"; private static final String UUID = "uuid";
@Override @Override
public GatewayFilter apply(Object config) { public GatewayFilter apply(Object config) {
return (exchange, chain) -> { return (exchange, chain) -> {
ServerHttpRequest request = exchange.getRequest(); ServerHttpRequest request = exchange.getRequest();
// 非登录/注册请求或验证码关闭,不处理 // 非登录/注册请求或验证码关闭,不处理
if (!StringUtils.containsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL) || !captchaProperties.getEnabled()) { if (!StringUtils.containsAnyIgnoreCase(request.getURI().getPath(), VALIDATE_URL) || !captchaProperties.getEnabled()) {
return chain.filter(exchange); return chain.filter(exchange);
} }
try { try {
String rspStr = resolveBodyFromRequest(request); String rspStr = resolveBodyFromRequest(request);
Map<String, String> obj = JsonUtils.parseMap(rspStr); Map<String, String> obj = JsonUtils.parseMap(rspStr);
validateCodeService.checkCapcha(obj.get(CODE), obj.get(UUID)); validateCodeService.checkCaptcha(obj.get(CODE), obj.get(UUID));
} catch (Exception e) { } catch (Exception e) {
return WebFluxUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage()); return WebFluxUtils.webFluxResponseWriter(exchange.getResponse(), e.getMessage());
} }
return chain.filter(exchange); return chain.filter(exchange);
}; };
} }
private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest) { private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest) {
// 获取请求体 // 获取请求体
Flux<DataBuffer> body = serverHttpRequest.getBody(); Flux<DataBuffer> body = serverHttpRequest.getBody();
AtomicReference<String> bodyRef = new AtomicReference<>(); AtomicReference<String> bodyRef = new AtomicReference<>();
body.subscribe(buffer -> { body.subscribe(buffer -> {
CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer()); CharBuffer charBuffer = StandardCharsets.UTF_8.decode(buffer.asByteBuffer());
DataBufferUtils.release(buffer); DataBufferUtils.release(buffer);
bodyRef.set(charBuffer.toString()); bodyRef.set(charBuffer.toString());
}); });
return bodyRef.get(); return bodyRef.get();
} }
} }

View File

@ -1,110 +1,110 @@
package com.ruoyi.gateway.filter; package com.ruoyi.gateway.filter;
import cn.hutool.http.HtmlUtil; import cn.hutool.http.HtmlUtil;
import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.gateway.config.properties.XssProperties; import com.ruoyi.gateway.config.properties.XssProperties;
import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufAllocator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.io.buffer.*; import org.springframework.core.io.buffer.*;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpRequestDecorator; import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true") @ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
public class XssFilter implements GlobalFilter, Ordered { public class XssFilter implements GlobalFilter, Ordered {
// 跨站脚本的 xss 配置nacos自行添加 // 跨站脚本的 xss 配置nacos自行添加
@Autowired @Autowired
private XssProperties xss; private XssProperties xss;
@Override @Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest(); ServerHttpRequest request = exchange.getRequest();
// GET DELETE 不过滤 // GET DELETE 不过滤
HttpMethod method = request.getMethod(); HttpMethod method = request.getMethod();
if (method == null || method.matches("GET") || method.matches("DELETE")) { if (method == null || method.matches("GET") || method.matches("DELETE")) {
return chain.filter(exchange); return chain.filter(exchange);
} }
// 非json类型不过滤 // 非json类型不过滤
if (!isJsonRequest(exchange)) { if (!isJsonRequest(exchange)) {
return chain.filter(exchange); return chain.filter(exchange);
} }
// excludeUrls 不过滤 // excludeUrls 不过滤
String url = request.getURI().getPath(); String url = request.getURI().getPath();
if (StringUtils.matches(url, xss.getExcludeUrls())) { if (StringUtils.matches(url, xss.getExcludeUrls())) {
return chain.filter(exchange); return chain.filter(exchange);
} }
ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange); ServerHttpRequestDecorator httpRequestDecorator = requestDecorator(exchange);
return chain.filter(exchange.mutate().request(httpRequestDecorator).build()); return chain.filter(exchange.mutate().request(httpRequestDecorator).build());
} }
private ServerHttpRequestDecorator requestDecorator(ServerWebExchange exchange) { private ServerHttpRequestDecorator requestDecorator(ServerWebExchange exchange) {
ServerHttpRequestDecorator serverHttpRequestDecorator = new ServerHttpRequestDecorator(exchange.getRequest()) { ServerHttpRequestDecorator serverHttpRequestDecorator = new ServerHttpRequestDecorator(exchange.getRequest()) {
@Override @Override
public Flux<DataBuffer> getBody() { public Flux<DataBuffer> getBody() {
Flux<DataBuffer> body = super.getBody(); Flux<DataBuffer> body = super.getBody();
return body.buffer().map(dataBuffers -> { return body.buffer().map(dataBuffers -> {
DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory(); DataBufferFactory dataBufferFactory = new DefaultDataBufferFactory();
DataBuffer join = dataBufferFactory.join(dataBuffers); DataBuffer join = dataBufferFactory.join(dataBuffers);
byte[] content = new byte[join.readableByteCount()]; byte[] content = new byte[join.readableByteCount()];
join.read(content); join.read(content);
DataBufferUtils.release(join); DataBufferUtils.release(join);
String bodyStr = new String(content, StandardCharsets.UTF_8); String bodyStr = new String(content, StandardCharsets.UTF_8);
// 防xss攻击过滤 // 防xss攻击过滤
bodyStr = HtmlUtil.cleanHtmlTag(bodyStr); bodyStr = HtmlUtil.cleanHtmlTag(bodyStr);
// 转成字节 // 转成字节
byte[] bytes = bodyStr.getBytes(); byte[] bytes = bodyStr.getBytes();
NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT); NettyDataBufferFactory nettyDataBufferFactory = new NettyDataBufferFactory(ByteBufAllocator.DEFAULT);
DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length); DataBuffer buffer = nettyDataBufferFactory.allocateBuffer(bytes.length);
buffer.write(bytes); buffer.write(bytes);
return buffer; return buffer;
}); });
} }
@Override @Override
public HttpHeaders getHeaders() { public HttpHeaders getHeaders() {
HttpHeaders httpHeaders = new HttpHeaders(); HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.putAll(super.getHeaders()); httpHeaders.putAll(super.getHeaders());
// 由于修改了请求体的body导致content-length长度不确定因此需要删除原先的content-length // 由于修改了请求体的body导致content-length长度不确定因此需要删除原先的content-length
httpHeaders.remove(HttpHeaders.CONTENT_LENGTH); httpHeaders.remove(HttpHeaders.CONTENT_LENGTH);
httpHeaders.set(HttpHeaders.TRANSFER_ENCODING, "chunked"); httpHeaders.set(HttpHeaders.TRANSFER_ENCODING, "chunked");
return httpHeaders; return httpHeaders;
} }
}; };
return serverHttpRequestDecorator; return serverHttpRequestDecorator;
} }
/** /**
* Json * Json
* *
* @param request * @param exchange HTTP
*/ */
public boolean isJsonRequest(ServerWebExchange exchange) { public boolean isJsonRequest(ServerWebExchange exchange) {
String header = exchange.getRequest().getHeaders().getFirst(HttpHeaders.CONTENT_TYPE); String header = exchange.getRequest().getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
} }
@Override @Override
public int getOrder() { public int getOrder() {
return -100; return -100;
} }
} }

View File

@ -29,7 +29,7 @@ public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
public Mono<ServerResponse> handle(ServerRequest serverRequest) { public Mono<ServerResponse> handle(ServerRequest serverRequest) {
R<Map<String, Object>> ajax; R<Map<String, Object>> ajax;
try { try {
ajax = validateCodeService.createCapcha(); ajax = validateCodeService.createCaptcha();
} catch (CaptchaException | IOException e) { } catch (CaptchaException | IOException e) {
return Mono.error(e); return Mono.error(e);
} }

View File

@ -15,10 +15,10 @@ public interface ValidateCodeService {
/** /**
* *
*/ */
R<Map<String, Object>> createCapcha() throws IOException, CaptchaException; R<Map<String, Object>> createCaptcha() throws IOException, CaptchaException;
/** /**
* *
*/ */
void checkCapcha(String key, String value) throws CaptchaException; void checkCaptcha(String key, String value) throws CaptchaException;
} }

View File

@ -36,7 +36,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
* *
*/ */
@Override @Override
public R<Map<String, Object>> createCapcha() throws IOException, CaptchaException { public R<Map<String, Object>> createCaptcha() throws IOException, CaptchaException {
Map<String, Object> ajax = new HashMap<>(); Map<String, Object> ajax = new HashMap<>();
boolean captchaOnOff = captchaProperties.getEnabled(); boolean captchaOnOff = captchaProperties.getEnabled();
ajax.put("captchaOnOff", captchaOnOff); ajax.put("captchaOnOff", captchaOnOff);
@ -83,7 +83,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
* *
*/ */
@Override @Override
public void checkCapcha(String code, String uuid) throws CaptchaException { public void checkCaptcha(String code, String uuid) throws CaptchaException {
if (StringUtils.isEmpty(code)) { if (StringUtils.isEmpty(code)) {
throw new CaptchaException("验证码不能为空"); throw new CaptchaException("验证码不能为空");
} }

View File

@ -293,8 +293,17 @@ public class GenTableServiceImpl implements IGenTableService {
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
column.setColumnId(prevColumn.getColumnId()); column.setColumnId(prevColumn.getColumnId());
if (column.isList()) { if (column.isList()) {
// 如果是列表,继续保留字典类型 // 如果是列表,继续保留查询方式/字典类型选项
column.setDictType(prevColumn.getDictType()); column.setDictType(prevColumn.getDictType());
column.setQueryType(prevColumn.getQueryType());
}
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
&& (column.isInsert() || column.isEdit())
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
{
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType());
} }
genTableColumnMapper.updateById(column); genTableColumnMapper.updateById(column);
} else { } else {

View File

@ -40,6 +40,7 @@ public class GenUtils {
column.setJavaField(StringUtils.toCamelCase(columnName)); column.setJavaField(StringUtils.toCamelCase(columnName));
// 设置默认类型 // 设置默认类型
column.setJavaType(GenConstants.TYPE_STRING); column.setJavaType(GenConstants.TYPE_STRING);
column.setQueryType(GenConstants.QUERY_EQ);
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) { if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType)) {
// 字符串长度超过500设置为文本域 // 字符串长度超过500设置为文本域
@ -130,8 +131,7 @@ public class GenUtils {
public static String getModuleName(String packageName) { public static String getModuleName(String packageName) {
int lastIndex = packageName.lastIndexOf("."); int lastIndex = packageName.lastIndexOf(".");
int nameLength = packageName.length(); int nameLength = packageName.length();
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength); return StringUtils.substring(packageName, lastIndex + 1, nameLength);
return moduleName;
} }
/** /**
@ -143,8 +143,7 @@ public class GenUtils {
public static String getBusinessName(String tableName) { public static String getBusinessName(String tableName) {
int lastIndex = tableName.lastIndexOf("_"); int lastIndex = tableName.lastIndexOf("_");
int nameLength = tableName.length(); int nameLength = tableName.length();
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength); return StringUtils.substring(tableName, lastIndex + 1, nameLength);
return businessName;
} }
/** /**
@ -219,4 +218,4 @@ public class GenUtils {
return 0; return 0;
} }
} }
} }

View File

@ -197,8 +197,7 @@ public class VelocityUtils {
*/ */
public static String getPackagePrefix(String packageName) { public static String getPackagePrefix(String packageName) {
int lastIndex = packageName.lastIndexOf("."); int lastIndex = packageName.lastIndexOf(".");
String basePackage = StringUtils.substring(packageName, 0, lastIndex); return StringUtils.substring(packageName, 0, lastIndex);
return basePackage;
} }
/** /**

View File

@ -35,7 +35,7 @@ public interface SysUserMapper extends BaseMapperPlus<SysUserMapper, SysUser, Sy
List<SysUser> selectUserList(SysUser sysUser); List<SysUser> selectUserList(SysUser sysUser);
/** /**
* *
* *
* @param user * @param user
* @return * @return

View File

@ -59,7 +59,6 @@ public interface ISysConfigService {
* *
* *
* @param configIds ID * @param configIds ID
* @return
*/ */
void deleteConfigByIds(Long[] configIds); void deleteConfigByIds(Long[] configIds);

View File

@ -44,7 +44,6 @@ public interface ISysDictDataService {
* *
* *
* @param dictCodes ID * @param dictCodes ID
* @return
*/ */
void deleteDictDataByIds(Long[] dictCodes); void deleteDictDataByIds(Long[] dictCodes);

View File

@ -13,6 +13,7 @@ import java.util.List;
* @author ruoyi * @author ruoyi
*/ */
public interface ISysDictTypeService { public interface ISysDictTypeService {
TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery); TableDataInfo<SysDictType> selectPageDictTypeList(SysDictType dictType, PageQuery pageQuery);
/** /**
@ -58,7 +59,6 @@ public interface ISysDictTypeService {
* *
* *
* @param dictIds ID * @param dictIds ID
* @return
*/ */
void deleteDictTypeByIds(Long[] dictIds); void deleteDictTypeByIds(Long[] dictIds);

View File

@ -34,7 +34,7 @@ public interface ISysLogininforService {
* *
* *
* @param infoIds ID * @param infoIds ID
* @return * @return
*/ */
int deleteLogininforByIds(Long[] infoIds); int deleteLogininforByIds(Long[] infoIds);

View File

@ -12,6 +12,7 @@ import java.util.List;
* @author ruoyi * @author ruoyi
*/ */
public interface ISysPostService { public interface ISysPostService {
TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery); TableDataInfo<SysPost> selectPagePostList(SysPost post, PageQuery pageQuery);
/** /**
@ -82,7 +83,6 @@ public interface ISysPostService {
* *
* @param postIds ID * @param postIds ID
* @return * @return
* @throws Exception
*/ */
int deletePostByIds(Long[] postIds); int deletePostByIds(Long[] postIds);

View File

@ -137,7 +137,6 @@ public class SysConfigServiceImpl implements ISysConfigService {
* *
* *
* @param configIds ID * @param configIds ID
* @return
*/ */
@Override @Override
public void deleteConfigByIds(Long[] configIds) { public void deleteConfigByIds(Long[] configIds) {

View File

@ -82,7 +82,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
* *
* *
* @param dictCodes ID * @param dictCodes ID
* @return
*/ */
@Override @Override
public void deleteDictDataByIds(Long[] dictCodes) { public void deleteDictDataByIds(Long[] dictCodes) {

View File

@ -125,7 +125,6 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService {
* *
* *
* @param dictIds ID * @param dictIds ID
* @return
*/ */
@Override @Override
public void deleteDictTypeByIds(Long[] dictIds) { public void deleteDictTypeByIds(Long[] dictIds) {

View File

@ -77,7 +77,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
* *
* *
* @param infoIds ID * @param infoIds ID
* @return * @return
*/ */
@Override @Override
public int deleteLogininforByIds(Long[] infoIds) { public int deleteLogininforByIds(Long[] infoIds) {

View File

@ -415,7 +415,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
* *
*/ */
private boolean hasChild(List<SysMenu> list, SysMenu t) { private boolean hasChild(List<SysMenu> list, SysMenu t) {
return getChildList(list, t).size() > 0 ? true : false; return getChildList(list, t).size() > 0;
} }
/** /**

View File

@ -148,7 +148,6 @@ public class SysPostServiceImpl implements ISysPostService {
* *
* @param postIds ID * @param postIds ID
* @return * @return
* @throws Exception
*/ */
@Override @Override
public int deletePostByIds(Long[] postIds) { public int deletePostByIds(Long[] postIds) {

View File

@ -374,7 +374,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
* *
* *
* @param roleId ID * @param roleId ID
* @param userIds ID * @param userIds ID
* @return * @return
*/ */
@Override @Override

View File

@ -50,7 +50,7 @@
</select> </select>
<select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult"> <select id="selectMenuListByUserId" parameterType="SysMenu" resultMap="SysMenuResult">
select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.query, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time select distinct m.menu_id, m.parent_id, m.menu_name, m.path, m.component, m.`query`, m.visible, m.status, ifnull(m.perms,'') as perms, m.is_frame, m.is_cache, m.menu_type, m.icon, m.order_num, m.create_time
from sys_menu m from sys_menu m
left join sys_role_menu rm on m.menu_id = rm.menu_id left join sys_role_menu rm on m.menu_id = rm.menu_id
left join sys_user_role ur on rm.role_id = ur.role_id left join sys_user_role ur on rm.role_id = ur.role_id

View File

@ -26,7 +26,7 @@
<!-- 文件列表 --> <!-- 文件列表 -->
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul"> <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList"> <li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link :href="file.url" :underline="false" target="_blank"> <el-link :href="file.url" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span> <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link> </el-link>

View File

@ -155,7 +155,7 @@ export const dynamicRoutes = [
permissions: ['tool:gen:edit'], permissions: ['tool:gen:edit'],
children: [ children: [
{ {
path: 'index', path: 'index/:tableId(\\d+)',
component: () => import('@/views/tool/gen/editTable'), component: () => import('@/views/tool/gen/editTable'),
name: 'GenEdit', name: 'GenEdit',
meta: { title: '修改生成配置', activeMenu: '/tool/gen' } meta: { title: '修改生成配置', activeMenu: '/tool/gen' }

View File

@ -5,11 +5,11 @@ let confGlobal
let someSpanIsNot24 let someSpanIsNot24
export function dialogWrapper(str) { export function dialogWrapper(str) {
return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Titile"> return `<el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Title">
${str} ${str}
<div slot="footer"> <div slot="footer">
<el-button @click="close">取消</el-button> <el-button @click="close">取消</el-button>
<el-button type="primary" @click="handelConfirm">确定</el-button> <el-button type="primary" @click="handleConfirm">确定</el-button>
</div> </div>
</el-dialog>` </el-dialog>`
} }

View File

@ -98,7 +98,7 @@ function mixinMethod(type) {
close: `close() { close: `close() {
this.$emit('update:visible', false) this.$emit('update:visible', false)
},`, },`,
handelConfirm: `handelConfirm() { handleConfirm: `handleConfirm() {
this.$refs['${confGlobal.formRef}'].validate(valid => { this.$refs['${confGlobal.formRef}'].validate(valid => {
if(!valid) return if(!valid) return
this.close() this.close()

View File

@ -41,7 +41,7 @@
<el-button @click="close"> <el-button @click="close">
取消 取消
</el-button> </el-button>
<el-button type="primary" @click="handelConfirm"> <el-button type="primary" @click="handleConfirm">
确定 确定
</el-button> </el-button>
</div> </div>
@ -94,7 +94,7 @@ export default {
close(e) { close(e) {
this.$emit('update:visible', false) this.$emit('update:visible', false)
}, },
handelConfirm() { handleConfirm() {
this.$refs.elForm.validate(valid => { this.$refs.elForm.validate(valid => {
if (!valid) return if (!valid) return
this.$emit('confirm', { ...this.formData }) this.$emit('confirm', { ...this.formData })

View File

@ -59,7 +59,7 @@
<div slot="footer"> <div slot="footer">
<el-button <el-button
type="primary" type="primary"
@click="handelConfirm" @click="handleConfirm"
> >
确定 确定
</el-button> </el-button>
@ -133,7 +133,7 @@ export default {
close() { close() {
this.$emit('update:visible', false) this.$emit('update:visible', false)
}, },
handelConfirm() { handleConfirm() {
this.$refs.elForm.validate(valid => { this.$refs.elForm.validate(valid => {
if (!valid) return if (!valid) return
if (this.dataType === 'number') { if (this.dataType === 'number') {

View File

@ -146,7 +146,7 @@ import { beautifierConf, titleCase } from '@/utils/index'
import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html' import { makeUpHtml, vueTemplate, vueScript, cssStyle } from '@/utils/generator/html'
import { makeUpJs } from '@/utils/generator/js' import { makeUpJs } from '@/utils/generator/js'
import { makeUpCss } from '@/utils/generator/css' import { makeUpCss } from '@/utils/generator/css'
import drawingDefalut from '@/utils/generator/drawingDefalut' import drawingDefault from '@/utils/generator/drawingDefault'
import logo from '@/assets/logo/logo.png' import logo from '@/assets/logo/logo.png'
import CodeTypeDialog from './CodeTypeDialog' import CodeTypeDialog from './CodeTypeDialog'
import DraggableItem from './DraggableItem' import DraggableItem from './DraggableItem'
@ -171,15 +171,15 @@ export default {
selectComponents, selectComponents,
layoutComponents, layoutComponents,
labelWidth: 100, labelWidth: 100,
drawingList: drawingDefalut, drawingList: drawingDefault,
drawingData: {}, drawingData: {},
activeId: drawingDefalut[0].formId, activeId: drawingDefault[0].formId,
drawerVisible: false, drawerVisible: false,
formData: {}, formData: {},
dialogVisible: false, dialogVisible: false,
generateConf: null, generateConf: null,
showFileName: false, showFileName: false,
activeData: drawingDefalut[0] activeData: drawingDefault[0]
} }
}, },
created() { created() {

View File

@ -159,7 +159,7 @@ export default {
}; };
}, },
created() { created() {
const tableId = this.$route.query && this.$route.query.tableId; const tableId = this.$route.params && this.$route.params.tableId;
if (tableId) { if (tableId) {
// //
getGenTable(tableId).then(res => { getGenTable(tableId).then(res => {

View File

@ -321,7 +321,7 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleEditTable(row) { handleEditTable(row) {
const tableId = row.tableId || this.ids[0]; const tableId = row.tableId || this.ids[0];
this.$router.push({ path: '/tool/gen-edit/index', query: { tableId: tableId, pageNum: this.queryParams.pageNum } }); this.$router.push({ path: '/tool/gen-edit/index/' + tableId, query: { pageNum: this.queryParams.pageNum } });
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {