/
/
This commit is contained in:
16
FastChar.iml
16
FastChar.iml
@@ -10,15 +10,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module-library">
|
|
||||||
<library>
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$USER_HOME$/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre/lib/rt.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
</library>
|
|
||||||
</orderEntry>
|
|
||||||
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
|
<orderEntry type="library" name="Maven: javax.servlet:javax.servlet-api:3.0.1" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-jdbc:9.0.19" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-jdbc:9.0.19" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-juli:9.0.19" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat:tomcat-juli:9.0.19" level="project" />
|
||||||
@@ -55,5 +46,12 @@
|
|||||||
<orderEntry type="library" scope="TEST" name="Maven: com.sun.jersey.contribs:jersey-multipart:1.18" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: com.sun.jersey.contribs:jersey-multipart:1.18" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: org.jvnet.mimepull:mimepull:1.9.3" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: org.jvnet.mimepull:mimepull:1.9.3" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: com.sun.jersey:jersey-core:1.18" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: com.sun.jersey:jersey-core:1.18" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: io.netty:netty-all:4.1.58.Final" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-mock:2.0.8" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: commons-logging:commons-logging:1.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: log4j:log4j:1.2.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: logkit:logkit:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: avalon-framework:avalon-framework:4.1.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: javax.servlet:servlet-api:2.3" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.fastchar</groupId>
|
<groupId>com.fastchar</groupId>
|
||||||
<artifactId>fastchar</artifactId>
|
<artifactId>fastchar</artifactId>
|
||||||
<version>1.5.4</version>
|
<version>1.5.5</version>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -316,6 +316,24 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
<version>4.1.58.Final</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework/spring-mock -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework</groupId>
|
||||||
|
<artifactId>spring-mock</artifactId>
|
||||||
|
<version>2.0.8</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@ package com.fastchar.core;
|
|||||||
|
|
||||||
import com.fastchar.database.FastDb;
|
import com.fastchar.database.FastDb;
|
||||||
import com.fastchar.interfaces.*;
|
import com.fastchar.interfaces.*;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,8 +157,13 @@ public final class FastChar {
|
|||||||
return FastEngine.instance().getProperties(fileName);
|
return FastEngine.instance().getProperties(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FastFindClass getFindClass() {
|
||||||
|
return FastEngine.instance().getFindClass();
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isMain() {
|
public static boolean isMain() {
|
||||||
return FastEngine.instance().isMain();
|
return FastEngine.instance().isMain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,14 @@ import java.util.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统全局配置
|
* 系统全局配置
|
||||||
|
*
|
||||||
* @author 沈建(Janesen)
|
* @author 沈建(Janesen)
|
||||||
*/
|
*/
|
||||||
public class FastConstant {
|
public class FastConstant {
|
||||||
/**
|
/**
|
||||||
* FastChar框架的版本
|
* FastChar框架的版本
|
||||||
*/
|
*/
|
||||||
public static final String FAST_CHAR_VERSION = "1.5.4";
|
public static final String FAST_CHAR_VERSION = "1.5.5";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库xml配置文件的前缀
|
* 数据库xml配置文件的前缀
|
||||||
@@ -62,7 +63,7 @@ public class FastConstant {
|
|||||||
private boolean logHeaders = false;//打印请求的header信息
|
private boolean logHeaders = false;//打印请求的header信息
|
||||||
private boolean logRemoteAddress = false;//打印远程请求的地址
|
private boolean logRemoteAddress = false;//打印远程请求的地址
|
||||||
private boolean logInterceptorUseTotal = false;//打印拦截器的耗时时间
|
private boolean logInterceptorUseTotal = false;//打印拦截器的耗时时间
|
||||||
private boolean logFilterResponseTime =false;//是否只打印 超时的路由日志
|
private boolean logFilterResponseTime = false;//是否只打印 超时的路由日志
|
||||||
private boolean logSql = true;//是否打印sql语句日志
|
private boolean logSql = true;//是否打印sql语句日志
|
||||||
private boolean logExtract = false;//是否打印解压jar包的文件日志
|
private boolean logExtract = false;//是否打印解压jar包的文件日志
|
||||||
private boolean logSameJar = false;//是否打印不同版本的jar包
|
private boolean logSameJar = false;//是否打印不同版本的jar包
|
||||||
@@ -83,6 +84,9 @@ public class FastConstant {
|
|||||||
private boolean webStarted;//web服务器是否已启动
|
private boolean webStarted;//web服务器是否已启动
|
||||||
private boolean webStopped;//web服务器是否已停止
|
private boolean webStopped;//web服务器是否已停止
|
||||||
|
|
||||||
|
private boolean decodeUploadFileName = true;//是否使用URLDecoder解码上传文件的名称
|
||||||
|
private String decodeUploadFileNameEncoding = encoding;//URLDecoder解码时的编码
|
||||||
|
|
||||||
private int sessionMaxInterval = 30 * 60;//session失效时间,单位秒 默认30分钟
|
private int sessionMaxInterval = 30 * 60;//session失效时间,单位秒 默认30分钟
|
||||||
|
|
||||||
|
|
||||||
@@ -604,6 +608,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加允许跨域的域名
|
* 添加允许跨域的域名
|
||||||
|
*
|
||||||
* @param domains 域名地址 支持匹配符*
|
* @param domains 域名地址 支持匹配符*
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -624,6 +629,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取允许跨域的域名地址
|
* 获取允许跨域的域名地址
|
||||||
|
*
|
||||||
* @return Set<String>
|
* @return Set<String>
|
||||||
*/
|
*/
|
||||||
public Set<String> getCrossAllowDomains() {
|
public Set<String> getCrossAllowDomains() {
|
||||||
@@ -632,6 +638,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否只打印请求响应时间超过配置的maxUseTotalLog时间日志
|
* 是否只打印请求响应时间超过配置的maxUseTotalLog时间日志
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isLogFilterResponseTime() {
|
public boolean isLogFilterResponseTime() {
|
||||||
@@ -640,6 +647,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否只打印请求响应时间超过配置的maxResponseTime时间日志
|
* 设置是否只打印请求响应时间超过配置的maxResponseTime时间日志
|
||||||
|
*
|
||||||
* @param logFilterResponseTime 布尔值
|
* @param logFilterResponseTime 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -650,6 +658,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否打印sql语句
|
* 是否打印sql语句
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isLogSql() {
|
public boolean isLogSql() {
|
||||||
@@ -658,6 +667,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否打印sql语句
|
* 设置是否打印sql语句
|
||||||
|
*
|
||||||
* @param logSql 布尔值
|
* @param logSql 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -668,6 +678,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取session失效时间,默认 30分钟
|
* 获取session失效时间,默认 30分钟
|
||||||
|
*
|
||||||
* @return 时间(秒)
|
* @return 时间(秒)
|
||||||
*/
|
*/
|
||||||
public int getSessionMaxInterval() {
|
public int getSessionMaxInterval() {
|
||||||
@@ -676,6 +687,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置session失效时间
|
* 设置session失效时间
|
||||||
|
*
|
||||||
* @param sessionMaxInterval 时间(秒)
|
* @param sessionMaxInterval 时间(秒)
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -686,6 +698,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否打印解压jar包的文件日志
|
* 是否打印解压jar包的文件日志
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isLogExtract() {
|
public boolean isLogExtract() {
|
||||||
@@ -694,6 +707,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否打印解压jar包的文件日志
|
* 设置是否打印解压jar包的文件日志
|
||||||
|
*
|
||||||
* @param logExtract 布尔值
|
* @param logExtract 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -704,6 +718,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否打印远程请求的地址
|
* 是否打印远程请求的地址
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isLogRemoteAddress() {
|
public boolean isLogRemoteAddress() {
|
||||||
@@ -712,6 +727,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否打印远程请求接口的地址
|
* 设置是否打印远程请求接口的地址
|
||||||
|
*
|
||||||
* @param logRemoteAddress 布尔值
|
* @param logRemoteAddress 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -722,6 +738,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否允许系统使用System.out输出打印
|
* 是否允许系统使用System.out输出打印
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isSystemOutPrint() {
|
public boolean isSystemOutPrint() {
|
||||||
@@ -730,6 +747,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置是否允许系统使用System.out输出打印
|
* 配置是否允许系统使用System.out输出打印
|
||||||
|
*
|
||||||
* @param systemOutPrint 布尔值
|
* @param systemOutPrint 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -740,6 +758,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取项目的Web服务器是否已启动
|
* 获取项目的Web服务器是否已启动
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isWebStarted() {
|
public boolean isWebStarted() {
|
||||||
@@ -748,6 +767,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置项目的Web服务器是否已启动
|
* 设置项目的Web服务器是否已启动
|
||||||
|
*
|
||||||
* @param webStarted 布尔值
|
* @param webStarted 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -759,6 +779,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否打印不同版本的JAR包
|
* 是否打印不同版本的JAR包
|
||||||
|
*
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
public boolean isLogSameJar() {
|
public boolean isLogSameJar() {
|
||||||
@@ -767,6 +788,7 @@ public class FastConstant {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否打印不同版本的JAR包
|
* 设置是否打印不同版本的JAR包
|
||||||
|
*
|
||||||
* @param logSameJar 布尔值
|
* @param logSameJar 布尔值
|
||||||
* @return 当前对象
|
* @return 当前对象
|
||||||
*/
|
*/
|
||||||
@@ -775,6 +797,24 @@ public class FastConstant {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDecodeUploadFileName() {
|
||||||
|
return decodeUploadFileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FastConstant setDecodeUploadFileName(boolean decodeUploadFileName) {
|
||||||
|
this.decodeUploadFileName = decodeUploadFileName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDecodeUploadFileNameEncoding() {
|
||||||
|
return decodeUploadFileNameEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FastConstant setDecodeUploadFileNameEncoding(String decodeUploadFileNameEncoding) {
|
||||||
|
this.decodeUploadFileNameEncoding = decodeUploadFileNameEncoding;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FastConstant{" +
|
return "FastConstant{" +
|
||||||
@@ -811,6 +851,8 @@ public class FastConstant {
|
|||||||
", propertiesName='" + propertiesName + '\'' +
|
", propertiesName='" + propertiesName + '\'' +
|
||||||
", webStarted=" + webStarted +
|
", webStarted=" + webStarted +
|
||||||
", webStopped=" + webStopped +
|
", webStopped=" + webStopped +
|
||||||
|
", decodeUploadFileName=" + decodeUploadFileName +
|
||||||
|
", decodeUploadFileNameEncoding='" + decodeUploadFileNameEncoding + '\'' +
|
||||||
", sessionMaxInterval=" + sessionMaxInterval +
|
", sessionMaxInterval=" + sessionMaxInterval +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,6 +209,9 @@ public final class FastDatabases {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (FastTableInfo<?> table : databaseInfo.getTables()) {
|
for (FastTableInfo<?> table : databaseInfo.getTables()) {
|
||||||
|
if (table.getName().contains("*")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (table.getBoolean("enable", true) && table.isFromXml()) {
|
if (table.getBoolean("enable", true) && table.isFromXml()) {
|
||||||
if (!databaseOperate.checkTableExists(databaseInfo, table)) {
|
if (!databaseOperate.checkTableExists(databaseInfo, table)) {
|
||||||
if (notifyListener(1, databaseInfo, table, null)) {
|
if (notifyListener(1, databaseInfo, table, null)) {
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ public final class FastEngine {
|
|||||||
System.setErr(new FastErrorPrintStream(System.out, true));
|
System.setErr(new FastErrorPrintStream(System.out, true));
|
||||||
|
|
||||||
observable.addObserver(FastDatabaseObserver.class);
|
observable.addObserver(FastDatabaseObserver.class);
|
||||||
|
|
||||||
constant.addCrossHeaders("Content-Type", "Access-Control-Allow-Headers", "Authorization", "X-Requested-With", "token");
|
constant.addCrossHeaders("Content-Type", "Access-Control-Allow-Headers", "Authorization", "X-Requested-With", "token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -645,7 +645,7 @@ public abstract class FastEntity<E extends FastEntity<?>> extends ConcurrentHash
|
|||||||
/**
|
/**
|
||||||
* 设置数据到数据库中,根据指定的检测属性,如果不存在则添加,存在则修改
|
* 设置数据到数据库中,根据指定的检测属性,如果不存在则添加,存在则修改
|
||||||
*
|
*
|
||||||
* @param handler 操作句柄,可根据code判断数据最终是添加还是更新 0:添加 1:更新
|
* @param handler 操作句柄,可根据code判断数据最终是添加还是更新 【0:添加 1:更新】
|
||||||
* @param checks 检测属性名,用作where判断
|
* @param checks 检测属性名,用作where判断
|
||||||
* @return 布尔值
|
* @return 布尔值
|
||||||
*/
|
*/
|
||||||
@@ -1184,6 +1184,17 @@ public abstract class FastEntity<E extends FastEntity<?>> extends ConcurrentHash
|
|||||||
return getMapWrap().isNull(attr);
|
return getMapWrap().isNull(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否不为null
|
||||||
|
*
|
||||||
|
* @param attr 属性名
|
||||||
|
* @return 布尔值
|
||||||
|
*/
|
||||||
|
public boolean isNotNull(String attr) {
|
||||||
|
return getMapWrap().isNotNull(attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为Timestamp类型
|
* 是否为Timestamp类型
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ import com.fastchar.utils.FastStringUtils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.net.URLDecoder;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@@ -33,17 +35,20 @@ public class FastFile<T> {
|
|||||||
|
|
||||||
public static FastFile<?> newInstance(String attachDirectory, String fileName) {
|
public static FastFile<?> newInstance(String attachDirectory, String fileName) {
|
||||||
return FastChar.getOverrides().newInstance(FastFile.class)
|
return FastChar.getOverrides().newInstance(FastFile.class)
|
||||||
.setAttachDirectory(attachDirectory).setFileName(fileName);
|
.setAttachDirectory(attachDirectory).setFileName(fileName).setParamName(fileName);
|
||||||
}
|
}
|
||||||
public static FastFile<?> newInstance( String fileName) {
|
public static FastFile<?> newInstance( String fileName) {
|
||||||
return FastChar.getOverrides().newInstance(FastFile.class)
|
return FastChar.getOverrides().newInstance(FastFile.class)
|
||||||
.setAttachDirectory(FastChar.getConstant().getAttachDirectory())
|
.setAttachDirectory(FastChar.getConstant().getAttachDirectory())
|
||||||
|
.setParamName(fileName)
|
||||||
.setFileName(fileName);
|
.setFileName(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FastFile<?> newInstance(File file) {
|
public static FastFile<?> newInstance(File file) {
|
||||||
return FastChar.getOverrides().newInstance(FastFile.class)
|
return FastChar.getOverrides()
|
||||||
|
.newInstance(FastFile.class)
|
||||||
.setAttachDirectory(file.getParent())
|
.setAttachDirectory(file.getParent())
|
||||||
|
.setParamName(file.getName())
|
||||||
.setFileName(file.getName());
|
.setFileName(file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +109,15 @@ public class FastFile<T> {
|
|||||||
|
|
||||||
public FastFile<T> setUploadFileName(String uploadFileName) {
|
public FastFile<T> setUploadFileName(String uploadFileName) {
|
||||||
this.uploadFileName = uploadFileName;
|
this.uploadFileName = uploadFileName;
|
||||||
|
if (FastChar.getConstant().isDecodeUploadFileName()) {
|
||||||
|
if (FastStringUtils.isNotEmpty(this.uploadFileName)) {
|
||||||
|
try {
|
||||||
|
this.uploadFileName = URLDecoder.decode(this.uploadFileName, FastChar.getConstant().getDecodeUploadFileNameEncoding());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,15 @@ public class FastMapWrap {
|
|||||||
return "<null>".equalsIgnoreCase(String.valueOf(value));
|
return "<null>".equalsIgnoreCase(String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否不为null
|
||||||
|
* @param attr 属性名
|
||||||
|
* @return 布尔值
|
||||||
|
*/
|
||||||
|
public boolean isNotNull(String attr) {
|
||||||
|
return !isNull(attr);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为Timestamp类型
|
* 是否为Timestamp类型
|
||||||
* @param attr 属性名
|
* @param attr 属性名
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.fastchar.core;
|
|||||||
public class FastRequestParam {
|
public class FastRequestParam {
|
||||||
private String name;
|
private String name;
|
||||||
private String value;
|
private String value;
|
||||||
|
private boolean doSet;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -21,4 +22,13 @@ public class FastRequestParam {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDoSet() {
|
||||||
|
return doSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FastRequestParam setDoSet(boolean doSet) {
|
||||||
|
this.doSet = doSet;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -307,7 +307,8 @@ public final class FastScanner {
|
|||||||
extract = scannerJar.getExtract();
|
extract = scannerJar.getExtract();
|
||||||
}
|
}
|
||||||
if (extract) {
|
if (extract) {
|
||||||
String logInfo = FastChar.getLocal().getInfo(FastCharLocal.SCANNER_ERROR1, scannerJar.getJarFileName());
|
String logInfo = FastChar.getLocal().getInfo(FastCharLocal.SCANNER_ERROR1,
|
||||||
|
scannerJar.getJarFileName() + " (" + FastFileUtils.getFileSize(scannerJar.getJarFile()) + ") ");
|
||||||
FastChar.getLog().info(logInfo);
|
FastChar.getLog().info(logInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +406,8 @@ public final class FastScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (extract) {
|
if (extract) {
|
||||||
FastChar.getLog().info(FastChar.getLocal().getInfo(FastCharLocal.SCANNER_ERROR2, scannerJar.getJarFileName()));
|
FastChar.getLog().info(FastChar.getLocal().getInfo(FastCharLocal.SCANNER_ERROR2,
|
||||||
|
scannerJar.getJarFileName() + " (" + FastFileUtils.getFileSize(scannerJar.getJarFile()) + ") "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -648,7 +650,6 @@ public final class FastScanner {
|
|||||||
private final String jarVersion;
|
private final String jarVersion;
|
||||||
private String jarName;
|
private String jarName;
|
||||||
|
|
||||||
|
|
||||||
public File getJarFile() {
|
public File getJarFile() {
|
||||||
return jarFile;
|
return jarFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public final class FastDatabaseXml {
|
|||||||
|
|
||||||
|
|
||||||
public static class DatabaseInfoHandler extends DefaultHandler {
|
public static class DatabaseInfoHandler extends DefaultHandler {
|
||||||
private File xmlFile;
|
private final File xmlFile;
|
||||||
private Locator locator;
|
private Locator locator;
|
||||||
private FastDatabaseInfo databaseInfo;
|
private FastDatabaseInfo databaseInfo;
|
||||||
private FastTableInfo<?> tableInfo;
|
private FastTableInfo<?> tableInfo;
|
||||||
|
|||||||
@@ -151,6 +151,17 @@ public class FastDatabaseInfo extends FastBaseInfo {
|
|||||||
return (List<T>) tables;
|
return (List<T>) tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <T extends FastTableInfo<?>> List<T> findTables(String name) {
|
||||||
|
List<T> findTales = new ArrayList<>();
|
||||||
|
for (FastTableInfo<?> table : tables) {
|
||||||
|
if (table.getName().contains(name)) {
|
||||||
|
findTales.add((T) table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return findTales;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public FastDatabaseInfo setTables(List<FastTableInfo<?>> tables) {
|
public FastDatabaseInfo setTables(List<FastTableInfo<?>> tables) {
|
||||||
this.tables = tables;
|
this.tables = tables;
|
||||||
return this;
|
return this;
|
||||||
@@ -337,6 +348,20 @@ public class FastDatabaseInfo extends FastBaseInfo {
|
|||||||
|
|
||||||
|
|
||||||
public void validate() throws FastDatabaseException {
|
public void validate() throws FastDatabaseException {
|
||||||
|
//合并 * 号匹配的表格
|
||||||
|
|
||||||
|
List<FastTableInfo<?>> matchesTableList = findTables("*");
|
||||||
|
for (FastTableInfo<?> matchesTable : matchesTableList) {
|
||||||
|
for (FastTableInfo<?> table : this.tables) {
|
||||||
|
if (table.isLock()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (FastStringUtils.matches(matchesTable.getName(), table.getName())) {
|
||||||
|
table.merge(matchesTable, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<FastTableInfo<?>> tables = new ArrayList<>(getTables());
|
List<FastTableInfo<?>> tables = new ArrayList<>(getTables());
|
||||||
for (FastTableInfo<?> table : tables) {
|
for (FastTableInfo<?> table : tables) {
|
||||||
for (FastColumnInfo<?> column : table.getColumns()) {
|
for (FastColumnInfo<?> column : table.getColumns()) {
|
||||||
@@ -348,6 +373,8 @@ public class FastDatabaseInfo extends FastBaseInfo {
|
|||||||
table.validate();
|
table.validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.fastchar.core.FastMapWrap;
|
|||||||
import com.fastchar.exception.FastDatabaseException;
|
import com.fastchar.exception.FastDatabaseException;
|
||||||
|
|
||||||
import com.fastchar.local.FastCharLocal;
|
import com.fastchar.local.FastCharLocal;
|
||||||
|
import com.fastchar.utils.FastBooleanUtils;
|
||||||
import com.fastchar.utils.FastClassUtils;
|
import com.fastchar.utils.FastClassUtils;
|
||||||
import com.fastchar.utils.FastStringUtils;
|
import com.fastchar.utils.FastStringUtils;
|
||||||
|
|
||||||
@@ -27,6 +28,8 @@ public class FastTableInfo<T> extends FastBaseInfo {
|
|||||||
private String comment = "";
|
private String comment = "";
|
||||||
private String data;
|
private String data;
|
||||||
private boolean ignoreCase = true;
|
private boolean ignoreCase = true;
|
||||||
|
private String lock ;//锁定表格,不能*匹配表格合并
|
||||||
|
|
||||||
|
|
||||||
private List<FastColumnInfo<?>> columns = new ArrayList<>();
|
private List<FastColumnInfo<?>> columns = new ArrayList<>();
|
||||||
private FastMapWrap mapColumn;
|
private FastMapWrap mapColumn;
|
||||||
@@ -106,6 +109,15 @@ public class FastTableInfo<T> extends FastBaseInfo {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLock() {
|
||||||
|
return FastBooleanUtils.formatToBoolean(lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FastTableInfo<T> setLock(boolean lock) {
|
||||||
|
this.lock = String.valueOf(lock);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public <E extends FastColumnInfo<?>> List<E> getPrimaries() {
|
public <E extends FastColumnInfo<?>> List<E> getPrimaries() {
|
||||||
if (mapPrimary != null) {
|
if (mapPrimary != null) {
|
||||||
return new ArrayList<E>((Collection<? extends E>) mapPrimary.getMap().values());
|
return new ArrayList<E>((Collection<? extends E>) mapPrimary.getMap().values());
|
||||||
@@ -148,6 +160,10 @@ public class FastTableInfo<T> extends FastBaseInfo {
|
|||||||
|
|
||||||
|
|
||||||
public FastTableInfo<?> merge(FastTableInfo<?> info) {
|
public FastTableInfo<?> merge(FastTableInfo<?> info) {
|
||||||
|
return merge(info, false);
|
||||||
|
}
|
||||||
|
public FastTableInfo<?> merge(FastTableInfo<?> info,boolean onlyColumns) {
|
||||||
|
if (!onlyColumns) {
|
||||||
for (String key : info.keySet()) {
|
for (String key : info.keySet()) {
|
||||||
if ("columns".equals(String.valueOf(key))) {
|
if ("columns".equals(String.valueOf(key))) {
|
||||||
continue;
|
continue;
|
||||||
@@ -160,6 +176,7 @@ public class FastTableInfo<T> extends FastBaseInfo {
|
|||||||
if (info.getLineNumber() != 0) {
|
if (info.getLineNumber() != 0) {
|
||||||
setLineNumber(info.getLineNumber());
|
setLineNumber(info.getLineNumber());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (FastColumnInfo<?> column : info.getColumns()) {
|
for (FastColumnInfo<?> column : info.getColumns()) {
|
||||||
FastColumnInfo<?> existColumn = this.getColumnInfo(column.getName());
|
FastColumnInfo<?> existColumn = this.getColumnInfo(column.getName());
|
||||||
if (existColumn != null) {
|
if (existColumn != null) {
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ public class FastMySqlDatabaseOperateProvider implements IFastDatabaseOperate {
|
|||||||
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(deleteIndexStr);
|
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(deleteIndexStr);
|
||||||
}
|
}
|
||||||
String createIndexSql = String.format("alter table %s add %s index %s (%s%s)", tableName, convertIndex,
|
String createIndexSql = String.format("alter table %s add %s index %s (%s%s)", tableName, convertIndex,
|
||||||
indexName, columnName, getIndexMaxLength(getType(columnInfo)));
|
indexName, columnName, getIndexMaxLength(getLength(columnInfo), getType(columnInfo)));
|
||||||
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(createIndexSql);
|
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(createIndexSql);
|
||||||
FastChar.getLog().info(FastMySqlDatabaseOperateProvider.class,
|
FastChar.getLog().info(FastMySqlDatabaseOperateProvider.class,
|
||||||
FastChar.getLocal().getInfo(FastCharLocal.DB_TABLE_INFO4, databaseInfo.getName(), tableName, columnInfo.getName(), indexName));
|
FastChar.getLocal().getInfo(FastCharLocal.DB_TABLE_INFO4, databaseInfo.getName(), tableName, columnInfo.getName(), indexName));
|
||||||
@@ -511,7 +511,7 @@ public class FastMySqlDatabaseOperateProvider implements IFastDatabaseOperate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getIndexMaxLength(String type) {
|
public String getIndexMaxLength(String length,String type) {
|
||||||
if ("fulltext".equals(type.toLowerCase())) {
|
if ("fulltext".equals(type.toLowerCase())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -523,7 +523,11 @@ public class FastMySqlDatabaseOperateProvider implements IFastDatabaseOperate {
|
|||||||
|| FastType.isByteArrayType(type)) {
|
|| FastType.isByteArrayType(type)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "(155)";
|
int numberLength = FastNumberUtils.formatToInt(length);
|
||||||
|
if (numberLength == 0) {
|
||||||
|
numberLength = 50;
|
||||||
|
}
|
||||||
|
return "(" + Math.min(numberLength, 155) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -337,7 +337,7 @@ public class FastOracleDatabaseOperateProvider implements IFastDatabaseOperate {
|
|||||||
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(deleteIndexStr);
|
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(deleteIndexStr);
|
||||||
}
|
}
|
||||||
String createIndexSql = String.format("alter table %s add %s index %s (%s%s)", tableName, convertIndex,
|
String createIndexSql = String.format("alter table %s add %s index %s (%s%s)", tableName, convertIndex,
|
||||||
indexName, columnName, getIndexMaxLength(getType(columnInfo)));
|
indexName, columnName, getIndexMaxLength(getLength(columnInfo), getType(columnInfo)));
|
||||||
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(createIndexSql);
|
fastDb.setLog(true).setDatabase(databaseInfo.getName()).update(createIndexSql);
|
||||||
FastChar.getLog().info(FastMySqlDatabaseOperateProvider.class,
|
FastChar.getLog().info(FastMySqlDatabaseOperateProvider.class,
|
||||||
FastChar.getLocal().getInfo(FastCharLocal.DB_TABLE_INFO4, databaseInfo.getName(), tableName, columnInfo.getName(), indexName));
|
FastChar.getLocal().getInfo(FastCharLocal.DB_TABLE_INFO4, databaseInfo.getName(), tableName, columnInfo.getName(), indexName));
|
||||||
@@ -487,7 +487,7 @@ public class FastOracleDatabaseOperateProvider implements IFastDatabaseOperate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getIndexMaxLength(String type) {
|
public String getIndexMaxLength(String length,String type) {
|
||||||
if ("fulltext".equals(type.toLowerCase())) {
|
if ("fulltext".equals(type.toLowerCase())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -499,7 +499,11 @@ public class FastOracleDatabaseOperateProvider implements IFastDatabaseOperate {
|
|||||||
|| FastType.isByteArrayType(type)) {
|
|| FastType.isByteArrayType(type)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "(155)";
|
int numberLength = FastNumberUtils.formatToInt(length);
|
||||||
|
if (numberLength == 0) {
|
||||||
|
numberLength = 50;
|
||||||
|
}
|
||||||
|
return "(" + Math.min(numberLength, 155) + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.fastchar.exception.FastSqlException;
|
|||||||
import com.fastchar.interfaces.IFastColumnSecurity;
|
import com.fastchar.interfaces.IFastColumnSecurity;
|
||||||
import com.fastchar.local.FastCharLocal;
|
import com.fastchar.local.FastCharLocal;
|
||||||
import com.fastchar.utils.FastArrayUtils;
|
import com.fastchar.utils.FastArrayUtils;
|
||||||
|
import com.fastchar.utils.FastNumberUtils;
|
||||||
import com.fastchar.utils.FastStringUtils;
|
import com.fastchar.utils.FastStringUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
|||||||
@@ -79,13 +79,17 @@ public class FastEhCache2Provider implements IFastCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(String tag, String key, Object data) {
|
public void set(String tag, String key, Object data) {
|
||||||
if (FastStringUtils.isEmpty(tag)||FastStringUtils.isEmpty(key)) {
|
if (FastStringUtils.isEmpty(tag) || FastStringUtils.isEmpty(key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Cache cache = getCache(tag);
|
Cache cache = getCache(tag);
|
||||||
|
if (data == null) {
|
||||||
|
cache.remove(key);
|
||||||
|
} else {
|
||||||
Element element = new Element(key, data);
|
Element element = new Element(key, data);
|
||||||
cache.put(element);
|
cache.put(element);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T get(String tag, String key) {
|
public <T> T get(String tag, String key) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class FastEhCache3Provider implements IFastCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(String tag, String key, Object data) {
|
public void set(String tag, String key, Object data) {
|
||||||
if (FastStringUtils.isEmpty(tag)||FastStringUtils.isEmpty(key)) {
|
if (FastStringUtils.isEmpty(tag) || FastStringUtils.isEmpty(key)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Cache<String,Object> cache = getCache(tag);
|
Cache<String,Object> cache = getCache(tag);
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ public class FastRedisConfig implements IFastConfig {
|
|||||||
private JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
private JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
|
||||||
|
|
||||||
public FastRedisConfig() {
|
public FastRedisConfig() {
|
||||||
jedisPoolConfig.setSoftMinEvictableIdleTimeMillis(1800000);
|
jedisPoolConfig.setSoftMinEvictableIdleTimeMillis(60000);
|
||||||
|
jedisPoolConfig.setMinEvictableIdleTimeMillis(60000);
|
||||||
|
jedisPoolConfig.setTestWhileIdle(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ public class FastRedisNormalProvider implements IFastCache {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try (Jedis jedis = getJedis()) {
|
try (Jedis jedis = getJedis()) {
|
||||||
return jedis.exists(wrapKey(tag, key));
|
return jedis.get(wrapKey(tag, key)) != null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +99,13 @@ public class FastRedisNormalProvider implements IFastCache {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try (Jedis jedis = getJedis()) {
|
try (Jedis jedis = getJedis()) {
|
||||||
|
if (data == null) {
|
||||||
|
jedis.del(wrapKey(tag, key).getBytes());
|
||||||
|
}else{
|
||||||
jedis.set(wrapKey(tag, key).getBytes(), FastSerializeUtils.serialize(data));
|
jedis.set(wrapKey(tag, key).getBytes(), FastSerializeUtils.serialize(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T get(String tag, String key) throws Exception {
|
public <T> T get(String tag, String key) throws Exception {
|
||||||
|
|||||||
@@ -92,6 +92,14 @@ public final class FastCharLocal {
|
|||||||
public static final String PARAM_ERROR2 = "Param_Error2";
|
public static final String PARAM_ERROR2 = "Param_Error2";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述模板:
|
||||||
|
* 参数{0}值错误!
|
||||||
|
*/
|
||||||
|
public static final String PARAM_ERROR3 = "Param_Error3";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 描述模板:
|
* 描述模板:
|
||||||
* 请求前置的拦截器{0}没有执行response或invoke方法!
|
* 请求前置的拦截器{0}没有执行response或invoke方法!
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class FastCharLocal_CN extends FastCharBaseLocal {
|
|||||||
//参数相关错误
|
//参数相关错误
|
||||||
private final String Param_Error1 = "参数{0}不可为空!";
|
private final String Param_Error1 = "参数{0}不可为空!";
|
||||||
private final String Param_Error2 = "参数{0}值错误!";
|
private final String Param_Error2 = "参数{0}值错误!";
|
||||||
|
private final String Param_Error3 = "参数异常!";
|
||||||
|
|
||||||
private final String Interceptor_Error1 = "请求前置的拦截器{0}没有执行response或invoke方法!";
|
private final String Interceptor_Error1 = "请求前置的拦截器{0}没有执行response或invoke方法!";
|
||||||
private final String Interceptor_Error2 = "请求后置的拦截器{0}没有执行response或invoke方法!";
|
private final String Interceptor_Error2 = "请求后置的拦截器{0}没有执行response或invoke方法!";
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.fastchar.core.FastChar;
|
|||||||
import com.fastchar.core.FastFile;
|
import com.fastchar.core.FastFile;
|
||||||
import com.fastchar.exception.FastFileException;
|
import com.fastchar.exception.FastFileException;
|
||||||
import com.fastchar.local.FastCharLocal;
|
import com.fastchar.local.FastCharLocal;
|
||||||
import com.fastchar.utils.FastHttpUtils;
|
import com.fastchar.utils.FastRequestUtils;
|
||||||
|
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -56,7 +56,7 @@ public class FastMultipartRequest {
|
|||||||
MultipartParser parser = new MultipartParser(request, maxPostSize, true, true, encoding);
|
MultipartParser parser = new MultipartParser(request, maxPostSize, true, true, encoding);
|
||||||
Vector existingValues;
|
Vector existingValues;
|
||||||
if (request.getQueryString() != null) {
|
if (request.getQueryString() != null) {
|
||||||
Hashtable queryParameters = FastHttpUtils.parseQueryString(request.getQueryString());
|
Hashtable queryParameters = FastRequestUtils.parseQueryString(request.getQueryString());
|
||||||
Enumeration queryParameterNames = queryParameters.keys();
|
Enumeration queryParameterNames = queryParameters.keys();
|
||||||
|
|
||||||
while (queryParameterNames.hasMoreElements()) {
|
while (queryParameterNames.hasMoreElements()) {
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ public class FastOutError extends FastOut<FastOutError> {
|
|||||||
.replace("\t", " ");
|
.replace("\t", " ");
|
||||||
String html = "";
|
String html = "";
|
||||||
if (getStatus() == 404) {
|
if (getStatus() == 404) {
|
||||||
html = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>404</title><style>* {margin: 0;padding: 0;}table {width: 100%;font-weight: bold;font-size: 20px;}tr {background-color: lightgray;}td {padding-left: 10px;padding-top: 5px;padding-bottom: 5px;word-wrap: break-word; word-break:break-all;}</style></head><body><table><tr style=\"background-color: orangered; color: #ffffff;\"><td width=\"200px;\" align=\"right\">HTTP Status:</td><td>404</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">HttpMethod:</td><td>"+action.getRequestMethod()+"</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">Message:</td><td>Http url does not exist!</td></tr><tr><td align=\"right\" valign=\"top\">Description:</td><td>" + description + "</td></tr><tr><td align=\"right\">Powered By:</td><td>" + POWERED_BY + "</td></tr><tr><td align=\"right\">Version:</td><td>" + FastConstant.FAST_CHAR_VERSION + "</td></tr></table></body></html>";
|
html = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>404</title><style>* {margin: 0;padding: 0;}table {width: 100%;font-weight: bold;font-size: 20px;}tr {background-color: lightgray;}td {padding-left: 10px;padding-top: 5px;padding-bottom: 5px;word-wrap: break-word; word-break:break-all;}</style></head><body><table><tr style=\"background-color: orangered; color: #ffffff;\"><td width=\"200px;\" align=\"right\">HTTP Status:</td><td>404</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">HTTP Method:</td><td>"+action.getRequestMethod()+"</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">Message:</td><td>Http url does not exist!</td></tr><tr><td align=\"right\" valign=\"top\">Description:</td><td>" + description + "</td></tr><tr><td align=\"right\">Powered By:</td><td>" + POWERED_BY + "</td></tr><tr><td align=\"right\">Version:</td><td>" + FastConstant.FAST_CHAR_VERSION + "</td></tr></table></body></html>";
|
||||||
} else if (getStatus() == 502) {
|
} else if (getStatus() == 502) {
|
||||||
html = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>502</title><style>* {margin: 0;padding: 0;}table {width: 100%;font-weight: bold;font-size: 20px;}tr {background-color: lightgray;}td {padding-left: 10px;padding-top: 5px;padding-bottom: 5px;word-wrap: break-word; word-break:break-all;}</style></head><body><table><tr style=\"background-color: orangered; color: #ffffff;\"><td width=\"200px;\" align=\"right\">HTTP Status:</td><td>502</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">HttpMethod:</td><td>"+action.getRequestMethod()+"</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">Message:</td><td>The Http response is not received!</td></tr><tr><td align=\"right\" valign=\"top\">Description:</td><td>" + description + "</td></tr><tr><td align=\"right\">Powered By:</td><td>" + POWERED_BY + "</td></tr><tr><td align=\"right\">Version:</td><td>" + FastConstant.FAST_CHAR_VERSION + "</td></tr></table></body></html>";
|
html = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>502</title><style>* {margin: 0;padding: 0;}table {width: 100%;font-weight: bold;font-size: 20px;}tr {background-color: lightgray;}td {padding-left: 10px;padding-top: 5px;padding-bottom: 5px;word-wrap: break-word; word-break:break-all;}</style></head><body><table><tr style=\"background-color: orangered; color: #ffffff;\"><td width=\"200px;\" align=\"right\">HTTP Status:</td><td>502</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">HTTP Method:</td><td>"+action.getRequestMethod()+"</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">Message:</td><td>The Http response is not received!</td></tr><tr><td align=\"right\" valign=\"top\">Description:</td><td>" + description + "</td></tr><tr><td align=\"right\">Powered By:</td><td>" + POWERED_BY + "</td></tr><tr><td align=\"right\">Version:</td><td>" + FastConstant.FAST_CHAR_VERSION + "</td></tr></table></body></html>";
|
||||||
} else {
|
} else {
|
||||||
html = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>" + getStatus() + "</title><style>* {margin: 0;padding: 0;}table {width: 100%;font-weight: bold;font-size: 20px;}tr {background-color: lightgray;}td {padding-left: 10px;padding-top: 5px;padding-bottom: 5px; word-wrap: break-word; word-break:break-all;}</style></head><body><table><tr style=\"background-color: orangered; color: #ffffff;\"><td width=\"200px;\" align=\"right\">HTTP Status:</td><td>500</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">HttpMethod:</td><td>"+action.getRequestMethod()+"</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">Message:</td><td>An error occurred on the server!</td></tr><tr><td align=\"right\" valign=\"top\">Description:</td><td>" + description + "</td></tr><tr><td align=\"right\">Powered By:</td><td>" + POWERED_BY + "</td></tr><tr><td align=\"right\">Version:</td><td>" + FastConstant.FAST_CHAR_VERSION + "</td></tr></table></body></html>";
|
html = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"><title>" + getStatus() + "</title><style>* {margin: 0;padding: 0;}table {width: 100%;font-weight: bold;font-size: 20px;}tr {background-color: lightgray;}td {padding-left: 10px;padding-top: 5px;padding-bottom: 5px; word-wrap: break-word; word-break:break-all;}</style></head><body><table><tr style=\"background-color: orangered; color: #ffffff;\"><td width=\"200px;\" align=\"right\">HTTP Status:</td><td>500</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">HTTP Method:</td><td>"+action.getRequestMethod()+"</td></tr><tr><td style=\"background-color: lightgray\" align=\"right\">Message:</td><td>An error occurred on the server!</td></tr><tr><td align=\"right\" valign=\"top\">Description:</td><td>" + description + "</td></tr><tr><td align=\"right\">Powered By:</td><td>" + POWERED_BY + "</td></tr><tr><td align=\"right\">Version:</td><td>" + FastConstant.FAST_CHAR_VERSION + "</td></tr></table></body></html>";
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.fastchar.out;
|
package com.fastchar.out;
|
||||||
|
|
||||||
|
import com.fastchar.annotation.AFastClassFind;
|
||||||
import com.fastchar.core.FastAction;
|
import com.fastchar.core.FastAction;
|
||||||
import com.fastchar.core.FastChar;
|
import com.fastchar.core.FastChar;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
@@ -14,6 +15,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* 响应Freemarker模板
|
* 响应Freemarker模板
|
||||||
*/
|
*/
|
||||||
|
@AFastClassFind(value = "freemarker.template.Template", url = "https://mvnrepository.com/artifact/org.freemarker/freemarker")
|
||||||
public class FastOutFreemarker extends FastOut<FastOutFreemarker> {
|
public class FastOutFreemarker extends FastOut<FastOutFreemarker> {
|
||||||
|
|
||||||
public FastOutFreemarker() {
|
public FastOutFreemarker() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.fastchar.out;
|
package com.fastchar.out;
|
||||||
|
|
||||||
|
import com.fastchar.annotation.AFastClassFind;
|
||||||
import com.fastchar.core.FastAction;
|
import com.fastchar.core.FastAction;
|
||||||
import com.fastchar.core.FastChar;
|
import com.fastchar.core.FastChar;
|
||||||
import org.thymeleaf.context.WebContext;
|
import org.thymeleaf.context.WebContext;
|
||||||
@@ -13,6 +14,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* 响应输出Thymeleaf模板
|
* 响应输出Thymeleaf模板
|
||||||
*/
|
*/
|
||||||
|
@AFastClassFind(value = "org.thymeleaf.context.WebContext", url = "https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf")
|
||||||
public class FastOutThymeleaf extends FastOut<FastOutThymeleaf> {
|
public class FastOutThymeleaf extends FastOut<FastOutThymeleaf> {
|
||||||
public FastOutThymeleaf() {
|
public FastOutThymeleaf() {
|
||||||
this.contentType = "text/html";
|
this.contentType = "text/html";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.fastchar.out;
|
package com.fastchar.out;
|
||||||
|
|
||||||
|
import com.fastchar.annotation.AFastClassFind;
|
||||||
import com.fastchar.core.FastAction;
|
import com.fastchar.core.FastAction;
|
||||||
import com.fastchar.core.FastChar;
|
import com.fastchar.core.FastChar;
|
||||||
import com.fastchar.local.FastCharLocal;
|
import com.fastchar.local.FastCharLocal;
|
||||||
@@ -16,6 +17,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* 响应输出Velocity模板
|
* 响应输出Velocity模板
|
||||||
*/
|
*/
|
||||||
|
@AFastClassFind(value = "org.apache.velocity.VelocityContext", url = "https://mvnrepository.com/artifact/org.apache.velocity/velocity-engine-core")
|
||||||
public class FastOutVelocity extends FastOut<FastOutVelocity> {
|
public class FastOutVelocity extends FastOut<FastOutVelocity> {
|
||||||
|
|
||||||
public FastOutVelocity() {
|
public FastOutVelocity() {
|
||||||
@@ -24,6 +26,7 @@ public class FastOutVelocity extends FastOut<FastOutVelocity> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 响应数据
|
* 响应数据
|
||||||
|
*
|
||||||
* @param action
|
* @param action
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -51,15 +54,15 @@ public class FastOutVelocity extends FastOut<FastOutVelocity> {
|
|||||||
context.put(key, finalContext.get(key));
|
context.put(key, finalContext.get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Enumeration<String> attrs = request.getAttributeNames(); attrs.hasMoreElements();) {
|
for (Enumeration<String> attrs = request.getAttributeNames(); attrs.hasMoreElements(); ) {
|
||||||
String attrName = attrs.nextElement();
|
String attrName = attrs.nextElement();
|
||||||
context.put(attrName, request.getAttribute(attrName));
|
context.put(attrName, request.getAttribute(attrName));
|
||||||
}
|
}
|
||||||
for (Enumeration<String> attrs = request.getSession().getAttributeNames(); attrs.hasMoreElements();) {
|
for (Enumeration<String> attrs = request.getSession().getAttributeNames(); attrs.hasMoreElements(); ) {
|
||||||
String attrName = attrs.nextElement();
|
String attrName = attrs.nextElement();
|
||||||
context.put(attrName, request.getSession().getAttribute(attrName));
|
context.put(attrName, request.getSession().getAttribute(attrName));
|
||||||
}
|
}
|
||||||
try (PrintWriter writer = response.getWriter()){
|
try (PrintWriter writer = response.getWriter()) {
|
||||||
template.merge(context, writer);
|
template.merge(context, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class FastDateUtils {
|
|||||||
return parse(date, pattern, null);
|
return parse(date, pattern, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date parse(String date, String pattern, Date defaultValue){
|
public static Date parse(String date, String pattern, Date defaultValue) {
|
||||||
try {
|
try {
|
||||||
if (FastStringUtils.isEmpty(date)) {
|
if (FastStringUtils.isEmpty(date)) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
@@ -45,7 +45,6 @@ public class FastDateUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Date addYears(Date date, int amount) {
|
public static Date addYears(Date date, int amount) {
|
||||||
return add(date, 1, amount);
|
return add(date, 1, amount);
|
||||||
}
|
}
|
||||||
@@ -141,7 +140,7 @@ public class FastDateUtils {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
SimpleDateFormat sdf2 = new SimpleDateFormat(timePattern);
|
SimpleDateFormat sdf2 = new SimpleDateFormat(timePattern);
|
||||||
int subDay = diffDay(dateTime, new Date());
|
int subDay = (int) diffDay(dateTime, new Date());
|
||||||
switch (subDay) {
|
switch (subDay) {
|
||||||
case 0:
|
case 0:
|
||||||
return FastChar.getLocal().getInfo(FastCharLocal.DATE_ERROR1) + sdf2.format(dateTime);
|
return FastChar.getLocal().getInfo(FastCharLocal.DATE_ERROR1) + sdf2.format(dateTime);
|
||||||
@@ -153,43 +152,42 @@ public class FastDateUtils {
|
|||||||
return format(dateTime, "yyyy-MM-dd ") + sdf2.format(dateTime);
|
return format(dateTime, "yyyy-MM-dd ") + sdf2.format(dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int diffDay(Date first, Date two) {
|
public static double diffDay(Date first, Date two) {
|
||||||
try {
|
try {
|
||||||
return (int) Math.abs( (first.getTime() - two.getTime()) / (60 * 60 * 1000 * 24));
|
return Math.abs(first.getTime() - two.getTime()) / (60.0 * 60 * 1000 * 24);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int diffHour(Date first, Date two) {
|
public static double diffHour(Date first, Date two) {
|
||||||
try {
|
try {
|
||||||
return (int) Math.abs((first.getTime() - two.getTime()) / (60 * 60 * 1000));
|
return Math.abs(first.getTime() - two.getTime()) / (60.0 * 60 * 1000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int diffMinute(Date first, Date two) {
|
public static double diffMinute(Date first, Date two) {
|
||||||
try {
|
try {
|
||||||
return (int) Math.abs((first.getTime() - two.getTime()) / (60 * 1000));
|
return Math.abs(first.getTime() - two.getTime()) / (60.0 * 1000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int diffSecond(Date first, Date two) {
|
public static double diffSecond(Date first, Date two) {
|
||||||
try {
|
try {
|
||||||
return (int) Math.abs((first.getTime() - two.getTime()) / (1000));
|
return Math.abs(first.getTime() - two.getTime()) / 1000.0;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static int diffYear(Date first, Date two) {
|
public static int diffYear(Date first, Date two) {
|
||||||
try {
|
try {
|
||||||
Calendar firstCal = Calendar.getInstance();
|
Calendar firstCal = Calendar.getInstance();
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import java.lang.reflect.Array;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
public class FastEnumUtils {
|
public class FastEnumUtils {
|
||||||
|
|
||||||
|
|
||||||
public static <T extends Enum> T formatToEnum(Class<T> clazz, int index){
|
public static <T extends Enum> T formatToEnum(Class<T> clazz, int index) {
|
||||||
return formatToEnum(clazz, index, null);
|
return formatToEnum(clazz, index, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ public class FastEnumUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <T extends Enum> T formatToEnum(Class<T> clazz, String name){
|
public static <T extends Enum> T formatToEnum(Class<T> clazz, String name) {
|
||||||
return formatToEnum(clazz, name, null);
|
return formatToEnum(clazz, name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +38,9 @@ public class FastEnumUtils {
|
|||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
return formatToEnum(clazz, index, defaultValue);
|
return formatToEnum(clazz, index, defaultValue);
|
||||||
}
|
}
|
||||||
|
if (FastNumberUtils.isNumber(name)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return (T) Enum.valueOf(clazz, name);
|
return (T) Enum.valueOf(clazz, name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -82,6 +85,11 @@ public class FastEnumUtils {
|
|||||||
return enumList.toArray((T[]) Array.newInstance(targetClass, enumList.size()));
|
return enumList.toArray((T[]) Array.newInstance(targetClass, enumList.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T extends Enum<?>> T[] getEnumValuesOr(Class<T> targetClass, String... keys) {
|
||||||
|
return getEnumValues(targetClass, keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Integer[] getEnumOrdinals(Class<? extends Enum<?>> targetClass, String... keys) {
|
public static Integer[] getEnumOrdinals(Class<? extends Enum<?>> targetClass, String... keys) {
|
||||||
List<Integer> enumList = new ArrayList<>();
|
List<Integer> enumList = new ArrayList<>();
|
||||||
Enum[] enumConstants = targetClass.getEnumConstants();
|
Enum[] enumConstants = targetClass.getEnumConstants();
|
||||||
@@ -116,4 +124,7 @@ public class FastEnumUtils {
|
|||||||
return enumList.toArray(new Integer[]{});
|
return enumList.toArray(new Integer[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Integer[] getEnumOrdinalsOr(Class<? extends Enum<?>> targetClass, String... keys) {
|
||||||
|
return getEnumOrdinals(targetClass, keys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.net.URLConnection;
|
|||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
@@ -76,7 +77,6 @@ public class FastFileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isImageFileByMimeType(String mimeType) {
|
public static boolean isImageFileByMimeType(String mimeType) {
|
||||||
String[] mimeTypes = new String[]{
|
String[] mimeTypes = new String[]{
|
||||||
"image/bmp",
|
"image/bmp",
|
||||||
@@ -93,6 +93,7 @@ public class FastFileUtils {
|
|||||||
|
|
||||||
return isTargetFileByMimeType(mimeType, mimeTypes);
|
return isTargetFileByMimeType(mimeType, mimeTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMP4FileByMimeType(String mimeType) {
|
public static boolean isMP4FileByMimeType(String mimeType) {
|
||||||
String[] extensions = new String[]{
|
String[] extensions = new String[]{
|
||||||
"video/mp4"
|
"video/mp4"
|
||||||
@@ -121,6 +122,7 @@ public class FastFileUtils {
|
|||||||
};
|
};
|
||||||
return isTargetFileByMimeType(mimeType, extensions);
|
return isTargetFileByMimeType(mimeType, extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isExcelFileByMimeType(String mimeType) {
|
public static boolean isExcelFileByMimeType(String mimeType) {
|
||||||
String[] extensions = new String[]{
|
String[] extensions = new String[]{
|
||||||
"application/vnd.ms-excel",
|
"application/vnd.ms-excel",
|
||||||
@@ -128,6 +130,7 @@ public class FastFileUtils {
|
|||||||
};
|
};
|
||||||
return isTargetFileByMimeType(mimeType, extensions);
|
return isTargetFileByMimeType(mimeType, extensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWordFileByMimeType(String mimeType) {
|
public static boolean isWordFileByMimeType(String mimeType) {
|
||||||
String[] extensions = new String[]{
|
String[] extensions = new String[]{
|
||||||
"application/msword",
|
"application/msword",
|
||||||
@@ -171,7 +174,6 @@ public class FastFileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static FileInputStream openInputStream(File file) throws IOException {
|
public static FileInputStream openInputStream(File file) throws IOException {
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
@@ -826,7 +828,7 @@ public class FastFileUtils {
|
|||||||
return urlType;
|
return urlType;
|
||||||
}
|
}
|
||||||
InputStream inputStream = conn.getInputStream();
|
InputStream inputStream = conn.getInputStream();
|
||||||
String guessType = HttpURLConnection.guessContentTypeFromStream( new BufferedInputStream(inputStream));
|
String guessType = HttpURLConnection.guessContentTypeFromStream(new BufferedInputStream(inputStream));
|
||||||
if (FastStringUtils.isEmpty(guessType)) {
|
if (FastStringUtils.isEmpty(guessType)) {
|
||||||
return urlType;
|
return urlType;
|
||||||
}
|
}
|
||||||
@@ -837,8 +839,6 @@ public class FastFileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void writeByteArrayToFile(File file, byte[] data) throws IOException {
|
public static void writeByteArrayToFile(File file, byte[] data) throws IOException {
|
||||||
writeByteArrayToFile(file, data, false);
|
writeByteArrayToFile(file, data, false);
|
||||||
}
|
}
|
||||||
@@ -856,4 +856,21 @@ public class FastFileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getFileSize(File file) {
|
||||||
|
if (file == null || !file.exists()) {
|
||||||
|
return "0B";
|
||||||
|
}
|
||||||
|
if (file.length() < 1024) {
|
||||||
|
return file.length() + "B";
|
||||||
|
}
|
||||||
|
long size = (long) Math.ceil(file.length() / 1024.0);
|
||||||
|
if (size < 1024) {
|
||||||
|
return size + "KB";
|
||||||
|
} else {
|
||||||
|
double endSize = size / 1024.0;
|
||||||
|
return FastNumberUtils.formatToDouble(endSize, 1) + "MB";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public class FastLockUtils {
|
public class FastLockUtils {
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, ReentrantLock> lockMap = new ConcurrentHashMap<String, ReentrantLock>();
|
private static final ConcurrentHashMap<String, ReentrantLock> LOCK_MAP = new ConcurrentHashMap<String, ReentrantLock>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -18,13 +18,12 @@ public class FastLockUtils {
|
|||||||
* @return ReentrantLock
|
* @return ReentrantLock
|
||||||
*/
|
*/
|
||||||
public static ReentrantLock getLock(String key) {
|
public static ReentrantLock getLock(String key) {
|
||||||
ReentrantLock lock = lockMap.get(key);
|
ReentrantLock lock = LOCK_MAP.get(key);
|
||||||
if (lock != null) {
|
if (lock != null) {
|
||||||
return lock;
|
return lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock = new ReentrantLock();
|
lock = new ReentrantLock();
|
||||||
ReentrantLock previousLock = lockMap.putIfAbsent(key, lock);
|
ReentrantLock previousLock = LOCK_MAP.putIfAbsent(key, lock);
|
||||||
return previousLock == null ? lock : previousLock;
|
return previousLock == null ? lock : previousLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ public class FastLockUtils {
|
|||||||
* @param key 唯一key
|
* @param key 唯一key
|
||||||
*/
|
*/
|
||||||
public static void removeLock(String key) {
|
public static void removeLock(String key) {
|
||||||
lockMap.remove(key);
|
LOCK_MAP.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import java.util.StringTokenizer;
|
|||||||
* @author 沈建(Janesen)
|
* @author 沈建(Janesen)
|
||||||
* @date 2020/8/6 17:46
|
* @date 2020/8/6 17:46
|
||||||
*/
|
*/
|
||||||
public class FastHttpUtils {
|
public class FastRequestUtils {
|
||||||
|
|
||||||
private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
|
private static final String LSTRING_FILE = "javax.servlet.http.LocalStrings";
|
||||||
private static final ResourceBundle L_STRINGS = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
|
private static final ResourceBundle L_STRINGS = ResourceBundle.getBundle("javax.servlet.http.LocalStrings");
|
||||||
|
|
||||||
public FastHttpUtils() {
|
public FastRequestUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Hashtable<String, String[]> parseQueryString(String s) {
|
public static Hashtable<String, String[]> parseQueryString(String s) {
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.fastchar.validators;
|
package com.fastchar.validators;
|
||||||
|
|
||||||
import com.fastchar.interfaces.IFastValidator;
|
import com.fastchar.interfaces.IFastValidator;
|
||||||
|
import com.fastchar.local.FastCharLocal;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -9,6 +10,9 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public abstract class FastBaseValidator implements IFastValidator {
|
public abstract class FastBaseValidator implements IFastValidator {
|
||||||
|
|
||||||
|
private boolean securityMessage;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> pluckKeys(String validator) {
|
public Set<String> pluckKeys(String validator) {
|
||||||
Set<String> keys = new HashSet<>();
|
Set<String> keys = new HashSet<>();
|
||||||
@@ -32,8 +36,20 @@ public abstract class FastBaseValidator implements IFastValidator {
|
|||||||
|
|
||||||
|
|
||||||
protected String formatMessage(String message, String key) {
|
protected String formatMessage(String message, String key) {
|
||||||
|
if (isSecurityMessage()) {
|
||||||
|
return FastCharLocal.PARAM_ERROR3;
|
||||||
|
}
|
||||||
message = message.replaceAll("#.*", "");
|
message = message.replaceAll("#.*", "");
|
||||||
return MessageFormat.format(message, key);
|
return MessageFormat.format(message, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isSecurityMessage() {
|
||||||
|
return securityMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FastBaseValidator setSecurityMessage(boolean securityMessage) {
|
||||||
|
this.securityMessage = securityMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import java.util.regex.Pattern;
|
|||||||
*/
|
*/
|
||||||
public class FastNullValidator extends FastBaseValidator {
|
public class FastNullValidator extends FastBaseValidator {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String validate(String validator, String key, Object value) {
|
public String validate(String validator, String key, Object value) {
|
||||||
if (checkKey(validator, key)) {
|
if (checkKey(validator, key)) {
|
||||||
|
|||||||
@@ -143,3 +143,12 @@ V1.5.5
|
|||||||
4、优化FastDateUtils类!
|
4、优化FastDateUtils类!
|
||||||
5、优化FastSerializeUtils类!
|
5、优化FastSerializeUtils类!
|
||||||
6、优化FastEntity类,新增getColumns方法!
|
6、优化FastEntity类,新增getColumns方法!
|
||||||
|
7、优化FastEnumUtils类!
|
||||||
|
8、新增表格xml配置名称"*"可通用配置所有表格列!
|
||||||
|
9、新增setParam方法,可以强制设置提交的参数!
|
||||||
|
10、优化FastFile类!
|
||||||
|
|
||||||
|
V1.5.6
|
||||||
|
1、优化FastAction的获取附件方法。
|
||||||
|
2、优化FastBaseValidator验证器!
|
||||||
|
3、优化Jedis读取Redis问题!
|
||||||
Reference in New Issue
Block a user