From 62cb72eab9dfbf54ffa24ce2098506ab300854ef Mon Sep 17 00:00:00 2001 From: kdjj2006 Date: Mon, 25 Jul 2022 15:41:38 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9HashMap=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=AE=B9=E9=87=8F=EF=BC=8C=E5=87=8F=E5=B0=91?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E6=89=A9=E5=AE=B9=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E6=80=A7=E8=83=BD=20(#760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 获取验证码逻辑,无需加锁,不涉及线程安全问题,提高效率 * 自定义生成策略时,Map容量设置不准确,会导致无必要的扩容 --- .../src/main/java/me/zhengjie/config/RedisConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java index bad7f79f..95217a26 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java @@ -106,7 +106,7 @@ public class RedisConfig extends CachingConfigurerSupport { @Override public KeyGenerator keyGenerator() { return (target, method, params) -> { - Map container = new HashMap<>(4); + Map container = new HashMap<>(8); Class targetClassClass = target.getClass(); // 类地址 container.put("class",targetClassClass.toGenericString()); From 5cfa96e127f16dd2e31e3b08042f366950e5d63f Mon Sep 17 00:00:00 2001 From: Zheng Jie <201507802@qq.com> Date: Tue, 2 Aug 2022 13:48:48 +0800 Subject: [PATCH 02/10] update domain --- README.md | 8 ++++---- .../main/java/me/zhengjie/annotation/DataPermission.java | 2 +- .../src/main/java/me/zhengjie/config/RsaProperties.java | 2 +- .../src/main/java/me/zhengjie/config/SwaggerConfig.java | 2 +- .../src/main/java/me/zhengjie/utils/CloseUtil.java | 2 +- .../java/me/zhengjie/utils/enums/RequestMethodEnum.java | 2 +- .../modules/system/service/impl/DataServiceImpl.java | 2 +- .../modules/system/service/impl/VerifyServiceImpl.java | 4 ++-- .../src/main/resources/template/email/email.ftl | 2 +- .../src/main/resources/template/email/taskAlarm.ftl | 2 +- .../resources/template/generator/admin/Controller.ftl | 2 +- .../src/main/resources/template/generator/admin/Dto.ftl | 2 +- .../main/resources/template/generator/admin/Entity.ftl | 2 +- .../main/resources/template/generator/admin/Mapper.ftl | 2 +- .../resources/template/generator/admin/QueryCriteria.ftl | 2 +- .../resources/template/generator/admin/Repository.ftl | 2 +- .../main/resources/template/generator/admin/Service.ftl | 2 +- .../resources/template/generator/admin/ServiceImpl.ftl | 2 +- pom.xml | 4 ++-- 19 files changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 7462baca..0b7c3f34 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

EL-ADMIN 后台管理系统

+

ELADMIN 后台管理系统

[![AUR](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/elunez/eladmin/blob/master/LICENSE) @@ -11,9 +11,9 @@ #### 项目简介 一个基于 Spring Boot 2.1.0 、 Spring Boot Jpa、 JWT、Spring Security、Redis、Vue的前后端分离的后台管理系统 -**开发文档:** [https://el-admin.vip](https://el-admin.vip) +**开发文档:** [https://eladmin.vip](https://eladmin.vip) -**体验地址:** [https://el-admin.vip/demo](https://el-admin.vip/demo) +**体验地址:** [https://eladmin.vip/demo](https://eladmin.vip/demo) **账号密码:** `admin / 123456` @@ -102,7 +102,7 @@ - 感谢 [d15801543974](https://github.com/d15801543974) 大佬提供的基于注解的通用查询方式 #### 项目捐赠 -项目的发展离不开你的支持,请作者喝杯咖啡吧☕ [Donate](https://el-admin.vip/donation/) +项目的发展离不开你的支持,请作者喝杯咖啡吧☕ [Donate](https://eladmin.vip/donation/) #### 反馈交流 - QQ交流群:一群:891137268 、二群:947578238、三群:659622532 \ No newline at end of file diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/DataPermission.java b/eladmin-common/src/main/java/me/zhengjie/annotation/DataPermission.java index b73c1a24..044d551e 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/DataPermission.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/DataPermission.java @@ -28,7 +28,7 @@ import java.lang.annotation.Target; * 应该是 @DataPermission(joinName = "dept", fieldName = "id") *

* @author Zheng Jie - * @website https://el-admin.vip + * @website https://eladmin.vip * @date 2020-05-07 **/ @Target(ElementType.TYPE) diff --git a/eladmin-common/src/main/java/me/zhengjie/config/RsaProperties.java b/eladmin-common/src/main/java/me/zhengjie/config/RsaProperties.java index a3594cdb..0a4a5375 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/RsaProperties.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/RsaProperties.java @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; /** * @author Zheng Jie - * @website https://el-admin.vip + * @website https://eladmin.vip * @description * @date 2020-05-18 **/ diff --git a/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java index 6d267746..989be98d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java @@ -77,7 +77,7 @@ public class SwaggerConfig { private ApiInfo apiInfo() { return new ApiInfoBuilder() .description("一个简单且易上手的 Spring boot 后台管理框架") - .title("EL-ADMIN 接口文档") + .title("ELADMIN 接口文档") .version("2.6") .build(); } diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/CloseUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/CloseUtil.java index 98d375be..f39919f2 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/CloseUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/CloseUtil.java @@ -19,7 +19,7 @@ import java.io.Closeable; /** * @author Zheng Jie - * @website https://el-admin.vip + * @website https://eladmin.vip * @description 用于关闭各种连接,缺啥补啥 * @date 2021-03-05 **/ diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/enums/RequestMethodEnum.java b/eladmin-common/src/main/java/me/zhengjie/utils/enums/RequestMethodEnum.java index 35e42b80..7de5146c 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/enums/RequestMethodEnum.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/enums/RequestMethodEnum.java @@ -20,7 +20,7 @@ import lombok.Getter; /** * @author Zheng Jie - * @website https://el-admin.vip + * @website https://eladmin.vip * @description * @date 2020-06-10 **/ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DataServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DataServiceImpl.java index 2933db9c..cd9cfd43 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DataServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DataServiceImpl.java @@ -30,7 +30,7 @@ import java.util.*; /** * @author Zheng Jie - * @website https://el-admin.vip + * @website https://eladmin.vip * @description 数据权限服务实现 * @date 2020-05-07 **/ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java index ec3230c7..79d307f9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java @@ -60,11 +60,11 @@ public class VerifyServiceImpl implements VerifyService { throw new BadRequestException("服务异常,请联系网站负责人"); } content = template.render(Dict.create().set("code",code)); - emailVo = new EmailVo(Collections.singletonList(email),"EL-ADMIN后台管理系统",content); + emailVo = new EmailVo(Collections.singletonList(email),"ELADMIN后台管理系统",content); // 存在就再次发送原来的验证码 } else { content = template.render(Dict.create().set("code",oldCode)); - emailVo = new EmailVo(Collections.singletonList(email),"EL-ADMIN后台管理系统",content); + emailVo = new EmailVo(Collections.singletonList(email),"ELADMIN后台管理系统",content); } return emailVo; } diff --git a/eladmin-system/src/main/resources/template/email/email.ftl b/eladmin-system/src/main/resources/template/email/email.ftl index 2f82fcb5..606d490e 100644 --- a/eladmin-system/src/main/resources/template/email/email.ftl +++ b/eladmin-system/src/main/resources/template/email/email.ftl @@ -39,7 +39,7 @@ font-size: 12px; padding: 20px 0px; font-family: Microsoft YaHei;"> - Copyright ©${.now?string("yyyy")} EL-ADMIN 后台管理系统 All Rights Reserved. + Copyright ©${.now?string("yyyy")} ELADMIN 后台管理系统 All Rights Reserved.
diff --git a/eladmin-system/src/main/resources/template/email/taskAlarm.ftl b/eladmin-system/src/main/resources/template/email/taskAlarm.ftl index b116decb..a29b0780 100644 --- a/eladmin-system/src/main/resources/template/email/taskAlarm.ftl +++ b/eladmin-system/src/main/resources/template/email/taskAlarm.ftl @@ -60,7 +60,7 @@ font-size: 12px; padding: 20px 0px; font-family: Microsoft YaHei;"> - Copyright ©${.now?string("yyyy")} EL-ADMIN 后台管理系统 All Rights Reserved. + Copyright ©${.now?string("yyyy")} ELADMIN 后台管理系统 All Rights Reserved. diff --git a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl index f81e280f..5af73ddb 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl @@ -31,7 +31,7 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @author ${author} * @date ${date} **/ diff --git a/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl b/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl index e388a0b4..ac81d988 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl @@ -29,7 +29,7 @@ import com.alibaba.fastjson.serializer.ToStringSerializer; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @description / * @author ${author} * @date ${date} diff --git a/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl b/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl index c5cf9c26..2e85cea8 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl @@ -37,7 +37,7 @@ import java.math.BigDecimal; import java.io.Serializable; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @description / * @author ${author} * @date ${date} diff --git a/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl b/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl index 3387f060..7bd67c0a 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl @@ -22,7 +22,7 @@ import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @author ${author} * @date ${date} **/ diff --git a/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl b/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl index 2a4d1ff4..b94f0f45 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl @@ -30,7 +30,7 @@ import me.zhengjie.annotation.Query; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @author ${author} * @date ${date} **/ diff --git a/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl b/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl index 2420d4b0..dac1e924 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl @@ -20,7 +20,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @author ${author} * @date ${date} **/ diff --git a/eladmin-system/src/main/resources/template/generator/admin/Service.ftl b/eladmin-system/src/main/resources/template/generator/admin/Service.ftl index 9ecbe249..ef337149 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Service.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Service.ftl @@ -25,7 +25,7 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @description 服务接口 * @author ${author} * @date ${date} diff --git a/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl b/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl index 17f04547..4f1f07da 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl @@ -54,7 +54,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; /** -* @website https://el-admin.vip +* @website https://eladmin.vip * @description 服务实现 * @author ${author} * @date ${date} diff --git a/pom.xml b/pom.xml index 14bf38dc..7dc9a3c6 100644 --- a/pom.xml +++ b/pom.xml @@ -17,8 +17,8 @@ eladmin-generator - EL-ADMIN 后台管理 - https://el-admin.vip + ELADMIN 后台管理 + https://eladmin.vip org.springframework.boot From 62fab6e76ef7efb970219ccd12362aab11670f82 Mon Sep 17 00:00:00 2001 From: yujr1990 <109193514+yujr1990@users.noreply.github.com> Date: Wed, 10 Aug 2022 11:12:55 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=88=A4=E6=96=AD=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @0001 @修改登录日志判断方式 Co-authored-by: yujr --- .../main/java/me/zhengjie/service/impl/LogServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java b/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java index 729a7930..6d2d6611 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java @@ -96,9 +96,9 @@ public class LogServiceImpl implements LogService { log.setUsername(username); log.setParams(getParameter(method, joinPoint.getArgs())); // 记录登录用户,隐藏密码信息 - if(log.getDescription().equals("用户登录")){ + if(signature.getName().equals("login") && StringUtils.isNotEmpty(log.getParams())){ JSONObject obj = JSONUtil.parseObj(log.getParams()); - log.setUsername(obj.get("username").toString()); + log.setUsername(obj.getStr("username", "")); log.setParams(JSONUtil.toJsonStr(Dict.create().set("username", log.getUsername()))); } log.setBrowser(browser); @@ -120,7 +120,7 @@ public class LogServiceImpl implements LogService { //将RequestParam注解修饰的参数作为请求参数 RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class); if (requestParam != null) { - Map map = new HashMap<>(4); + Map map = new HashMap<>(2); String key = parameters[i].getName(); if (!StringUtils.isEmpty(requestParam.value())) { key = requestParam.value(); From 164ce50bb097634bc7e666ac4b514e27a1a0e270 Mon Sep 17 00:00:00 2001 From: Zheng Jie <201507802@qq.com> Date: Tue, 30 Aug 2022 11:59:24 +0800 Subject: [PATCH 04/10] update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b7c3f34..62eb60cd 100644 --- a/README.md +++ b/README.md @@ -87,9 +87,9 @@ #### 特别鸣谢 -- 感谢 [JetBrains](https://www.jetbrains.com/) 提供的非商业开源软件开发授权 +- 感谢 [七牛云](https://portal.qiniu.com/signup?utm_source=kaiyuan&utm_media=ELADMIN) 提供的免费云存储与CDN加速支持 -- 感谢 [七牛云](https://www.qiniu.com/) 提供的免费云存储与CDN加速支持 +- 感谢 [JetBrains](https://www.jetbrains.com/) 提供的非商业开源软件开发授权 - 感谢 [PanJiaChen](https://github.com/PanJiaChen/vue-element-admin) 大佬提供的前端模板 From e0af08ebddc35cca0ac2fe401ffa415a00b9eb72 Mon Sep 17 00:00:00 2001 From: kdjj2006 Date: Mon, 24 Oct 2022 18:00:30 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86badsm?= =?UTF-8?q?ell:=E5=8C=85=E6=8B=AC=E7=A9=BA=E6=8C=87=E9=92=88=E9=A3=8E?= =?UTF-8?q?=E9=99=A9=E4=BB=A5=E5=8F=8A=E5=A4=9A=E6=AC=A1=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=9A=84=E6=8F=90=E5=8F=96=20(#772)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 获取验证码逻辑,无需加锁,不涉及线程安全问题,提高效率 * 自定义生成策略时,Map容量设置不准确,会导致无必要的扩容 * 优化badsmell:包括空指针以及多次使用变量的提取 * 修改优化部分badsmeall --- .../service/impl/GeneratorServiceImpl.java | 7 +++--- .../system/service/impl/MenuServiceImpl.java | 24 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java index 43255dfa..0341b115 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java @@ -59,6 +59,7 @@ public class GeneratorServiceImpl implements GeneratorService { private final ColumnInfoRepository columnInfoRepository; + private final String CONFIG_MESSAGE = "请先配置生成器"; @Override public Object getTables() { // 使用预编译防止sql注入 @@ -169,7 +170,7 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public void generator(GenConfig genConfig, List columns) { if (genConfig.getId() == null) { - throw new BadRequestException("请先配置生成器"); + throw new BadRequestException(CONFIG_MESSAGE); } try { GenUtil.generatorCode(columns, genConfig); @@ -182,7 +183,7 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public ResponseEntity preview(GenConfig genConfig, List columns) { if (genConfig.getId() == null) { - throw new BadRequestException("请先配置生成器"); + throw new BadRequestException(CONFIG_MESSAGE); } List> genList = GenUtil.preview(columns, genConfig); return new ResponseEntity<>(genList, HttpStatus.OK); @@ -191,7 +192,7 @@ public class GeneratorServiceImpl implements GeneratorService { @Override public void download(GenConfig genConfig, List columns, HttpServletRequest request, HttpServletResponse response) { if (genConfig.getId() == null) { - throw new BadRequestException("请先配置生成器"); + throw new BadRequestException(CONFIG_MESSAGE); } try { File file = new File(GenUtil.download(columns, genConfig)); 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 c1bc4d1f..ca8297e7 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 @@ -59,6 +59,12 @@ public class MenuServiceImpl implements MenuService { private final RoleService roleService; private final RedisUtils redisUtils; + private static final String HTTP_PRE = "http://"; + private static final String HTTPS_PRE = "https://"; + private static final String YES_STR = "是"; + private static final String NO_STR = "否"; + private static final String BAD_REQUEST = "外链必须以http://或者https://开头"; + @Override public List queryAll(MenuQueryCriteria criteria, Boolean isQuery) throws Exception { Sort sort = Sort.by(Sort.Direction.ASC, "menuSort"); @@ -114,13 +120,12 @@ public class MenuServiceImpl implements MenuService { throw new EntityExistException(Menu.class,"componentName",resources.getComponentName()); } } - if(resources.getPid().equals(0L)){ + if (Long.valueOf(0L).equals(resources.getPid())) { resources.setPid(null); } if(resources.getIFrame()){ - String http = "http://", https = "https://"; - if (!(resources.getPath().toLowerCase().startsWith(http)||resources.getPath().toLowerCase().startsWith(https))) { - throw new BadRequestException("外链必须以http://或者https://开头"); + if (!(resources.getPath().toLowerCase().startsWith(HTTP_PRE)||resources.getPath().toLowerCase().startsWith(HTTPS_PRE))) { + throw new BadRequestException(BAD_REQUEST); } } menuRepository.save(resources); @@ -140,9 +145,8 @@ public class MenuServiceImpl implements MenuService { ValidationUtil.isNull(menu.getId(),"Permission","id",resources.getId()); if(resources.getIFrame()){ - String http = "http://", https = "https://"; - if (!(resources.getPath().toLowerCase().startsWith(http)||resources.getPath().toLowerCase().startsWith(https))) { - throw new BadRequestException("外链必须以http://或者https://开头"); + if (!(resources.getPath().toLowerCase().startsWith(HTTP_PRE)||resources.getPath().toLowerCase().startsWith(HTTPS_PRE))) { + throw new BadRequestException(BAD_REQUEST); } } Menu menu1 = menuRepository.findByTitle(resources.getTitle()); @@ -322,9 +326,9 @@ public class MenuServiceImpl implements MenuService { map.put("菜单标题", menuDTO.getTitle()); map.put("菜单类型", menuDTO.getType() == null ? "目录" : menuDTO.getType() == 1 ? "菜单" : "按钮"); map.put("权限标识", menuDTO.getPermission()); - map.put("外链菜单", menuDTO.getIFrame() ? "是" : "否"); - map.put("菜单可见", menuDTO.getHidden() ? "否" : "是"); - map.put("是否缓存", menuDTO.getCache() ? "是" : "否"); + map.put("外链菜单", menuDTO.getIFrame() ? YES_STR : NO_STR); + map.put("菜单可见", menuDTO.getHidden() ? NO_STR : YES_STR); + map.put("是否缓存", menuDTO.getCache() ? YES_STR : NO_STR); map.put("创建日期", menuDTO.getCreateTime()); list.add(map); } From 7a7fb53ea71ab54aea7e7d4a0432832bd7cf54ab Mon Sep 17 00:00:00 2001 From: jiandan217 <1351066935@qq.com> Date: Mon, 24 Oct 2022 18:01:35 +0800 Subject: [PATCH 06/10] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=95=B0=E6=8D=AE=E9=AA=8C=E8=AF=81=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=20message=20(#771)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/handler/GlobalExceptionHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java index 56d73f7d..23cbb383 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java @@ -23,10 +23,11 @@ import me.zhengjie.utils.ThrowableUtil; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; -import java.util.Objects; import static org.springframework.http.HttpStatus.*; /** @@ -95,11 +96,10 @@ public class GlobalExceptionHandler { public ResponseEntity handleMethodArgumentNotValidException(MethodArgumentNotValidException e){ // 打印堆栈信息 log.error(ThrowableUtil.getStackTrace(e)); - String[] str = Objects.requireNonNull(e.getBindingResult().getAllErrors().get(0).getCodes())[1].split("\\."); - String message = e.getBindingResult().getAllErrors().get(0).getDefaultMessage(); - String msg = "不能为空"; - if(msg.equals(message)){ - message = str[1] + ":" + message; + ObjectError objectError = e.getBindingResult().getAllErrors().get(0); + String message = objectError.getDefaultMessage(); + if (objectError instanceof FieldError) { + message = ((FieldError) objectError).getField() + ": " + message; } return buildResponseEntity(ApiError.error(message)); } From a330519f6af7d323c164150c75aa5060d5f216e7 Mon Sep 17 00:00:00 2001 From: bearBoy80 <61624754+bearBoy80@users.noreply.github.com> Date: Mon, 24 Oct 2022 18:03:17 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E4=BC=98=E5=8C=96tomcat=E9=85=8D?= =?UTF-8?q?=E7=BD=AErelaxedQueryChars=E6=96=B9=E5=BC=8F,=E9=87=87=E7=94=A8?= =?UTF-8?q?TomcatConnectorCustomizer=E6=9D=A5=E5=AE=9E=E7=8E=B0=20(#764)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create RelaxedQueryCharsConnectorCustomizer * delete tomcat relaxedQueryChars code * 优化tomcat配置relaxedQueryChars方式 --- .../src/main/java/me/zhengjie/AppRun.java | 7 ------- .../config/RelaxedQueryCharsConnectorCustomizer | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 eladmin-system/src/main/java/me/zhengjie/config/RelaxedQueryCharsConnectorCustomizer diff --git a/eladmin-system/src/main/java/me/zhengjie/AppRun.java b/eladmin-system/src/main/java/me/zhengjie/AppRun.java index f16bf975..fa4d67ff 100644 --- a/eladmin-system/src/main/java/me/zhengjie/AppRun.java +++ b/eladmin-system/src/main/java/me/zhengjie/AppRun.java @@ -56,13 +56,6 @@ public class AppRun { return new SpringContextHolder(); } - @Bean - public ServletWebServerFactory webServerFactory() { - TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory(); - fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}")); - return fa; - } - /** * 访问首页提示 * diff --git a/eladmin-system/src/main/java/me/zhengjie/config/RelaxedQueryCharsConnectorCustomizer b/eladmin-system/src/main/java/me/zhengjie/config/RelaxedQueryCharsConnectorCustomizer new file mode 100644 index 00000000..2ca2ad47 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/config/RelaxedQueryCharsConnectorCustomizer @@ -0,0 +1,16 @@ +package me.zhengjie.config; + +import org.apache.catalina.connector.Connector; +import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; +import org.springframework.context.annotation.Configuration; + +/** + * @author bearBoy80 + */ +@Configuration(proxyBeanMethods = false) +public class RelaxedQueryCharsConnectorCustomizer implements TomcatConnectorCustomizer { + @Override + public void customize(Connector connector) { + connector.setProperty("relaxedQueryChars", "[]{}"); + } +} From f3cdf8ccfced849f902f58ac95c8b0bb48d68cb4 Mon Sep 17 00:00:00 2001 From: Zheng Jie <201507802@qq.com> Date: Mon, 24 Oct 2022 18:17:35 +0800 Subject: [PATCH 08/10] update org.apache.commons version --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 7dc9a3c6..18068474 100644 --- a/pom.xml +++ b/pom.xml @@ -185,6 +185,12 @@ 1.6.2 + + org.apache.commons + commons-text + 1.10.0 + + nl.basjes.parse.useragent From e6085ab0f6e388573f72595d98c85c6c6123768c Mon Sep 17 00:00:00 2001 From: Zheng Jie <201507802@qq.com> Date: Thu, 23 Mar 2023 14:08:12 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96=20ht?= =?UTF-8?q?tps://github.com/elunez/eladmin/pull/792=20https://github.com/e?= =?UTF-8?q?lunez/eladmin/pull/789?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/me/zhengjie/utils/QueryHelp.java | 6 ++++-- .../src/main/java/me/zhengjie/utils/RedisUtils.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java b/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java index 69cb5e24..671fff71 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java @@ -161,8 +161,10 @@ public class QueryHelp { break; case BETWEEN: List between = new ArrayList<>((List)val); - list.add(cb.between(getExpression(attributeName, join, root).as((Class) between.get(0).getClass()), - (Comparable) between.get(0), (Comparable) between.get(1))); + if(between.size() == 2){ + list.add(cb.between(getExpression(attributeName, join, root).as((Class) between.get(0).getClass()), + (Comparable) between.get(0), (Comparable) between.get(1))); + } break; default: break; } diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java index b49b3ca5..eb292ed9 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java @@ -185,7 +185,8 @@ public class RedisUtils { } else { Set keySet = new HashSet<>(); for (String key : keys) { - keySet.addAll(redisTemplate.keys(key)); + if (redisTemplate.hasKey(key)) + keySet.add(key); } long count = redisTemplate.delete(keySet); log.debug("--------------------------------------------"); From 19dea052371d4b3fe90650fa3f49d7bf0cff31a8 Mon Sep 17 00:00:00 2001 From: Zheng Jie <201507802@qq.com> Date: Mon, 17 Apr 2023 10:21:25 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=9A=84=E9=AA=8C=E8=AF=81=EF=BC=9A?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E6=8E=89=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=9D=9E=E6=B3=95=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/me/zhengjie/utils/FileUtil.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) 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 0d8d5fb4..ca2b674d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java @@ -182,7 +182,8 @@ public class FileUtil extends cn.hutool.core.io.FileUtil { public static File upload(MultipartFile file, String filePath) { Date date = new Date(); SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS"); - String name = getFileNameNoEx(file.getOriginalFilename()); + // 过滤非法文件名 + String name = getFileNameNoEx(verifyFilename(file.getOriginalFilename())); String suffix = getExtensionName(file.getOriginalFilename()); String nowStr = "-" + format.format(date); try { @@ -350,6 +351,44 @@ public class FileUtil extends cn.hutool.core.io.FileUtil { } } + /** + * 验证并过滤非法的文件名 + * @param fileName 文件名 + * @return 文件名 + */ + public static String verifyFilename(String fileName) { + // 过滤掉特殊字符 + fileName = fileName.replaceAll("[\\\\/:*?\"<>|~\\s]", ""); + + // 去掉文件名开头和结尾的空格和点 + fileName = fileName.trim().replaceAll("^[. ]+|[. ]+$", ""); + + // 不允许文件名超过255(在Mac和Linux中)或260(在Windows中)个字符 + int maxFileNameLength = 255; + if (System.getProperty("os.name").startsWith("Windows")) { + maxFileNameLength = 260; + } + if (fileName.length() > maxFileNameLength) { + fileName = fileName.substring(0, maxFileNameLength); + } + + // 过滤掉控制字符 + fileName = fileName.replaceAll("[\\p{Cntrl}]", ""); + + // 过滤掉 ".." 路径 + fileName = fileName.replaceAll("\\.{2,}", ""); + + // 去掉文件名开头的 ".." + fileName = fileName.replaceAll("^\\.+/", ""); + + // 保留文件名中最后一个 "." 字符,过滤掉其他 "." + fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") + + fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2"); + + return fileName; + } + + public static String getMd5(File file) { return getMd5(getByte(file)); }