diff --git a/.gitignore b/.gitignore
index dce96c00..c75c505b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
*.iml
*/target/*
*/*.iml
+/.gradle/
diff --git a/README.md b/README.md
index 0b3233ae..8a970d21 100644
--- a/README.md
+++ b/README.md
@@ -13,6 +13,8 @@
**开发文档:** [https://el-admin.vip](https://el-admin.vip)
+**备用文档:** [https://doc.el-admin.xin](https://doc.el-admin.xin)
+
**体验地址:** [https://el-admin.xin](https://el-admin.xin)
**账号密码:** `admin / 123456`
@@ -48,7 +50,6 @@
- 定时任务:整合Quartz做定时任务,加入任务日志,任务运行情况一目了然
- 代码生成:高灵活度生成前后端代码,减少大量重复的工作任务
- 邮件工具:配合富文本,发送html格式的邮件
-- 免费图床:使用sm.ms图床,用作公共图片上传使用,该图床不怎么稳定,不太建议使用
- 七牛云存储:可同步七牛云存储的数据到系统,无需登录七牛云直接操作云数据
- 支付宝支付:整合了支付宝支付并且提供了测试账号,可自行测试
- 服务监控:监控服务器的负载情况
@@ -89,20 +90,20 @@
#### 系统预览
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
-  |
-  |
+  |
+  |
diff --git a/eladmin-common/pom.xml b/eladmin-common/pom.xml
index 82f65340..2150b4b7 100644
--- a/eladmin-common/pom.xml
+++ b/eladmin-common/pom.xml
@@ -5,7 +5,7 @@
eladmin
me.zhengjie
- 2.5
+ 2.6
4.0.0
diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java b/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
index 127ec43a..08f9c3c1 100644
--- a/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
+++ b/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java
@@ -41,8 +41,6 @@ public class ElAdminConstant {
* 常用接口
*/
public static class Url {
- // 免费图床
- public static final String SM_MS_URL = "https://sm.ms/api";
// IP归属地查询
public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp?ip=%s&json=true";
}
diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
index 8868ba6d..5edd7041 100644
--- a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
+++ b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
@@ -43,7 +43,9 @@ import java.util.Map;
* @date 2018-12-27
*/
public class FileUtil extends cn.hutool.core.io.FileUtil {
+
private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
+
/**
* 系统临时目录
*
@@ -75,6 +77,13 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
*/
private static final DecimalFormat DF = new DecimalFormat("0.00");
+ public static final String IMAGE = "图片";
+ public static final String TXT = "文档";
+ public static final String MUSIC = "音乐";
+ public static final String VIDEO = "视频";
+ public static final String OTHER = "其他";
+
+
/**
* MultipartFile转File
*/
@@ -217,15 +226,15 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
String video = "avi mpg mpe mpeg asf wmv mov qt rm mp4 flv m4v webm ogv ogg";
String image = "bmp dib pcp dif wmf gif jpg tif eps psd cdr iff tga pcd mpt png jpeg";
if (image.contains(type)) {
- return "图片";
+ return IMAGE;
} else if (documents.contains(type)) {
- return "文档";
+ return TXT;
} else if (music.contains(type)) {
- return "音乐";
+ return MUSIC;
} else if (video.contains(type)) {
- return "视频";
+ return VIDEO;
} else {
- return "其他";
+ return OTHER;
}
}
diff --git a/eladmin-generator/pom.xml b/eladmin-generator/pom.xml
index fbb8e55c..52cdcfbe 100644
--- a/eladmin-generator/pom.xml
+++ b/eladmin-generator/pom.xml
@@ -5,7 +5,7 @@
eladmin
me.zhengjie
- 2.5
+ 2.6
4.0.0
@@ -20,7 +20,7 @@
me.zhengjie
eladmin-common
- 2.5
+ 2.6
diff --git a/eladmin-logging/pom.xml b/eladmin-logging/pom.xml
index a1b1d9ea..a713b3f8 100644
--- a/eladmin-logging/pom.xml
+++ b/eladmin-logging/pom.xml
@@ -5,7 +5,7 @@
eladmin
me.zhengjie
- 2.5
+ 2.6
4.0.0
@@ -16,7 +16,7 @@
me.zhengjie
eladmin-common
- 2.5
+ 2.6
\ No newline at end of file
diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml
index 6ccc1480..bca08a7a 100644
--- a/eladmin-system/pom.xml
+++ b/eladmin-system/pom.xml
@@ -5,7 +5,7 @@
eladmin
me.zhengjie
- 2.5
+ 2.6
4.0.0
@@ -23,7 +23,7 @@
me.zhengjie
eladmin-generator
- 2.5
+ 2.6
me.zhengjie
@@ -36,7 +36,7 @@
me.zhengjie
eladmin-tools
- 2.5
+ 2.6
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java
index df9c64f2..27acc0e7 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java
@@ -20,13 +20,15 @@ import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.util.StringUtils;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
+
import javax.sql.DataSource;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.sql.*;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
* @author /
@@ -36,20 +38,6 @@ public class SqlUtils {
public static final String COLON = ":";
- private static volatile Map map = new HashMap<>();
-
- private static String getKey(String jdbcUrl, String username, String password) {
- StringBuilder sb = new StringBuilder();
- if (!StringUtils.isEmpty(username)) {
- sb.append(username);
- }
- if (!StringUtils.isEmpty(password)) {
- sb.append(COLON).append(password);
- }
- sb.append(COLON).append(jdbcUrl.trim());
-
- return SecureUtil.md5(sb.toString());
- }
/**
* 获取数据源
@@ -60,55 +48,44 @@ public class SqlUtils {
* @return DataSource
*/
private static DataSource getDataSource(String jdbcUrl, String userName, String password) {
- String key = getKey(jdbcUrl, userName, password);
- if (!map.containsKey(key) || null == map.get(key)) {
- DruidDataSource druidDataSource = new DruidDataSource();
-
- String className;
- try {
- className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
- } catch (SQLException e) {
- throw new RuntimeException("Get class name error: =" + jdbcUrl);
- }
- if (StringUtils.isEmpty(className)) {
- DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
- if (null == dataTypeEnum) {
- throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
- }
- druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
- } else {
- druidDataSource.setDriverClassName(className);
- }
-
-
- druidDataSource.setUrl(jdbcUrl);
- druidDataSource.setUsername(userName);
- druidDataSource.setPassword(password);
- // 配置获取连接等待超时的时间
- druidDataSource.setMaxWait(3000);
- // 配置初始化大小、最小、最大
- druidDataSource.setInitialSize(1);
- druidDataSource.setMinIdle(1);
- druidDataSource.setMaxActive(1);
-
- // 配置间隔多久才进行一次检测需要关闭的空闲连接,单位是毫秒
- druidDataSource.setTimeBetweenEvictionRunsMillis(50000);
- // 配置一旦重试多次失败后等待多久再继续重试连接,单位是毫秒
- druidDataSource.setTimeBetweenConnectErrorMillis(18000);
- // 配置一个连接在池中最小生存的时间,单位是毫秒
- druidDataSource.setMinEvictableIdleTimeMillis(300000);
- // 这个特性能解决 MySQL 服务器8小时关闭连接的问题
- druidDataSource.setMaxEvictableIdleTimeMillis(25200000);
-
- try {
- druidDataSource.init();
- } catch (SQLException e) {
- log.error("Exception during pool initialization", e);
- throw new RuntimeException(e.getMessage());
- }
- map.put(key, druidDataSource);
+ DruidDataSource druidDataSource = new DruidDataSource();
+ String className;
+ try {
+ className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
+ } catch (SQLException e) {
+ throw new RuntimeException("Get class name error: =" + jdbcUrl);
}
- return map.get(key);
+ if (StringUtils.isEmpty(className)) {
+ DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
+ if (null == dataTypeEnum) {
+ throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
+ }
+ druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
+ } else {
+ druidDataSource.setDriverClassName(className);
+ }
+
+
+ druidDataSource.setUrl(jdbcUrl);
+ druidDataSource.setUsername(userName);
+ druidDataSource.setPassword(password);
+ // 配置获取连接等待超时的时间
+ druidDataSource.setMaxWait(3000);
+ // 配置初始化大小、最小、最大
+ druidDataSource.setInitialSize(1);
+ druidDataSource.setMinIdle(1);
+ druidDataSource.setMaxActive(1);
+
+ // 如果链接出现异常则直接判定为失败而不是一直重试
+ druidDataSource.setBreakAfterAcquireFailure(true);
+ try {
+ druidDataSource.init();
+ } catch (SQLException e) {
+ log.error("Exception during pool initialization", e);
+ throw new RuntimeException(e.getMessage());
+ }
+
+ return druidDataSource;
}
private static Connection getConnection(String jdbcUrl, String userName, String password) {
@@ -187,14 +164,14 @@ public class SqlUtils {
* @param sqlList /
*/
public static void batchExecute(Connection connection, List sqlList) throws SQLException {
- Statement st = connection.createStatement();
- for (String sql : sqlList) {
- if (sql.endsWith(";")) {
- sql = sql.substring(0, sql.length() - 1);
- }
- st.addBatch(sql);
+ Statement st = connection.createStatement();
+ for (String sql : sqlList) {
+ if (sql.endsWith(";")) {
+ sql = sql.substring(0, sql.length() - 1);
}
- st.executeBatch();
+ st.addBatch(sql);
+ }
+ st.executeBatch();
}
/**
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
index afed088a..575880cb 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
@@ -27,6 +27,7 @@ import me.zhengjie.annotation.rest.AnonymousGetMapping;
import me.zhengjie.annotation.rest.AnonymousPostMapping;
import me.zhengjie.config.RsaProperties;
import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.modules.security.config.bean.LoginCodeEnum;
import me.zhengjie.modules.security.config.bean.LoginProperties;
import me.zhengjie.modules.security.config.bean.SecurityProperties;
import me.zhengjie.modules.security.security.TokenProvider;
@@ -119,8 +120,13 @@ public class AuthorizationController {
// 获取运算的结果
Captcha captcha = loginProperties.getCaptcha();
String uuid = properties.getCodeKey() + IdUtil.simpleUUID();
+ //当验证码类型为 arithmetic时且长度 >= 2 时,captcha.text()的结果有几率为浮点型
+ String captchaValue = captcha.text();
+ if (captcha.getCharType() - 1 == LoginCodeEnum.arithmetic.ordinal() && captchaValue.contains(".")) {
+ captchaValue = captchaValue.split("\\.")[0];
+ }
// 保存
- redisUtils.set(uuid, captcha.text(), loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);
+ redisUtils.set(uuid, captchaValue, loginProperties.getLoginCode().getExpiration(), TimeUnit.MINUTES);
// 验证码信息
Map imgResult = new HashMap(2) {{
put("img", captcha.toBase64());
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java
index ec2338f7..ac2bcbe2 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java
@@ -96,7 +96,6 @@ public class DeptServiceImpl implements DeptService {
}
@Override
- @Cacheable(key = "'pid:' + #p0")
public List findByPid(long pid) {
return deptRepository.findByPid(pid);
}
@@ -113,7 +112,6 @@ public class DeptServiceImpl implements DeptService {
// 计算子节点数目
resources.setSubCount(0);
// 清理缓存
- redisUtils.del("dept::pid:" + (resources.getPid() == null ? 0 : resources.getPid()));
updateSubCnt(resources.getPid());
}
@@ -134,7 +132,7 @@ public class DeptServiceImpl implements DeptService {
updateSubCnt(oldPid);
updateSubCnt(newPid);
// 清理缓存
- delCaches(resources.getId(), oldPid, newPid);
+ delCaches(resources.getId());
}
@Override
@@ -142,7 +140,7 @@ public class DeptServiceImpl implements DeptService {
public void delete(Set deptDtos) {
for (DeptDto deptDto : deptDtos) {
// 清理缓存
- delCaches(deptDto.getId(), deptDto.getPid(), null);
+ delCaches(deptDto.getId());
deptRepository.deleteById(deptDto.getId());
updateSubCnt(deptDto.getPid());
}
@@ -273,15 +271,11 @@ public class DeptServiceImpl implements DeptService {
/**
* 清理缓存
* @param id /
- * @param oldPid /
- * @param newPid /
*/
- public void delCaches(Long id, Long oldPid, Long newPid){
+ public void delCaches(Long id){
List users = userRepository.findByDeptRoleId(id);
// 删除数据权限
redisUtils.delByKeys("data::user:",users.stream().map(User::getId).collect(Collectors.toSet()));
redisUtils.del("dept::id:" + id);
- redisUtils.del("dept::pid:" + (oldPid == null ? 0 : oldPid));
- redisUtils.del("dept::pid:" + (newPid == null ? 0 : newPid));
}
}
\ No newline at end of file
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java
index 1f8f974e..05d42e3f 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java
@@ -93,6 +93,6 @@ public class DictDetailServiceImpl implements DictDetailService {
public void delCaches(DictDetail dictDetail){
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
- redisUtils.del("dept::name:" + dict.getName());
+ redisUtils.del("dict::name:" + dict.getName());
}
}
\ No newline at end of file
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java
index 3c041ddd..0f64bc7f 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java
@@ -115,6 +115,6 @@ public class DictServiceImpl implements DictService {
}
public void delCaches(Dict dict){
- redisUtils.del("dept::name:" + dict.getName());
+ redisUtils.del("dict::name:" + dict.getName());
}
}
\ No newline at end of file
diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
index 386d06c3..f0ce9f71 100644
--- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
+++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
@@ -128,7 +128,6 @@ public class MenuServiceImpl implements MenuService {
resources.setSubCount(0);
// 更新父节点菜单数目
updateSubCnt(resources.getPid());
- redisUtils.del("menu::pid:" + (resources.getPid() == null ? 0 : resources.getPid()));
}
@Override
@@ -183,7 +182,7 @@ public class MenuServiceImpl implements MenuService {
updateSubCnt(oldPid);
updateSubCnt(newPid);
// 清理缓存
- delCaches(resources.getId(), oldPid, newPid);
+ delCaches(resources.getId());
}
@Override
@@ -204,7 +203,7 @@ public class MenuServiceImpl implements MenuService {
public void delete(Set