Compare commits
89 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a872b9e02e | ||
|
|
4ef6d1a981 | ||
|
|
6959238eec | ||
|
|
a94de0c372 | ||
|
|
1d250a126a | ||
|
|
57f67c0a0e | ||
|
|
7dc85de589 | ||
|
|
ebf7b52656 | ||
|
|
021672b180 | ||
|
|
0c84378419 | ||
|
|
968e5fe357 | ||
|
|
bc66796ca7 | ||
|
|
c16e81b410 | ||
|
|
8a64867ed3 | ||
|
|
43a6f86115 | ||
|
|
38f8c6cda3 | ||
|
|
41db27ae0d | ||
|
|
90ec91cc69 | ||
|
|
1ce27089e2 | ||
|
|
8ebb5b07f6 | ||
|
|
2717f036ec | ||
|
|
34125ee274 | ||
|
|
7d6e99c8fb | ||
|
|
d9e18a70c7 | ||
|
|
c9ecd3cfc8 | ||
|
|
fe030b75c6 | ||
|
|
8563888fd5 | ||
|
|
39a5f6164d | ||
|
|
8b3a20b68b | ||
|
|
f6f824054a | ||
|
|
9e163b1034 | ||
|
|
1f92830aec | ||
|
|
85c50bbd40 | ||
|
|
6c7decc4a3 | ||
|
|
bfabf1a85e | ||
|
|
5706c8bfc9 | ||
|
|
27434ee26e | ||
|
|
7bcf1095ff | ||
|
|
01abf24665 | ||
|
|
8f4724fab2 | ||
|
|
b908885634 | ||
|
|
91d0e233f9 | ||
|
|
cfdc99f190 | ||
|
|
c553d966d6 | ||
|
|
0267908ece | ||
|
|
7fdcecb912 | ||
|
|
e1b6cdc831 | ||
|
|
596b1245d9 | ||
|
|
145e0b6b07 | ||
|
|
437220e34a | ||
|
|
28e1cd6f1d | ||
|
|
09286c8287 | ||
|
|
b195480441 | ||
|
|
ec73aa0ab0 | ||
|
|
55bc4dd3ad | ||
|
|
7a82d8a31c | ||
|
|
3e6044d902 | ||
|
|
15dcb1b27d | ||
|
|
849b3a7ec0 | ||
|
|
225a6a94ad | ||
|
|
8c52dd5db1 | ||
|
|
300bbd5f8f | ||
|
|
099ce0758b | ||
|
|
f91bb55f38 | ||
|
|
0e67815b8d | ||
|
|
19ba6daea7 | ||
|
|
45a09933b0 | ||
|
|
fc88e47a4b | ||
|
|
dc088a4764 | ||
|
|
6895d57cfa | ||
|
|
1b09cf9969 | ||
|
|
086ca1d882 | ||
|
|
d336c0fcf7 | ||
|
|
9736100fdc | ||
|
|
38acf1ae16 | ||
|
|
7ffa86df6e | ||
|
|
2a8a7edb83 | ||
|
|
4cf49b7446 | ||
|
|
9db7917975 | ||
|
|
5dfa01c421 | ||
|
|
4f8e2ccb4e | ||
|
|
b643b97603 | ||
|
|
e651f23210 | ||
|
|
8ecd600155 | ||
|
|
45fabc8ca0 | ||
|
|
89fdfc2070 | ||
|
|
a8cc129464 | ||
|
|
a1577453c3 | ||
|
|
2288884964 |
11
README.md
11
README.md
@@ -21,6 +21,7 @@ JeeSite 自开源以来已被广大爱好者用到了企业、政府、医疗、
|
||||
* 视图层:Spring MVC 4.3、Beetl 2.7 替换JSP、Bootstrap 3.3、AdminLTE 2.4
|
||||
* 前端组件:jQuery 1.12、jqGrid 4.7、layer 3.0、zTree 3.5、jquery-validation
|
||||
* 工具组件:Apache Commons、Logback 1.1、Jackson 2.8、POI 3.14、Quartz 2.2
|
||||
* JFlow工作流引擎:<https://gitee.com/thinkgem/jeesite4-jflow> :<http://ccflow.org>
|
||||
* 乐云短信网关:SmsUtils.java :<http://www.lehuo520.cn>
|
||||
* 技术选型详情:<http://jeesite4.mydoc.io/?t=273599>
|
||||
|
||||
@@ -38,6 +39,8 @@ JeeSite 自开源以来已被广大爱好者用到了企业、政府、医疗、
|
||||
* 数据表格API (DataGrid.js):<http://jeesite4.mydoc.io/?t=301488>
|
||||
* 修改 (默认) 视图,新增主题:<http://jeesite4.mydoc.io/?t=267355>
|
||||
* 手机 API 接口调用、前后分离:<http://jeesite4.mydoc.io/?t=270527>
|
||||
* 代码生成工具使用手册:<http://jeesite4.mydoc.io/?t=316743>
|
||||
* 常见问题:<http://jeesite4.mydoc.io/?t=284210>
|
||||
|
||||
# 快速体验
|
||||
|
||||
@@ -90,12 +93,12 @@ JeeSite的小版本(4.0.x)升级是非常便捷的,你只需要将 pom.xml
|
||||
# 技术交流方式
|
||||
|
||||
* QQ 群号: `127515876(已满)` `209330483(已满)` `223507718(已满)` `709534275` `730390092`
|
||||
* 入群须知:目前为付费群,刚入群会有5分钟禁言,腾讯预设置的,无法解除,稍等片刻即可正常发言;由于群容量有限,为了维持运营千人QQ群的所需支付的QQ年费会员费用,故开启付费入群模式,申请者只需支付少量金额即可加入,这样也可以保证只有真实交流需求的人进入,避免闲杂做广告人员的乱入;新手提问前,请先阅读此[【文章】](http://www.dianbo.org/9238/stone/tiwendezhihui.htm)。
|
||||
* Gitee:<https://gitee.com/thinkgem/jeesite4>
|
||||
* 问题反馈:<https://gitee.com/thinkgem/jeesite4/issues> [【新手必读】](http://www.dianbo.org/9238/stone/tiwendezhihui.htm)
|
||||
* 码云Gitee:<https://gitee.com/thinkgem/jeesite4>
|
||||
* GitHub:<https://github.com/thinkgem/jeesite4>
|
||||
* 问题反馈:<https://gitee.com/thinkgem/jeesite4/issues>
|
||||
* 作者博客:<https://my.oschina.net/thinkgem/blog>
|
||||
* 作者博客:<https://my.oschina.net/thinkgem>
|
||||
* 官方网站:<http://jeesite.com>
|
||||
* 官方论坛:<http://jeesite.net>
|
||||
* 微信公众号:
|
||||
|
||||

|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
</faceted-project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
</faceted-project>
|
||||
|
||||
227
common/pom.xml
227
common/pom.xml
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.jeesite</groupId>
|
||||
<artifactId>jeesite-parent</artifactId>
|
||||
<version>4.0.5-SNAPSHOT</version>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -27,17 +27,16 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
@@ -46,19 +45,33 @@
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>${commons-beanutils.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>${commons-text.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Tools Ant Tar Zip -->
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>${ant.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Java serialization -->
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
<artifactId>fst</artifactId>
|
||||
<version>${ruedigermoeller-fst.version}</version>
|
||||
<version>${fst.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Json in java -->
|
||||
<!-- Json in java -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>${json.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson json -->
|
||||
@@ -93,11 +106,91 @@
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Bean To Bean copy -->
|
||||
<!-- Apache HTTP -->
|
||||
<dependency>
|
||||
<groupId>net.sf.dozer</groupId>
|
||||
<artifactId>dozer</artifactId>
|
||||
<version>${dozer.version}</version>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jsoup HTTP -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>${jsoup.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Email -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-email</artifactId>
|
||||
<version>${commons-email.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>${activation.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- User Agent -->
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>${UserAgentUtils.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 图片Meta获取 -->
|
||||
<dependency>
|
||||
<groupId>com.drewnoakes</groupId>
|
||||
<artifactId>metadata-extractor</artifactId>
|
||||
<version>${metadata-extractor.version}</version>
|
||||
</dependency>
|
||||
<!-- 缩略图工具 -->
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>${thumbnailator.version}</version>
|
||||
</dependency>
|
||||
<!-- 图片验证码生成 -->
|
||||
<dependency>
|
||||
<groupId>com.bladejava</groupId>
|
||||
<artifactId>blade-patchca</artifactId>
|
||||
<version>${blade-patchca.version}</version>
|
||||
</dependency>
|
||||
<!-- File MimeType ContentType -->
|
||||
<dependency>
|
||||
<groupId>net.sf.jmimemagic</groupId>
|
||||
<artifactId>jmimemagic</artifactId>
|
||||
<version>${jmimemagic.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-xc</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>log4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 条形码、二维码生成 -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${zxing.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>${zxing.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- POI Office Tools -->
|
||||
@@ -128,109 +221,14 @@
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Email -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-email</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 条形码、二维码生成 -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- User Agent -->
|
||||
<dependency>
|
||||
<groupId>eu.bitwalker</groupId>
|
||||
<artifactId>UserAgentUtils</artifactId>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache HTTP -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jsoup HTTP -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 图片Meta获取 -->
|
||||
<dependency>
|
||||
<groupId>com.drewnoakes</groupId>
|
||||
<artifactId>metadata-extractor</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
<!-- 缩略图工具 -->
|
||||
<dependency>
|
||||
<groupId>net.coobird</groupId>
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.8</version>
|
||||
</dependency>
|
||||
<!-- 图片验证码生成 -->
|
||||
<dependency>
|
||||
<groupId>com.bladejava</groupId>
|
||||
<artifactId>blade-patchca</artifactId>
|
||||
<version>1.0.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Tools Ant Tar Zip -->
|
||||
<dependency>
|
||||
<groupId>org.apache.ant</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
<version>1.9.7</version>
|
||||
</dependency>
|
||||
|
||||
<!-- File MimeType ContentType -->
|
||||
<dependency>
|
||||
<groupId>net.sf.jmimemagic</groupId>
|
||||
<artifactId>jmimemagic</artifactId>
|
||||
<version>0.1.3</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-xc</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>log4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- pinyin4j -->
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.0</version>
|
||||
<version>${pinyin4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- LOGGING begin -->
|
||||
<!-- Logging begin -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
@@ -255,9 +253,9 @@
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
</dependency>
|
||||
<!-- LOGGING end -->
|
||||
<!-- Logging end -->
|
||||
|
||||
<!-- Spring Core Web-->
|
||||
<!-- Spring begin -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
@@ -266,12 +264,7 @@
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Bean validate -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring end -->
|
||||
|
||||
<!-- JUnit Test -->
|
||||
<dependency>
|
||||
|
||||
@@ -8,15 +8,18 @@ package com.jeesite.common.codec;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.codec.DecoderException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.lang.ExceptionUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
|
||||
@@ -167,7 +170,9 @@ public class EncodeUtils {
|
||||
* URL 解码, Encode默认为UTF-8.
|
||||
*/
|
||||
public static String decodeUrl(String part, String encoding) {
|
||||
|
||||
if (part == null){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return URLDecoder.decode(part, encoding);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
@@ -181,30 +186,29 @@ public class EncodeUtils {
|
||||
public static String decodeUrl2(String part) {
|
||||
return decodeUrl(decodeUrl(part));
|
||||
}
|
||||
|
||||
|
||||
// 预编译XSS过滤正则表达式
|
||||
private static Pattern p1 = Pattern.compile("<\\s*(script|link|style|iframe)\\s([\\s\\S]+?)<\\/\\s*\\1\\s*>", Pattern.CASE_INSENSITIVE);
|
||||
private static Pattern p2 = Pattern.compile("\\s*on[a-z]+\\s*=\\s*(\"[^\"]+\"|'[^']+'|[^\\s]+)\\s*(?=>)", Pattern.CASE_INSENSITIVE);
|
||||
private static Pattern p3 = Pattern.compile("\\s*(href|src)\\s*=\\s*(\"\\s*(javascript|vbscript):[^\"]+\"|'\\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\\s]+)\\s*(?=>)", Pattern.CASE_INSENSITIVE);
|
||||
private static Pattern p4 = Pattern.compile("epression\\((.|\\n)*\\);?", Pattern.CASE_INSENSITIVE);
|
||||
private static List<Pattern> xssPatterns = ListUtils.newArrayList(
|
||||
Pattern.compile("(<\\s*(script|link|style|iframe)([\\s\\S]*?)(>|<\\/\\s*\\1\\s*>))|(</\\s*(script|link|style|iframe)\\s*>)", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("\\s*(href|src)\\s*=\\s*(\"\\s*(javascript|vbscript):[^\"]+\"|'\\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\\s]+)\\s*(?=>)", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("\\s*on[a-z]+\\s*=\\s*(\"[^\"]+\"|'[^']+'|[^\\s]+)\\s*(?=>)", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("(eval\\((.|\\n)*\\)|xpression\\((.|\\n)*\\))", Pattern.CASE_INSENSITIVE)
|
||||
);
|
||||
|
||||
/**
|
||||
* XSS 非法字符过滤
|
||||
* 内容以<!--HTML-->开头的用以下规则(保留标签,去掉js脚本):
|
||||
* 1、<\s*(script|link|style|iframe)\s([\s\S]+?)<\/\s*\1\s*>
|
||||
* 2、\s*on[a-z]+\s*=\s*("[^"]+"|'[^']+'|[^\s]+)\s*(?=>)
|
||||
* 3、\s*(href|src)\s*=\s*("\s*(javascript|vbscript):[^"]+"|'\s*(javascript|vbscript):[^']+'|(javascript|vbscript):[^\s]+)\s*(?=>)
|
||||
* 4、epression\((.|\n)*\);?
|
||||
* 其它情况下:进行HTML4编码
|
||||
* XSS 非法字符过滤,内容以<!--HTML-->开头的用以下规则(保留标签)
|
||||
* @author ThinkGem
|
||||
*/
|
||||
public static String xssFilter(String text) {
|
||||
String oriValue = StringUtils.trim(text);
|
||||
if (text != null){
|
||||
String oriValue = StringUtils.trim(text), value = oriValue;
|
||||
value = p1.matcher(value).replaceAll("");
|
||||
value = p2.matcher(value).replaceAll("");
|
||||
value = p3.matcher(value).replaceAll("");
|
||||
value = p4.matcher(value).replaceAll("");
|
||||
String value = oriValue;
|
||||
for (Pattern pattern : xssPatterns) {
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
if (matcher.find()) {
|
||||
value = matcher.replaceAll(StringUtils.EMPTY);
|
||||
}
|
||||
}
|
||||
// 如果开始不是HTML,XML,JOSN格式,则再进行HTML的 "、<、> 转码。
|
||||
if (!StringUtils.startsWithIgnoreCase(value, "<!--HTML-->") // HTML
|
||||
&& !StringUtils.startsWithIgnoreCase(value, "<?xml ") // XML
|
||||
@@ -215,7 +219,7 @@ public class EncodeUtils {
|
||||
value = value.replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
||||
}
|
||||
if (logger.isInfoEnabled() && !value.equals(oriValue)){
|
||||
logger.info("xssFilter: {} to {}", text, value);
|
||||
logger.info("xssFilter: {} <=<=<= {}", value, text);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -223,7 +227,7 @@ public class EncodeUtils {
|
||||
}
|
||||
|
||||
// 预编译SQL过滤正则表达式
|
||||
private static Pattern p5 = Pattern.compile("(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)", Pattern.CASE_INSENSITIVE);
|
||||
private static Pattern sqlPattern = Pattern.compile("(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* SQL过滤,防止注入,传入参数输入有select相关代码,替换空。
|
||||
@@ -231,13 +235,48 @@ public class EncodeUtils {
|
||||
*/
|
||||
public static String sqlFilter(String text){
|
||||
if (text != null){
|
||||
String value = p5.matcher(text).replaceAll("");
|
||||
String value = text;
|
||||
Matcher matcher = sqlPattern.matcher(text);
|
||||
if (matcher.find()) {
|
||||
value = matcher.replaceAll(StringUtils.EMPTY);
|
||||
}
|
||||
if (logger.isWarnEnabled() && !value.equals(text)){
|
||||
logger.warn("sqlFilter: {} to {}", text, value);
|
||||
logger.info("sqlFilter: {} <=<=<= {}", value, text);
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// xssFilter("你好,<script>alert(document.cookie)</script>我还在。");
|
||||
// xssFilter("你好,<strong>加粗文字</strong>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,\"><strong>加粗文字</strong>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<iframe src=\"abcdef\"></iframe><strong>加粗文字</strong>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<iframe src=\"abcdef\"/><strong>加粗文字</strong>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<iframe src=\"abcdef\"><strong>加粗文字</strong>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<script type=\"text/javascript\">alert(document.cookie)</script>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<script\n type=\"text/javascript\">\nalert(document.cookie)\n</script>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<script src='' onerror='alert(document.cookie)'></script>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<script type=text/javascript>alert()我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<script>alert(document.cookie)</script>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<script>window.location='url'我还在。");
|
||||
// xssFilter("<!--HTML-->你好,</script></iframe>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,eval(abc)我还在。");
|
||||
// xssFilter("<!--HTML-->你好,xpression(abc)我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<img src='abc.jpg' onerror='location='';alert(document.cookie);'></img>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<img src='abc.jpg' onerror='alert(document.cookie);'/>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<img src='abc.jpg' onerror='alert(document.cookie);'>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<a onload='alert(\"abc\")'>hello</a>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<a href=\"/abc\">hello</a>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<a href='/abc'>hello</a>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<a href='vbscript:alert(\"abc\");'>hello</a>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,<a href='javascript:alert(\"abc\");'>hello</a>我还在。");
|
||||
// xssFilter("<!--HTML-->你好,?abc=def&hello=123&world={\"a\":1}我还在。");
|
||||
// sqlFilter("你好,select * from xxx where abc=def and 1=1我还在。");
|
||||
// sqlFilter("你好,insert into xxx values(1,2,3,4,5)我还在。");
|
||||
// sqlFilter("你好,delete from xxx我还在。");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,16 @@
|
||||
*/
|
||||
package com.jeesite.common.codec;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.jeesite.common.io.IOUtils;
|
||||
|
||||
/**
|
||||
* MD5不可逆加密工具类
|
||||
* @author ThinkGem
|
||||
@@ -17,7 +21,6 @@ public class Md5Utils {
|
||||
|
||||
private static final String MD5 = "MD5";
|
||||
private static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
|
||||
/**
|
||||
* 对输入字符串进行md5散列.
|
||||
@@ -63,5 +66,33 @@ public class Md5Utils {
|
||||
public static byte[] md5(InputStream input) throws IOException {
|
||||
return DigestUtils.digest(input, MD5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件的MD5值
|
||||
*/
|
||||
public static String md5File(File file) {
|
||||
return md5File(file, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件的MD5值,支持获取文件部分的MD5值
|
||||
* uploader.md5File(file, 0, 10 * 1024 * 1024)
|
||||
*/
|
||||
public static String md5File(File file, int size) {
|
||||
if (file != null && file.exists()){
|
||||
try (InputStream in = FileUtils.openInputStream(file)){
|
||||
byte[] bytes = null;
|
||||
if (size != -1 && file.length() >= size){
|
||||
bytes = IOUtils.toByteArray(in, size);
|
||||
}else{
|
||||
bytes = IOUtils.toByteArray(in);
|
||||
}
|
||||
return EncodeUtils.encodeHex(md5(bytes));
|
||||
} catch (IOException e) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -383,7 +383,8 @@ public class ListUtils extends org.apache.commons.collections.ListUtils {
|
||||
public static <T> List<T> listOrderBy(List<T> list, String orderBy){
|
||||
if (list != null && StringUtils.isNotBlank(orderBy)){
|
||||
final String[] ss = orderBy.trim().split(" ");
|
||||
if (ss != null && ss.length == 2){
|
||||
if (ss != null){
|
||||
final String t = ss.length==2 ? ss[1] : "asc";
|
||||
Collections.sort(list, new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
@@ -395,12 +396,13 @@ public class ListUtils extends org.apache.commons.collections.ListUtils {
|
||||
s1 = ObjectUtils.toString(ReflectUtils.invokeGetter(o1, ss[0]));
|
||||
s2 = ObjectUtils.toString(ReflectUtils.invokeGetter(o2, ss[0]));
|
||||
}
|
||||
if ("asc".equals(ss[1])){
|
||||
if ("asc".equalsIgnoreCase(t)){
|
||||
return s1.compareTo(s2);
|
||||
}else{
|
||||
return s2.compareTo(s1);
|
||||
}
|
||||
}});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -242,14 +242,10 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
* @author ThinkGem 2016-7-4
|
||||
*/
|
||||
public static String readFileToString(String classResourcePath){
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = new ClassPathResource(classResourcePath).getInputStream();
|
||||
try (InputStream in = new ClassPathResource(classResourcePath).getInputStream()){
|
||||
return IOUtils.toString(in, Charsets.toCharset("UTF-8"));
|
||||
} catch (IOException e) {
|
||||
logger.warn("Error file convert: {}", e.getMessage());
|
||||
}finally{
|
||||
IOUtils.closeQuietly(in);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -758,7 +754,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
try {
|
||||
response.addHeader("Content-Disposition", "attachment; filename=\"" +
|
||||
EncodeUtils.encodeUrl(StringUtils.isBlank(fileName) ? file.getName() : fileName) + "\"");
|
||||
response.setContentType(getContentType(file.getName())); // set the MIME type.
|
||||
response.setContentType(FileUtils.getContentType(file.getName())); // set the MIME type.
|
||||
response.addHeader("Content-Length", String.valueOf(contentLength));
|
||||
os = response.getOutputStream();
|
||||
out = new BufferedOutputStream(os);
|
||||
@@ -808,20 +804,20 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
logger.debug("提醒:向客户端传输时出现IO异常,但此异常是允许的,有可能客户端取消了下载,导致此异常,不用关心!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
logger.debug(e.getMessage(), e);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
// logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (raf != null) {
|
||||
try {
|
||||
raf.close();
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
// logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -944,9 +940,9 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
projectPath = file.toString();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
;
|
||||
// 忽略异常
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// 忽略异常
|
||||
}
|
||||
// 取不到,取当前工作路径
|
||||
if (StringUtils.isBlank(projectPath)){
|
||||
@@ -982,9 +978,9 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
webappPath = file.toString();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
;
|
||||
// 忽略异常
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// 忽略异常
|
||||
}
|
||||
// 取不到,取当前工作路径
|
||||
if (StringUtils.isBlank(webappPath)){
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
*/
|
||||
package com.jeesite.common.io;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 数据流工具类
|
||||
@@ -80,4 +83,24 @@ public class IOUtils extends org.apache.commons.io.IOUtils {
|
||||
return fileOutputStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a <code>Closeable</code> unconditionally.
|
||||
*/
|
||||
public static void closeQuietly(final InputStream input) {
|
||||
closeQuietly((Closeable) input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a <code>Closeable</code> unconditionally.
|
||||
*/
|
||||
public static void closeQuietly(final Closeable closeable) {
|
||||
try {
|
||||
if (closeable != null) {
|
||||
closeable.close();
|
||||
}
|
||||
} catch (final IOException ioe) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||
@@ -37,7 +36,7 @@ public class PropertiesUtils {
|
||||
"classpath:config/application.yml", "classpath:application.yml"};
|
||||
|
||||
private static Logger logger = PropertiesUtils.initLogger();
|
||||
|
||||
private final Set<String> configSet = SetUtils.newLinkedHashSet();
|
||||
private final Properties properties = new Properties();
|
||||
|
||||
/**
|
||||
@@ -55,7 +54,7 @@ public class PropertiesUtils {
|
||||
for(Resource resource : resources){
|
||||
configSet.add("classpath:config/"+resource.getFilename());
|
||||
}
|
||||
configSet.add("classpath:config/jeesite.yml");
|
||||
//configSet.add("classpath:config/jeesite.yml");
|
||||
// 获取全局设置默认的配置文件(以下是支持环境配置的属性文件)
|
||||
Set<String> set = SetUtils.newLinkedHashSet();
|
||||
for (String configFile : DEFAULT_CONFIG_FILE){
|
||||
@@ -83,7 +82,7 @@ public class PropertiesUtils {
|
||||
}
|
||||
for (String location : configFiles){
|
||||
configSet.add(location);
|
||||
if (StringUtils.isNotBlank(profiles) && !StringUtils.equals(profiles, "default")){
|
||||
if (StringUtils.isNotBlank(profiles)){
|
||||
if (location.endsWith(".properties")){
|
||||
configSet.add(StringUtils.substringBeforeLast(location, ".properties")
|
||||
+ "-" + profiles + ".properties");
|
||||
@@ -108,14 +107,11 @@ public class PropertiesUtils {
|
||||
Resource resource = ResourceUtils.getResource(location);
|
||||
if (resource.exists()){
|
||||
if (location.endsWith(".properties")){
|
||||
InputStreamReader is = null;
|
||||
try {
|
||||
is = new InputStreamReader(resource.getInputStream(), "UTF-8");
|
||||
try (InputStreamReader is = new InputStreamReader(resource.getInputStream(), "UTF-8")){
|
||||
properties.load(is);
|
||||
configSet.add(location);
|
||||
} catch (IOException ex) {
|
||||
logger.error("Load " + location + " failure. ", ex);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
else if (location.endsWith(".yml")){
|
||||
@@ -125,18 +121,24 @@ public class PropertiesUtils {
|
||||
properties.put(ObjectUtils.toString(entry.getKey()),
|
||||
ObjectUtils.toString(entry.getValue()));
|
||||
}
|
||||
configSet.add(location);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Load " + location + " failure. ", e);
|
||||
}
|
||||
// 存储当前加载的配置文件路径和名称
|
||||
properties.setProperty("configFiles", StringUtils.join(configFiles, ","));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前加载的属性
|
||||
* 获取当前加载的属性文件
|
||||
*/
|
||||
public Set<String> getConfigSet() {
|
||||
return configSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前加载的属性数据
|
||||
*/
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
@@ -170,7 +172,7 @@ public class PropertiesUtils {
|
||||
while(m.find()) {
|
||||
String g = m.group();
|
||||
String keyChild = g.replaceAll("\\$\\{", "").replaceAll("\\}", "");
|
||||
value = value.replace(g, getProperty(keyChild));
|
||||
value = StringUtils.replace(value, g, getProperty(keyChild));
|
||||
}
|
||||
return value;
|
||||
}else{
|
||||
|
||||
@@ -67,14 +67,10 @@ public class ResourceUtils extends org.springframework.util.ResourceUtils {
|
||||
* @author ThinkGem
|
||||
*/
|
||||
public static String getResourceFileContent(String location){
|
||||
InputStream is = null;
|
||||
try{
|
||||
is = ResourceUtils.getResourceFileStream(location);
|
||||
try(InputStream is = ResourceUtils.getResourceFileStream(location)){
|
||||
return IOUtils.toString(is, "UTF-8");
|
||||
}catch (IOException e) {
|
||||
throw ExceptionUtils.unchecked(e);
|
||||
}finally{
|
||||
IOUtils.closeQuietly(is);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ public class ByteUtils {
|
||||
* @return
|
||||
*/
|
||||
public static String formatByteSize(long byteSize) {
|
||||
|
||||
if (byteSize <= -1){
|
||||
return String.valueOf(byteSize);
|
||||
}
|
||||
|
||||
double size = 1.0 * byteSize;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package com.jeesite.common.lang;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* BigDecimal工具类
|
||||
@@ -92,4 +93,19 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {
|
||||
return bg.setScale(0, BigDecimal.ROUND_HALF_UP).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化数值类型
|
||||
* @param data
|
||||
* @param pattern
|
||||
*/
|
||||
public static String formatNumber(Object data, String pattern) {
|
||||
DecimalFormat df = null;
|
||||
if (pattern == null) {
|
||||
df = new DecimalFormat();
|
||||
} else {
|
||||
df = new DecimalFormat(pattern);
|
||||
}
|
||||
return df.format(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,13 +14,12 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.nustaq.serialization.FSTConfiguration;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import com.jeesite.common.io.IOUtils;
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
|
||||
/**
|
||||
* 对象操作工具类, 继承org.apache.commons.lang3.ObjectUtils类
|
||||
* @author ThinkGem
|
||||
* @version 2014-6-29
|
||||
* @version 2018-08-11
|
||||
*/
|
||||
public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
|
||||
@@ -117,9 +116,13 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
if (source == null){
|
||||
return null;
|
||||
}
|
||||
Object target = BeanUtils.instantiate(source.getClass());
|
||||
BeanUtils.copyProperties(source, target, ignoreProperties);
|
||||
return target;
|
||||
try {
|
||||
Object target = source.getClass().newInstance();
|
||||
BeanUtils.copyProperties(source, target, ignoreProperties);
|
||||
return target;
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw ExceptionUtils.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,18 +164,12 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
}
|
||||
long beginTime = System.currentTimeMillis();
|
||||
byte[] bytes = null;
|
||||
ObjectOutputStream oos = null;
|
||||
ByteArrayOutputStream baos = null;
|
||||
try {
|
||||
baos = new ByteArrayOutputStream();
|
||||
oos = new ObjectOutputStream(baos);
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);) {
|
||||
oos.writeObject(object);
|
||||
bytes = baos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(oos);
|
||||
IOUtils.closeQuietly(baos);
|
||||
}
|
||||
long totalTime = System.currentTimeMillis() - beginTime;
|
||||
if (totalTime > 3000){
|
||||
@@ -192,19 +189,13 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
}
|
||||
long beginTime = System.currentTimeMillis();
|
||||
Object object = null;
|
||||
ByteArrayInputStream bais = null;
|
||||
ObjectInputStream ois = null;
|
||||
try {
|
||||
if (bytes.length > 0) {
|
||||
bais = new ByteArrayInputStream(bytes);
|
||||
ois = new ObjectInputStream(bais);
|
||||
if (bytes.length > 0) {
|
||||
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);) {
|
||||
object = ois.readObject();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(ois);
|
||||
IOUtils.closeQuietly(bais);
|
||||
}
|
||||
long totalTime = System.currentTimeMillis() - beginTime;
|
||||
if (totalTime > 3000){
|
||||
@@ -212,73 +203,14 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
// // Kryo不是线程安全的,所以要建立一个线程变量,每一个线程实例化一次
|
||||
// public static final ThreadLocal<Kryo> kryos = new ThreadLocal<Kryo>() {
|
||||
// @Override
|
||||
// protected Kryo initialValue() {
|
||||
// Kryo kryo = new Kryo();
|
||||
// // 设置false关闭注册行为, Kryo支持对注册行为,如kryo.register(SomeClazz.class);
|
||||
// // 这会赋予该Class一个从0开始的编号,但Kryo使用注册行为最大的问题在于,
|
||||
// // 其不保证同一个Class每一次注册的号码想用,这与注册的顺序有关,也就意味着在不同的机器、
|
||||
// // 同一个机器重启前后都有可能拥有不同的编号,这会导致序列化产生问题,所以在分布式项目中,一般关闭注册行为。
|
||||
// kryo.setRegistrationRequired(false);
|
||||
// // 支持循环引用
|
||||
// kryo.setReferences(true);
|
||||
// return kryo;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// /**
|
||||
// * Kryo序列化对象
|
||||
// * @param object
|
||||
// * @return
|
||||
// */
|
||||
// public static byte[] serializeKryo(Object object) {
|
||||
// byte[] bytes = null;
|
||||
// Output output = null;
|
||||
// try {
|
||||
// if (object != null) {
|
||||
// output = new Output(1024, -1);
|
||||
// kryos.get().writeClassAndObject(output, object);
|
||||
// bytes = output.toBytes();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (output != null) {
|
||||
// output.close();
|
||||
// }
|
||||
// }
|
||||
// return bytes;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Kryo反序列化对象
|
||||
// * @param bytes
|
||||
// * @return
|
||||
// */
|
||||
// public static Object unserializeKryo(byte[] bytes) {
|
||||
// Object object = null;
|
||||
// Input input = null;
|
||||
// try {
|
||||
// if (bytes != null && bytes.length > 0) {
|
||||
// input = new Input(bytes, 0, bytes.length);
|
||||
// object = kryos.get().readClassAndObject(input);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (input != null) {
|
||||
// input.close();
|
||||
// }
|
||||
// }
|
||||
// return object;
|
||||
// }
|
||||
|
||||
// FST序列化配置对象
|
||||
private static FSTConfiguration fst = FSTConfiguration.createDefaultConfiguration();
|
||||
|
||||
private static ThreadLocal<FSTConfiguration> fst = new NamedThreadLocal<FSTConfiguration>("FSTConfiguration") {
|
||||
public FSTConfiguration initialValue() {
|
||||
return FSTConfiguration.createDefaultConfiguration();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* FST 序列化对象
|
||||
* @param object
|
||||
@@ -289,7 +221,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
return null;
|
||||
}
|
||||
long beginTime = System.currentTimeMillis();
|
||||
byte[] bytes = fst.asByteArray(object);
|
||||
byte[] bytes = fst.get().asByteArray(object);
|
||||
long totalTime = System.currentTimeMillis() - beginTime;
|
||||
if (totalTime > 3000){
|
||||
System.out.println("Fst serialize time: " + TimeUtils.formatDateAgo(totalTime));
|
||||
@@ -307,7 +239,7 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
|
||||
return null;
|
||||
}
|
||||
long beginTime = System.currentTimeMillis();
|
||||
Object object = fst.asObject(bytes);
|
||||
Object object = fst.get().asObject(bytes);
|
||||
long totalTime = System.currentTimeMillis() - beginTime;
|
||||
if (totalTime > 3000){
|
||||
System.out.println("Fst unserialize time: " + TimeUtils.formatDateAgo(totalTime));
|
||||
|
||||
@@ -9,8 +9,6 @@ import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
|
||||
@@ -140,7 +138,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int currentLength = 0;
|
||||
for (char c : stripHtml(StringEscapeUtils.unescapeHtml4(str)).toCharArray()) {
|
||||
for (char c : stripHtml(EncodeUtils.decodeHtml(str)).toCharArray()) {
|
||||
currentLength += String.valueOf(c).getBytes("GBK").length;
|
||||
if (currentLength <= length - 3) {
|
||||
sb.append(c);
|
||||
@@ -250,16 +248,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
s = s.toLowerCase();
|
||||
|
||||
StringBuilder sb = new StringBuilder(s.length());
|
||||
boolean upperCase = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
if (c == SEPARATOR) {
|
||||
upperCase = true;
|
||||
upperCase = i != 1; // 不允许第二个字符是大写
|
||||
} else if (upperCase) {
|
||||
sb.append(Character.toUpperCase(c));
|
||||
upperCase = false;
|
||||
@@ -267,7 +263,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -297,18 +292,14 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean upperCase = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
|
||||
boolean nextUpperCase = true;
|
||||
|
||||
if (i < (s.length() - 1)) {
|
||||
nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
|
||||
}
|
||||
|
||||
if ((i > 0) && Character.isUpperCase(c)) {
|
||||
if (!upperCase || !nextUpperCase) {
|
||||
sb.append(SEPARATOR);
|
||||
@@ -317,10 +308,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||
} else {
|
||||
upperCase = false;
|
||||
}
|
||||
|
||||
sb.append(Character.toLowerCase(c));
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.common.mail;
|
||||
|
||||
/**
|
||||
* 发送电子邮件
|
||||
*/
|
||||
@Deprecated
|
||||
public class EmailUtils {
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
* @param toAddress 接收地址
|
||||
* @param subject 标题
|
||||
* @param content 内容
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean sendEmail(String toAddress, String subject, String content) {
|
||||
return com.jeesite.common.msg.EmailUtils.send(toAddress, subject, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件
|
||||
* @param toAddress 接收地址
|
||||
* @param subject 标题
|
||||
* @param content 内容
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean sendEmail(String fromAddress, String fromPassword, String fromHostName,
|
||||
String sslOnConnect, String sslSmtpPort, String toAddress, String subject, String content) {
|
||||
return com.jeesite.common.msg.EmailUtils.send(fromAddress, fromPassword, fromHostName, sslOnConnect, sslSmtpPort, toAddress, subject, content);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2005-2012 springside.org.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
*/
|
||||
package com.jeesite.common.mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.dozer.DozerBeanMapper;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
|
||||
/**
|
||||
* 简单封装Dozer, 实现深度转换Bean<->Bean的Mapper.实现:
|
||||
*
|
||||
* 1. 持有Mapper的单例.
|
||||
* 2. 返回值类型转换.
|
||||
* 3. 批量转换Collection中的所有对象.
|
||||
* 4. 区分创建新的B对象与将对象A值复制到已存在的B对象两种函数.
|
||||
*
|
||||
* @author calvin
|
||||
* @version 2013-01-15
|
||||
*/
|
||||
public class BeanMapper {
|
||||
|
||||
/**
|
||||
* 持有Dozer单例, 避免重复创建DozerMapper消耗资源.
|
||||
*/
|
||||
private static DozerBeanMapper dozer = new DozerBeanMapper();
|
||||
|
||||
/**
|
||||
* 基于Dozer转换对象的类型.
|
||||
*/
|
||||
public static <T> T map(Object source, Class<T> destinationClass) {
|
||||
return dozer.map(source, destinationClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于Dozer转换Collection中对象的类型.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static <T> List<T> mapList(Collection sourceList, Class<T> destinationClass) {
|
||||
List<T> destinationList = ListUtils.newArrayList();
|
||||
for (Object sourceObject : sourceList) {
|
||||
T destinationObject = dozer.map(sourceObject, destinationClass);
|
||||
destinationList.add(destinationObject);
|
||||
}
|
||||
return destinationList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于Dozer将对象A的值拷贝到对象B中.
|
||||
*/
|
||||
public static void copy(Object source, Object destinationObject) {
|
||||
dozer.map(source, destinationObject);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import java.util.TimeZone;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
@@ -46,6 +47,8 @@ public class JsonMapper extends ObjectMapper {
|
||||
}
|
||||
|
||||
public JsonMapper() {
|
||||
// Spring ObjectMapper 初始化配置,支持 @JsonView
|
||||
new Jackson2ObjectMapperBuilder().configure(this);
|
||||
// 为Null时不序列化
|
||||
this.setSerializationInclusion(Include.NON_NULL);
|
||||
// 允许单引号
|
||||
@@ -61,7 +64,7 @@ public class JsonMapper extends ObjectMapper {
|
||||
@Override
|
||||
public void serialize(Object value, JsonGenerator jgen,
|
||||
SerializerProvider provider) throws IOException, JsonProcessingException {
|
||||
jgen.writeString("");
|
||||
jgen.writeString(StringUtils.EMPTY);
|
||||
}
|
||||
});
|
||||
// // 统一默认Date类型转换格式。如果设置,Bean中的@JsonFormat将失效
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.dom4j.Element;
|
||||
import org.dom4j.Namespace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
|
||||
@@ -46,6 +47,8 @@ public class XmlMapper extends com.fasterxml.jackson.dataformat.xml.XmlMapper{
|
||||
* 构造方法
|
||||
*/
|
||||
public XmlMapper() {
|
||||
// Spring ObjectMapper 初始化配置,支持 @JsonView
|
||||
new Jackson2ObjectMapperBuilder().configure(this);
|
||||
// 设置时区
|
||||
this.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ public class EmailUtils {
|
||||
* @return
|
||||
*/
|
||||
public static boolean send(String toAddress, String subject, String content) {
|
||||
PropertiesUtils loader = PropertiesUtils.getInstance();
|
||||
String fromAddress = loader.getProperty("msg.email.fromAddress");
|
||||
String fromPassword = loader.getProperty("msg.email.fromPassword");
|
||||
String fromHostName = loader.getProperty("msg.email.fromHostName");
|
||||
String sslOnConnect = loader.getProperty("msg.email.sslOnConnect", "false");
|
||||
String sslSmtpPort = loader.getProperty("msg.email.sslSmtpPort");
|
||||
PropertiesUtils props = PropertiesUtils.getInstance();
|
||||
String fromAddress = props.getProperty("msg.email.fromAddress");
|
||||
String fromPassword = props.getProperty("msg.email.fromPassword");
|
||||
String fromHostName = props.getProperty("msg.email.fromHostName");
|
||||
String sslOnConnect = props.getProperty("msg.email.sslOnConnect", "false");
|
||||
String sslSmtpPort = props.getProperty("msg.email.sslSmtpPort");
|
||||
return send(fromAddress, fromPassword, fromHostName, sslOnConnect, sslSmtpPort, toAddress, subject, content);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,141 +1,43 @@
|
||||
package com.jeesite.common.msg;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jeesite.common.io.PropertiesUtils;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
|
||||
/**
|
||||
* 发送短信(乐云短信)
|
||||
* 发送短信(请实现send方法)
|
||||
*/
|
||||
public class SmsUtils {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(SmsUtils.class);
|
||||
private final static PropertiesUtils props = PropertiesUtils.getInstance();
|
||||
private final static String url = props.getProperty("msg.sms.url", "http://lehuo520.cn/a/sms/api");
|
||||
private final static String data = props.getProperty("msg.sms.data", "username=jeesite&password=jeesite.com");
|
||||
private final static String prefix = props.getProperty("msg.sms.prefix", "【JeeSite】");
|
||||
private final static String suffix = props.getProperty("msg.sms.suffix", "");
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// String phone = "18500000000"; // 收短信人手机号码;例如:18500000000 支持多号码,号码之间用英文逗号隔开,最多100个
|
||||
// String content = "您好,您的验证码是:123456(请勿透露给其他人)感谢您的使用。"; // 输入需要发送内容;例如:你好这是一条测试短信
|
||||
// String smsid = ""; // 短信id,查询短信状态报告时需要,可为空
|
||||
// System.out.println(send(content, phone)); // 发短信
|
||||
// System.out.println(status(smsid, phone)); // 取状态
|
||||
// System.out.println(reply()); //取上行 回复短信
|
||||
// }
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* @param content 接受内容
|
||||
* @param phone 接受手机号码
|
||||
* @return {"result":"0","describing":"提交成功","sms":[{"phone":"18073110001,18073110002","smsid":"83bd18f1d48b4cc9b9fe7810c768ac43","status":"3"}]}
|
||||
* 模拟发送短信
|
||||
* @param content 短信内容
|
||||
* @param mobile 接受手机号码
|
||||
*/
|
||||
public static String send(String content, String phone) {
|
||||
return send(content, phone, null);
|
||||
public static String send(String content, String mobile) {
|
||||
// PropertiesUtils props = PropertiesUtils.getInstance();
|
||||
// String url = props.getProperty("msg.sms.url");
|
||||
// String data = props.getProperty("msg.sms.data");
|
||||
// String prefix = props.getProperty("msg.sms.prefix", "");
|
||||
// String suffix = props.getProperty("msg.sms.suffix", "");
|
||||
// Connection conn = Jsoup.connect(url);
|
||||
// conn.postDataCharset("UTF-8");
|
||||
// conn.method(Method.POST);
|
||||
// for (String param : StringUtils.split(data, "&")){
|
||||
// String[] ss = StringUtils.split(param, "=");
|
||||
// if (ss.length == 1){
|
||||
// conn.data(ss[0], "");
|
||||
// }else if (ss.length == 2){
|
||||
// conn.data(ss[0], ss[1]);
|
||||
// }
|
||||
// }
|
||||
// // 手机号码
|
||||
// conn.data("mobile", mobile);
|
||||
// // 短信内容
|
||||
// conn.data("content", prefix + content + suffix);
|
||||
logger.warn("模拟发送短信成功!请实现 "+SmsUtils.class+" 的 send 方法。");
|
||||
return "{result:0,message:\"模拟发送短信成功!\"}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送短信
|
||||
* @param content 接受内容
|
||||
* @param phone 接受手机号码
|
||||
* @param sendtime 发送时间为空立即发送
|
||||
* @return {"result":"0","describing":"提交成功","sms":[{"phone":"18073110001,18073110002","smsid":"83bd18f1d48b4cc9b9fe7810c768ac43","status":"3"}]}
|
||||
*/
|
||||
public static String send(String content, String phone, Date sendTime) {
|
||||
String res = "";
|
||||
try {
|
||||
String param = data + "&phone=" + phone + "&content=" + URLEncoder
|
||||
.encode(prefix + content + suffix, "UTF-8")
|
||||
+ "&sendTime=" + (sendTime != null ? DateUtils
|
||||
.formatDate(sendTime, "yyyyMMddHHmm") : "");
|
||||
res = connectURL(url + "/send", param);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
* @param smsid,phone可为空,为空取最近两天未获取状态报告,沦询间隔时间不能低于5分钟
|
||||
* @return 请求错误返回页面示例: {"result":"-1","describing":"帐号不存在,请检查用户名或者密码是否正确","sms":[]} 请求成功返回页面示例:
|
||||
* {"result":"0","describing":"提交成功","sms":[{"phone":"18073110001","smsid":"83bd18f1d48b4cc9b9fe7810c768ac43","status":"7"},{"phone":"18073110001","smsid":"83bd18f1d48b4cc9b9fe7810c768ac43","status":"8"}]}
|
||||
*/
|
||||
public static String status(String smsid, String phone) {
|
||||
String res = "";
|
||||
try {
|
||||
String param = data + "&smsid=" + smsid;
|
||||
res = connectURL(url + "/status", param);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取回复
|
||||
* @param smsid:下发短信对应短信ID,taskId同一批任务ID
|
||||
* @return {"result":"0","sms":[{"phone":"18073110001","neirong":"已收到","taskId":"83bd18f1d48b4cc9b9fe7810c768ac43"},"smsId":"83bd18f1d48b48j9b9fe7810c768ac43"}]}
|
||||
*/
|
||||
public static String reply() {
|
||||
String res = "";
|
||||
try {
|
||||
String param = data;
|
||||
res = connectURL(url + "/query", param);
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进行http提交
|
||||
* @param
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @throws Exception
|
||||
*/
|
||||
private static String connectURL(String url, String param) throws IOException {
|
||||
String res = "";
|
||||
HttpURLConnection urlConn = null;
|
||||
URL url1 = new URL(url);
|
||||
urlConn = (HttpURLConnection) url1.openConnection();
|
||||
urlConn.setRequestMethod("POST");
|
||||
urlConn.setDoOutput(true);
|
||||
OutputStream out = null;
|
||||
BufferedReader rd = null;
|
||||
try{
|
||||
out = urlConn.getOutputStream();
|
||||
out.write(param.getBytes("UTF-8"));
|
||||
out.flush();
|
||||
rd = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), "UTF-8"));
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int ch;
|
||||
while ((ch = rd.read()) > -1) {
|
||||
sb.append((char) ch);
|
||||
}
|
||||
res = sb.toString().trim();
|
||||
}finally {
|
||||
if (out!=null){
|
||||
out.close();
|
||||
}
|
||||
if (rd!=null){
|
||||
rd.close();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.jeesite.common.network;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.io.PropertiesUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
|
||||
public class IpUtils {
|
||||
@@ -16,20 +17,23 @@ public class IpUtils {
|
||||
if (request == null) {
|
||||
return "unknown";
|
||||
}
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
String ip = null;
|
||||
String xffName = PropertiesUtils.getInstance()
|
||||
.getProperty("shiro.remoteAddrHeaderName");
|
||||
if (StringUtils.isNotBlank(xffName)){
|
||||
ip = request.getHeader(xffName);
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("WL-Proxy-Client-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getHeader("X-Real-IP");
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
|
||||
if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
return StringUtils.split(ObjectUtils.toString(ip), ",")[0];
|
||||
if (StringUtils.isNotBlank(ip)){
|
||||
ip = EncodeUtils.xssFilter(ip);
|
||||
ip = StringUtils.split(ip, ",")[0];
|
||||
}
|
||||
if (StringUtils.isBlank(ip)){
|
||||
ip = "unknown";
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,20 +43,21 @@ public class ReflectUtils {
|
||||
* 调用Getter方法.
|
||||
* 支持多级,如:对象名.对象名.方法
|
||||
*/
|
||||
public static Object invokeGetter(Object obj, String propertyName) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeGetter(Object obj, String propertyName) {
|
||||
Object object = obj;
|
||||
for (String name : StringUtils.split(propertyName, ".")){
|
||||
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
|
||||
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
|
||||
}
|
||||
return object;
|
||||
return (E)object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用Setter方法, 仅匹配方法名。
|
||||
* 支持多级,如:对象名.对象名.方法
|
||||
*/
|
||||
public static void invokeSetter(Object obj, String propertyName, Object value) {
|
||||
public static <E> void invokeSetter(Object obj, String propertyName, E value) {
|
||||
Object object = obj;
|
||||
String[] names = StringUtils.split(propertyName, ".");
|
||||
for (int i=0; i<names.length; i++){
|
||||
@@ -73,14 +74,17 @@ public class ReflectUtils {
|
||||
/**
|
||||
* 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
|
||||
*/
|
||||
public static Object getFieldValue(final Object obj, final String fieldName) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E getFieldValue(final Object obj, final String fieldName) {
|
||||
Field field = getAccessibleField(obj, fieldName);
|
||||
if (field == null) {
|
||||
throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
//throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
return null;
|
||||
}
|
||||
Object result = null;
|
||||
E result = null;
|
||||
try {
|
||||
result = field.get(obj);
|
||||
result = (E)field.get(obj);
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("不可能抛出的异常{}", e.getMessage());
|
||||
}
|
||||
@@ -90,10 +94,12 @@ public class ReflectUtils {
|
||||
/**
|
||||
* 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
|
||||
*/
|
||||
public static void setFieldValue(final Object obj, final String fieldName, final Object value) {
|
||||
public static <E> void setFieldValue(final Object obj, final String fieldName, final E value) {
|
||||
Field field = getAccessibleField(obj, fieldName);
|
||||
if (field == null) {
|
||||
throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
//throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
field.set(obj, value);
|
||||
@@ -107,17 +113,20 @@ public class ReflectUtils {
|
||||
* 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用.
|
||||
* 同时匹配方法名+参数类型,
|
||||
*/
|
||||
public static Object invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
|
||||
final Object[] args) {
|
||||
if (obj == null || methodName == null){
|
||||
return null;
|
||||
}
|
||||
Method method = getAccessibleMethod(obj, methodName, parameterTypes);
|
||||
if (method == null) {
|
||||
throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
//throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return method.invoke(obj, args);
|
||||
return (E)method.invoke(obj, args);
|
||||
} catch (Exception e) {
|
||||
String msg = "method: "+method+", obj: "+obj+", args: "+args+"";
|
||||
throw convertReflectionExceptionToUnchecked(msg, e);
|
||||
@@ -129,10 +138,14 @@ public class ReflectUtils {
|
||||
* 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用.
|
||||
* 只匹配函数名,如果有多个同名函数调用第一个。
|
||||
*/
|
||||
public static Object invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
|
||||
Method method = getAccessibleMethodByName(obj, methodName, args.length);
|
||||
if (method == null) {
|
||||
throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
// 如果为空不报错,直接返回空。
|
||||
// throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
// 类型转换(将参数数据类型转换为目标方法参数类型)
|
||||
@@ -162,7 +175,7 @@ public class ReflectUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
return method.invoke(obj, args);
|
||||
return (E)method.invoke(obj, args);
|
||||
} catch (Exception e) {
|
||||
String msg = "method: "+method+", obj: "+obj+", args: "+args+"";
|
||||
throw convertReflectionExceptionToUnchecked(msg, e);
|
||||
@@ -174,7 +187,11 @@ public class ReflectUtils {
|
||||
* 如向上转型到Object仍无法找到, 返回null.
|
||||
*/
|
||||
public static Field getAccessibleField(final Object obj, final String fieldName) {
|
||||
Validate.notNull(obj, "object can't be null");
|
||||
// 为空不报错。直接返回 null
|
||||
// Validate.notNull(obj, "object can't be null");
|
||||
if (obj == null){
|
||||
return null;
|
||||
}
|
||||
Validate.notBlank(fieldName, "fieldName can't be blank");
|
||||
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
|
||||
try {
|
||||
@@ -197,7 +214,11 @@ public class ReflectUtils {
|
||||
*/
|
||||
public static Method getAccessibleMethod(final Object obj, final String methodName,
|
||||
final Class<?>... parameterTypes) {
|
||||
Validate.notNull(obj, "object can't be null");
|
||||
// 为空不报错。直接返回 null
|
||||
// Validate.notNull(obj, "object can't be null");
|
||||
if (obj == null){
|
||||
return null;
|
||||
}
|
||||
Validate.notBlank(methodName, "methodName can't be blank");
|
||||
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
|
||||
try {
|
||||
@@ -219,7 +240,11 @@ public class ReflectUtils {
|
||||
* 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
|
||||
*/
|
||||
public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) {
|
||||
Validate.notNull(obj, "object can't be null");
|
||||
// 为空不报错。直接返回 null
|
||||
// Validate.notNull(obj, "object can't be null");
|
||||
if (obj == null){
|
||||
return null;
|
||||
}
|
||||
Validate.notBlank(methodName, "methodName can't be blank");
|
||||
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
|
||||
Method[] methods = searchType.getDeclaredMethods();
|
||||
@@ -279,19 +304,19 @@ public class ReflectUtils {
|
||||
Type genType = clazz.getGenericSuperclass();
|
||||
|
||||
if (!(genType instanceof ParameterizedType)) {
|
||||
logger.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType");
|
||||
logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
|
||||
|
||||
if (index >= params.length || index < 0) {
|
||||
logger.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
|
||||
logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
|
||||
+ params.length);
|
||||
return Object.class;
|
||||
}
|
||||
if (!(params[index] instanceof Class)) {
|
||||
logger.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
|
||||
logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
|
||||
24
common/src/main/java/com/jeesite/common/ueditor/Encoder.java
Normal file
24
common/src/main/java/com/jeesite/common/ueditor/Encoder.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.jeesite.common.ueditor;
|
||||
|
||||
public class Encoder {
|
||||
|
||||
public static String toUnicode ( String input ) {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
char[] chars = input.toCharArray();
|
||||
|
||||
for ( char ch : chars ) {
|
||||
|
||||
if ( ch < 256 ) {
|
||||
builder.append( ch );
|
||||
} else {
|
||||
builder.append( "\\u" + Integer.toHexString( ch& 0xffff ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
170
common/src/main/java/com/jeesite/common/ueditor/PathFormat.java
Normal file
170
common/src/main/java/com/jeesite/common/ueditor/PathFormat.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package com.jeesite.common.ueditor;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
|
||||
public class PathFormat {
|
||||
|
||||
private static final String TIME = "time";
|
||||
private static final String FULL_YEAR = "yyyy";
|
||||
private static final String YEAR = "yy";
|
||||
private static final String MONTH = "mm";
|
||||
private static final String DAY = "dd";
|
||||
private static final String HOUR = "hh";
|
||||
private static final String MINUTE = "ii";
|
||||
private static final String SECOND = "ss";
|
||||
private static final String RAND = "rand";
|
||||
private static final String USERID = "userid"; // ThinkGem 添加自定义变量,获取当前用户ID
|
||||
|
||||
private static Date currentDate = null;
|
||||
|
||||
private static Pattern pattern = Pattern.compile( "\\{([^\\}]+)\\}", Pattern.CASE_INSENSITIVE );
|
||||
|
||||
public static String parse ( String input ) {
|
||||
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
|
||||
PathFormat.currentDate = new Date();
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
while ( matcher.find() ) {
|
||||
|
||||
matcher.appendReplacement(sb, PathFormat.getString( matcher.group( 1 ) ) );
|
||||
|
||||
}
|
||||
|
||||
matcher.appendTail(sb);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化路径, 把windows路径替换成标准路径
|
||||
* @param input 待格式化的路径
|
||||
* @return 格式化后的路径
|
||||
*/
|
||||
public static String format ( String input ) {
|
||||
|
||||
return input.replace( "\\", "/" );
|
||||
|
||||
}
|
||||
|
||||
public static String parse ( String input, String filename ) {
|
||||
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
String matchStr = null;
|
||||
|
||||
PathFormat.currentDate = new Date();
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
while ( matcher.find() ) {
|
||||
|
||||
matchStr = matcher.group( 1 );
|
||||
if ( matchStr.indexOf( "filename" ) != -1 ) {
|
||||
filename = filename.replace( "$", "\\$" ).replaceAll( "[\\/:*?\"<>|]", "" );
|
||||
matcher.appendReplacement(sb, filename );
|
||||
} else {
|
||||
matcher.appendReplacement(sb, PathFormat.getString( matchStr ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
matcher.appendTail(sb);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String getString ( String pattern ) {
|
||||
|
||||
pattern = pattern.toLowerCase();
|
||||
|
||||
// time 处理
|
||||
if ( pattern.indexOf( PathFormat.TIME ) != -1 ) {
|
||||
return PathFormat.getTimestamp();
|
||||
} else if ( pattern.indexOf( PathFormat.FULL_YEAR ) != -1 ) {
|
||||
return PathFormat.getFullYear();
|
||||
} else if ( pattern.indexOf( PathFormat.YEAR ) != -1 ) {
|
||||
return PathFormat.getYear();
|
||||
} else if ( pattern.indexOf( PathFormat.MONTH ) != -1 ) {
|
||||
return PathFormat.getMonth();
|
||||
} else if ( pattern.indexOf( PathFormat.DAY ) != -1 ) {
|
||||
return PathFormat.getDay();
|
||||
} else if ( pattern.indexOf( PathFormat.HOUR ) != -1 ) {
|
||||
return PathFormat.getHour();
|
||||
} else if ( pattern.indexOf( PathFormat.MINUTE ) != -1 ) {
|
||||
return PathFormat.getMinute();
|
||||
} else if ( pattern.indexOf( PathFormat.SECOND ) != -1 ) {
|
||||
return PathFormat.getSecond();
|
||||
} else if ( pattern.indexOf( PathFormat.RAND ) != -1 ) {
|
||||
return PathFormat.getRandom( pattern );
|
||||
} else if ( pattern.indexOf( PathFormat.USERID ) != -1 ) {
|
||||
return PathFormat.getUserid( pattern );
|
||||
}
|
||||
|
||||
return pattern;
|
||||
|
||||
}
|
||||
|
||||
private static String getTimestamp () {
|
||||
return System.currentTimeMillis() + "";
|
||||
}
|
||||
|
||||
private static String getFullYear () {
|
||||
return new SimpleDateFormat( "yyyy" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getYear () {
|
||||
return new SimpleDateFormat( "yy" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getMonth () {
|
||||
return new SimpleDateFormat( "MM" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getDay () {
|
||||
return new SimpleDateFormat( "dd" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getHour () {
|
||||
return new SimpleDateFormat( "HH" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getMinute () {
|
||||
return new SimpleDateFormat( "mm" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getSecond () {
|
||||
return new SimpleDateFormat( "ss" ).format( PathFormat.currentDate );
|
||||
}
|
||||
|
||||
private static String getRandom ( String pattern ) {
|
||||
|
||||
int length = 0;
|
||||
pattern = pattern.split( ":" )[ 1 ].trim();
|
||||
|
||||
length = Integer.parseInt( pattern );
|
||||
|
||||
return ( Math.random() + "" ).replace( ".", "" ).substring( 0, length );
|
||||
|
||||
}
|
||||
|
||||
private static String getUserid(String pattern) {
|
||||
String userId = null;
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
if (request != null){
|
||||
userId = (String)request.getSession().getAttribute("userCode");
|
||||
}
|
||||
return StringUtils.isNotBlank(userId) ? userId : "0";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 定义请求action类型
|
||||
* @author hancong03@baidu.com
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public final class ActionMap {
|
||||
|
||||
// 获取配置请求
|
||||
public static final int CONFIG = 0;
|
||||
public static final int UPLOAD_IMAGE = 1;
|
||||
public static final int UPLOAD_SCRAWL = 2;
|
||||
public static final int UPLOAD_VIDEO = 3;
|
||||
public static final int UPLOAD_FILE = 4;
|
||||
public static final int CATCH_IMAGE = 5;
|
||||
public static final int LIST_FILE = 6;
|
||||
public static final int LIST_IMAGE = 7;
|
||||
|
||||
public static final Map<String, Integer> mapping;
|
||||
|
||||
static {
|
||||
mapping = new HashMap<String, Integer>(){{
|
||||
put( "config", ActionMap.CONFIG );
|
||||
put( "uploadimage", ActionMap.UPLOAD_IMAGE );
|
||||
put( "uploadscrawl", ActionMap.UPLOAD_SCRAWL );
|
||||
put( "uploadvideo", ActionMap.UPLOAD_VIDEO );
|
||||
put( "uploadfile", ActionMap.UPLOAD_FILE );
|
||||
put( "catchimage", ActionMap.CATCH_IMAGE );
|
||||
put( "listfile", ActionMap.LIST_FILE );
|
||||
put( "listimage", ActionMap.LIST_IMAGE );
|
||||
}};
|
||||
}
|
||||
|
||||
public static int getType ( String key ) {
|
||||
return ActionMap.mapping.get( key );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
public enum ActionState {
|
||||
UNKNOW_ERROR
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class AppInfo {
|
||||
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int MAX_SIZE = 1;
|
||||
public static final int PERMISSION_DENIED = 2;
|
||||
public static final int FAILED_CREATE_FILE = 3;
|
||||
public static final int IO_ERROR = 4;
|
||||
public static final int NOT_MULTIPART_CONTENT = 5;
|
||||
public static final int PARSE_REQUEST_ERROR = 6;
|
||||
public static final int NOTFOUND_UPLOAD_DATA = 7;
|
||||
public static final int NOT_ALLOW_FILE_TYPE = 8;
|
||||
|
||||
public static final int INVALID_ACTION = 101;
|
||||
public static final int CONFIG_ERROR = 102;
|
||||
|
||||
public static final int PREVENT_HOST = 201;
|
||||
public static final int CONNECTION_ERROR = 202;
|
||||
public static final int REMOTE_FAIL = 203;
|
||||
|
||||
public static final int NOT_DIRECTORY = 301;
|
||||
public static final int NOT_EXIST = 302;
|
||||
|
||||
public static final int ILLEGAL = 401;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static Map<Integer, String> info = new HashMap<Integer, String>(){{
|
||||
|
||||
put( AppInfo.SUCCESS, "SUCCESS" );
|
||||
|
||||
// 无效的Action
|
||||
put( AppInfo.INVALID_ACTION, "\u65E0\u6548\u7684Action" );
|
||||
// 配置文件初始化失败
|
||||
put( AppInfo.CONFIG_ERROR, "\u914D\u7F6E\u6587\u4EF6\u521D\u59CB\u5316\u5931\u8D25" );
|
||||
// 抓取远程图片失败
|
||||
put( AppInfo.REMOTE_FAIL, "\u6293\u53D6\u8FDC\u7A0B\u56FE\u7247\u5931\u8D25" );
|
||||
|
||||
// 被阻止的远程主机
|
||||
put( AppInfo.PREVENT_HOST, "\u88AB\u963B\u6B62\u7684\u8FDC\u7A0B\u4E3B\u673A" );
|
||||
// 远程连接出错
|
||||
put( AppInfo.CONNECTION_ERROR, "\u8FDC\u7A0B\u8FDE\u63A5\u51FA\u9519" );
|
||||
|
||||
// "文件大小超出限制"
|
||||
put( AppInfo.MAX_SIZE, "\u6587\u4ef6\u5927\u5c0f\u8d85\u51fa\u9650\u5236" );
|
||||
// 权限不足, 多指写权限
|
||||
put( AppInfo.PERMISSION_DENIED, "\u6743\u9650\u4E0D\u8DB3" );
|
||||
// 创建文件失败
|
||||
put( AppInfo.FAILED_CREATE_FILE, "\u521B\u5EFA\u6587\u4EF6\u5931\u8D25" );
|
||||
// IO错误
|
||||
put( AppInfo.IO_ERROR, "IO\u9519\u8BEF" );
|
||||
// 上传表单不是multipart/form-data类型
|
||||
put( AppInfo.NOT_MULTIPART_CONTENT, "\u4E0A\u4F20\u8868\u5355\u4E0D\u662Fmultipart/form-data\u7C7B\u578B" );
|
||||
// 解析上传表单错误
|
||||
put( AppInfo.PARSE_REQUEST_ERROR, "\u89E3\u6790\u4E0A\u4F20\u8868\u5355\u9519\u8BEF" );
|
||||
// 未找到上传数据
|
||||
put( AppInfo.NOTFOUND_UPLOAD_DATA, "\u672A\u627E\u5230\u4E0A\u4F20\u6570\u636E" );
|
||||
// 不允许的文件类型
|
||||
put( AppInfo.NOT_ALLOW_FILE_TYPE, "\u4E0D\u5141\u8BB8\u7684\u6587\u4EF6\u7C7B\u578B" );
|
||||
|
||||
// 指定路径不是目录
|
||||
put( AppInfo.NOT_DIRECTORY, "\u6307\u5B9A\u8DEF\u5F84\u4E0D\u662F\u76EE\u5F55" );
|
||||
// 指定路径并不存在
|
||||
put( AppInfo.NOT_EXIST, "\u6307\u5B9A\u8DEF\u5F84\u5E76\u4E0D\u5B58\u5728" );
|
||||
|
||||
// callback参数名不合法
|
||||
put( AppInfo.ILLEGAL, "Callback\u53C2\u6570\u540D\u4E0D\u5408\u6CD5" );
|
||||
|
||||
}};
|
||||
|
||||
public static String getStateInfo ( int key ) {
|
||||
return AppInfo.info.get( key );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jeesite.common.ueditor.Encoder;
|
||||
|
||||
public class BaseState implements State {
|
||||
|
||||
private boolean state = false;
|
||||
private String info = null;
|
||||
|
||||
private Map<String, String> infoMap = new HashMap<String, String>();
|
||||
|
||||
public BaseState () {
|
||||
this.state = true;
|
||||
}
|
||||
|
||||
public BaseState ( boolean state ) {
|
||||
this.setState( state );
|
||||
}
|
||||
|
||||
public BaseState ( boolean state, String info ) {
|
||||
this.setState( state );
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public BaseState ( boolean state, int infoCode ) {
|
||||
this.setState( state );
|
||||
this.info = AppInfo.getStateInfo( infoCode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuccess () {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public void setState ( boolean state ) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public void setInfo ( String info ) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public void setInfo ( int infoCode ) {
|
||||
this.info = AppInfo.getStateInfo( infoCode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJSONString() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
|
||||
String key = null;
|
||||
String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append( "{\"state\": \"" + stateVal + "\"" );
|
||||
|
||||
Iterator<String> iterator = this.infoMap.keySet().iterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
|
||||
key = iterator.next();
|
||||
|
||||
builder.append( ",\"" + key + "\": \"" + this.infoMap.get(key) + "\"" );
|
||||
|
||||
}
|
||||
|
||||
builder.append( "}" );
|
||||
|
||||
return Encoder.toUnicode( builder.toString() );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInfo(String name, String val) {
|
||||
this.infoMap.put(name, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInfo(String name, long val) {
|
||||
this.putInfo(name, val+"");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FileType {
|
||||
|
||||
public static final String JPG = "JPG";
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static final Map<String, String> types = new HashMap<String, String>(){{
|
||||
|
||||
put( FileType.JPG, ".jpg" );
|
||||
|
||||
}};
|
||||
|
||||
public static String getSuffix ( String key ) {
|
||||
return FileType.types.get( key );
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据给定的文件名,获取其后缀信息
|
||||
* @param filename
|
||||
* @return
|
||||
*/
|
||||
public static String getSuffixByFilename ( String filename ) {
|
||||
|
||||
return filename.substring( filename.lastIndexOf( "." ) ).toLowerCase();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MIMEType {
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static final Map<String, String> types = new HashMap<String, String>(){{
|
||||
put( "image/gif", ".gif" );
|
||||
put( "image/jpeg", ".jpg" );
|
||||
put( "image/jpg", ".jpg" );
|
||||
put( "image/png", ".png" );
|
||||
put( "image/bmp", ".bmp" );
|
||||
}};
|
||||
|
||||
public static String getSuffix ( String mime ) {
|
||||
return MIMEType.types.get( mime );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.jeesite.common.ueditor.Encoder;
|
||||
|
||||
/**
|
||||
* 多状态集合状态
|
||||
* 其包含了多个状态的集合, 其本身自己也是一个状态
|
||||
* @author hancong03@baidu.com
|
||||
*/
|
||||
public class MultiState implements State {
|
||||
|
||||
private boolean state = false;
|
||||
private String info = null;
|
||||
private Map<String, Long> intMap = new HashMap<String, Long>();
|
||||
private Map<String, String> infoMap = new HashMap<String, String>();
|
||||
private List<String> stateList = new ArrayList<String>();
|
||||
|
||||
public MultiState ( boolean state ) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public MultiState ( boolean state, String info ) {
|
||||
this.state = state;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public MultiState ( boolean state, int infoKey ) {
|
||||
this.state = state;
|
||||
this.info = AppInfo.getStateInfo( infoKey );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuccess() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public void addState ( State state ) {
|
||||
stateList.add( state.toJSONString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* 该方法调用无效果
|
||||
*/
|
||||
@Override
|
||||
public void putInfo(String name, String val) {
|
||||
this.infoMap.put(name, val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJSONString() {
|
||||
|
||||
String stateVal = this.isSuccess() ? AppInfo.getStateInfo( AppInfo.SUCCESS ) : this.info;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append( "{\"state\": \"" + stateVal + "\"" );
|
||||
|
||||
// 数字转换
|
||||
Iterator<String> iterator = this.intMap.keySet().iterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
|
||||
stateVal = iterator.next();
|
||||
|
||||
builder.append( ",\""+ stateVal +"\": " + this.intMap.get( stateVal ) );
|
||||
|
||||
}
|
||||
|
||||
iterator = this.infoMap.keySet().iterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
|
||||
stateVal = iterator.next();
|
||||
|
||||
builder.append( ",\""+ stateVal +"\": \"" + this.infoMap.get( stateVal ) + "\"" );
|
||||
|
||||
}
|
||||
|
||||
builder.append( ", list: [" );
|
||||
|
||||
|
||||
iterator = this.stateList.iterator();
|
||||
|
||||
while ( iterator.hasNext() ) {
|
||||
|
||||
builder.append( iterator.next() + "," );
|
||||
|
||||
}
|
||||
|
||||
if ( this.stateList.size() > 0 ) {
|
||||
builder.deleteCharAt( builder.length() - 1 );
|
||||
}
|
||||
|
||||
builder.append( " ]}" );
|
||||
|
||||
return Encoder.toUnicode( builder.toString() );
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putInfo(String name, long val) {
|
||||
this.intMap.put( name, val );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.jeesite.common.ueditor.define;
|
||||
|
||||
/**
|
||||
* 处理状态接口
|
||||
* @author hancong03@baidu.com
|
||||
*/
|
||||
public interface State {
|
||||
|
||||
public boolean isSuccess ();
|
||||
|
||||
public void putInfo( String name, String val );
|
||||
|
||||
public void putInfo ( String name, long val );
|
||||
|
||||
public String toJSONString ();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.jeesite.common.ueditor.hunter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.MultiState;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
|
||||
public class FileManager {
|
||||
|
||||
public static final String USERFILES_BASE_URL = "/userfiles/";
|
||||
|
||||
private String dir = null;
|
||||
private String rootPath = null;
|
||||
private String[] allowFiles = null;
|
||||
private int count = 0;
|
||||
|
||||
public FileManager ( Map<String, Object> conf ) {
|
||||
|
||||
this.rootPath = (String)conf.get( "rootPath" );
|
||||
this.dir = this.rootPath + (String)conf.get( "dir" );
|
||||
this.allowFiles = this.getAllowFiles( conf.get("allowFiles") );
|
||||
this.count = (Integer)conf.get( "count" );
|
||||
|
||||
}
|
||||
|
||||
public State listFile (HttpServletRequest request, int index ) {
|
||||
|
||||
// File dir = new File( this.dir );
|
||||
File dir = new File( PathFormat.parse(this.dir) ); // ThinkGem 路径中有变量时变量不转化问题
|
||||
State state = null;
|
||||
|
||||
if ( !dir.exists() ) {
|
||||
return new BaseState( false, AppInfo.NOT_EXIST );
|
||||
}
|
||||
|
||||
if ( !dir.isDirectory() ) {
|
||||
return new BaseState( false, AppInfo.NOT_DIRECTORY );
|
||||
}
|
||||
|
||||
Collection<File> list = FileUtils.listFiles( dir, this.allowFiles, true );
|
||||
|
||||
if ( index < 0 || index > list.size() ) {
|
||||
state = new MultiState( true );
|
||||
} else {
|
||||
Object[] fileList = Arrays.copyOfRange( list.toArray(), index, index + this.count );
|
||||
state = this.getState(request, fileList );
|
||||
}
|
||||
|
||||
state.putInfo( "start", index );
|
||||
state.putInfo( "total", list.size() );
|
||||
|
||||
return state;
|
||||
|
||||
}
|
||||
|
||||
private State getState (HttpServletRequest request, Object[] files ) {
|
||||
|
||||
MultiState state = new MultiState( true );
|
||||
BaseState fileState = null;
|
||||
|
||||
File file = null;
|
||||
|
||||
for ( Object obj : files ) {
|
||||
if ( obj == null ) {
|
||||
break;
|
||||
}
|
||||
file = (File)obj;
|
||||
fileState = new BaseState( true );
|
||||
//fileState.putInfo( "url", PathFormat.format( this.getPath( file ) ) );
|
||||
// ThinkGem 将绝对路径转换为虚拟路径
|
||||
String url = PathFormat.format( this.getPath( file ) );
|
||||
int index = url.indexOf(USERFILES_BASE_URL);
|
||||
if(index > 0) {
|
||||
url = url.substring(index + USERFILES_BASE_URL.length());
|
||||
}
|
||||
fileState.putInfo( "url", request.getContextPath() + USERFILES_BASE_URL + url );
|
||||
state.addState( fileState );
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
}
|
||||
|
||||
private String getPath ( File file ) {
|
||||
|
||||
String path = file.getAbsolutePath();
|
||||
|
||||
return path.replace( this.rootPath, "/" );
|
||||
|
||||
}
|
||||
|
||||
private String[] getAllowFiles ( Object fileExt ) {
|
||||
|
||||
String[] exts = null;
|
||||
String ext = null;
|
||||
|
||||
if ( fileExt == null ) {
|
||||
return new String[ 0 ];
|
||||
}
|
||||
|
||||
exts = (String[])fileExt;
|
||||
|
||||
for ( int i = 0, len = exts.length; i < len; i++ ) {
|
||||
|
||||
ext = exts[ i ];
|
||||
exts[ i ] = ext.replace( ".", "" );
|
||||
|
||||
}
|
||||
|
||||
return exts;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.jeesite.common.ueditor.hunter;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.MIMEType;
|
||||
import com.jeesite.common.ueditor.define.MultiState;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
import com.jeesite.common.ueditor.upload.StorageManager;
|
||||
|
||||
/**
|
||||
* 图片抓取器
|
||||
* @author hancong03@baidu.com
|
||||
*/
|
||||
public class ImageHunter {
|
||||
|
||||
private HttpServletRequest request = null;
|
||||
private String filename = null;
|
||||
private String savePath = null;
|
||||
private String rootPath = null;
|
||||
private List<String> allowTypes = null;
|
||||
private long maxSize = -1;
|
||||
|
||||
private List<String> filters = null;
|
||||
|
||||
public ImageHunter (HttpServletRequest request, Map<String, Object> conf ) {
|
||||
|
||||
this.request = request;
|
||||
this.filename = (String)conf.get( "filename" );
|
||||
this.savePath = (String)conf.get( "savePath" );
|
||||
this.rootPath = (String)conf.get( "rootPath" );
|
||||
this.maxSize = (Long)conf.get( "maxSize" );
|
||||
this.allowTypes = Arrays.asList( (String[])conf.get( "allowFiles" ) );
|
||||
this.filters = Arrays.asList( (String[])conf.get( "filter" ) );
|
||||
|
||||
}
|
||||
|
||||
public State capture ( String[] list ) {
|
||||
|
||||
MultiState state = new MultiState( true );
|
||||
|
||||
for ( String source : list ) {
|
||||
state.addState( captureRemoteData( source ) );
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
}
|
||||
|
||||
public State captureRemoteData ( String urlStr ) {
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
URL url = null;
|
||||
String suffix = null;
|
||||
|
||||
try {
|
||||
url = new URL( urlStr );
|
||||
|
||||
if ( !validHost( url.getHost() ) ) {
|
||||
return new BaseState( false, AppInfo.PREVENT_HOST );
|
||||
}
|
||||
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setInstanceFollowRedirects( true );
|
||||
connection.setUseCaches( true );
|
||||
|
||||
if ( !validContentState( connection.getResponseCode() ) ) {
|
||||
return new BaseState( false, AppInfo.CONNECTION_ERROR );
|
||||
}
|
||||
|
||||
suffix = MIMEType.getSuffix( connection.getContentType() );
|
||||
|
||||
if ( !validFileType( suffix ) ) {
|
||||
return new BaseState( false, AppInfo.NOT_ALLOW_FILE_TYPE );
|
||||
}
|
||||
|
||||
if ( !validFileSize( connection.getContentLength() ) ) {
|
||||
return new BaseState( false, AppInfo.MAX_SIZE );
|
||||
}
|
||||
|
||||
String savePath = this.getPath( this.savePath, this.filename, suffix );
|
||||
String physicalPath = this.rootPath + savePath;
|
||||
|
||||
State state = StorageManager.saveFileByInputStream( connection.getInputStream(), physicalPath );
|
||||
|
||||
if ( state.isSuccess() ) {
|
||||
state.putInfo( "url", request.getContextPath() + PathFormat.format( savePath ) );
|
||||
state.putInfo( "source", urlStr );
|
||||
}
|
||||
|
||||
return state;
|
||||
|
||||
} catch ( Exception e ) {
|
||||
return new BaseState( false, AppInfo.REMOTE_FAIL );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String getPath ( String savePath, String filename, String suffix ) {
|
||||
|
||||
return PathFormat.parse( savePath + suffix, filename );
|
||||
|
||||
}
|
||||
|
||||
private boolean validHost ( String hostname ) {
|
||||
try {
|
||||
InetAddress ip = InetAddress.getByName(hostname);
|
||||
if (ip.isSiteLocalAddress()) {
|
||||
return false;
|
||||
}
|
||||
} catch (UnknownHostException e) {
|
||||
return false;
|
||||
}
|
||||
return !filters.contains( hostname );
|
||||
|
||||
}
|
||||
|
||||
private boolean validContentState ( int code ) {
|
||||
|
||||
return HttpURLConnection.HTTP_OK == code;
|
||||
|
||||
}
|
||||
|
||||
private boolean validFileType ( String type ) {
|
||||
|
||||
return this.allowTypes.contains( type );
|
||||
|
||||
}
|
||||
|
||||
private boolean validFileSize ( int size ) {
|
||||
return size < this.maxSize;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.jeesite.common.ueditor.upload;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.FileType;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
|
||||
public final class Base64Uploader {
|
||||
|
||||
public static State save(HttpServletRequest request, String content, Map<String, Object> conf) {
|
||||
|
||||
byte[] data = decode(content);
|
||||
|
||||
long maxSize = ((Long) conf.get("maxSize")).longValue();
|
||||
|
||||
if (!validSize(data, maxSize)) {
|
||||
return new BaseState(false, AppInfo.MAX_SIZE);
|
||||
}
|
||||
|
||||
String suffix = FileType.getSuffix("JPG");
|
||||
|
||||
String savePath = PathFormat.parse((String) conf.get("savePath"),
|
||||
(String) conf.get("filename"));
|
||||
|
||||
savePath = savePath + suffix;
|
||||
String physicalPath = (String) conf.get("rootPath") + savePath;
|
||||
|
||||
State storageState = StorageManager.saveBinaryFile(data, physicalPath);
|
||||
|
||||
if (storageState.isSuccess()) {
|
||||
String ctx = request.getContextPath(); // ThinkGem 修正上传图片后返回无contextpath问题
|
||||
storageState.putInfo("url", ctx + PathFormat.format(savePath));
|
||||
storageState.putInfo("type", suffix);
|
||||
storageState.putInfo("original", "");
|
||||
}
|
||||
|
||||
return storageState;
|
||||
}
|
||||
|
||||
private static byte[] decode(String content) {
|
||||
return Base64.decodeBase64(content);
|
||||
}
|
||||
|
||||
private static boolean validSize(byte[] data, long length) {
|
||||
return data.length <= length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.jeesite.common.ueditor.upload;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.fileupload.FileItemIterator;
|
||||
import org.apache.commons.fileupload.FileItemStream;
|
||||
import org.apache.commons.fileupload.FileUploadException;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import com.jeesite.common.io.FileUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.media.VideoUtils;
|
||||
import com.jeesite.common.ueditor.PathFormat;
|
||||
import com.jeesite.common.ueditor.define.ActionMap;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.FileType;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import net.coobird.thumbnailator.Thumbnails.Builder;
|
||||
|
||||
public class BinaryUploader {
|
||||
|
||||
public static final State save(HttpServletRequest request,
|
||||
Map<String, Object> conf) {
|
||||
FileItemStream fileStream = null; // 原始上传
|
||||
MultipartFile fileStream2 = null; // Spring MVC 上传
|
||||
boolean isAjaxUpload = request.getHeader( "X_Requested_With" ) != null;
|
||||
|
||||
if (!ServletFileUpload.isMultipartContent(request)) {
|
||||
return new BaseState(false, AppInfo.NOT_MULTIPART_CONTENT);
|
||||
}
|
||||
|
||||
ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
|
||||
|
||||
if ( isAjaxUpload ) {
|
||||
upload.setHeaderEncoding( "UTF-8" );
|
||||
}
|
||||
|
||||
try {
|
||||
FileItemIterator iterator = upload.getItemIterator(request);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
fileStream = iterator.next();
|
||||
|
||||
if (!fileStream.isFormField()) {
|
||||
break;
|
||||
}
|
||||
fileStream = null;
|
||||
}
|
||||
|
||||
if (fileStream == null) {
|
||||
// 原始上传无文件,则检查是否是Spring MVC上传 ThinkGem
|
||||
MultipartFile file = null;
|
||||
if (request instanceof MultipartHttpServletRequest){
|
||||
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
|
||||
Iterator<String> it = multiRequest.getFileNames();
|
||||
while (it.hasNext()) {
|
||||
file = multiRequest.getFile(it.next());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (file != null && !file.isEmpty() && file.getOriginalFilename() != null) {
|
||||
fileStream2 = file;
|
||||
}
|
||||
}
|
||||
|
||||
if (fileStream == null && fileStream2 == null) {
|
||||
return new BaseState(false, AppInfo.NOTFOUND_UPLOAD_DATA);
|
||||
}
|
||||
|
||||
String savePath = (String) conf.get("savePath");
|
||||
String originFileName = fileStream != null ? fileStream.getName() : fileStream2.getOriginalFilename();
|
||||
String suffix = FileType.getSuffixByFilename(originFileName);
|
||||
|
||||
originFileName = originFileName.substring(0,
|
||||
originFileName.length() - suffix.length());
|
||||
savePath = savePath + suffix;
|
||||
|
||||
long maxSize = ((Long) conf.get("maxSize")).longValue();
|
||||
|
||||
if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
|
||||
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
|
||||
}
|
||||
|
||||
savePath = PathFormat.parse(savePath, originFileName);
|
||||
|
||||
String physicalPath = FileUtils.path((String) conf.get("rootPath") + savePath);
|
||||
|
||||
InputStream is = fileStream != null ? fileStream.openStream() : fileStream2.getInputStream();
|
||||
State storageState = StorageManager.saveFileByInputStream(is, physicalPath, maxSize);
|
||||
is.close();
|
||||
|
||||
if (storageState.isSuccess()) {
|
||||
int actionCode = ((Integer) conf.get("actionCode")).intValue();
|
||||
String ctx = request.getContextPath(); // ThinkGem 修正上传图片后返回无contextpath问题
|
||||
|
||||
// 上传图片后,进行图片压缩
|
||||
if (actionCode == ActionMap.UPLOAD_IMAGE){
|
||||
|
||||
// 如果开启了压缩图片
|
||||
if ((Boolean)conf.get("imageCompressEnable")){
|
||||
Integer width = (Integer)conf.get("imageCompressBorder");
|
||||
// 过滤掉gif图片,因为gif图片转换后会出现黑色背景的情况(gif基本也没有比较大的图片)。
|
||||
if (StringUtils.inString(FileUtils.getFileExtension(physicalPath),
|
||||
"png","jpg","jpeg","bmp","ico")){
|
||||
Builder<File> file = Thumbnails.of(physicalPath);
|
||||
BufferedImage bufferedImage = ImageIO.read(new File(physicalPath));
|
||||
if (bufferedImage != null){
|
||||
if (bufferedImage.getWidth() <= width){
|
||||
file.width(bufferedImage.getWidth());
|
||||
}else{
|
||||
file.width(width);
|
||||
}
|
||||
file.toFile(physicalPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 上传成功后 转换格式 按照新的视频格式 返回前台 ThinkGem
|
||||
else if(actionCode == ActionMap.UPLOAD_VIDEO){
|
||||
final VideoUtils v = new VideoUtils(physicalPath);
|
||||
// 先截图
|
||||
if (v.cutPic()){
|
||||
// 开启进程,在转换视频文件
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
v.convert();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
storageState.putInfo("url", ctx + PathFormat.format(savePath) + "." + v.getOutputFileExtension());
|
||||
storageState.putInfo("type", "." + v.getOutputFileExtension());
|
||||
storageState.putInfo("original", originFileName +"."+ v.getInputFileExtension());
|
||||
return storageState;
|
||||
}
|
||||
}
|
||||
storageState.putInfo("url", ctx + PathFormat.format(savePath));
|
||||
storageState.putInfo("type", suffix);
|
||||
storageState.putInfo("original", originFileName + suffix);
|
||||
}
|
||||
|
||||
return storageState;
|
||||
} catch (FileUploadException e) {
|
||||
return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR);
|
||||
} catch (IOException e) {
|
||||
return new BaseState(false, AppInfo.IO_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean validType(String type, String[] allowTypes) {
|
||||
List<String> list = Arrays.asList(allowTypes);
|
||||
|
||||
return list.contains(type);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.jeesite.common.ueditor.upload;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.jeesite.common.idgen.IdGenerate;
|
||||
import com.jeesite.common.io.FileUtils;
|
||||
import com.jeesite.common.io.PropertiesUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.ueditor.define.AppInfo;
|
||||
import com.jeesite.common.ueditor.define.BaseState;
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
|
||||
public class StorageManager {
|
||||
|
||||
public static final int BUFFER_SIZE = 8192;
|
||||
|
||||
public StorageManager() {
|
||||
|
||||
}
|
||||
|
||||
public static State saveBinaryFile(byte[] data, String path) {
|
||||
File file = new File(path);
|
||||
|
||||
State state = valid(file);
|
||||
|
||||
if (!state.isSuccess()) {
|
||||
return state;
|
||||
}
|
||||
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
bos = new BufferedOutputStream(new FileOutputStream(file));
|
||||
bos.write(data);
|
||||
} catch (IOException ioe) {
|
||||
return new BaseState(false, AppInfo.IO_ERROR);
|
||||
}finally {
|
||||
if (bos != null){
|
||||
try {
|
||||
bos.flush();
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 验证允许的上传的文件类型(如果没有设置则不验证,默认不设置)
|
||||
String allowContentTypes = PropertiesUtils.getInstance()
|
||||
.getProperty("file.allowContentTypes");
|
||||
if(StringUtils.isNotBlank(allowContentTypes)){
|
||||
String rct = FileUtils.getRealContentType(file);
|
||||
if (!StringUtils.inString(rct, allowContentTypes.split(","))){
|
||||
file.delete();
|
||||
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
state = new BaseState(true, file.getAbsolutePath());
|
||||
state.putInfo( "size", data.length );
|
||||
state.putInfo( "title", file.getName() );
|
||||
return state;
|
||||
}
|
||||
|
||||
public static State saveFileByInputStream(InputStream is, String path, long maxSize) {
|
||||
State state = null;
|
||||
|
||||
File tmpFile = getTmpFile();
|
||||
|
||||
byte[] dataBuf = new byte[ 2048 ];
|
||||
BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
|
||||
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
try{
|
||||
bos = new BufferedOutputStream(
|
||||
new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE);
|
||||
int count = 0;
|
||||
while ((count = bis.read(dataBuf)) != -1) {
|
||||
bos.write(dataBuf, 0, count);
|
||||
}
|
||||
}finally {
|
||||
if (bos != null){
|
||||
bos.flush();
|
||||
bos.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpFile.length() > maxSize) {
|
||||
tmpFile.delete();
|
||||
return new BaseState(false, AppInfo.MAX_SIZE);
|
||||
}
|
||||
|
||||
// 验证允许的上传的文件类型(如果没有设置则不验证,默认不设置)
|
||||
String allowContentTypes = PropertiesUtils.getInstance()
|
||||
.getProperty("file.allowContentTypes");
|
||||
if(StringUtils.isNotBlank(allowContentTypes)){
|
||||
String rct = FileUtils.getRealContentType(tmpFile);
|
||||
if (!StringUtils.inString(rct, allowContentTypes.split(","))){
|
||||
tmpFile.delete();
|
||||
return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
state = saveTmpFile(tmpFile, path);
|
||||
|
||||
if (!state.isSuccess()) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
|
||||
return state;
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}finally {
|
||||
if (bis != null){
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new BaseState(false, AppInfo.IO_ERROR);
|
||||
}
|
||||
|
||||
public static State saveFileByInputStream(InputStream is, String path) {
|
||||
State state = null;
|
||||
|
||||
File tmpFile = getTmpFile();
|
||||
|
||||
byte[] dataBuf = new byte[ 2048 ];
|
||||
BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE);
|
||||
|
||||
try {
|
||||
BufferedOutputStream bos = null;
|
||||
try{
|
||||
bos = new BufferedOutputStream(new FileOutputStream(tmpFile),
|
||||
StorageManager.BUFFER_SIZE);
|
||||
int count = 0;
|
||||
while ((count = bis.read(dataBuf)) != -1) {
|
||||
bos.write(dataBuf, 0, count);
|
||||
}
|
||||
}finally {
|
||||
if (bos != null){
|
||||
bos.flush();
|
||||
bos.close();
|
||||
}
|
||||
}
|
||||
state = saveTmpFile(tmpFile, path);
|
||||
if (!state.isSuccess()) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
return state;
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}finally {
|
||||
if (bis != null){
|
||||
try {
|
||||
bis.close();
|
||||
} catch (IOException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new BaseState(false, AppInfo.IO_ERROR);
|
||||
}
|
||||
|
||||
private static File getTmpFile() {
|
||||
// File tmpDir = FileUtils.getTempDirectory();
|
||||
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
// String tmpFileName = (Math.random() * 10000 + "").replace(".", "");
|
||||
// return new File(tmpDir, tmpFileName);
|
||||
return new File(tmpDir, IdGenerate.randomBase62(10));
|
||||
}
|
||||
|
||||
private static State saveTmpFile(File tmpFile, String path) {
|
||||
State state = null;
|
||||
File targetFile = new File(path);
|
||||
|
||||
if (targetFile.canWrite()) {
|
||||
return new BaseState(false, AppInfo.PERMISSION_DENIED);
|
||||
}
|
||||
try {
|
||||
FileUtils.moveFile(tmpFile, targetFile);
|
||||
} catch (IOException e) {
|
||||
return new BaseState(false, AppInfo.IO_ERROR);
|
||||
}
|
||||
|
||||
state = new BaseState(true);
|
||||
state.putInfo( "size", targetFile.length() );
|
||||
state.putInfo( "title", targetFile.getName() );
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
private static State valid(File file) {
|
||||
File parentPath = file.getParentFile();
|
||||
|
||||
if ((!parentPath.exists()) && (!parentPath.mkdirs())) {
|
||||
return new BaseState(false, AppInfo.FAILED_CREATE_FILE);
|
||||
}
|
||||
|
||||
if (!parentPath.canWrite()) {
|
||||
return new BaseState(false, AppInfo.PERMISSION_DENIED);
|
||||
}
|
||||
|
||||
return new BaseState(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.jeesite.common.ueditor.upload;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.jeesite.common.ueditor.define.State;
|
||||
|
||||
public class Uploader {
|
||||
|
||||
private HttpServletRequest request = null;
|
||||
private Map<String, Object> conf = null;
|
||||
|
||||
public Uploader(HttpServletRequest request, Map<String, Object> conf) {
|
||||
this.request = request;
|
||||
this.conf = conf;
|
||||
}
|
||||
|
||||
public final State doExec() {
|
||||
String filedName = (String) this.conf.get("fieldName");
|
||||
State state = null;
|
||||
|
||||
if ("true".equals(this.conf.get("isBase64"))) {
|
||||
state = Base64Uploader.save(this.request, this.request.getParameter(filedName),
|
||||
this.conf);
|
||||
} else {
|
||||
state = BinaryUploader.save(this.request, this.conf);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
package com.jeesite.common.utils.excel;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -13,8 +14,10 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -36,6 +39,7 @@ import org.slf4j.LoggerFactory;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.SetUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.reflect.ReflectUtils;
|
||||
@@ -47,9 +51,9 @@ import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||
/**
|
||||
* 导出Excel文件(导出“XLSX”格式,支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion)
|
||||
* @author ThinkGem
|
||||
* @version 2013-04-21
|
||||
* @version 2018-08-11
|
||||
*/
|
||||
public class ExcelExport {
|
||||
public class ExcelExport implements Closeable{
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ExcelExport.class);
|
||||
|
||||
@@ -76,7 +80,12 @@ public class ExcelExport {
|
||||
/**
|
||||
* 注解列表(Object[]{ ExcelField, Field/Method })
|
||||
*/
|
||||
List<Object[]> annotationList;
|
||||
private List<Object[]> annotationList;
|
||||
|
||||
/**
|
||||
* 用于清理缓存
|
||||
*/
|
||||
private Set<Class<?>> fieldTypes = SetUtils.newHashSet();
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
@@ -431,6 +440,7 @@ public class ExcelExport {
|
||||
if(val == null){
|
||||
cell.setCellValue("");
|
||||
}else if(fieldType != Class.class){
|
||||
fieldTypes.add(fieldType); // 先存起来,方便完成后清理缓存
|
||||
cell.setCellValue((String)fieldType.getMethod("setValue", Object.class).invoke(null, val));
|
||||
try{
|
||||
defaultDataFormat = (String)fieldType.getMethod("getDataFormat").invoke(null);
|
||||
@@ -456,8 +466,11 @@ public class ExcelExport {
|
||||
cell.setCellValue((Date) val);
|
||||
defaultDataFormat = "yyyy-MM-dd HH:mm";
|
||||
}else {
|
||||
cell.setCellValue((String)Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
|
||||
"fieldtype."+val.getClass().getSimpleName()+"Type")).getMethod("setValue", Object.class).invoke(null, val));
|
||||
// 如果没有指定 fieldType,切自行根据类型查找相应的转换类(com.jeesite.common.utils.excel.fieldtype.值的类名+Type)
|
||||
Class<?> fieldType2 = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
|
||||
"fieldtype."+val.getClass().getSimpleName()+"Type"));
|
||||
fieldTypes.add(fieldType2); // 先存起来,方便完成后清理缓存
|
||||
cell.setCellValue((String)fieldType2.getMethod("setValue", Object.class).invoke(null, val));
|
||||
}
|
||||
}
|
||||
// if (val != null){
|
||||
@@ -572,14 +585,33 @@ public class ExcelExport {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理临时文件
|
||||
*/
|
||||
public ExcelExport dispose(){
|
||||
// /**
|
||||
// * 清理临时文件
|
||||
// * @deprecated see close()
|
||||
// */
|
||||
// public ExcelExport dispose(){
|
||||
// try {
|
||||
// this.close();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return this;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (wb instanceof SXSSFWorkbook){
|
||||
((SXSSFWorkbook)wb).dispose();
|
||||
}
|
||||
return this;
|
||||
Iterator<Class<?>> it = fieldTypes.iterator();
|
||||
while(it.hasNext()){
|
||||
Class<?> clazz = it.next();
|
||||
try {
|
||||
clazz.getMethod("clearCache").invoke(null);
|
||||
} catch (Exception e) {
|
||||
// 报错忽略,有可能没实现此方法
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
package com.jeesite.common.utils.excel;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -15,6 +16,7 @@ import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
@@ -34,6 +36,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.jeesite.common.callback.MethodCallback;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.SetUtils;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
@@ -45,9 +48,9 @@ import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||
/**
|
||||
* 导入Excel文件(支持“XLS”和“XLSX”格式)
|
||||
* @author ThinkGem
|
||||
* @version 2014-8-19
|
||||
* @version 2018-08-11
|
||||
*/
|
||||
public class ExcelImport {
|
||||
public class ExcelImport implements Closeable {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(ExcelImport.class);
|
||||
|
||||
@@ -66,6 +69,11 @@ public class ExcelImport {
|
||||
*/
|
||||
private int headerNum;
|
||||
|
||||
/**
|
||||
* 用于清理缓存
|
||||
*/
|
||||
private Set<Class<?>> fieldTypes = SetUtils.newHashSet();
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @param path 导入文件对象,读取第一个工作表
|
||||
@@ -418,6 +426,7 @@ public class ExcelImport {
|
||||
try {
|
||||
if (StringUtils.isNotBlank(ef.attrName())){
|
||||
if (ef.fieldType() != Class.class){
|
||||
fieldTypes.add(ef.fieldType()); // 先存起来,方便完成后清理缓存
|
||||
val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val);
|
||||
}
|
||||
}else{
|
||||
@@ -445,10 +454,14 @@ public class ExcelImport {
|
||||
}
|
||||
}else{
|
||||
if (ef.fieldType() != Class.class){
|
||||
fieldTypes.add(ef.fieldType()); // 先存起来,方便完成后清理缓存
|
||||
val = ef.fieldType().getMethod("getValue", String.class).invoke(null, val.toString());
|
||||
}else{
|
||||
val = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
|
||||
"fieldtype."+valType.getSimpleName()+"Type")).getMethod("getValue", String.class).invoke(null, val.toString());
|
||||
// 如果没有指定 fieldType,切自行根据类型查找相应的转换类(com.jeesite.common.utils.excel.fieldtype.值的类名+Type)
|
||||
Class<?> fieldType2 = Class.forName(this.getClass().getName().replaceAll(this.getClass().getSimpleName(),
|
||||
"fieldtype."+valType.getSimpleName()+"Type"));
|
||||
fieldTypes.add(fieldType2); // 先存起来,方便完成后清理缓存
|
||||
val = fieldType2.getMethod("getValue", String.class).invoke(null, val.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -481,6 +494,19 @@ public class ExcelImport {
|
||||
}
|
||||
return dataList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
Iterator<Class<?>> it = fieldTypes.iterator();
|
||||
while(it.hasNext()){
|
||||
Class<?> clazz = it.next();
|
||||
try {
|
||||
clazz.getMethod("clearCache").invoke(null);
|
||||
} catch (Exception e) {
|
||||
// 报错忽略,有可能没实现此方法
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 导入测试
|
||||
|
||||
@@ -37,4 +37,11 @@ public class MoneyType {
|
||||
return "0.00";
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public static void clearCache(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,6 +78,21 @@ public class ServletUtils {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 支持AJAX的页面跳转
|
||||
*/
|
||||
public static void redirectUrl(HttpServletRequest request, HttpServletResponse response, String url){
|
||||
try {
|
||||
if (ServletUtils.isAjaxRequest(request)){
|
||||
request.getRequestDispatcher(url).forward(request, response); // AJAX不支持Redirect改用Forward
|
||||
}else{
|
||||
response.sendRedirect(request.getContextPath() + url);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是Ajax异步请求
|
||||
* @param request
|
||||
@@ -173,9 +188,10 @@ public class ServletUtils {
|
||||
resultMap.put("data", data);
|
||||
}
|
||||
}
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
HttpServletRequest request = getRequest();
|
||||
String uri = request.getRequestURI();
|
||||
if (StringUtils.endsWithIgnoreCase(uri, ".xml")){
|
||||
if (StringUtils.endsWithIgnoreCase(uri, ".xml") || StringUtils
|
||||
.equalsIgnoreCase(request.getParameter("__ajax"), "xml")){
|
||||
return XmlMapper.toXml(resultMap);
|
||||
}else{
|
||||
String functionName = request.getParameter("__callback");
|
||||
@@ -202,7 +218,7 @@ public class ServletUtils {
|
||||
/**
|
||||
* 直接将结果JSON字符串渲染到客户端(支持JsonP,请求参数加:__callback=回调函数名)
|
||||
* @param response 渲染对象:{result:'true',message:'',data:{}}
|
||||
* @param result Global.TRUE or Globle.False
|
||||
* @param result 结果标识:Global.TRUE or Globle.False
|
||||
* @param message 执行消息
|
||||
* @param data 消息数据
|
||||
* @return null
|
||||
@@ -212,16 +228,18 @@ public class ServletUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转换为JSON字符串渲染到客户端(支持JsonP,请求参数加:__callback=回调函数名)
|
||||
* 将对象转换为JSON、XML、JSONP字符串渲染到客户端(JsonP,请求参数加:__callback=回调函数名)
|
||||
* @param request 请求对象,用来得到输出格式的指令:JSON、XML、JSONP
|
||||
* @param response 渲染对象
|
||||
* @param object 待转换JSON并渲染的对象
|
||||
* @return null
|
||||
*/
|
||||
public static String renderObject(HttpServletResponse response, Object object) {
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
HttpServletRequest request = getRequest();
|
||||
String uri = request.getRequestURI();
|
||||
if (StringUtils.endsWithIgnoreCase(uri, ".xml")){
|
||||
return XmlMapper.toXml(object);
|
||||
if (StringUtils.endsWithIgnoreCase(uri, ".xml") || StringUtils
|
||||
.equalsIgnoreCase(request.getParameter("__ajax"), "xml")){
|
||||
return renderString(response, XmlMapper.toXml(object));
|
||||
}else{
|
||||
String functionName = request.getParameter("__callback");
|
||||
if (StringUtils.isNotBlank(functionName)){
|
||||
@@ -250,8 +268,18 @@ public class ServletUtils {
|
||||
*/
|
||||
public static String renderString(HttpServletResponse response, String string, String type) {
|
||||
try {
|
||||
// response.reset(); // 先注释掉,否则以前设置的Header会被清理掉,如ajax登录设置记住我Cookie
|
||||
response.setContentType(type == null ? "application/json" : type);
|
||||
// response.reset(); // 注释掉,否则以前设置的Header会被清理掉,如ajax登录设置记住我的Cookie信息
|
||||
if (type == null){
|
||||
if ((StringUtils.startsWith(string, "{") && StringUtils.endsWith(string, "}"))
|
||||
|| (StringUtils.startsWith(string, "[") && StringUtils.endsWith(string, "]"))){
|
||||
type = "application/json";
|
||||
}else if (StringUtils.startsWith(string, "<") && StringUtils.endsWith(string, ">")){
|
||||
type = "application/xml";
|
||||
}else{
|
||||
type = "text/html";
|
||||
}
|
||||
}
|
||||
response.setContentType(type);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.getWriter().print(string);
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<fixed facet="jst.utility"/>
|
||||
<fixed facet="java"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
</faceted-project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<fixed facet="jst.utility"/>
|
||||
<fixed facet="java"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.8"/>
|
||||
</faceted-project>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
919
modules/core/db/db2/core.sql
Normal file
919
modules/core/db/db2/core.sql
Normal file
@@ -0,0 +1,919 @@
|
||||
|
||||
/* Drop Tables */
|
||||
|
||||
DROP TABLE js_gen_table_column;
|
||||
DROP TABLE js_gen_table;
|
||||
DROP TABLE js_sys_company_office;
|
||||
DROP TABLE js_sys_employee_post;
|
||||
DROP TABLE js_sys_user_data_scope;
|
||||
DROP TABLE js_sys_user_role;
|
||||
DROP TABLE js_sys_user;
|
||||
DROP TABLE js_sys_employee;
|
||||
DROP TABLE js_sys_company;
|
||||
DROP TABLE js_sys_area;
|
||||
DROP TABLE js_sys_config;
|
||||
DROP TABLE js_sys_dict_data;
|
||||
DROP TABLE js_sys_dict_type;
|
||||
DROP TABLE js_sys_file_upload;
|
||||
DROP TABLE js_sys_file_entity;
|
||||
DROP TABLE js_sys_job_log;
|
||||
DROP TABLE js_sys_job;
|
||||
DROP TABLE js_sys_lang;
|
||||
DROP TABLE js_sys_log;
|
||||
DROP TABLE js_sys_role_menu;
|
||||
DROP TABLE js_sys_menu;
|
||||
DROP TABLE js_sys_module;
|
||||
DROP TABLE js_sys_msg_inner_record;
|
||||
DROP TABLE js_sys_msg_inner;
|
||||
DROP TABLE js_sys_msg_push;
|
||||
DROP TABLE js_sys_msg_pushed;
|
||||
DROP TABLE js_sys_msg_template;
|
||||
DROP TABLE js_sys_office;
|
||||
DROP TABLE js_sys_post;
|
||||
DROP TABLE js_sys_role_data_scope;
|
||||
DROP TABLE js_sys_role;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Create Tables */
|
||||
|
||||
-- 代码生成表
|
||||
CREATE TABLE js_gen_table
|
||||
(
|
||||
table_name varchar(64) NOT NULL,
|
||||
class_name varchar(100) NOT NULL,
|
||||
comments varchar(500) NOT NULL,
|
||||
parent_table_name varchar(64),
|
||||
parent_table_fk_name varchar(64),
|
||||
data_source_name varchar(64),
|
||||
tpl_category varchar(200),
|
||||
package_name varchar(500),
|
||||
module_name varchar(30),
|
||||
sub_module_name varchar(30),
|
||||
function_name varchar(200),
|
||||
function_name_simple varchar(50),
|
||||
function_author varchar(50),
|
||||
gen_base_dir varchar(1000),
|
||||
options varchar(1000),
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (table_name)
|
||||
);
|
||||
|
||||
|
||||
-- 代码生成表列
|
||||
CREATE TABLE js_gen_table_column
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
table_name varchar(64) NOT NULL,
|
||||
column_name varchar(64) NOT NULL,
|
||||
column_sort decimal(10),
|
||||
column_type varchar(100) NOT NULL,
|
||||
column_label varchar(50),
|
||||
comments varchar(500) NOT NULL,
|
||||
attr_name varchar(200) NOT NULL,
|
||||
attr_type varchar(200) NOT NULL,
|
||||
is_pk char(1),
|
||||
is_null char(1),
|
||||
is_insert char(1),
|
||||
is_update char(1),
|
||||
is_list char(1),
|
||||
is_query char(1),
|
||||
query_type varchar(200),
|
||||
is_edit char(1),
|
||||
show_type varchar(200),
|
||||
options varchar(1000),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 行政区划
|
||||
CREATE TABLE js_sys_area
|
||||
(
|
||||
area_code varchar(100) NOT NULL,
|
||||
parent_code varchar(64) NOT NULL,
|
||||
parent_codes varchar(1000) NOT NULL,
|
||||
tree_sort decimal(10) NOT NULL,
|
||||
tree_sorts varchar(1000) NOT NULL,
|
||||
tree_leaf char(1) NOT NULL,
|
||||
tree_level decimal(4) NOT NULL,
|
||||
tree_names varchar(1000) NOT NULL,
|
||||
area_name varchar(100) NOT NULL,
|
||||
area_type char(1),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (area_code)
|
||||
);
|
||||
|
||||
|
||||
-- 公司表
|
||||
CREATE TABLE js_sys_company
|
||||
(
|
||||
company_code varchar(64) NOT NULL,
|
||||
parent_code varchar(64) NOT NULL,
|
||||
parent_codes varchar(1000) NOT NULL,
|
||||
tree_sort decimal(10) NOT NULL,
|
||||
tree_sorts varchar(1000) NOT NULL,
|
||||
tree_leaf char(1) NOT NULL,
|
||||
tree_level decimal(4) NOT NULL,
|
||||
tree_names varchar(1000) NOT NULL,
|
||||
view_code varchar(100) NOT NULL,
|
||||
company_name varchar(200) NOT NULL,
|
||||
full_name varchar(200) NOT NULL,
|
||||
area_code varchar(100),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
extend_s1 varchar(500),
|
||||
extend_s2 varchar(500),
|
||||
extend_s3 varchar(500),
|
||||
extend_s4 varchar(500),
|
||||
extend_s5 varchar(500),
|
||||
extend_s6 varchar(500),
|
||||
extend_s7 varchar(500),
|
||||
extend_s8 varchar(500),
|
||||
extend_i1 decimal(19),
|
||||
extend_i2 decimal(19),
|
||||
extend_i3 decimal(19),
|
||||
extend_i4 decimal(19),
|
||||
extend_f1 decimal(19,4),
|
||||
extend_f2 decimal(19,4),
|
||||
extend_f3 decimal(19,4),
|
||||
extend_f4 decimal(19,4),
|
||||
extend_d1 timestamp,
|
||||
extend_d2 timestamp,
|
||||
extend_d3 timestamp,
|
||||
extend_d4 timestamp,
|
||||
PRIMARY KEY (company_code)
|
||||
);
|
||||
|
||||
|
||||
-- 公司部门关联表
|
||||
CREATE TABLE js_sys_company_office
|
||||
(
|
||||
company_code varchar(64) NOT NULL,
|
||||
office_code varchar(64) NOT NULL,
|
||||
PRIMARY KEY (company_code, office_code)
|
||||
);
|
||||
|
||||
|
||||
-- 参数配置表
|
||||
CREATE TABLE js_sys_config
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
config_name varchar(100) NOT NULL,
|
||||
config_key varchar(100) NOT NULL,
|
||||
config_value varchar(1000),
|
||||
is_sys char(1) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 字典数据表
|
||||
CREATE TABLE js_sys_dict_data
|
||||
(
|
||||
dict_code varchar(64) NOT NULL,
|
||||
parent_code varchar(64) NOT NULL,
|
||||
parent_codes varchar(1000) NOT NULL,
|
||||
tree_sort decimal(10) NOT NULL,
|
||||
tree_sorts varchar(1000) NOT NULL,
|
||||
tree_leaf char(1) NOT NULL,
|
||||
tree_level decimal(4) NOT NULL,
|
||||
tree_names varchar(1000) NOT NULL,
|
||||
dict_label varchar(100) NOT NULL,
|
||||
dict_value varchar(100) NOT NULL,
|
||||
dict_type varchar(100) NOT NULL,
|
||||
is_sys char(1) NOT NULL,
|
||||
description varchar(500),
|
||||
css_style varchar(500),
|
||||
css_class varchar(500),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
extend_s1 varchar(500),
|
||||
extend_s2 varchar(500),
|
||||
extend_s3 varchar(500),
|
||||
extend_s4 varchar(500),
|
||||
extend_s5 varchar(500),
|
||||
extend_s6 varchar(500),
|
||||
extend_s7 varchar(500),
|
||||
extend_s8 varchar(500),
|
||||
extend_i1 decimal(19),
|
||||
extend_i2 decimal(19),
|
||||
extend_i3 decimal(19),
|
||||
extend_i4 decimal(19),
|
||||
extend_f1 decimal(19,4),
|
||||
extend_f2 decimal(19,4),
|
||||
extend_f3 decimal(19,4),
|
||||
extend_f4 decimal(19,4),
|
||||
extend_d1 timestamp,
|
||||
extend_d2 timestamp,
|
||||
extend_d3 timestamp,
|
||||
extend_d4 timestamp,
|
||||
PRIMARY KEY (dict_code)
|
||||
);
|
||||
|
||||
|
||||
-- 字典类型表
|
||||
CREATE TABLE js_sys_dict_type
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
dict_name varchar(100) NOT NULL,
|
||||
dict_type varchar(100) NOT NULL,
|
||||
is_sys char(1) NOT NULL,
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 员工表
|
||||
CREATE TABLE js_sys_employee
|
||||
(
|
||||
emp_code varchar(64) NOT NULL,
|
||||
emp_name varchar(100) NOT NULL,
|
||||
emp_name_en varchar(100),
|
||||
office_code varchar(64) NOT NULL,
|
||||
office_name varchar(100) NOT NULL,
|
||||
company_code varchar(64),
|
||||
company_name varchar(200),
|
||||
status char(1) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
PRIMARY KEY (emp_code)
|
||||
);
|
||||
|
||||
|
||||
-- 员工与岗位关联表
|
||||
CREATE TABLE js_sys_employee_post
|
||||
(
|
||||
emp_code varchar(64) NOT NULL,
|
||||
post_code varchar(64) NOT NULL,
|
||||
PRIMARY KEY (emp_code, post_code)
|
||||
);
|
||||
|
||||
|
||||
-- 文件实体表
|
||||
CREATE TABLE js_sys_file_entity
|
||||
(
|
||||
file_id varchar(64) NOT NULL,
|
||||
file_md5 varchar(64) NOT NULL UNIQUE,
|
||||
file_path varchar(1000) NOT NULL,
|
||||
file_content_type varchar(200) NOT NULL,
|
||||
file_extension varchar(100) NOT NULL,
|
||||
file_size decimal(31) NOT NULL,
|
||||
PRIMARY KEY (file_id)
|
||||
);
|
||||
|
||||
|
||||
-- 文件上传表
|
||||
CREATE TABLE js_sys_file_upload
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
file_id varchar(64) NOT NULL,
|
||||
file_name varchar(500) NOT NULL,
|
||||
file_type varchar(20) NOT NULL,
|
||||
biz_key varchar(64),
|
||||
biz_type varchar(64),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 作业调度表
|
||||
CREATE TABLE js_sys_job
|
||||
(
|
||||
job_name varchar(64) NOT NULL,
|
||||
job_group varchar(64) NOT NULL,
|
||||
description varchar(100) NOT NULL,
|
||||
invoke_target varchar(1000) NOT NULL,
|
||||
cron_expression varchar(255) NOT NULL,
|
||||
misfire_instruction decimal(1) NOT NULL,
|
||||
concurrent char(1) NOT NULL,
|
||||
status char(1) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (job_name, job_group)
|
||||
);
|
||||
|
||||
|
||||
-- 作业调度日志表
|
||||
CREATE TABLE js_sys_job_log
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
job_name varchar(64) NOT NULL,
|
||||
job_group varchar(64) NOT NULL,
|
||||
job_type varchar(50),
|
||||
job_event varchar(200),
|
||||
job_message varchar(500),
|
||||
is_exception char(1),
|
||||
exception_info clob,
|
||||
create_date timestamp,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 国际化语言
|
||||
CREATE TABLE js_sys_lang
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
module_code varchar(64) NOT NULL,
|
||||
lang_code varchar(500) NOT NULL,
|
||||
lang_text varchar(500) NOT NULL,
|
||||
lang_type varchar(50) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 操作日志表
|
||||
CREATE TABLE js_sys_log
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
log_type varchar(50) NOT NULL,
|
||||
log_title varchar(500) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_by_name varchar(100) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
request_uri varchar(500),
|
||||
request_method varchar(10),
|
||||
request_params clob,
|
||||
diff_modify_data clob,
|
||||
biz_key varchar(64),
|
||||
biz_type varchar(64),
|
||||
remote_addr varchar(255) NOT NULL,
|
||||
server_addr varchar(255) NOT NULL,
|
||||
is_exception char(1),
|
||||
exception_info clob,
|
||||
user_agent varchar(500),
|
||||
device_name varchar(100),
|
||||
browser_name varchar(100),
|
||||
execute_time decimal(19),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 菜单表
|
||||
CREATE TABLE js_sys_menu
|
||||
(
|
||||
menu_code varchar(64) NOT NULL,
|
||||
parent_code varchar(64) NOT NULL,
|
||||
parent_codes varchar(1000) NOT NULL,
|
||||
tree_sort decimal(10) NOT NULL,
|
||||
tree_sorts varchar(1000) NOT NULL,
|
||||
tree_leaf char(1) NOT NULL,
|
||||
tree_level decimal(4) NOT NULL,
|
||||
tree_names varchar(1000) NOT NULL,
|
||||
menu_name varchar(100) NOT NULL,
|
||||
menu_type char(1) NOT NULL,
|
||||
menu_href varchar(1000),
|
||||
menu_target varchar(20),
|
||||
menu_icon varchar(100),
|
||||
menu_color varchar(50),
|
||||
permission varchar(1000),
|
||||
weight decimal(4),
|
||||
is_show char(1) NOT NULL,
|
||||
sys_code varchar(64) NOT NULL,
|
||||
module_codes varchar(500) NOT NULL,
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
extend_s1 varchar(500),
|
||||
extend_s2 varchar(500),
|
||||
extend_s3 varchar(500),
|
||||
extend_s4 varchar(500),
|
||||
extend_s5 varchar(500),
|
||||
extend_s6 varchar(500),
|
||||
extend_s7 varchar(500),
|
||||
extend_s8 varchar(500),
|
||||
extend_i1 decimal(19),
|
||||
extend_i2 decimal(19),
|
||||
extend_i3 decimal(19),
|
||||
extend_i4 decimal(19),
|
||||
extend_f1 decimal(19,4),
|
||||
extend_f2 decimal(19,4),
|
||||
extend_f3 decimal(19,4),
|
||||
extend_f4 decimal(19,4),
|
||||
extend_d1 timestamp,
|
||||
extend_d2 timestamp,
|
||||
extend_d3 timestamp,
|
||||
extend_d4 timestamp,
|
||||
PRIMARY KEY (menu_code)
|
||||
);
|
||||
|
||||
|
||||
-- 模块表
|
||||
CREATE TABLE js_sys_module
|
||||
(
|
||||
module_code varchar(64) NOT NULL,
|
||||
module_name varchar(100) NOT NULL,
|
||||
description varchar(500),
|
||||
main_class_name varchar(500),
|
||||
current_version varchar(50),
|
||||
upgrade_info varchar(300),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (module_code)
|
||||
);
|
||||
|
||||
|
||||
-- 内部消息
|
||||
CREATE TABLE js_sys_msg_inner
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
msg_title varchar(200) NOT NULL,
|
||||
content_level char(1) NOT NULL,
|
||||
content_type char(1),
|
||||
msg_content clob NOT NULL,
|
||||
receive_type char(1) NOT NULL,
|
||||
receive_codes clob NOT NULL,
|
||||
receive_names clob NOT NULL,
|
||||
send_user_code varchar(64) NOT NULL,
|
||||
send_user_name varchar(100) NOT NULL,
|
||||
send_date timestamp NOT NULL,
|
||||
is_attac char(1),
|
||||
notify_types varchar(100) NOT NULL,
|
||||
status char(1) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 内部消息发送记录表
|
||||
CREATE TABLE js_sys_msg_inner_record
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
msg_inner_id varchar(64) NOT NULL,
|
||||
receive_user_code varchar(64),
|
||||
receive_user_name varchar(100) NOT NULL,
|
||||
read_status char(1) NOT NULL,
|
||||
read_date timestamp,
|
||||
is_star char(1),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 消息推送表
|
||||
CREATE TABLE js_sys_msg_push
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
msg_type varchar(16) NOT NULL,
|
||||
msg_title varchar(200) NOT NULL,
|
||||
msg_content clob NOT NULL,
|
||||
biz_key varchar(64),
|
||||
biz_type varchar(64),
|
||||
receive_code varchar(64) NOT NULL,
|
||||
receive_user_code varchar(64) NOT NULL,
|
||||
receive_user_name varchar(100) NOT NULL,
|
||||
send_user_code varchar(64) NOT NULL,
|
||||
send_user_name varchar(100) NOT NULL,
|
||||
send_date timestamp NOT NULL,
|
||||
is_merge_push char(1),
|
||||
plan_push_date timestamp,
|
||||
push_number int,
|
||||
push_return_code varchar(200),
|
||||
push_return_msg_id varchar(200),
|
||||
push_return_content clob,
|
||||
push_status char(1),
|
||||
push_date timestamp,
|
||||
read_status char(1),
|
||||
read_date timestamp,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 消息已推送表
|
||||
CREATE TABLE js_sys_msg_pushed
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
msg_type varchar(16) NOT NULL,
|
||||
msg_title varchar(200) NOT NULL,
|
||||
msg_content clob NOT NULL,
|
||||
biz_key varchar(64),
|
||||
biz_type varchar(64),
|
||||
receive_code varchar(64) NOT NULL,
|
||||
receive_user_code varchar(64) NOT NULL,
|
||||
receive_user_name varchar(100) NOT NULL,
|
||||
send_user_code varchar(64) NOT NULL,
|
||||
send_user_name varchar(100) NOT NULL,
|
||||
send_date timestamp NOT NULL,
|
||||
is_merge_push char(1),
|
||||
plan_push_date timestamp,
|
||||
push_number int,
|
||||
push_return_content clob,
|
||||
push_return_code varchar(200),
|
||||
push_return_msg_id varchar(200),
|
||||
push_status char(1),
|
||||
push_date timestamp,
|
||||
read_status char(1),
|
||||
read_date timestamp,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 消息模板
|
||||
CREATE TABLE js_sys_msg_template
|
||||
(
|
||||
id varchar(64) NOT NULL,
|
||||
module_code varchar(64),
|
||||
tpl_key varchar(100) NOT NULL,
|
||||
tpl_name varchar(100) NOT NULL,
|
||||
tpl_type varchar(16) NOT NULL,
|
||||
tpl_content clob NOT NULL,
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
|
||||
-- 组织机构表
|
||||
CREATE TABLE js_sys_office
|
||||
(
|
||||
office_code varchar(64) NOT NULL,
|
||||
parent_code varchar(64) NOT NULL,
|
||||
parent_codes varchar(1000) NOT NULL,
|
||||
tree_sort decimal(10) NOT NULL,
|
||||
tree_sorts varchar(1000) NOT NULL,
|
||||
tree_leaf char(1) NOT NULL,
|
||||
tree_level decimal(4) NOT NULL,
|
||||
tree_names varchar(1000) NOT NULL,
|
||||
view_code varchar(100) NOT NULL,
|
||||
office_name varchar(100) NOT NULL,
|
||||
full_name varchar(200) NOT NULL,
|
||||
office_type char(1) NOT NULL,
|
||||
leader varchar(100),
|
||||
phone varchar(100),
|
||||
address varchar(255),
|
||||
zip_code varchar(100),
|
||||
email varchar(300),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
extend_s1 varchar(500),
|
||||
extend_s2 varchar(500),
|
||||
extend_s3 varchar(500),
|
||||
extend_s4 varchar(500),
|
||||
extend_s5 varchar(500),
|
||||
extend_s6 varchar(500),
|
||||
extend_s7 varchar(500),
|
||||
extend_s8 varchar(500),
|
||||
extend_i1 decimal(19),
|
||||
extend_i2 decimal(19),
|
||||
extend_i3 decimal(19),
|
||||
extend_i4 decimal(19),
|
||||
extend_f1 decimal(19,4),
|
||||
extend_f2 decimal(19,4),
|
||||
extend_f3 decimal(19,4),
|
||||
extend_f4 decimal(19,4),
|
||||
extend_d1 timestamp,
|
||||
extend_d2 timestamp,
|
||||
extend_d3 timestamp,
|
||||
extend_d4 timestamp,
|
||||
PRIMARY KEY (office_code)
|
||||
);
|
||||
|
||||
|
||||
-- 员工岗位表
|
||||
CREATE TABLE js_sys_post
|
||||
(
|
||||
post_code varchar(64) NOT NULL,
|
||||
post_name varchar(100) NOT NULL,
|
||||
post_type varchar(100),
|
||||
post_sort decimal(10),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
PRIMARY KEY (post_code)
|
||||
);
|
||||
|
||||
|
||||
-- 角色表
|
||||
CREATE TABLE js_sys_role
|
||||
(
|
||||
role_code varchar(64) NOT NULL,
|
||||
role_name varchar(100) NOT NULL,
|
||||
role_type varchar(100),
|
||||
role_sort decimal(10),
|
||||
is_sys char(1),
|
||||
user_type varchar(16),
|
||||
data_scope char(1),
|
||||
status char(1) DEFAULT '0' NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
PRIMARY KEY (role_code)
|
||||
);
|
||||
|
||||
|
||||
-- 角色数据权限表
|
||||
CREATE TABLE js_sys_role_data_scope
|
||||
(
|
||||
role_code varchar(64) NOT NULL,
|
||||
ctrl_type varchar(20) NOT NULL,
|
||||
ctrl_data varchar(64) NOT NULL,
|
||||
ctrl_permi varchar(64) NOT NULL,
|
||||
PRIMARY KEY (role_code, ctrl_type, ctrl_data, ctrl_permi)
|
||||
);
|
||||
|
||||
|
||||
-- 角色与菜单关联表
|
||||
CREATE TABLE js_sys_role_menu
|
||||
(
|
||||
role_code varchar(64) NOT NULL,
|
||||
menu_code varchar(64) NOT NULL,
|
||||
PRIMARY KEY (role_code, menu_code)
|
||||
);
|
||||
|
||||
|
||||
-- 用户表
|
||||
CREATE TABLE js_sys_user
|
||||
(
|
||||
user_code varchar(100) NOT NULL,
|
||||
login_code varchar(100) NOT NULL,
|
||||
user_name varchar(100) NOT NULL,
|
||||
password varchar(100) NOT NULL,
|
||||
email varchar(300),
|
||||
mobile varchar(100),
|
||||
phone varchar(100),
|
||||
sex char(1),
|
||||
avatar varchar(1000),
|
||||
sign varchar(200),
|
||||
wx_openid varchar(100),
|
||||
mobile_imei varchar(100),
|
||||
user_type varchar(16) NOT NULL,
|
||||
ref_code varchar(64),
|
||||
ref_name varchar(100),
|
||||
mgr_type char(1) NOT NULL,
|
||||
pwd_security_level decimal(1),
|
||||
pwd_update_date timestamp,
|
||||
pwd_update_record varchar(1000),
|
||||
pwd_question varchar(200),
|
||||
pwd_question_answer varchar(200),
|
||||
pwd_question_2 varchar(200),
|
||||
pwd_question_answer_2 varchar(200),
|
||||
pwd_question_3 varchar(200),
|
||||
pwd_question_answer_3 varchar(200),
|
||||
pwd_quest_update_date timestamp,
|
||||
last_login_ip varchar(100),
|
||||
last_login_date timestamp,
|
||||
freeze_date timestamp,
|
||||
freeze_cause varchar(200),
|
||||
user_weight decimal(8) DEFAULT 0,
|
||||
status char NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
update_by varchar(64) NOT NULL,
|
||||
update_date timestamp NOT NULL,
|
||||
remarks varchar(500),
|
||||
corp_code varchar(64) DEFAULT '0' NOT NULL,
|
||||
corp_name varchar(100) DEFAULT 'JeeSite' NOT NULL,
|
||||
extend_s1 varchar(500),
|
||||
extend_s2 varchar(500),
|
||||
extend_s3 varchar(500),
|
||||
extend_s4 varchar(500),
|
||||
extend_s5 varchar(500),
|
||||
extend_s6 varchar(500),
|
||||
extend_s7 varchar(500),
|
||||
extend_s8 varchar(500),
|
||||
extend_i1 decimal(19),
|
||||
extend_i2 decimal(19),
|
||||
extend_i3 decimal(19),
|
||||
extend_i4 decimal(19),
|
||||
extend_f1 decimal(19,4),
|
||||
extend_f2 decimal(19,4),
|
||||
extend_f3 decimal(19,4),
|
||||
extend_f4 decimal(19,4),
|
||||
extend_d1 timestamp,
|
||||
extend_d2 timestamp,
|
||||
extend_d3 timestamp,
|
||||
extend_d4 timestamp,
|
||||
PRIMARY KEY (user_code)
|
||||
);
|
||||
|
||||
|
||||
-- 用户数据权限表
|
||||
CREATE TABLE js_sys_user_data_scope
|
||||
(
|
||||
user_code varchar(100) NOT NULL,
|
||||
ctrl_type varchar(20) NOT NULL,
|
||||
ctrl_data varchar(64) NOT NULL,
|
||||
ctrl_permi varchar(64) NOT NULL,
|
||||
PRIMARY KEY (user_code, ctrl_type, ctrl_data, ctrl_permi)
|
||||
);
|
||||
|
||||
|
||||
-- 用户与角色关联表
|
||||
CREATE TABLE js_sys_user_role
|
||||
(
|
||||
user_code varchar(100) NOT NULL,
|
||||
role_code varchar(64) NOT NULL,
|
||||
PRIMARY KEY (user_code, role_code)
|
||||
);
|
||||
|
||||
|
||||
|
||||
/* Create Indexes */
|
||||
|
||||
CREATE INDEX idx_gen_table_ptn ON js_gen_table (parent_table_name);
|
||||
CREATE INDEX idx_gen_table_column_tn ON js_gen_table_column (table_name);
|
||||
CREATE INDEX idx_sys_area_pc ON js_sys_area (parent_code);
|
||||
CREATE INDEX idx_sys_area_ts ON js_sys_area (tree_sort);
|
||||
CREATE INDEX idx_sys_area_status ON js_sys_area (status);
|
||||
CREATE INDEX idx_sys_area_pcs ON js_sys_area (parent_codes);
|
||||
CREATE INDEX idx_sys_area_tss ON js_sys_area (tree_sorts);
|
||||
CREATE INDEX idx_sys_company_cc ON js_sys_company (corp_code);
|
||||
CREATE INDEX idx_sys_company_pc ON js_sys_company (parent_code);
|
||||
CREATE INDEX idx_sys_company_ts ON js_sys_company (tree_sort);
|
||||
CREATE INDEX idx_sys_company_status ON js_sys_company (status);
|
||||
CREATE INDEX idx_sys_company_vc ON js_sys_company (view_code);
|
||||
CREATE INDEX idx_sys_company_pcs ON js_sys_company (parent_codes);
|
||||
CREATE INDEX idx_sys_company_tss ON js_sys_company (tree_sorts);
|
||||
CREATE INDEX idx_sys_config_key ON js_sys_config (config_key);
|
||||
CREATE INDEX idx_sys_dict_data_cc ON js_sys_dict_data (corp_code);
|
||||
CREATE INDEX idx_sys_dict_data_dt ON js_sys_dict_data (dict_type);
|
||||
CREATE INDEX idx_sys_dict_data_pc ON js_sys_dict_data (parent_code);
|
||||
CREATE INDEX idx_sys_dict_data_status ON js_sys_dict_data (status);
|
||||
CREATE INDEX idx_sys_dict_data_pcs ON js_sys_dict_data (parent_codes);
|
||||
CREATE INDEX idx_sys_dict_data_ts ON js_sys_dict_data (tree_sort);
|
||||
CREATE INDEX idx_sys_dict_data_tss ON js_sys_dict_data (tree_sorts);
|
||||
CREATE INDEX idx_sys_dict_data_dv ON js_sys_dict_data (dict_value);
|
||||
CREATE INDEX idx_sys_dict_type_is ON js_sys_dict_type (is_sys);
|
||||
CREATE INDEX idx_sys_dict_type_status ON js_sys_dict_type (status);
|
||||
CREATE INDEX idx_sys_employee_cco ON js_sys_employee (company_code);
|
||||
CREATE INDEX idx_sys_employee_cc ON js_sys_employee (corp_code);
|
||||
CREATE INDEX idx_sys_employee_ud ON js_sys_employee (update_date);
|
||||
CREATE INDEX idx_sys_employee_oc ON js_sys_employee (office_code);
|
||||
CREATE INDEX idx_sys_employee_status ON js_sys_employee (status);
|
||||
CREATE INDEX idx_sys_file_entity_md5 ON js_sys_file_entity (file_md5);
|
||||
CREATE INDEX idx_sys_file_entity_size ON js_sys_file_entity (file_size);
|
||||
CREATE INDEX idx_sys_file_biz_ft ON js_sys_file_upload (file_type);
|
||||
CREATE INDEX idx_sys_file_biz_fi ON js_sys_file_upload (file_id);
|
||||
CREATE INDEX idx_sys_file_biz_status ON js_sys_file_upload (status);
|
||||
CREATE INDEX idx_sys_file_biz_cb ON js_sys_file_upload (create_by);
|
||||
CREATE INDEX idx_sys_file_biz_ud ON js_sys_file_upload (update_date);
|
||||
CREATE INDEX idx_sys_file_biz_bt ON js_sys_file_upload (biz_type);
|
||||
CREATE INDEX idx_sys_file_biz_bk ON js_sys_file_upload (biz_key);
|
||||
CREATE INDEX idx_sys_job_status ON js_sys_job (status);
|
||||
CREATE INDEX idx_sys_job_log_jn ON js_sys_job_log (job_name);
|
||||
CREATE INDEX idx_sys_job_log_jg ON js_sys_job_log (job_group);
|
||||
CREATE INDEX idx_sys_job_log_t ON js_sys_job_log (job_type);
|
||||
CREATE INDEX idx_sys_job_log_e ON js_sys_job_log (job_event);
|
||||
CREATE INDEX idx_sys_job_log_ie ON js_sys_job_log (is_exception);
|
||||
CREATE INDEX idx_sys_lang_code ON js_sys_lang (lang_code);
|
||||
CREATE INDEX idx_sys_lang_type ON js_sys_lang (lang_type);
|
||||
CREATE INDEX idx_sys_log_cb ON js_sys_log (create_by);
|
||||
CREATE INDEX idx_sys_log_cc ON js_sys_log (corp_code);
|
||||
CREATE INDEX idx_sys_log_lt ON js_sys_log (log_type);
|
||||
CREATE INDEX idx_sys_log_bk ON js_sys_log (biz_key);
|
||||
CREATE INDEX idx_sys_log_bt ON js_sys_log (biz_type);
|
||||
CREATE INDEX idx_sys_log_ie ON js_sys_log (is_exception);
|
||||
CREATE INDEX idx_sys_log_cd ON js_sys_log (create_date);
|
||||
CREATE INDEX idx_sys_menu_pc ON js_sys_menu (parent_code);
|
||||
CREATE INDEX idx_sys_menu_ts ON js_sys_menu (tree_sort);
|
||||
CREATE INDEX idx_sys_menu_status ON js_sys_menu (status);
|
||||
CREATE INDEX idx_sys_menu_mt ON js_sys_menu (menu_type);
|
||||
CREATE INDEX idx_sys_menu_pss ON js_sys_menu (parent_codes);
|
||||
CREATE INDEX idx_sys_menu_tss ON js_sys_menu (tree_sorts);
|
||||
CREATE INDEX idx_sys_menu_sc ON js_sys_menu (sys_code);
|
||||
CREATE INDEX idx_sys_menu_is ON js_sys_menu (is_show);
|
||||
CREATE INDEX idx_sys_menu_mcs ON js_sys_menu (module_codes);
|
||||
CREATE INDEX idx_sys_menu_wt ON js_sys_menu (weight);
|
||||
CREATE INDEX idx_sys_module_status ON js_sys_module (status);
|
||||
CREATE INDEX idx_sys_msg_inner_cb ON js_sys_msg_inner (create_by);
|
||||
CREATE INDEX idx_sys_msg_inner_status ON js_sys_msg_inner (status);
|
||||
CREATE INDEX idx_sys_msg_inner_cl ON js_sys_msg_inner (content_level);
|
||||
CREATE INDEX idx_sys_msg_inner_sc ON js_sys_msg_inner (send_user_code);
|
||||
CREATE INDEX idx_sys_msg_inner_sd ON js_sys_msg_inner (send_date);
|
||||
CREATE INDEX idx_sys_msg_inner_r_mi ON js_sys_msg_inner_record (msg_inner_id);
|
||||
CREATE INDEX idx_sys_msg_inner_r_rc ON js_sys_msg_inner_record (receive_user_code);
|
||||
CREATE INDEX idx_sys_msg_inner_r_ruc ON js_sys_msg_inner_record (receive_user_code);
|
||||
CREATE INDEX idx_sys_msg_inner_r_status ON js_sys_msg_inner_record (read_status);
|
||||
CREATE INDEX idx_sys_msg_inner_r_star ON js_sys_msg_inner_record (is_star);
|
||||
CREATE INDEX idx_sys_msg_push_type ON js_sys_msg_push (msg_type);
|
||||
CREATE INDEX idx_sys_msg_push_rc ON js_sys_msg_push (receive_code);
|
||||
CREATE INDEX idx_sys_msg_push_uc ON js_sys_msg_push (receive_user_code);
|
||||
CREATE INDEX idx_sys_msg_push_suc ON js_sys_msg_push (send_user_code);
|
||||
CREATE INDEX idx_sys_msg_push_pd ON js_sys_msg_push (plan_push_date);
|
||||
CREATE INDEX idx_sys_msg_push_ps ON js_sys_msg_push (push_status);
|
||||
CREATE INDEX idx_sys_msg_push_rs ON js_sys_msg_push (read_status);
|
||||
CREATE INDEX idx_sys_msg_push_bk ON js_sys_msg_push (biz_key);
|
||||
CREATE INDEX idx_sys_msg_push_bt ON js_sys_msg_push (biz_type);
|
||||
CREATE INDEX idx_sys_msg_push_imp ON js_sys_msg_push (is_merge_push);
|
||||
CREATE INDEX idx_sys_msg_pushed_type ON js_sys_msg_pushed (msg_type);
|
||||
CREATE INDEX idx_sys_msg_pushed_rc ON js_sys_msg_pushed (receive_code);
|
||||
CREATE INDEX idx_sys_msg_pushed_uc ON js_sys_msg_pushed (receive_user_code);
|
||||
CREATE INDEX idx_sys_msg_pushed_suc ON js_sys_msg_pushed (send_user_code);
|
||||
CREATE INDEX idx_sys_msg_pushed_pd ON js_sys_msg_pushed (plan_push_date);
|
||||
CREATE INDEX idx_sys_msg_pushed_ps ON js_sys_msg_pushed (push_status);
|
||||
CREATE INDEX idx_sys_msg_pushed_rs ON js_sys_msg_pushed (read_status);
|
||||
CREATE INDEX idx_sys_msg_pushed_bk ON js_sys_msg_pushed (biz_key);
|
||||
CREATE INDEX idx_sys_msg_pushed_bt ON js_sys_msg_pushed (biz_type);
|
||||
CREATE INDEX idx_sys_msg_pushed_imp ON js_sys_msg_pushed (is_merge_push);
|
||||
CREATE INDEX idx_sys_msg_tpl_key ON js_sys_msg_template (tpl_key);
|
||||
CREATE INDEX idx_sys_msg_tpl_type ON js_sys_msg_template (tpl_type);
|
||||
CREATE INDEX idx_sys_msg_tpl_status ON js_sys_msg_template (status);
|
||||
CREATE INDEX idx_sys_office_cc ON js_sys_office (corp_code);
|
||||
CREATE INDEX idx_sys_office_pc ON js_sys_office (parent_code);
|
||||
CREATE INDEX idx_sys_office_pcs ON js_sys_office (parent_codes);
|
||||
CREATE INDEX idx_sys_office_status ON js_sys_office (status);
|
||||
CREATE INDEX idx_sys_office_ot ON js_sys_office (office_type);
|
||||
CREATE INDEX idx_sys_office_vc ON js_sys_office (view_code);
|
||||
CREATE INDEX idx_sys_office_ts ON js_sys_office (tree_sort);
|
||||
CREATE INDEX idx_sys_office_tss ON js_sys_office (tree_sorts);
|
||||
CREATE INDEX idx_sys_post_cc ON js_sys_post (corp_code);
|
||||
CREATE INDEX idx_sys_post_status ON js_sys_post (status);
|
||||
CREATE INDEX idx_sys_post_ps ON js_sys_post (post_sort);
|
||||
CREATE INDEX idx_sys_role_cc ON js_sys_role (corp_code);
|
||||
CREATE INDEX idx_sys_role_is ON js_sys_role (is_sys);
|
||||
CREATE INDEX idx_sys_role_status ON js_sys_role (status);
|
||||
CREATE INDEX idx_sys_role_rs ON js_sys_role (role_sort);
|
||||
CREATE INDEX idx_sys_user_lc ON js_sys_user (login_code);
|
||||
CREATE INDEX idx_sys_user_email ON js_sys_user (email);
|
||||
CREATE INDEX idx_sys_user_mobile ON js_sys_user (mobile);
|
||||
CREATE INDEX idx_sys_user_wo ON js_sys_user (wx_openid);
|
||||
CREATE INDEX idx_sys_user_imei ON js_sys_user (mobile_imei);
|
||||
CREATE INDEX idx_sys_user_rt ON js_sys_user (user_type);
|
||||
CREATE INDEX idx_sys_user_rc ON js_sys_user (ref_code);
|
||||
CREATE INDEX idx_sys_user_mt ON js_sys_user (mgr_type);
|
||||
CREATE INDEX idx_sys_user_us ON js_sys_user (user_weight);
|
||||
CREATE INDEX idx_sys_user_ud ON js_sys_user (update_date);
|
||||
CREATE INDEX idx_sys_user_status ON js_sys_user (status);
|
||||
CREATE INDEX idx_sys_user_cc ON js_sys_user (corp_code);
|
||||
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ CREATE TABLE [js_gen_table]
|
||||
[comments] nvarchar(500) NOT NULL,
|
||||
[parent_table_name] varchar(64),
|
||||
[parent_table_fk_name] varchar(64),
|
||||
[data_source_name] varchar(64),
|
||||
[tpl_category] varchar(200),
|
||||
[package_name] varchar(500),
|
||||
[module_name] varchar(30),
|
||||
@@ -175,7 +176,7 @@ CREATE TABLE [js_sys_config]
|
||||
[id] varchar(64) NOT NULL,
|
||||
[config_name] nvarchar(100) NOT NULL,
|
||||
[config_key] varchar(100) NOT NULL,
|
||||
[config_value] nvarchar(1000) NOT NULL,
|
||||
[config_value] nvarchar(1000),
|
||||
[is_sys] char(1) NOT NULL,
|
||||
[create_by] varchar(64) NOT NULL,
|
||||
[create_date] datetime NOT NULL,
|
||||
@@ -292,7 +293,7 @@ CREATE TABLE [js_sys_file_entity]
|
||||
[file_path] nvarchar(1000) NOT NULL,
|
||||
[file_content_type] varchar(200) NOT NULL,
|
||||
[file_extension] varchar(100) NOT NULL,
|
||||
[file_size] decimal(38) NOT NULL,
|
||||
[file_size] decimal(31) NOT NULL,
|
||||
PRIMARY KEY ([file_id])
|
||||
);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ CREATE TABLE js_gen_table
|
||||
comments varchar(500) NOT NULL COMMENT '表说明',
|
||||
parent_table_name varchar(64) COMMENT '关联父表的表名',
|
||||
parent_table_fk_name varchar(64) COMMENT '本表关联父表的外键名',
|
||||
data_source_name varchar(64) COMMENT '数据源名称',
|
||||
tpl_category varchar(200) COMMENT '使用的模板',
|
||||
package_name varchar(500) COMMENT '生成包路径',
|
||||
module_name varchar(30) COMMENT '生成模块名',
|
||||
@@ -176,7 +177,7 @@ CREATE TABLE js_sys_config
|
||||
id varchar(64) NOT NULL COMMENT '编号',
|
||||
config_name varchar(100) NOT NULL COMMENT '名称',
|
||||
config_key varchar(100) NOT NULL COMMENT '参数键',
|
||||
config_value varchar(1000) NOT NULL COMMENT '参数值',
|
||||
config_value varchar(1000) COMMENT '参数值',
|
||||
is_sys char(1) NOT NULL COMMENT '系统内置(1是 0否)',
|
||||
create_by varchar(64) NOT NULL COMMENT '创建者',
|
||||
create_date datetime NOT NULL COMMENT '创建时间',
|
||||
@@ -293,7 +294,7 @@ CREATE TABLE js_sys_file_entity
|
||||
file_path varchar(1000) NOT NULL COMMENT '文件相对路径',
|
||||
file_content_type varchar(200) NOT NULL COMMENT '文件内容类型',
|
||||
file_extension varchar(100) NOT NULL COMMENT '文件后缀扩展名',
|
||||
file_size decimal(38) NOT NULL COMMENT '文件大小(单位B)',
|
||||
file_size decimal(31) NOT NULL COMMENT '文件大小(单位B)',
|
||||
PRIMARY KEY (file_id),
|
||||
UNIQUE (file_md5)
|
||||
) COMMENT = '文件实体表';
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
-- 打开 my.ini 给 [mysqld] 增加如下配置:
|
||||
-- sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
|
||||
|
||||
set global read_only=0;
|
||||
|
||||
create user 'jeesite'@'%' identified by 'jeesite';
|
||||
|
||||
create database jeesite DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
|
||||
|
||||
grant all privileges on jeesite.* to 'jeesite'@'%' identified by 'jeesite';
|
||||
|
||||
flush privileges;
|
||||
@@ -46,6 +46,7 @@ CREATE TABLE js_gen_table
|
||||
comments nvarchar2(500) NOT NULL,
|
||||
parent_table_name varchar2(64),
|
||||
parent_table_fk_name varchar2(64),
|
||||
data_source_name varchar2(64),
|
||||
tpl_category varchar2(200),
|
||||
package_name varchar2(500),
|
||||
module_name varchar2(30),
|
||||
@@ -175,7 +176,7 @@ CREATE TABLE js_sys_config
|
||||
id varchar2(64) NOT NULL,
|
||||
config_name nvarchar2(100) NOT NULL,
|
||||
config_key varchar2(100) NOT NULL,
|
||||
config_value nvarchar2(1000) NOT NULL,
|
||||
config_value nvarchar2(1000),
|
||||
is_sys char(1) NOT NULL,
|
||||
create_by varchar2(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
@@ -292,7 +293,7 @@ CREATE TABLE js_sys_file_entity
|
||||
file_path nvarchar2(1000) NOT NULL,
|
||||
file_content_type varchar2(200) NOT NULL,
|
||||
file_extension varchar2(100) NOT NULL,
|
||||
file_size number(38) NOT NULL,
|
||||
file_size number(31) NOT NULL,
|
||||
PRIMARY KEY (file_id)
|
||||
);
|
||||
|
||||
@@ -924,6 +925,7 @@ COMMENT ON COLUMN js_gen_table.class_name IS '实体类名称';
|
||||
COMMENT ON COLUMN js_gen_table.comments IS '表说明';
|
||||
COMMENT ON COLUMN js_gen_table.parent_table_name IS '关联父表的表名';
|
||||
COMMENT ON COLUMN js_gen_table.parent_table_fk_name IS '本表关联父表的外键名';
|
||||
COMMENT ON COLUMN js_gen_table.data_source_name IS '数据源名称';
|
||||
COMMENT ON COLUMN js_gen_table.tpl_category IS '使用的模板';
|
||||
COMMENT ON COLUMN js_gen_table.package_name IS '生成包路径';
|
||||
COMMENT ON COLUMN js_gen_table.module_name IS '生成模块名';
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
create user jeesite
|
||||
identified by jeesite
|
||||
quota unlimited on users;
|
||||
|
||||
grant connect,resource,create session,select any table,
|
||||
create any view,create any table,create any index,
|
||||
drop any table,drop any view,drop any index
|
||||
to jeesite;
|
||||
|
||||
-- 多数据源分布式事务下,需要对目标用户进行如下授权,否则会提示错误:ResourceException: Error in recovery
|
||||
grant select on sys.dba_pending_transactions to jeesite;
|
||||
grant select on sys.pending_trans$ to jeesite;
|
||||
grant select on sys.dba_2pc_pending to jeesite;
|
||||
grant execute on sys.dbms_system to jeesite;
|
||||
@@ -46,6 +46,7 @@ CREATE TABLE js_gen_table
|
||||
comments varchar(500) NOT NULL,
|
||||
parent_table_name varchar(64),
|
||||
parent_table_fk_name varchar(64),
|
||||
data_source_name varchar(64),
|
||||
tpl_category varchar(200),
|
||||
package_name varchar(500),
|
||||
module_name varchar(30),
|
||||
@@ -175,7 +176,7 @@ CREATE TABLE js_sys_config
|
||||
id varchar(64) NOT NULL,
|
||||
config_name varchar(100) NOT NULL,
|
||||
config_key varchar(100) NOT NULL,
|
||||
config_value varchar(1000) NOT NULL,
|
||||
config_value varchar(1000),
|
||||
is_sys char(1) NOT NULL,
|
||||
create_by varchar(64) NOT NULL,
|
||||
create_date timestamp NOT NULL,
|
||||
@@ -292,7 +293,7 @@ CREATE TABLE js_sys_file_entity
|
||||
file_path varchar(1000) NOT NULL,
|
||||
file_content_type varchar(200) NOT NULL,
|
||||
file_extension varchar(100) NOT NULL,
|
||||
file_size decimal(38) NOT NULL,
|
||||
file_size decimal(31) NOT NULL,
|
||||
PRIMARY KEY (file_id)
|
||||
) WITHOUT OIDS;
|
||||
|
||||
@@ -924,6 +925,7 @@ COMMENT ON COLUMN js_gen_table.class_name IS '实体类名称';
|
||||
COMMENT ON COLUMN js_gen_table.comments IS '表说明';
|
||||
COMMENT ON COLUMN js_gen_table.parent_table_name IS '关联父表的表名';
|
||||
COMMENT ON COLUMN js_gen_table.parent_table_fk_name IS '本表关联父表的外键名';
|
||||
COMMENT ON COLUMN js_gen_table.data_source_name IS '数据源名称';
|
||||
COMMENT ON COLUMN js_gen_table.tpl_category IS '使用的模板';
|
||||
COMMENT ON COLUMN js_gen_table.package_name IS '生成包路径';
|
||||
COMMENT ON COLUMN js_gen_table.module_name IS '生成模块名';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.jeesite</groupId>
|
||||
<artifactId>jeesite-parent</artifactId>
|
||||
<version>4.0.5-SNAPSHOT</version>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<relativePath>../../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -23,12 +23,38 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- JDBC device begin -->
|
||||
<dependency>
|
||||
<groupId>com.oracle</groupId>
|
||||
<artifactId>ojdbc6</artifactId>
|
||||
<version>11.2.0.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sourceforge.jtds</groupId>
|
||||
<artifactId>jtds</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- JDBC device end -->
|
||||
|
||||
<!-- Common -->
|
||||
<dependency>
|
||||
<groupId>com.jeesite</groupId>
|
||||
<artifactId>jeesite-common</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Framework -->
|
||||
<dependency>
|
||||
<groupId>com.jeesite</groupId>
|
||||
<artifactId>jeesite-framework</artifactId>
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.jeesite.common.codec.DesUtils;
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
@@ -31,6 +32,7 @@ import com.jeesite.common.shiro.authc.FormToken;
|
||||
import com.jeesite.common.shiro.realm.BaseAuthorizingRealm;
|
||||
import com.jeesite.common.shiro.realm.LoginInfo;
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
|
||||
/**
|
||||
* 表单验证(包含验证码)过滤类
|
||||
@@ -93,7 +95,7 @@ public class FormAuthenticationFilter extends org.apache.shiro.web.filter.authc.
|
||||
}
|
||||
// 登录成功后,判断是否需要记住用户名
|
||||
if (WebUtils.isTrue(request, DEFAULT_REMEMBER_USERCODE_PARAM)) {
|
||||
rememberUserCodeCookie.setValue(username);
|
||||
rememberUserCodeCookie.setValue(EncodeUtils.xssFilter(username));
|
||||
rememberUserCodeCookie.saveTo((HttpServletRequest)request, (HttpServletResponse)response);
|
||||
} else {
|
||||
rememberUserCodeCookie.removeFrom((HttpServletRequest)request, (HttpServletResponse)response);
|
||||
@@ -157,6 +159,9 @@ public class FormAuthenticationFilter extends org.apache.shiro.web.filter.authc.
|
||||
return captcha;
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转登录页时,跳转到默认首页
|
||||
*/
|
||||
@Override
|
||||
protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
|
||||
PermissionsAuthorizationFilter.redirectToDefaultPath(request, response);
|
||||
@@ -208,6 +213,18 @@ public class FormAuthenticationFilter extends org.apache.shiro.web.filter.authc.
|
||||
boolean isLogin = WebUtils.isTrue(request, "__login");
|
||||
return super.isLoginSubmission(request, response) || isLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行登录方法
|
||||
*/
|
||||
@Override
|
||||
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
|
||||
// 是否在登录后生成新的Session(默认false)
|
||||
if (Global.getPropertyToBoolean("shiro.isGenerateNewSessionAfterLogin", "false")){
|
||||
UserUtils.getSubject().logout();
|
||||
}
|
||||
return super.executeLogin(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录成功调用事件
|
||||
|
||||
@@ -18,9 +18,6 @@ import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.shiro.realm.BaseAuthorizingRealm;
|
||||
import com.jeesite.common.shiro.realm.LoginInfo;
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
import com.jeesite.modules.sys.entity.Log;
|
||||
import com.jeesite.modules.sys.utils.LogUtils;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
|
||||
/**
|
||||
* 登出过滤器
|
||||
@@ -39,17 +36,19 @@ public class LogoutFilter extends org.apache.shiro.web.filter.authc.LogoutFilter
|
||||
String redirectUrl = getRedirectUrl(request, response, subject);
|
||||
//try/catch added for SHIRO-298:
|
||||
try {
|
||||
// 记录用户退出日志(@Deprecated v4.0.5支持setAuthorizingRealm,之后版本可删除此if子句)
|
||||
if (authorizingRealm == null){
|
||||
LogUtils.saveLog(UserUtils.getUser(), ServletUtils.getRequest(),
|
||||
"系统退出", Log.TYPE_LOGIN_LOGOUT);
|
||||
Object principal = subject.getPrincipal();
|
||||
if (principal != null){
|
||||
// // 记录用户退出日志(@Deprecated v4.0.5支持setAuthorizingRealm,之后版本可删除此if子句)
|
||||
// if (authorizingRealm == null){
|
||||
// LogUtils.saveLog(UserUtils.getUser(), ServletUtils.getRequest(),
|
||||
// "系统退出", Log.TYPE_LOGIN_LOGOUT);
|
||||
// }
|
||||
// else{
|
||||
// 退出成功之前初始化授权信息并处理登录后的操作
|
||||
authorizingRealm.onLogoutSuccess((LoginInfo)subject.getPrincipal(),
|
||||
(HttpServletRequest)request);
|
||||
// }
|
||||
}
|
||||
// 退出成功之前初始化授权信息并处理登录后的操作
|
||||
else{
|
||||
authorizingRealm.onLogoutSuccess((LoginInfo)subject.getPrincipal(),
|
||||
(HttpServletRequest)request);
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
subject.logout();
|
||||
} catch (SessionException ise) {
|
||||
|
||||
@@ -5,6 +5,10 @@ package com.jeesite.common.shiro.realm;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
|
||||
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.codec.Sha1Utils;
|
||||
import com.jeesite.common.utils.SpringUtils;
|
||||
import com.jeesite.modules.sys.entity.Log;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
@@ -18,11 +22,48 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
* @version 2018-7-11
|
||||
*/
|
||||
public class AuthorizingRealm extends BaseAuthorizingRealm {
|
||||
|
||||
|
||||
public static final String HASH_ALGORITHM = "SHA-1";
|
||||
public static final int HASH_INTERATIONS = 1024;
|
||||
public static final int SALT_SIZE = 8;
|
||||
|
||||
private UserService userService;
|
||||
|
||||
public AuthorizingRealm() {
|
||||
super();
|
||||
// 设定密码校验的Hash算法与迭代次数
|
||||
HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(HASH_ALGORITHM);
|
||||
matcher.setHashIterations(HASH_INTERATIONS);
|
||||
this.setCredentialsMatcher(matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成密文密码,生成随机的16位salt并经过1024次 sha-1 hash
|
||||
* @param plainPassword 明文密码
|
||||
* @return 16位salt密钥 + 40位hash密码
|
||||
*/
|
||||
public String encryptPassword(String plainPassword) {
|
||||
String plain = EncodeUtils.decodeHtml(plainPassword);
|
||||
byte[] salt = Sha1Utils.genSalt(SALT_SIZE);
|
||||
byte[] hashPassword = Sha1Utils.sha1(plain.getBytes(), salt, HASH_INTERATIONS);
|
||||
return EncodeUtils.encodeHex(salt) + EncodeUtils.encodeHex(hashPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证密码正确性
|
||||
* @param plainPassword 明文密码
|
||||
* @param password 密文密码
|
||||
* @return 验证成功返回true
|
||||
*/
|
||||
public boolean validatePassword(String plainPassword, String password) {
|
||||
try{
|
||||
String plain = EncodeUtils.decodeHtml(plainPassword);
|
||||
byte[] salt = EncodeUtils.decodeHex(password.substring(0, 16));
|
||||
byte[] hashPassword = Sha1Utils.sha1(plain.getBytes(), salt, HASH_INTERATIONS);
|
||||
return password.equals(EncodeUtils.encodeHex(salt) + EncodeUtils.encodeHex(hashPassword));
|
||||
}catch(Exception e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,7 +46,6 @@ public class CasAuthorizingRealm extends BaseAuthorizingRealm {
|
||||
private UserService userService;
|
||||
private EmpUserService empUserService;
|
||||
|
||||
///////////// CAS /////////////
|
||||
private CasOutHandler casOutHandler;
|
||||
private String casServerUrl; // CAS 服务器地址
|
||||
private String casServerCallbackUrl; // CAS 服务器回调地址
|
||||
@@ -56,10 +55,7 @@ public class CasAuthorizingRealm extends BaseAuthorizingRealm {
|
||||
super();
|
||||
this.setAuthenticationTokenClass(CasToken.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取登录令牌
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected FormToken getFormToken(AuthenticationToken authcToken) {
|
||||
|
||||
@@ -105,9 +101,6 @@ public class CasAuthorizingRealm extends BaseAuthorizingRealm {
|
||||
return token;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取用户信息
|
||||
*/
|
||||
@Override
|
||||
protected User getUserInfo(FormToken token) {
|
||||
|
||||
@@ -117,7 +110,7 @@ public class CasAuthorizingRealm extends BaseAuthorizingRealm {
|
||||
|
||||
// 如果允许客户端创建账号,则创建账号
|
||||
if (ObjectUtils.toBoolean(attrs.get("isAllowClientCreateUser"))){
|
||||
|
||||
|
||||
// 获取CAS传递过来的用户属性信息
|
||||
user = new User(EncodeUtils.decodeUrl(ObjectUtils.toString(attrs.get("userCode"))));
|
||||
user.setLoginCode(EncodeUtils.decodeUrl(ObjectUtils.toString(attrs.get("loginCode"))));
|
||||
@@ -178,9 +171,6 @@ public class CasAuthorizingRealm extends BaseAuthorizingRealm {
|
||||
return user;
|
||||
}
|
||||
|
||||
/*
|
||||
* 认证密码匹配调用方法
|
||||
*/
|
||||
@Override
|
||||
protected void assertCredentialsMatch(AuthenticationToken authcToken,
|
||||
AuthenticationInfo info) throws AuthenticationException {
|
||||
|
||||
@@ -5,6 +5,8 @@ package com.jeesite.common.utils.excel.fieldtype;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.modules.sys.entity.Area;
|
||||
import com.jeesite.modules.sys.utils.AreaUtils;
|
||||
@@ -12,12 +14,12 @@ import com.jeesite.modules.sys.utils.AreaUtils;
|
||||
/**
|
||||
* 字段类型转换
|
||||
* @author ThinkGem
|
||||
* @version 2013-03-10
|
||||
* @version 2018-08-11
|
||||
* @example fieldType = AreaType.class
|
||||
*/
|
||||
public class AreaType {
|
||||
|
||||
private static ThreadLocal<List<Area>> cache = new ThreadLocal<>();
|
||||
private static ThreadLocal<List<Area>> cache = new NamedThreadLocal<>("AreaType");
|
||||
|
||||
/**
|
||||
* 获取对象值(导入)
|
||||
@@ -45,4 +47,12 @@ public class AreaType {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public static void clearCache(){
|
||||
cache.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ package com.jeesite.common.utils.excel.fieldtype;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.modules.sys.entity.Company;
|
||||
import com.jeesite.modules.sys.utils.EmpUtils;
|
||||
@@ -12,12 +14,12 @@ import com.jeesite.modules.sys.utils.EmpUtils;
|
||||
/**
|
||||
* 字段类型转换
|
||||
* @author ThinkGem
|
||||
* @version 2015-03-24
|
||||
* @version 2018-08-11
|
||||
* @example fieldType = CompanyType.class
|
||||
*/
|
||||
public class CompanyType {
|
||||
|
||||
private static ThreadLocal<List<Company>> cache = new ThreadLocal<>();
|
||||
private static ThreadLocal<List<Company>> cache = new NamedThreadLocal<>("CompanyType");
|
||||
|
||||
/**
|
||||
* 获取对象值(导入)
|
||||
@@ -45,4 +47,11 @@ public class CompanyType {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public static void clearCache(){
|
||||
cache.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ package com.jeesite.common.utils.excel.fieldtype;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.modules.sys.utils.EmpUtils;
|
||||
@@ -12,12 +14,12 @@ import com.jeesite.modules.sys.utils.EmpUtils;
|
||||
/**
|
||||
* 字段类型转换
|
||||
* @author ThinkGem
|
||||
* @version 2013-03-10
|
||||
* @version 2018-08-11
|
||||
* @example fieldType = OfficeType.class
|
||||
*/
|
||||
public class OfficeType {
|
||||
|
||||
private static ThreadLocal<List<Office>> cache = new ThreadLocal<>();
|
||||
private static ThreadLocal<List<Office>> cache = new NamedThreadLocal<>("OfficeType");
|
||||
|
||||
/**
|
||||
* 获取对象值(导入)
|
||||
@@ -45,4 +47,11 @@ public class OfficeType {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public static void clearCache(){
|
||||
cache.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ package com.jeesite.common.utils.excel.fieldtype;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.core.NamedThreadLocal;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.utils.SpringUtils;
|
||||
@@ -14,13 +16,13 @@ import com.jeesite.modules.sys.service.PostService;
|
||||
/**
|
||||
* 字段类型转换
|
||||
* @author ThinkGem
|
||||
* @version 2015-03-24
|
||||
* @version 2018-08-11
|
||||
* @example fieldType = PostListType.class
|
||||
*/
|
||||
public class PostListType {
|
||||
|
||||
private static PostService postService = SpringUtils.getBean(PostService.class);
|
||||
private static ThreadLocal<List<Post>> cache = new ThreadLocal<>();
|
||||
private static ThreadLocal<List<Post>> cache = new NamedThreadLocal<>("PostListType");
|
||||
|
||||
/**
|
||||
* 获取对象值(导入)
|
||||
@@ -53,4 +55,11 @@ public class PostListType {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理缓存
|
||||
*/
|
||||
public static void clearCache(){
|
||||
cache.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,12 @@ import org.apache.shiro.realm.Realm;
|
||||
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
|
||||
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
|
||||
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
@@ -44,6 +47,20 @@ import com.jeesite.common.shiro.web.WebSecurityManager;
|
||||
@Configuration
|
||||
public class ShiroConfig {
|
||||
|
||||
/**
|
||||
* Apache Shiro Filter
|
||||
* @throws Exception
|
||||
*/
|
||||
@Bean
|
||||
@Order(3000)
|
||||
@ConditionalOnMissingBean(name="shiroFilterProxy")
|
||||
public FilterRegistrationBean<Filter> shiroFilterProxy(ShiroFilterFactoryBean shiroFilter) throws Exception {
|
||||
FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
|
||||
bean.setFilter((Filter) shiroFilter.getInstance());
|
||||
bean.addUrlPatterns("/*");
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* CAS登录过滤器
|
||||
*/
|
||||
@@ -101,7 +118,7 @@ public class ShiroConfig {
|
||||
ShiroFilterFactoryBean bean = new ShiroFilterFactoryBean();
|
||||
bean.setSecurityManager(securityManager);
|
||||
bean.setLoginUrl(Global.getProperty("shiro.loginUrl"));
|
||||
bean.setSuccessUrl(Global.getProperty("shiro.successUrl"));
|
||||
bean.setSuccessUrl(Global.getProperty("adminPath")+"/index");
|
||||
Map<String, Filter> filters = bean.getFilters();
|
||||
filters.put("cas", shiroCasFilter(casAuthorizingRealm));
|
||||
filters.put("authc", shiroAuthcFilter(authorizingRealm));
|
||||
|
||||
@@ -25,8 +25,8 @@ public class DruidStatConfig {
|
||||
* 注册DruidFilter拦截
|
||||
*/
|
||||
@Bean
|
||||
public FilterRegistrationBean duridFilter() {
|
||||
FilterRegistrationBean bean = new FilterRegistrationBean();
|
||||
public FilterRegistrationBean<WebStatFilter> duridFilter() {
|
||||
FilterRegistrationBean<WebStatFilter> bean = new FilterRegistrationBean<>();
|
||||
bean.setFilter(new WebStatFilter());
|
||||
bean.addInitParameter("exclusions", "*.css,*.js,*.png,"
|
||||
+ "*.jpg,*.gif,*.jpeg,*.bmp,*.ico,*.swf,*.psd,*.htc,*.htm,*.html,"
|
||||
@@ -40,8 +40,8 @@ public class DruidStatConfig {
|
||||
* 注册DruidServlet
|
||||
*/
|
||||
@Bean
|
||||
public ServletRegistrationBean druidServlet() {
|
||||
ServletRegistrationBean bean = new ServletRegistrationBean();
|
||||
public ServletRegistrationBean<StatViewServlet> druidServlet() {
|
||||
ServletRegistrationBean<StatViewServlet> bean = new ServletRegistrationBean<>();
|
||||
bean.setServlet(new StatViewServlet());
|
||||
bean.addUrlMappings("/druid/*");
|
||||
return bean;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.config.web;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 页面缓存,如果需要,则加入如下依赖并取消下面注释
|
||||
|
||||
1、pom.xml:
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache-web</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
|
||||
2、application.yml:
|
||||
# 页面缓存配置
|
||||
ehcache:
|
||||
pageCaching:
|
||||
enabled: false
|
||||
urlPatterns: "*.html"
|
||||
|
||||
* @author ThinkGem
|
||||
* @version 2017年11月30日
|
||||
*/
|
||||
@Configuration
|
||||
public class PageCacheConfig {
|
||||
|
||||
// /**
|
||||
// * PageCache Filter, cache .html suffix.
|
||||
// */
|
||||
// @Bean
|
||||
// @Order(2000)
|
||||
// @ConditionalOnProperty(name = "ehcache.pageCaching.enabled", havingValue = "true")
|
||||
// @ConditionalOnMissingBean(name="pageCachingFilter")
|
||||
// public FilterRegistrationBean<PageCachingFilter> pageCachingFilter(EhCacheManagerFactoryBean ehCacheManager) {
|
||||
// FilterRegistrationBean<PageCachingFilter> bean = new FilterRegistrationBean<>();
|
||||
// SimplePageCachingFilter pageCachingFilter = new SimplePageCachingFilter();
|
||||
// pageCachingFilter.setCacheManager(ehCacheManager.getObject());
|
||||
// bean.setFilter(pageCachingFilter);
|
||||
// bean.addInitParameter("cacheName", "pageCachingFilter");
|
||||
// bean.addUrlPatterns(StringUtils.split(Global.getProperty(
|
||||
// "ehcache.pageCaching.urlPatterns"), ","));
|
||||
// return bean;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
@@ -22,7 +22,7 @@ import com.jeesite.modules.sys.interceptor.LogInterceptor;
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ConditionalOnProperty(name="web.interceptor.log.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class LogInterceptorConfig extends WebMvcConfigurerAdapter {
|
||||
public class LogInterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
@@ -22,7 +22,7 @@ import com.jeesite.modules.sys.interceptor.MobileInterceptor;
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ConditionalOnProperty(name="web.interceptor.mobile.enabled", havingValue="true", matchIfMissing=false)
|
||||
public class MobileViewInterceptorConfig extends WebMvcConfigurerAdapter {
|
||||
public class MobileViewInterceptorConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
|
||||
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
package com.jeesite.modules.sys.entity;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
import com.jeesite.common.entity.TreeEntity;
|
||||
|
||||
@@ -9,7 +9,7 @@ import javax.validation.constraints.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.entity.BaseEntity;
|
||||
|
||||
@@ -61,7 +61,9 @@ import com.jeesite.common.utils.excel.fieldtype.OfficeType;
|
||||
@Column(name="area_name", label="区域名称", isQuery=false),
|
||||
@Column(name="area_type", label="区域类型"),
|
||||
}),
|
||||
}, extWhereKeys="dsfOffice, dsfCompany", orderBy="a.user_weight DESC, a.update_date DESC"
|
||||
},
|
||||
extWhereKeys="dsfOffice, dsfCompany",
|
||||
orderBy="a.user_weight DESC, a.update_date DESC"
|
||||
)
|
||||
public class EmpUser extends User {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.entity.BaseEntity;
|
||||
|
||||
@@ -6,7 +6,7 @@ package com.jeesite.modules.sys.entity;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.jeesite.common.entity.BaseEntity;
|
||||
@@ -47,7 +47,7 @@ public class Office extends TreeEntity<Office> {
|
||||
private String viewCode; // 机构代码(作为显示用,多租户内唯一)
|
||||
private String officeName; // 机构名称
|
||||
private String fullName; // 机构全称
|
||||
private String officeType; // 机构类型(1:公司;2:部门;3:小组)
|
||||
private String officeType; // 机构类型(1:省级公司;2:市级公司;3:部门)
|
||||
private String leader; // 负责人
|
||||
private String phone; // 电话
|
||||
private String address; // 联系地址
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
package com.jeesite.modules.sys.entity;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
import com.jeesite.common.entity.BaseEntity;
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
@@ -16,7 +16,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
@Column(includeEntity=BaseEntity.class),
|
||||
@Column(includeEntity=DataEntity.class),
|
||||
@Column(name="post_code", attrName="postCode", label="岗位编码", isPK=true),
|
||||
@Column(name="post_name", attrName="postName", label="岗位名称", queryType=QueryType.LIKE),
|
||||
@Column(name="post_name", attrName="postName", label="岗位名称"),
|
||||
@Column(name="post_type", attrName="postType", label="岗位分类", comment="岗位分类(高管、中层、基层)"),
|
||||
@Column(name="post_sort", attrName="postSort", label="岗位排序", comment="岗位排序(升序)"),
|
||||
}, orderBy="a.update_date DESC"
|
||||
@@ -57,6 +57,14 @@ public class Post extends DataEntity<Post> {
|
||||
this.postName = postName;
|
||||
}
|
||||
|
||||
public String getPostName_like() {
|
||||
return getSqlMap().getWhere().getValue("post_name", QueryType.LIKE);
|
||||
}
|
||||
|
||||
public void setPostName_like(String roleName) {
|
||||
getSqlMap().getWhere().and("post_name", QueryType.LIKE, roleName);
|
||||
}
|
||||
|
||||
@Length(min=0, max=100, message="岗位分类长度不能超过 100 个字符")
|
||||
public String getPostType() {
|
||||
return postType;
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.core.NamedThreadLocal;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.jeesite.common.lang.ByteUtils;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.lang.TimeUtils;
|
||||
import com.jeesite.common.service.BaseService;
|
||||
@@ -21,12 +22,12 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
/**
|
||||
* 日志拦截器
|
||||
* @author ThinkGem
|
||||
* @version 2014-8-19
|
||||
* @version 2018-08-11
|
||||
*/
|
||||
public class LogInterceptor extends BaseService implements HandlerInterceptor {
|
||||
|
||||
private static final ThreadLocal<Long> startTimeThreadLocal =
|
||||
new NamedThreadLocal<Long>("ThreadLocal StartTime");
|
||||
new NamedThreadLocal<Long>("LogInterceptor StartTime");
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
|
||||
@@ -61,10 +62,10 @@ public class LogInterceptor extends BaseService implements HandlerInterceptor {
|
||||
|
||||
// 打印JVM信息。
|
||||
if (logger.isDebugEnabled()){
|
||||
logger.debug("计时结束: {} 用时: {} URI: {} 最大内存: {}m 已分配内存: {}m 已分配内存中的剩余空间: {}m 最大可用内存: {}m",
|
||||
DateUtils.formatDate(endTime, "hh:mm:ss.SSS"), TimeUtils.formatDateAgo(executeTime),
|
||||
request.getRequestURI(), Runtime.getRuntime().maxMemory()/1024/1024, Runtime.getRuntime().totalMemory()/1024/1024, Runtime.getRuntime().freeMemory()/1024/1024,
|
||||
(Runtime.getRuntime().maxMemory()-Runtime.getRuntime().totalMemory()+Runtime.getRuntime().freeMemory())/1024/1024);
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
logger.debug("计时结束: {} 用时: {} URI: {} 总内存: {} 已用内存: {}",
|
||||
DateUtils.formatDate(endTime, "hh:mm:ss.SSS"), TimeUtils.formatDateAgo(executeTime), request.getRequestURI(),
|
||||
ByteUtils.formatByteSize(runtime.totalMemory()), ByteUtils.formatByteSize(runtime.totalMemory()-runtime.freeMemory()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class EmpUserService extends CrudService<EmpUserDao, EmpUser> {
|
||||
* 分页查询数据
|
||||
*/
|
||||
@Override
|
||||
public Page<EmpUser> findPage(Page<EmpUser> page, EmpUser empUser) {
|
||||
return super.findPage(page, empUser);
|
||||
public Page<EmpUser> findPage(EmpUser empUser) {
|
||||
return super.findPage(empUser);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +116,7 @@ public class EmpUserService extends CrudService<EmpUserDao, EmpUser> {
|
||||
int successNum = 0; int failureNum = 0;
|
||||
StringBuilder successMsg = new StringBuilder();
|
||||
StringBuilder failureMsg = new StringBuilder();
|
||||
try {
|
||||
ExcelImport ei = new ExcelImport(file, 2, 0);
|
||||
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||
List<EmpUser> list = ei.getDataList(EmpUser.class);
|
||||
for (EmpUser user : list) {
|
||||
try{
|
||||
|
||||
@@ -41,8 +41,8 @@ public class EmployeeService extends CrudService<EmployeeDao, Employee> {
|
||||
* 查询分页数据
|
||||
*/
|
||||
@Override
|
||||
public Page<Employee> findPage(Page<Employee> page, Employee employee) {
|
||||
return super.findPage(page, employee);
|
||||
public Page<Employee> findPage(Employee employee) {
|
||||
return super.findPage(employee);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
*/
|
||||
package com.jeesite.modules.sys.service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.sys.dao.LogDao;
|
||||
import com.jeesite.modules.sys.entity.Log;
|
||||
@@ -28,22 +25,19 @@ public class LogService extends CrudService<LogDao, Log> {
|
||||
* 查询日志记录
|
||||
*/
|
||||
@Override
|
||||
public Page<Log> findPage(Page<Log> page, Log log) {
|
||||
|
||||
// 设置默认时间范围,默认当前月
|
||||
if (log.getCreateDate_gte() == null){
|
||||
log.setCreateDate_gte(DateUtils.setDays(new Date(), 1));
|
||||
}
|
||||
if (log.getCreateDate_lte() == null){
|
||||
log.setCreateDate_lte(DateUtils.addDays(DateUtils.addMonths(log.getCreateDate_gte(), 1), -1));
|
||||
}
|
||||
|
||||
public Page<Log> findPage(Log log) {
|
||||
// // 设置默认时间范围,默认当前月
|
||||
// if (log.getCreateDate_gte() == null){
|
||||
// log.setCreateDate_gte(DateUtils.setDays(new Date(), 1));
|
||||
// }
|
||||
// if (log.getCreateDate_lte() == null){
|
||||
// log.setCreateDate_lte(DateUtils.addDays(DateUtils.addMonths(log.getCreateDate_gte(), 1), -1));
|
||||
// }
|
||||
// 普通用户看自己的,管理员看全部的。
|
||||
if (!log.getCurrentUser().isAdmin()){
|
||||
log.setCreateBy(log.getCurrentUser().getUserCode());
|
||||
}
|
||||
|
||||
return super.findPage(page, log);
|
||||
return super.findPage(log);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ public class PostService extends CrudService<PostDao, Post> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询可分页的岗位列表
|
||||
* 查询岗位
|
||||
*/
|
||||
@Override
|
||||
public Page<Post> findPage(Page<Post> page, Post post) {
|
||||
return super.findPage(page, post);
|
||||
public Page<Post> findPage(Post post) {
|
||||
return super.findPage(post);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
///**
|
||||
// * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
// */
|
||||
//package com.jeesite.modules.sys.service.impl;
|
||||
//
|
||||
//import javax.servlet.http.HttpServletRequest;
|
||||
//import javax.servlet.http.HttpServletResponse;
|
||||
//
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import com.jeesite.modules.file.entity.FileEntity;
|
||||
//import com.jeesite.modules.file.entity.FileUpload;
|
||||
//import com.jeesite.modules.file.service.FileUploadServiceExtendSupport;
|
||||
//
|
||||
///**
|
||||
// * 文件上传扩展实现类
|
||||
// * @author ThinkGem
|
||||
// * @version 2018年10月13日
|
||||
// */
|
||||
//@Service
|
||||
//public class FileUploadServiceExtendImpl extends FileUploadServiceExtendSupport {
|
||||
//
|
||||
// @Override
|
||||
// public boolean fileExists(FileEntity fileEntity) {
|
||||
// System.out.println("============= fileupload fileExists ");
|
||||
// return super.fileExists(fileEntity);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void uploadFile(FileEntity fileEntity) {
|
||||
// System.out.println("============= fileupload uploadFile ");
|
||||
// super.uploadFile(fileEntity);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void saveUploadFile(FileUpload fileUpload) {
|
||||
// System.out.println("============= fileupload saveUploadFile ");
|
||||
// super.saveUploadFile(fileUpload);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getFileUrl(FileUpload fileUpload) {
|
||||
// System.out.println("============= fileupload getFileUrl ");
|
||||
// return super.getFileUrl(fileUpload);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String downFile(FileUpload fileUpload, HttpServletRequest request, HttpServletResponse response) {
|
||||
// System.out.println("============= fileupload downFile ");
|
||||
// return super.downFile(fileUpload, request, response);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,49 @@
|
||||
///**
|
||||
// * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
// */
|
||||
//package com.jeesite.modules.sys.service.impl;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import com.jeesite.modules.sys.entity.Menu;
|
||||
//import com.jeesite.modules.sys.service.MenuServiceSupport;
|
||||
//
|
||||
///**
|
||||
// * 菜单服务扩展实现类
|
||||
// * @author ThinkGem
|
||||
// * @version 2018年10月13日
|
||||
// */
|
||||
//@Service
|
||||
//public class MenuServiceExtendImpl extends MenuServiceSupport {
|
||||
//
|
||||
// public MenuServiceExtendImpl() {
|
||||
// this.entityClass = Menu.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Menu get(Menu menu) {
|
||||
// System.out.println("============= menu get ");
|
||||
// return super.get(menu);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Menu> findList(Menu menu) {
|
||||
// System.out.println("============= menu findList ");
|
||||
// return super.findList(menu);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Menu> findByRoleCode(Menu menu) {
|
||||
// System.out.println("============= menu findByRoleCode ");
|
||||
// return super.findByRoleCode(menu);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Menu> findByUserCode(Menu menu) {
|
||||
// System.out.println("============= menu findByUserCode ");
|
||||
// return super.findByUserCode(menu);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,43 @@
|
||||
///**
|
||||
// * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
// */
|
||||
//package com.jeesite.modules.sys.service.impl;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import com.jeesite.modules.sys.entity.Role;
|
||||
//import com.jeesite.modules.sys.service.RoleServiceSupport;
|
||||
//
|
||||
///**
|
||||
// * 角色服务扩展实现类
|
||||
// * @author ThinkGem
|
||||
// * @version 2018年10月13日
|
||||
// */
|
||||
//@Service
|
||||
//public class RoleServiceExtendImpl extends RoleServiceSupport {
|
||||
//
|
||||
// public RoleServiceExtendImpl() {
|
||||
// this.entityClass = Role.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public Role get(Role role) {
|
||||
// System.out.println("============= role get ");
|
||||
// return super.get(role);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Role> findList(Role role) {
|
||||
// System.out.println("============= role findList ");
|
||||
// return super.findList(role);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<Role> findListByUserCode(Role role) {
|
||||
// System.out.println("============= role findListByUserCode ");
|
||||
// return super.findListByUserCode(role);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,49 @@
|
||||
///**
|
||||
// * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
// */
|
||||
//package com.jeesite.modules.sys.service.impl;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
//import com.jeesite.modules.sys.entity.User;
|
||||
//import com.jeesite.modules.sys.service.UserServiceSupport;
|
||||
//
|
||||
///**
|
||||
// * 用户服务扩展实现类
|
||||
// * @author ThinkGem
|
||||
// * @version 2018年10月13日
|
||||
// */
|
||||
//@Service
|
||||
//public class UserServiceExtendImpl extends UserServiceSupport {
|
||||
//
|
||||
// public UserServiceExtendImpl() {
|
||||
// this.entityClass = User.class;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public User get(User user) {
|
||||
// System.out.println("============= user get ");
|
||||
// return super.get(user);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public User getByLoginCode(User user) {
|
||||
// System.out.println("============= user getByLoginCode ");
|
||||
// return super.getByLoginCode(user);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public User getByUserTypeAndRefCode(User user) {
|
||||
// System.out.println("============= user getByUserTypeAndRefCode ");
|
||||
// return super.getByUserTypeAndRefCode(user);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<User> findList(User user) {
|
||||
// System.out.println("============= user findList ");
|
||||
// return super.findList(user);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -34,6 +35,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/area")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class AreaController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -27,7 +28,6 @@ import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.sys.entity.Company;
|
||||
import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.modules.sys.entity.UserDataScope;
|
||||
import com.jeesite.modules.sys.service.CompanyService;
|
||||
import com.jeesite.modules.sys.service.OfficeService;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
@@ -39,6 +39,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/company")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class CompanyController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -72,7 +73,7 @@ public class CompanyController extends BaseController {
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public List<Company> listData(Company company) {
|
||||
public List<Company> listData(Company company, String ctrlPermi) {
|
||||
if (StringUtils.isBlank(company.getParentCode())) {
|
||||
company.setParentCode(Company.ROOT_CODE);
|
||||
}
|
||||
@@ -81,7 +82,7 @@ public class CompanyController extends BaseController {
|
||||
|| StringUtils.isNotBlank(company.getFullName())){
|
||||
company.setParentCode(null);
|
||||
}
|
||||
companyService.addDataScopeFilter(company, UserDataScope.CTRL_PERMI_MANAGE);
|
||||
companyService.addDataScopeFilter(company, ctrlPermi);
|
||||
List<Company> list = companyService.findList(company);
|
||||
return list;
|
||||
}
|
||||
@@ -209,8 +210,7 @@ public class CompanyController extends BaseController {
|
||||
Company where = new Company();
|
||||
where.setStatus(Company.STATUS_NORMAL);
|
||||
if (!(isAll != null && isAll)){
|
||||
companyService.addDataScopeFilter(where, StringUtils.defaultIfBlank(
|
||||
ctrlPermi, UserDataScope.CTRL_PERMI_HAVE));
|
||||
companyService.addDataScopeFilter(where, ctrlPermi);
|
||||
}
|
||||
List<Company> list = companyService.findList(where);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
*/
|
||||
package com.jeesite.modules.sys.web;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
@@ -17,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.sys.entity.Log;
|
||||
import com.jeesite.modules.sys.service.LogService;
|
||||
@@ -29,6 +27,7 @@ import com.jeesite.modules.sys.service.LogService;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/log")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class LogController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -48,13 +47,13 @@ public class LogController extends BaseController {
|
||||
@RequiresPermissions("sys:log:view")
|
||||
@RequestMapping(value = "list")
|
||||
public String list(Log log, Model model) {
|
||||
// 设置默认时间范围,默认当前月
|
||||
if (log.getCreateDate_gte() == null){
|
||||
log.setCreateDate_gte(DateUtils.setDays(new Date(), 1));
|
||||
}
|
||||
if (log.getCreateDate_lte() == null){
|
||||
log.setCreateDate_lte(DateUtils.addDays(DateUtils.addMonths(log.getCreateDate_gte(), 1), -1));
|
||||
}
|
||||
// // 设置默认时间范围,默认当前月
|
||||
// if (log.getCreateDate_gte() == null){
|
||||
// log.setCreateDate_gte(DateUtils.setDays(new Date(), 1));
|
||||
// }
|
||||
// if (log.getCreateDate_lte() == null){
|
||||
// log.setCreateDate_lte(DateUtils.addDays(DateUtils.addMonths(log.getCreateDate_gte(), 1), -1));
|
||||
// }
|
||||
model.addAttribute("log", log);
|
||||
return "modules/sys/logList";
|
||||
}
|
||||
@@ -66,7 +65,8 @@ public class LogController extends BaseController {
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public Page<Log> listData(Log log, HttpServletRequest request, HttpServletResponse response) {
|
||||
Page<Log> page = logService.findPage(new Page<Log>(request, response), log);
|
||||
log.setPage(new Page<>(request, response));
|
||||
Page<Log> page = logService.findPage(log);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.shiro.filter.FormAuthenticationFilter;
|
||||
import com.jeesite.common.shiro.realm.BaseAuthorizingRealm;
|
||||
@@ -34,7 +33,7 @@ import com.jeesite.common.web.CookieUtils;
|
||||
import com.jeesite.common.web.http.ServletUtils;
|
||||
import com.jeesite.modules.sys.entity.Menu;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.UserService;
|
||||
import com.jeesite.modules.sys.utils.PwdUtils;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
|
||||
/**
|
||||
@@ -55,7 +54,8 @@ public class LoginController extends BaseController{
|
||||
if (StringUtils.containsIgnoreCase(request.getRequestURI(), ";JSESSIONID=")){
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
return REDIRECT + adminPath + "/login" + queryString;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/login" + queryString);
|
||||
return null;
|
||||
}
|
||||
|
||||
LoginInfo loginInfo = UserUtils.getLoginInfo();
|
||||
@@ -64,16 +64,8 @@ public class LoginController extends BaseController{
|
||||
if(loginInfo != null){
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
String indexUrl = adminPath + "/index" + queryString;
|
||||
if (ServletUtils.isAjaxRequest(request)){
|
||||
try {
|
||||
request.getRequestDispatcher(indexUrl).forward(request, response); // AJAX不支持Redirect改用Forward
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return REDIRECT + indexUrl;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/index" + queryString);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果是登录操作,跳转到此,则认为是登录失败(支持GET登录时传递__login=true参数)
|
||||
@@ -87,7 +79,7 @@ public class LoginController extends BaseController{
|
||||
}
|
||||
|
||||
// 是否显示验证码
|
||||
model.addAttribute("isValidCodeLogin", ObjectUtils.toInteger(Global.getConfig("sys.login.failedNumAfterValidCode", "200")) == 0);
|
||||
model.addAttribute("isValidCodeLogin", Global.getConfigToInteger("sys.login.failedNumAfterValidCode", "200") == 0);
|
||||
|
||||
//获取当前会话对象
|
||||
Session session = UserUtils.getSession();
|
||||
@@ -131,16 +123,8 @@ public class LoginController extends BaseController{
|
||||
if(loginInfo != null){
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
String indexUrl = adminPath + "/index" + queryString;
|
||||
if (ServletUtils.isAjaxRequest(request)){
|
||||
try {
|
||||
request.getRequestDispatcher(indexUrl).forward(request, response); // AJAX不支持Redirect改用Forward
|
||||
} catch (Exception ex) {
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return REDIRECT + indexUrl;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/index" + queryString);
|
||||
return null;
|
||||
}
|
||||
|
||||
String username = WebUtils.getCleanParam(request, FormAuthenticationFilter.DEFAULT_USERNAME_PARAM);
|
||||
@@ -203,12 +187,16 @@ public class LoginController extends BaseController{
|
||||
if (StringUtils.containsIgnoreCase(request.getRequestURI(), ";JSESSIONID=")){
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
return REDIRECT + adminPath + "/index" + queryString;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/index" + queryString);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 验证下用户权限,以便调用doGetAuthorizationInfo方法,保存单点登录登出句柄
|
||||
if (!SecurityUtils.getSubject().isPermitted("user")){
|
||||
return REDIRECT + adminPath + "/login";
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/login" + queryString);
|
||||
return null;
|
||||
}
|
||||
|
||||
//获取登录用户信息
|
||||
@@ -217,46 +205,68 @@ public class LoginController extends BaseController{
|
||||
// 未加载shiro模块时会为空,直接访问则提示操作权限不足。
|
||||
if(loginInfo == null){
|
||||
UserUtils.getSubject().logout();
|
||||
return REDIRECT + adminPath + "/login";
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/login" + queryString);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 当前用户对象信息
|
||||
User user = UserUtils.get(loginInfo.getId());
|
||||
if (user == null){
|
||||
UserUtils.getSubject().logout();
|
||||
return REDIRECT + adminPath + "/login";
|
||||
String queryString = request.getQueryString();
|
||||
queryString = queryString == null ? "" : "?" + queryString;
|
||||
ServletUtils.redirectUrl(request, response, adminPath + "/login" + queryString);
|
||||
return null;
|
||||
}
|
||||
model.addAttribute("user", user); // 设置当前用户信息
|
||||
|
||||
//获取当前会话对象
|
||||
Session session = UserUtils.getSession();
|
||||
|
||||
// 设置共享SessionId的Cookie值(第三方系统使用)
|
||||
String cookieName = Global.getProperty("session.shareSessionIdCookieName");
|
||||
if (StringUtils.isNotBlank(cookieName)){
|
||||
CookieUtils.setCookie((HttpServletResponse)response, cookieName, (String)session.getId());
|
||||
}
|
||||
|
||||
// 如果是登录操作,则设置登录信息(移动端用)
|
||||
model.addAttribute("result", Global.TRUE);
|
||||
if (request.getParameter("username") != null && request.getParameter("password") != null){
|
||||
// 是否是登录操作
|
||||
boolean isLogin = "true".equals(session.getAttribute("__login"));
|
||||
if (isLogin){
|
||||
// 获取后接着清除,防止下次获取仍然认为是登录状态
|
||||
session.removeAttribute("__login");
|
||||
// 设置共享SessionId的Cookie值(第三方系统使用)
|
||||
String cookieName = Global.getProperty("session.shareSessionIdCookieName");
|
||||
if (StringUtils.isNotBlank(cookieName)){
|
||||
CookieUtils.setCookie((HttpServletResponse)response, cookieName, (String)session.getId());
|
||||
}
|
||||
// 如果登录设置了语言,则切换语言
|
||||
if (loginInfo.getParam("lang") != null){
|
||||
Global.setLang(loginInfo.getParam("lang"), request, response);
|
||||
}
|
||||
model.addAttribute("message", text("sys.login.success"));
|
||||
}else{
|
||||
model.addAttribute("message", text("sys.login.getInfo"));
|
||||
}
|
||||
model.addAttribute("sessionid", (String)session.getId());
|
||||
|
||||
// 获取登录成功页面
|
||||
String successUrl = Global.getProperty("shiro.successUrl");
|
||||
if (!StringUtils.contains(successUrl, "://")){
|
||||
successUrl = request.getContextPath() + successUrl;
|
||||
}
|
||||
|
||||
// 登录操作如果是Ajax操作,直接返回登录信息字符串。
|
||||
if (ServletUtils.isAjaxRequest(request)){
|
||||
model.addAttribute("result", Global.TRUE);
|
||||
// 如果是登录,则返回登录成功信息,否则返回获取成功信息
|
||||
if (isLogin){
|
||||
model.addAttribute("message", text("sys.login.success"));
|
||||
}else{
|
||||
model.addAttribute("message", text("sys.login.getInfo"));
|
||||
}
|
||||
model.addAttribute("sessionid", (String)session.getId());
|
||||
model.addAttribute("__url", successUrl); // 告诉浏览器登录后跳转的页面
|
||||
return ServletUtils.renderObject(response, model);
|
||||
}
|
||||
// 如果是登录操作,则跳转到登录成功页
|
||||
else if (isLogin){
|
||||
return REDIRECT + successUrl;
|
||||
}
|
||||
|
||||
// 是否允许刷新主页,如果已登录,再次访问主页,则退出原账号。
|
||||
if (!ObjectUtils.toBoolean(Global.getConfig("shiro.isAllowRefreshIndex", "true"))){
|
||||
if (!Global.getConfigToBoolean("shiro.isAllowRefreshIndex", "true")){
|
||||
String logined = CookieUtils.getCookie(request, "LOGINED");
|
||||
if (StringUtils.isBlank(logined) || "false".equals(logined)){
|
||||
CookieUtils.setCookie(response, "LOGINED", "true");
|
||||
@@ -270,7 +280,7 @@ public class LoginController extends BaseController{
|
||||
}
|
||||
|
||||
// 初始密码策略和密码修改策略验证(0:关闭;1:提醒用户;2:强制修改初始或旧密码)
|
||||
String passwordModifyUrl = UserService.passwordModifyValid(user, model);
|
||||
String passwordModifyUrl = PwdUtils.passwordModifyValid(user, model);
|
||||
if (passwordModifyUrl != null){
|
||||
try {
|
||||
request.getRequestDispatcher(passwordModifyUrl).forward(request, response);
|
||||
@@ -324,8 +334,8 @@ public class LoginController extends BaseController{
|
||||
if (user.isSuperAdmin() && StringUtils.isNotBlank(sysCode)){
|
||||
if (!StringUtils.equals(principal.getParam("sysCode"), sysCode)){
|
||||
principal.setParam("sysCode", sysCode);
|
||||
UserUtils.removeCacheByKeyPrefix(UserUtils.CACHE_MENU_LIST);
|
||||
UserUtils.removeCache(UserUtils.CACHE_AUTH_INFO);
|
||||
UserUtils.removeCache(UserUtils.CACHE_MENU_LIST);
|
||||
}
|
||||
}
|
||||
return REDIRECT + adminPath + "/index";
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -23,7 +24,6 @@ import com.jeesite.common.idgen.IdGen;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.modules.sys.entity.UserDataScope;
|
||||
import com.jeesite.modules.sys.service.OfficeService;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
import com.jeesite.modules.sys.web.user.EmpUserController;
|
||||
@@ -35,6 +35,7 @@ import com.jeesite.modules.sys.web.user.EmpUserController;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/office")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class OfficeController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -69,7 +70,7 @@ public class OfficeController extends BaseController {
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public List<Office> listData(Office office) {
|
||||
public List<Office> listData(Office office, String ctrlPermi) {
|
||||
if (StringUtils.isBlank(office.getParentCode())){
|
||||
office.setParentCode(Office.ROOT_CODE);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ public class OfficeController extends BaseController {
|
||||
|| StringUtils.isNotBlank(office.getFullName())){
|
||||
office.setParentCode(null);
|
||||
}
|
||||
officeService.addDataScopeFilter(office, UserDataScope.CTRL_PERMI_MANAGE);
|
||||
officeService.addDataScopeFilter(office, ctrlPermi);
|
||||
List<Office> list = officeService.findList(office);
|
||||
return list;
|
||||
}
|
||||
@@ -202,7 +203,7 @@ public class OfficeController extends BaseController {
|
||||
* @param excludeCode 排除的ID
|
||||
* @param parentCode 上级Code
|
||||
* @param isAll 是否显示所有机构(true:不进行权限过滤)
|
||||
* @param officeTypes 机构类型(1:公司, 2:部门, 3:小组, 4:其它)
|
||||
* @param officeTypes 机构类型(1:省级公司;2:市级公司;3:部门)
|
||||
* @param companyCode 仅查询公司下的机构
|
||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
||||
* @param isShowFullName 是否显示全机构名称
|
||||
@@ -222,8 +223,7 @@ public class OfficeController extends BaseController {
|
||||
where.setStatus(Office.STATUS_NORMAL);
|
||||
where.setCompanyCode(companyCode);
|
||||
if (!(isAll != null && isAll)){
|
||||
officeService.addDataScopeFilter(where, StringUtils.defaultIfBlank(
|
||||
ctrlPermi, UserDataScope.CTRL_PERMI_HAVE));
|
||||
officeService.addDataScopeFilter(where, ctrlPermi);
|
||||
}
|
||||
List<Office> list = officeService.findList(where);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
@@ -270,7 +270,7 @@ public class OfficeController extends BaseController {
|
||||
map.put("isParent", true);
|
||||
List<Map<String, Object>> userList;
|
||||
userList = empUserController.treeData("u_", e.getOfficeCode(), e.getOfficeCode(),
|
||||
companyCode, postCode, roleCode, isAll, isShowCode);
|
||||
companyCode, postCode, roleCode, isAll, isShowCode, ctrlPermi);
|
||||
mapList.addAll(userList);
|
||||
}
|
||||
mapList.add(map);
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.apache.shiro.session.Session;
|
||||
import org.apache.shiro.subject.PrincipalCollection;
|
||||
import org.apache.shiro.subject.support.DefaultSubjectContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.beust.jcommander.internal.Maps;
|
||||
import com.jeesite.common.cache.CacheUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.lang.ObjectUtils;
|
||||
@@ -41,6 +44,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/online")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class OnlineController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
@@ -102,13 +106,15 @@ public class OnlineController extends BaseController{
|
||||
map.put("startTimestamp", DateUtils.formatDateTime(session.getStartTimestamp()));
|
||||
map.put("lastAccessTime", DateUtils.formatDateTime(session.getLastAccessTime()));
|
||||
map.put("timeout", TimeUtils.formatDateAgo(session.getTimeout()-(currentTime-session.getLastAccessTime().getTime())));
|
||||
PrincipalCollection pc = (PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
LoginInfo principal = (pc != null ? (LoginInfo)pc.getPrimaryPrincipal() : null);
|
||||
if (principal != null){
|
||||
map.put("userCode", session.getAttribute("userCode"));// principal.getId());
|
||||
map.put("userName", session.getAttribute("userName"));// principal.getName());
|
||||
map.put("userType", session.getAttribute("userType"));// ObjectUtils.toString(principal.getParam("userType")));
|
||||
map.put("deviceType", ObjectUtils.toString(principal.getParam("deviceType")));
|
||||
Object pc = session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
if (pc != null && pc instanceof PrincipalCollection){
|
||||
LoginInfo loginInfo = (LoginInfo)((PrincipalCollection)pc).getPrimaryPrincipal();
|
||||
if (loginInfo != null){
|
||||
map.put("userCode", session.getAttribute("userCode"));// principal.getId());
|
||||
map.put("userName", session.getAttribute("userName"));// principal.getName());
|
||||
map.put("userType", session.getAttribute("userType"));// ObjectUtils.toString(principal.getParam("userType")));
|
||||
map.put("deviceType", ObjectUtils.toString(loginInfo.getParam("deviceType")));
|
||||
}
|
||||
}
|
||||
map.put("host", session.getHost());
|
||||
list.add(map);
|
||||
@@ -143,6 +149,17 @@ public class OnlineController extends BaseController{
|
||||
public String tickOut(String sessionId) {
|
||||
Session session = sessionDAO.readSession(sessionId);
|
||||
if (session != null){
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> onlineTickOutMap = (Map<String, String>)CacheUtils.get("onlineTickOutMap");
|
||||
if (onlineTickOutMap == null){
|
||||
onlineTickOutMap = MapUtils.newConcurrentMap();
|
||||
}
|
||||
PrincipalCollection pc = (PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY);
|
||||
LoginInfo principal = (pc != null ? (LoginInfo)pc.getPrimaryPrincipal() : null);
|
||||
if (principal != null){
|
||||
onlineTickOutMap.put(principal.getId()+"_"+principal.getParam("deviceType", "PC"), StringUtils.EMPTY);
|
||||
}
|
||||
CacheUtils.put("onlineTickOutMap", onlineTickOutMap);
|
||||
sessionDAO.delete(session);
|
||||
return renderResult(Global.TRUE, "踢出已成功!");
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -29,6 +30,7 @@ import com.jeesite.modules.sys.service.PostService;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/post")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class PostController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -49,7 +51,8 @@ public class PostController extends BaseController {
|
||||
@RequestMapping(value = {"listData"})
|
||||
@ResponseBody
|
||||
public Page<Post> listData(Post post, HttpServletRequest request, HttpServletResponse response) {
|
||||
Page<Post> page = postService.findPage(new Page<Post>(request, response), post);
|
||||
post.setPage(new Page<>(request, response));
|
||||
Page<Post> page = postService.findPage(post);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -24,6 +25,7 @@ import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.UserService;
|
||||
import com.jeesite.modules.sys.utils.PwdUtils;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
import com.jeesite.modules.sys.utils.ValidCodeUtils;
|
||||
|
||||
@@ -34,6 +36,7 @@ import com.jeesite.modules.sys.utils.ValidCodeUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "/account")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class AccountController extends BaseController{
|
||||
|
||||
@Autowired
|
||||
@@ -199,9 +202,9 @@ public class AccountController extends BaseController{
|
||||
// 验证三个密保问题是否正确。
|
||||
User u = UserUtils.getByLoginCode(user.getLoginCode());
|
||||
if (!(u != null && loginCode.equals(user.getLoginCode())
|
||||
&& UserService.validatePassword(user.getPwdQuestionAnswer(), u.getPwdQuestionAnswer())
|
||||
&& UserService.validatePassword(user.getPwdQuestionAnswer2(), u.getPwdQuestionAnswer2())
|
||||
&& UserService.validatePassword(user.getPwdQuestionAnswer3(), u.getPwdQuestionAnswer3()))) {
|
||||
&& PwdUtils.validatePassword(user.getPwdQuestionAnswer(), u.getPwdQuestionAnswer())
|
||||
&& PwdUtils.validatePassword(user.getPwdQuestionAnswer2(), u.getPwdQuestionAnswer2())
|
||||
&& PwdUtils.validatePassword(user.getPwdQuestionAnswer3(), u.getPwdQuestionAnswer3()))) {
|
||||
return renderResult(Global.FALSE, "您填写的密保问题答案不正确!");
|
||||
}
|
||||
|
||||
|
||||
@@ -4,20 +4,26 @@
|
||||
package com.jeesite.modules.sys.web.user;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.session.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
@@ -35,6 +41,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/corpAdmin")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class CorpAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -62,7 +69,8 @@ public class CorpAdminController extends BaseController {
|
||||
user.getSqlMap().getWhere().disableAutoAddCorpCodeWhere()
|
||||
.and("corp_code", QueryType.EQ, user.getCorpCode_())
|
||||
.and("corp_name", QueryType.LIKE, user.getCorpName_());
|
||||
Page<User> page = userService.findPage(new Page<User>(request, response), user);
|
||||
user.setPage(new Page<>(request, response));
|
||||
Page<User> page = userService.findPage(user);
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -213,5 +221,55 @@ public class CorpAdminController extends BaseController {
|
||||
return renderResult(Global.TRUE, "取消用户'" + user.getUserName() + "'管理员身份成功!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户数据树格式
|
||||
* @param pId 父级编码,默认 -1
|
||||
* @param isShowCode 是否显示编码(true or 1:显示在左侧;2:显示在右侧;false or null:不显示)
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String pId, String isShowCode) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
User where = new User();
|
||||
List<User> list = userService.findCorpList(where);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
User e = list.get(i);
|
||||
Map<String, Object> map = MapUtils.newHashMap();
|
||||
map.put("id", e.getCorpCode_());
|
||||
map.put("pId", StringUtils.defaultIfBlank(pId, "-1"));
|
||||
map.put("name", StringUtils.getTreeNodeName(isShowCode, e.getCorpCode_(), e.getCorpName_()));
|
||||
mapList.add(map);
|
||||
}
|
||||
return mapList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换租户
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("sys:corpAdmin:edit")
|
||||
@RequestMapping(value = "switch/{corpCode}")
|
||||
@ResponseBody
|
||||
public String switchCorp(@PathVariable String corpCode) {
|
||||
if (UserUtils.getUser().isSuperAdmin()){
|
||||
User where = new User();
|
||||
where.setCorpCode_(corpCode);
|
||||
List<User> list = userService.findCorpList(where);
|
||||
if (list.size() > 0){
|
||||
Session session = UserUtils.getSession();
|
||||
User user = list.get(0);
|
||||
session.setAttribute("corpCode", user.getCorpCode_());
|
||||
session.setAttribute("corpName", user.getCorpName_());
|
||||
return renderResult(Global.TRUE, "租户切换成功!");
|
||||
}else{
|
||||
return renderResult(Global.TRUE, "租户切换失败,没有这个租户!");
|
||||
}
|
||||
}
|
||||
return renderResult(Global.FALSE, "租户切换失败,只有超级管理员才可以操作!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -22,12 +23,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
import com.jeesite.common.collect.MapUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.DateUtils;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.mapper.JsonMapper;
|
||||
import com.jeesite.common.utils.excel.ExcelExport;
|
||||
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
@@ -52,6 +55,7 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/empUser")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class EmpUserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -88,13 +92,14 @@ public class EmpUserController extends BaseController {
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public Page<EmpUser> listData(EmpUser empUser, Boolean isAll, HttpServletRequest request, HttpServletResponse response) {
|
||||
public Page<EmpUser> listData(EmpUser empUser, Boolean isAll, String ctrlPermi, HttpServletRequest request, HttpServletResponse response) {
|
||||
empUser.getEmployee().getOffice().setIsQueryChildren(true);
|
||||
empUser.getEmployee().getCompany().setIsQueryChildren(true);
|
||||
if (!(isAll != null && isAll)){
|
||||
empUserService.addDataScopeFilter(empUser, UserDataScope.CTRL_PERMI_MANAGE);
|
||||
empUserService.addDataScopeFilter(empUser, ctrlPermi);
|
||||
}
|
||||
Page<EmpUser> page = empUserService.findPage(new Page<EmpUser>(request, response), empUser);
|
||||
empUser.setPage(new Page<>(request, response));
|
||||
Page<EmpUser> page = empUserService.findPage(empUser);
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -167,16 +172,17 @@ public class EmpUserController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions("sys:empUser:view")
|
||||
@RequestMapping(value = "exportData")
|
||||
public void exportData(EmpUser empUser, Boolean isAll, HttpServletResponse response) {
|
||||
public void exportData(EmpUser empUser, Boolean isAll, String ctrlPermi, HttpServletResponse response) {
|
||||
empUser.getEmployee().getOffice().setIsQueryChildren(true);
|
||||
empUser.getEmployee().getCompany().setIsQueryChildren(true);
|
||||
if (!(isAll != null && isAll)){
|
||||
empUserService.addDataScopeFilter(empUser, UserDataScope.CTRL_PERMI_MANAGE);
|
||||
empUserService.addDataScopeFilter(empUser, ctrlPermi);
|
||||
}
|
||||
List<EmpUser> list = empUserService.findList(empUser);
|
||||
String fileName = "用户数据" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||
new ExcelExport("用户数据", EmpUser.class).setDataList(list)
|
||||
.write(response, fileName).dispose();
|
||||
try(ExcelExport ee = new ExcelExport("用户数据", EmpUser.class)){
|
||||
ee.setDataList(list).write(response, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,8 +200,9 @@ public class EmpUserController extends BaseController {
|
||||
}
|
||||
List<EmpUser> list = ListUtils.newArrayList(empUser);
|
||||
String fileName = "用户数据模板.xlsx";
|
||||
new ExcelExport("用户数据", EmpUser.class, Type.IMPORT).setDataList(list)
|
||||
.write(response, fileName).dispose();
|
||||
try(ExcelExport ee = new ExcelExport("用户数据", EmpUser.class, Type.IMPORT)){
|
||||
ee.setDataList(list).write(response, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,8 +354,8 @@ public class EmpUserController extends BaseController {
|
||||
@RequestMapping(value = "treeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> treeData(String idPrefix, String pId,
|
||||
String officeCode, String companyCode, String postCode,
|
||||
String roleCode, Boolean isAll, String isShowCode) {
|
||||
String officeCode, String companyCode, String postCode, String roleCode,
|
||||
Boolean isAll, String isShowCode, String ctrlPermi) {
|
||||
List<Map<String, Object>> mapList = ListUtils.newArrayList();
|
||||
EmpUser empUser = new EmpUser();
|
||||
Employee employee = empUser.getEmployee();
|
||||
@@ -362,11 +369,11 @@ public class EmpUserController extends BaseController {
|
||||
empUser.setUserType(User.USER_TYPE_EMPLOYEE);
|
||||
empUser.setMgrType(User.MGR_TYPE_NOT_ADMIN);
|
||||
if (!(isAll != null && isAll)) {
|
||||
empUserService.addDataScopeFilter(empUser);
|
||||
empUserService.addDataScopeFilter(empUser, ctrlPermi);
|
||||
}
|
||||
List<User> list = userService.findList(empUser);
|
||||
List<EmpUser> list = empUserService.findList(empUser);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
User e = list.get(i);
|
||||
EmpUser e = list.get(i);
|
||||
Map<String, Object> map = MapUtils.newHashMap();
|
||||
map.put("id", StringUtils.defaultIfBlank(idPrefix, "u_") + e.getId());
|
||||
map.put("pId", StringUtils.defaultIfBlank(pId, "0"));
|
||||
@@ -381,10 +388,12 @@ public class EmpUserController extends BaseController {
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "empUserSelect")
|
||||
public String empUserSelect(EmpUser empUser, String selectData, String checkbox, Model model) {
|
||||
model.addAttribute("selectData", selectData); // 指定默认选中的ID
|
||||
model.addAttribute("checkbox", checkbox); // 是否显示复选框,支持多选
|
||||
model.addAttribute("empUser", empUser); // ModelAttribute
|
||||
public String empUserSelect(EmpUser empUser, String selectData, Model model) {
|
||||
String selectDataJson = EncodeUtils.decodeUrl(selectData);
|
||||
if (JsonMapper.fromJson(selectDataJson, Map.class) != null){
|
||||
model.addAttribute("selectData", selectDataJson);
|
||||
}
|
||||
model.addAttribute("empUser", empUser);
|
||||
return "modules/sys/user/empUserSelect";
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -32,6 +33,7 @@ import com.jeesite.modules.sys.service.UserService;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/secAdmin")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
public class SecAdminController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -53,7 +55,8 @@ public class SecAdminController extends BaseController {
|
||||
@ResponseBody
|
||||
public Page<User> listData(User user, HttpServletRequest request, HttpServletResponse response) {
|
||||
user.setMgrType(User.MGR_TYPE_SEC_ADMIN); // 二级管理员
|
||||
Page<User> page = userService.findPage(new Page<User>(request, response), user);
|
||||
user.setPage(new Page<>(request, response));
|
||||
Page<User> page = userService.findPage(user);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# 温馨提示:不建议直接修改此文件,为了平台升级方便,建议将需要修改的参数值,复制到jeesite.yml里进行覆盖该参数值。
|
||||
# 温馨提示:不建议直接修改此文件,为了平台升级方便,建议将需要修改的参数值,复制到application.yml里进行覆盖该参数值。
|
||||
|
||||
#============================#
|
||||
#===== Database sttings =====#
|
||||
#============================#
|
||||
#======================================#
|
||||
#========== Database sttings ==========#
|
||||
#======================================#
|
||||
|
||||
# 数据库连接
|
||||
jdbc:
|
||||
@@ -24,26 +24,24 @@ jdbc:
|
||||
minIdle: 3
|
||||
# 最大连接数
|
||||
maxActive: 20
|
||||
|
||||
# 获取连接等待超时时间,单位毫秒(4.0.6+)
|
||||
maxWait: 60000
|
||||
|
||||
# 从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个。(4.0.6+)
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
|
||||
# 间隔多久才进行一次检测,检测需要关闭的空闲连接,单位毫秒(4.0.6+)
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
|
||||
# 一个连接在池中最小生存的时间,单位毫秒(4.0.6+)
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
|
||||
# 配置是否自动回收超时连接,超时时间,单位秒 (4.0.6+)
|
||||
removeAbandoned: true
|
||||
removeAbandonedTimeout: 1800
|
||||
|
||||
# # 多数据源名称列表,启用方式:@MyBatisDao(dataSourceName="ds2")
|
||||
# dataSourceNames: ds2
|
||||
#
|
||||
# # 多数据源配置:ds2
|
||||
# ds2:
|
||||
# type: oracle
|
||||
# driver: oracle.jdbc.driver.OracleDriver
|
||||
# url: jdbc:oracle:thin:@127.0.0.1:1521/orcl
|
||||
# username: jeesite
|
||||
# password: jeesite
|
||||
# testSql: SELECT 1 FROM DUAL
|
||||
# encrypt:
|
||||
# username: false
|
||||
# password: true
|
||||
# pool:
|
||||
# init: 1
|
||||
# minIdle: 3
|
||||
# maxActive: 20
|
||||
|
||||
# JTA 分布式事务(v4.0.4+)
|
||||
jta:
|
||||
enabled: false
|
||||
@@ -56,47 +54,44 @@ jdbc:
|
||||
stat:
|
||||
enabled: true
|
||||
|
||||
# Redis 配置
|
||||
redis:
|
||||
enabled: false
|
||||
|
||||
# Redis 连接参数
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
isSSL: false
|
||||
timeout: 2000
|
||||
password: 1234
|
||||
database: 0
|
||||
clientName: ~
|
||||
|
||||
# Redis 连接池配置
|
||||
pool:
|
||||
maxIdle: 3
|
||||
maxTotal: 20
|
||||
#======================================#
|
||||
#========== Spring settings ===========#
|
||||
#======================================#
|
||||
|
||||
# 是否启用Redis系统缓存及会话(专业版)
|
||||
cacheAndSession: false
|
||||
spring:
|
||||
|
||||
# 定义Key的前缀标识
|
||||
keyPrefix: ${jdbc.tablePrefix}
|
||||
# 缓存配置
|
||||
cache:
|
||||
# 缓存及会话共享(专业版)
|
||||
isClusterMode: false
|
||||
# 清理全部缓存按钮所清理的缓存列表
|
||||
clearNames: sysCache,corpCache,userCache,cmsCache
|
||||
|
||||
# 关闭 Spring Boot Banner 打印
|
||||
main:
|
||||
bannerMode: "off"
|
||||
|
||||
#============================#
|
||||
#===== System settings ======#
|
||||
#============================#
|
||||
# 日志配置
|
||||
logging:
|
||||
config: classpath:config/logback-spring.xml
|
||||
|
||||
#======================================#
|
||||
#========== System settings ===========#
|
||||
#======================================#
|
||||
|
||||
#管理基础路径
|
||||
# 管理基础路径
|
||||
adminPath: /a
|
||||
|
||||
#前端基础路径
|
||||
# 前端基础路径
|
||||
frontPath: /f
|
||||
|
||||
# 分页配置
|
||||
# 分页相关
|
||||
page:
|
||||
|
||||
# 分页默认大小
|
||||
pageSize: 20
|
||||
|
||||
# 用户相关参数
|
||||
# 用户相关
|
||||
user:
|
||||
|
||||
# 指定超级管理员编号(研发团队使用的账号)
|
||||
@@ -152,7 +147,7 @@ user:
|
||||
expandLevel: -1,
|
||||
remarks: ""
|
||||
}]
|
||||
|
||||
|
||||
# 多租户模式(SAAS模式)(专业版)
|
||||
useCorpModel: false
|
||||
|
||||
@@ -162,9 +157,59 @@ user:
|
||||
registerUser:
|
||||
enabled: false
|
||||
userTypes: 0, 1
|
||||
|
||||
# 角色管理
|
||||
role:
|
||||
# 扩展数据权限定义:3:本部门;4:本公司;5:本部门和本公司
|
||||
# 如果 ctrlTypeClass 为 NONE,则代表是不控制该类型权限
|
||||
extendDataScopes: >
|
||||
{
|
||||
3: {
|
||||
Office: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Office",
|
||||
ctrlDataAttrName: "currentUser.refObj.office.officeCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.office.parentCodes"
|
||||
},
|
||||
Company: {
|
||||
ctrlTypeClass: "NONE"
|
||||
}
|
||||
},
|
||||
4: {
|
||||
Office: {
|
||||
ctrlTypeClass: "NONE"
|
||||
},
|
||||
Company: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Company",
|
||||
ctrlDataAttrName: "currentUser.refObj.company.companyCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.company.parentCodes"
|
||||
}
|
||||
},
|
||||
5: {
|
||||
Office: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Office",
|
||||
ctrlDataAttrName: "currentUser.refObj.office.officeCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.office.parentCodes"
|
||||
},
|
||||
Company: {
|
||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Company",
|
||||
ctrlDataAttrName: "currentUser.refObj.company.companyCode",
|
||||
ctrlDataParentCodesAttrName: "currentUser.refObj.company.parentCodes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# 菜单管理
|
||||
menu:
|
||||
# 根据模块状态去更新相连的菜单状态(仅作为微服务时设为false)
|
||||
updateStatusByModuleStatus: true
|
||||
|
||||
# 国际化管理(专业版+)
|
||||
lang:
|
||||
enabled: true
|
||||
|
||||
# 任务调度(个人版+)
|
||||
job:
|
||||
enabled: true
|
||||
|
||||
# 是否自动启动任务调度(可关闭)
|
||||
autoStartup: true
|
||||
@@ -177,21 +222,43 @@ job:
|
||||
threadCount: 10
|
||||
threadPriority: 5
|
||||
|
||||
# 调度设置,集群中每一个实例都必须使用相同的instanceName名称 (区分特定的调度器实例)
|
||||
# 每一个instanceId必须不同,设置AUTO则自动生成
|
||||
scheduler:
|
||||
instanceName: JeeSiteScheduler
|
||||
instanceId: AUTO
|
||||
|
||||
# 任务调度集群设置
|
||||
jobStore:
|
||||
isClustered: true
|
||||
dataSourceName: job
|
||||
clusterCheckinInterval: 1000
|
||||
|
||||
# 内容管理
|
||||
cms:
|
||||
# 调度日志配置
|
||||
log:
|
||||
# 计划调度日志
|
||||
scheduler:
|
||||
enabled: true
|
||||
# 是否只保存错误日志
|
||||
errorLevel: true
|
||||
# 任务执行日志
|
||||
jobDetail:
|
||||
enabled: true
|
||||
# 是否只保存错误日志
|
||||
errorLevel: true
|
||||
# 计划触发日志
|
||||
trigger:
|
||||
enabled: false
|
||||
|
||||
# 内容管理主站点编码
|
||||
mainSiteCode: main
|
||||
## 内容管理
|
||||
#cms:
|
||||
#
|
||||
# # 内容管理主站点编码
|
||||
# mainSiteCode: main
|
||||
|
||||
#============================#
|
||||
#==== Framework settings ====#
|
||||
#============================#
|
||||
#======================================#
|
||||
#========= Framework settings =========#
|
||||
#======================================#
|
||||
|
||||
# Shiro 相关配置
|
||||
shiro:
|
||||
@@ -220,11 +287,19 @@ shiro:
|
||||
# 是否加密单点登录安全Key
|
||||
encryptKey: true
|
||||
|
||||
# 登录提交信息加密
|
||||
# 登录提交信息加密(如果不需要加密,设置为空即可)
|
||||
loginSubmit:
|
||||
|
||||
# 登录提交信息安全Key,加密用户名、密码、验证码,后再提交(key设置为3个,用逗号分隔)
|
||||
secretKey: thinkgem,jeesite,com
|
||||
|
||||
# 记住我密钥设置(设置为空则使用默认)
|
||||
rememberMe:
|
||||
# 密钥必须通过 com.jeesite.common.shiro.web.RememberMeManager 的main方法生成
|
||||
secretKey: ~
|
||||
|
||||
# 指定获取客户端IP的Header名称,防止IP伪造。指定为空,则使用原生方法获取IP。
|
||||
remoteAddrHeaderName: X-Forwarded-For
|
||||
|
||||
# 允许的请求方法设定,解决安全审计问题
|
||||
allowRequestMethods: GET,POST
|
||||
@@ -239,14 +314,13 @@ shiro:
|
||||
isAllowExternalSiteIframe: true
|
||||
|
||||
# 是否允许跨域访问,如果允许,设置允许的域名,全部域名设置*号,如果不允许,此设置应该为空
|
||||
# accessControlAllowOrigin: http://demo.jeesite.net
|
||||
# accessControlAllowOrigin: http://demo.jeesite.com
|
||||
# accessControlAllowOrigin: '*'
|
||||
|
||||
# URI 权限过滤器定义
|
||||
filterChainDefinitions: |
|
||||
/ReportServer/** = user
|
||||
${adminPath}/** = user
|
||||
# 是否在登录后生成新的Session(默认false)
|
||||
isGenerateNewSessionAfterLogin: false
|
||||
|
||||
# URI 权限过滤器定义
|
||||
# filterChainDefinitions: |
|
||||
# /ReportServer/** = user
|
||||
# ${adminPath}/file/** = anon
|
||||
@@ -258,12 +332,18 @@ shiro:
|
||||
# ${adminPath}/cms/article/* = anon
|
||||
# ${adminPath}/cms/link/* = anon
|
||||
# ${adminPath}/** = user
|
||||
filterChainDefinitions: |
|
||||
/ReportServer/** = user
|
||||
${adminPath}/** = user
|
||||
|
||||
# 默认的授权过滤定义,如果在filterChainDefinitions中已经定义,则该定义会被覆盖。
|
||||
defaultFilterChainDefinitions: |
|
||||
/static/** = anon
|
||||
/userfiles/** = anon
|
||||
/druid/** = perms[sys:state:druid]
|
||||
/v2/api-docs = perms[sys:swagger]
|
||||
/swagger-ui.html = perms[sys:swagger]
|
||||
/swagger-resources/** = perms[sys:swagger]
|
||||
${adminPath}/login-cas = cas
|
||||
${adminPath}/login = authc
|
||||
${adminPath}/logout = logout
|
||||
@@ -279,27 +359,30 @@ shiro:
|
||||
# Session 相关
|
||||
session:
|
||||
|
||||
#全局会话超时,单位:毫秒, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
||||
# 全局会话超时,单位:毫秒, 20m=1200000ms, 30m=1800000ms, 60m=3600000ms, 12h=43200000ms, 1day=86400000ms
|
||||
sessionTimeout: 1800000
|
||||
|
||||
#手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效
|
||||
# 手机APP设备会话超时参数设置,登录请求参数加 param_deviceType=mobileApp 时有效
|
||||
mobileAppSessionTimeout: 43200000
|
||||
|
||||
#定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话
|
||||
# 定时清理失效会话,清理用户直接关闭浏览器造成的孤立会话
|
||||
sessionTimeoutClean: 1200000
|
||||
|
||||
#会话唯一标识SessionId在Cookie中的名称。
|
||||
# 会话唯一标识SessionId在Cookie中的名称。
|
||||
sessionIdCookieName: jeesite.session.id
|
||||
|
||||
#共享的SessionId的Cookie名称,保存到跟路径下,第三方应用获取。同一域名下多个项目时需设置共享Cookie的名称。
|
||||
# 共享的SessionId的Cookie名称,保存到跟路径下,第三方应用获取。同一域名下多个项目时需设置共享Cookie的名称。
|
||||
#shareSessionIdCookieName: ${session.sessionIdCookieName}
|
||||
|
||||
# MyBatis 相关
|
||||
mybatis:
|
||||
|
||||
# 扫描基础包设置(Aliases、@MyBatisDao),如果多个,用“,”分隔
|
||||
# @MyBatisDao、Aliases 扫描基础包,如果多个,用“,”分隔
|
||||
scanBasePackage: com.jeesite.modules
|
||||
|
||||
# TypeHandlers 扫描基础包,如果多个,用“,”分隔
|
||||
scanTypeHandlersPackage: ~
|
||||
|
||||
# Mapper文件刷新线程
|
||||
mapper:
|
||||
refresh:
|
||||
@@ -308,21 +391,6 @@ mybatis:
|
||||
sleepSeconds: 3
|
||||
mappingPath: mappings
|
||||
|
||||
# 缓存设置
|
||||
ehcache:
|
||||
|
||||
# 缓存配置文件路径
|
||||
configFile: cache/ehcache-local.xml
|
||||
# configFile: cache/ehcache-rmi.xml
|
||||
|
||||
# 清理缓存的缓存名称
|
||||
clearNames: sysCache,userCache,corpCache,cmsCache,pageCachingFilter
|
||||
|
||||
# 页面缓存配置
|
||||
pageCaching:
|
||||
enabled: false
|
||||
urlPatterns: "*.html"
|
||||
|
||||
# Web 相关
|
||||
web:
|
||||
|
||||
@@ -347,6 +415,7 @@ web:
|
||||
${adminPath}/login,
|
||||
${adminPath}/desktop,
|
||||
${adminPath}/sys/online/count,
|
||||
${adminPath}/state/server/rtInfo,
|
||||
${adminPath}/**/treeData,
|
||||
${adminPath}/file/**,
|
||||
${adminPath}/tags/*,
|
||||
@@ -367,19 +436,28 @@ web:
|
||||
|
||||
# 自定义正则表达式验证(主键、登录名)
|
||||
validator:
|
||||
id: '[a-zA-Z0-9_\-/\u4e00-\u9fa5]{0,64}'
|
||||
id: '[a-zA-Z0-9_\-/#\u4e00-\u9fa5]{0,64}'
|
||||
user.loginCode: '[a-zA-Z0-9_\u4e00-\u9fa5]{4,20}'
|
||||
|
||||
|
||||
# 关闭核心模块的Web功能(仅作为微服务时设为false)
|
||||
core:
|
||||
enabled: true
|
||||
|
||||
# 在线API文档工具
|
||||
swagger:
|
||||
enabled: true
|
||||
|
||||
# 错误页面500.html是否输出错误信息(正式环境,为提供安全性可设置为false)
|
||||
error:
|
||||
page:
|
||||
printErrorInfo: true
|
||||
|
||||
#============================#
|
||||
#=== FileUpload settings ====#
|
||||
#============================#
|
||||
#======================================#
|
||||
#======== FileUpload settings =========#
|
||||
#======================================#
|
||||
|
||||
file:
|
||||
enabled: true
|
||||
|
||||
# 文件上传根路径,设置路径中不允许包含“userfiles”,在指定目录中系统会自动创建userfiles目录,如果不设置默认为contextPath路径
|
||||
# baseDir: D:/jeesite
|
||||
@@ -401,13 +479,14 @@ file:
|
||||
# application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
|
||||
# application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||
|
||||
#============================#
|
||||
#===== Message settings =====#
|
||||
#============================#
|
||||
#======================================#
|
||||
#========== Message settings ==========#
|
||||
#======================================#
|
||||
|
||||
# 消息提醒中心(专业版)
|
||||
msg:
|
||||
|
||||
enabled: true
|
||||
|
||||
# 是否开启实时发送消息(保存消息后立即检查未读消息并发送),分布式部署下请单独配置消息发送服务,不建议开启此选项。
|
||||
realtime:
|
||||
# 是否开启
|
||||
@@ -430,7 +509,7 @@ msg:
|
||||
# 短信网关
|
||||
sms:
|
||||
beanName: smsSendService
|
||||
url: http://lehuo520.cn/a/sms/api
|
||||
url: http://localhost:80/msg/sms/send
|
||||
data: username=jeesite&password=jeesite.com
|
||||
prefix: 【JeeSite】
|
||||
suffix: ~
|
||||
@@ -452,11 +531,11 @@ msg:
|
||||
debug: true
|
||||
# 微信OAuth登录授权回调地址
|
||||
oauth:
|
||||
redirectUri: http://demo.jeesite.com/jeesite
|
||||
redirectUri: http://demo.jeesite.com/js
|
||||
|
||||
#============================#
|
||||
#===== Video settings =======#
|
||||
#============================#
|
||||
#======================================#
|
||||
#========== Video settings ============#
|
||||
#======================================#
|
||||
|
||||
video:
|
||||
|
||||
@@ -469,8 +548,3 @@ video:
|
||||
|
||||
# 将mp4视频的元数据信息转到视频第一帧
|
||||
qtFaststartFile: d:/tools/video/qt-faststart/qt-faststart.exe
|
||||
|
||||
#============================#
|
||||
#===== Project settings =====#
|
||||
#============================#
|
||||
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
<included>
|
||||
|
||||
|
||||
<!-- https://github.com/spring-projects/spring-boot/blob/v2.0.5.RELEASE/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml -->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
|
||||
<logger name="org.springframework.boot.web.embedded" level="INFO" />
|
||||
<logger name="net.oschina.j2cache.caffeine.CaffeineProvider" level="ERROR" />
|
||||
|
||||
<!-- <logger name="org.apache.ibatis" level="DEBUG" /> -->
|
||||
<!-- <logger name="org.mybatis.spring" level="DEBUG" /> -->
|
||||
<!-- <logger name="org.springframework.jdbc" level="DEBUG" /> -->
|
||||
<logger name="org.mybatis.spring.transaction" level="DEBUG" />
|
||||
<logger name="org.apache.catalina.webresources.Cache" level="ERROR" />
|
||||
<logger name="org.springframework.boot.context.embedded" level="INFO" />
|
||||
<logger name="org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer" level="INFO" />
|
||||
<logger name="com.atomikos.icatch.config.UserTransactionServiceImp" level="ERROR" />
|
||||
<logger name="com.atomikos.jdbc.AbstractDataSourceBean" level="ERROR" />
|
||||
|
||||
<logger name="springfox.documentation.spring.web.readers.parameter.ParameterDataTypeReader" level="ERROR" />
|
||||
<!-- <logger name="io.swagger" level="DEBUG" /> -->
|
||||
<!-- <logger name="springfox" level="DEBUG" /> -->
|
||||
|
||||
<logger name="com.jeesite" level="DEBUG" />
|
||||
<logger name="com.jeesite.common.i18n" level="INFO" />
|
||||
<logger name="com.jeesite.common.shiro" level="INFO" />
|
||||
<logger name="com.jeesite.common.mybatis" level="INFO" />
|
||||
<logger name="com.jeesite.common.mybatis.mapper" level="DEBUG" />
|
||||
<logger name="com.jeesite.common.reflect.ReflectUtils" level="INFO" />
|
||||
<logger name="com.jeesite.common.io.FileUtils" level="INFO" />
|
||||
<logger name="com.jeesite.common.cache.JedisUtils" level="INFO" />
|
||||
<logger name="com.jeesite.common.web.view.JstlView" level="INFO" />
|
||||
<logger name="com.jeesite.modules.job.service.JobService" level="INFO" />
|
||||
|
||||
</included>
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
UPDATE ${_prefix}sys_menu SET permission='sys:stste:cache' WHERE permission='sys:stste:ehcache';
|
||||
UPDATE ${_prefix}sys_menu SET menu_href='/state/cache/index' WHERE menu_href='/state/ehcache';
|
||||
UPDATE ${_prefix}sys_menu SET menu_href='/state/server/index' WHERE menu_href='/state/server';
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
-- 代码生成添加数据源字段
|
||||
ALTER TABLE ${_prefix}gen_table ADD data_source_name varchar(64) NULL;
|
||||
|
||||
-- 新增在线文档Swagger菜单
|
||||
INSERT INTO ${_prefix}sys_menu (menu_code, parent_code, parent_codes, tree_sort, tree_sorts, tree_leaf, tree_level, tree_names, menu_name, menu_type, menu_href, menu_target, menu_icon, menu_color, permission, weight, is_show, sys_code, module_codes, status, create_by, create_date, update_by, update_date, remarks)
|
||||
VALUES ('1044942498470014976', '0', '0,', '9040', '0000009040,', '1', 0, '在线文档', '在线文档', '1', '//swagger-ui.html', '', 'icon-book-open', '', 'sys:swagger', 80, '0', 'default', 'core', '0', 'system', getdate(), 'system', getdate(), '');
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
UPDATE ${_prefix}sys_menu SET permission='sys:stste:cache' WHERE permission='sys:stste:ehcache';
|
||||
UPDATE ${_prefix}sys_menu SET menu_href='/state/cache/index' WHERE menu_href='/state/ehcache';
|
||||
UPDATE ${_prefix}sys_menu SET menu_href='/state/server/index' WHERE menu_href='/state/server';
|
||||
|
||||
commit;
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
-- 代码生成添加数据源字段
|
||||
ALTER TABLE ${_prefix}gen_table
|
||||
ADD COLUMN `data_source_name` varchar(64) NULL COMMENT '数据源名称' AFTER `tpl_category`;
|
||||
|
||||
-- 新增在线文档Swagger菜单
|
||||
INSERT INTO ${_prefix}sys_menu (menu_code, parent_code, parent_codes, tree_sort, tree_sorts, tree_leaf, tree_level, tree_names, menu_name, menu_type, menu_href, menu_target, menu_icon, menu_color, permission, weight, is_show, sys_code, module_codes, status, create_by, create_date, update_by, update_date, remarks)
|
||||
VALUES ('1044942498470014976', '0', '0,', '9040', '0000009040,', '1', 0, '在线文档', '在线文档', '1', '//swagger-ui.html', '', 'icon-book-open', '', 'sys:swagger', 80, '0', 'default', 'core', '0', 'system', now(), 'system', now(), '');
|
||||
|
||||
commit;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user