From b5b8d941f32395cf968cda40852382f2b0614a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=9F=E6=9B=BE=E4=B8=BA=E4=BD=A0=E3=80=81=E5=83=8F?= =?UTF-8?q?=E8=B6=85=E4=BA=BA?= <1553592282@qq.com> Date: Tue, 17 May 2022 02:08:37 +0000 Subject: [PATCH 01/14] =?UTF-8?q?update=20ruoyi-system/src/main/resources/?= =?UTF-8?q?mapper/system/SysOperLogMapper.xml.=20=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=E6=9F=A5=E4=B8=9A=E5=8A=A1=E7=B1=BB=E5=9E=8B=E4=B8=BA?= =?UTF-8?q?=E5=85=B6=E4=BB=96=EF=BC=88businessType=20=3D=200=EF=BC=89?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E6=97=B6=EF=BC=8C=E4=BC=9A=E6=9F=A5?= =?UTF-8?q?=E5=88=B0=E6=89=80=E6=9C=89=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原因:当参数为 Integer 类型 0 时,MyBatis 会把 0 当做空字符串处理 --- .../src/main/resources/mapper/system/SysOperLogMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml index 2359a49b..71a9ecb1 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -39,7 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND title like concat('%', #{title}, '%') - + AND business_type = #{businessType} From 4a0619cadb8d9c7647fcfc21ae7af103289b7646 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 20 May 2022 16:23:36 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E4=BC=98=E5=8C=96switch=20case=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/core/text/Convert.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java index 515cf0bc..165f40ac 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java @@ -562,17 +562,12 @@ public class Convert switch (valueStr) { case "true": - return true; - case "false": - return false; case "yes": - return true; case "ok": - return true; - case "no": - return false; case "1": return true; + case "false": + case "no": case "0": return false; default: From a92667c00093c4fa66a0b9602d8c18a35823571e Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 20 May 2022 16:23:52 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E4=B8=AD=E7=9A=84=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=80=BC=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/spring/SpringUtils.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java index 0d260442..2c251a91 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java @@ -143,4 +143,16 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC final String[] activeProfiles = getActiveProfiles(); return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null; } + + /** + * 获取配置文件中的值 + * + * @param key 配置文件的key + * @return 当前的配置文件的值 + * + */ + public static String getRequiredProperty(String key) + { + return applicationContext.getEnvironment().getRequiredProperty(key); + } } From 6805a96e533f56b86aaeecccc2693c6ff4064d31 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 20 May 2022 16:25:51 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=B3=9B=E5=9E=8B=E4=BD=BF=E5=85=B6=E7=9C=8B=E5=88=B0=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E5=B1=9E=E6=80=A7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/tool/TestController.java | 34 +++--- .../java/com/ruoyi/common/core/domain/R.java | 104 ++++++++++++++++++ 2 files changed, 122 insertions(+), 16 deletions(-) create mode 100644 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java index f1afe51c..c55f9749 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.R; import com.ruoyi.common.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -40,24 +40,24 @@ public class TestController extends BaseController @ApiOperation("获取用户列表") @GetMapping("/list") - public AjaxResult userList() + public R> userList() { List userList = new ArrayList(users.values()); - return AjaxResult.success(userList); + return R.ok(userList); } @ApiOperation("获取用户详细") @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @GetMapping("/{userId}") - public AjaxResult getUser(@PathVariable Integer userId) + public R getUser(@PathVariable Integer userId) { if (!users.isEmpty() && users.containsKey(userId)) { - return AjaxResult.success(users.get(userId)); + return R.ok(users.get(userId)); } else { - return error("用户不存在"); + return R.fail("用户不存在"); } } @@ -69,44 +69,46 @@ public class TestController extends BaseController @ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class) }) @PostMapping("/save") - public AjaxResult save(UserEntity user) + public R save(UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { - return error("用户ID不能为空"); + return R.fail("用户ID不能为空"); } - return AjaxResult.success(users.put(user.getUserId(), user)); + users.put(user.getUserId(), user); + return R.ok(); } @ApiOperation("更新用户") @PutMapping("/update") - public AjaxResult update(@RequestBody UserEntity user) + public R update(@RequestBody UserEntity user) { if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) { - return error("用户ID不能为空"); + return R.fail("用户ID不能为空"); } if (users.isEmpty() || !users.containsKey(user.getUserId())) { - return error("用户不存在"); + return R.fail("用户不存在"); } users.remove(user.getUserId()); - return AjaxResult.success(users.put(user.getUserId(), user)); + users.put(user.getUserId(), user); + return R.ok(); } @ApiOperation("删除用户信息") @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @DeleteMapping("/{userId}") - public AjaxResult delete(@PathVariable Integer userId) + public R delete(@PathVariable Integer userId) { if (!users.isEmpty() && users.containsKey(userId)) { users.remove(userId); - return success(); + return R.ok(); } else { - return error("用户不存在"); + return R.fail("用户不存在"); } } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java new file mode 100644 index 00000000..4ce56f15 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java @@ -0,0 +1,104 @@ +package com.ruoyi.common.core.domain; + +import java.io.Serializable; + +/** + * 响应信息主体 + * + * @author ruoyi + */ +public class R implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 成功 */ + public static final int SUCCESS = 0; + + /** 失败 */ + public static final int FAIL = 500; + + private int code; + + private String msg; + + private T data; + + public static R ok() + { + return restResult(null, SUCCESS, "操作成功"); + } + + public static R ok(T data) + { + return restResult(data, SUCCESS, "操作成功"); + } + + public static R ok(T data, String msg) + { + return restResult(data, SUCCESS, msg); + } + + public static R fail() + { + return restResult(null, FAIL, "操作失败"); + } + + public static R fail(String msg) + { + return restResult(null, FAIL, msg); + } + + public static R fail(T data) + { + return restResult(data, FAIL, "操作失败"); + } + + public static R fail(T data, String msg) + { + return restResult(data, FAIL, msg); + } + + public static R fail(int code, String msg) + { + return restResult(null, code, msg); + } + + private static R restResult(T data, int code, String msg) + { + R apiResult = new R<>(); + apiResult.setCode(code); + apiResult.setData(data); + apiResult.setMsg(msg); + return apiResult; + } + + public int getCode() + { + return code; + } + + public void setCode(int code) + { + this.code = code; + } + + public String getMsg() + { + return msg; + } + + public void setMsg(String msg) + { + this.msg = msg; + } + + public T getData() + { + return data; + } + + public void setData(T data) + { + this.data = data; + } +} From da0309eb09fe1c99f49b1666712a8da24d67e09a Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 22 May 2022 18:21:26 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=99=90=E5=88=B6=E5=8F=AA=E8=83=BD=E4=B8=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/web/controller/system/SysProfileController.java | 6 +++--- .../common/exception/file/InvalidExtensionException.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index be515fd6..848c9ca3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -1,6 +1,5 @@ package com.ruoyi.web.controller.system; -import java.io.IOException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -21,6 +20,7 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.file.MimeTypeUtils; import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.system.service.ISysUserService; @@ -121,12 +121,12 @@ public class SysProfileController extends BaseController */ @Log(title = "用户头像", businessType = BusinessType.UPDATE) @PostMapping("/avatar") - public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException + public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception { if (!file.isEmpty()) { LoginUser loginUser = getLoginUser(); - String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); + String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION); if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) { AjaxResult ajax = AjaxResult.success(); diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java index 68195374..a483f46b 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java @@ -18,7 +18,7 @@ public class InvalidExtensionException extends FileUploadException public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { - super("filename : [" + filename + "], extension : [" + extension + "], allowed extension : [" + Arrays.toString(allowedExtension) + "]"); + super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传 [" + Arrays.toString(allowedExtension) + "]格式文件"); this.allowedExtension = allowedExtension; this.extension = extension; this.filename = filename; From 77fffda10e215f6dd1833e5509c7434c87f07489 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Mon, 23 May 2022 09:38:52 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=BE=A4?= =?UTF-8?q?=E5=8F=B7=EF=BC=9A139821253?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- ruoyi-ui/src/views/index.vue | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ba50d3ef..20ea55b8 100644 --- a/README.md +++ b/README.md @@ -94,4 +94,4 @@ ## 若依前后端分离交流群 -QQ群: [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/已满-101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [![加入QQ群](https://img.shields.io/badge/已满-264312783-blue.svg)](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [![加入QQ群](https://img.shields.io/badge/167385320-blue.svg)](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) 点击按钮入群。 \ No newline at end of file +QQ群: [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/已满-101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [![加入QQ群](https://img.shields.io/badge/已满-264312783-blue.svg)](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [![加入QQ群](https://img.shields.io/badge/已满-167385320-blue.svg)](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) [![加入QQ群](https://img.shields.io/badge/139821253-blue.svg)](https://jq.qq.com/?_wv=1027&k=njiWDmkj) 点击按钮入群。 \ No newline at end of file diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 3b725987..08eb055e 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -118,11 +118,11 @@ >

- QQ群:满937441 - 满887144332 满180251782 满104180207 满186866453 - 满201396349 满101456076 满101539465 满264312783 - - 167385320 QQ群:满937441 满887144332 + 满180251782 满104180207 满186866453 满201396349 + 满101456076 满101539465 满264312783 满167385320 + + 139821253

From 524ad4e6ddc04f2f0cfacb33f42c2f022629bbbb Mon Sep 17 00:00:00 2001 From: abbfun <819589789@qq.com> Date: Mon, 23 May 2022 07:36:18 +0000 Subject: [PATCH 07/14] =?UTF-8?q?fastjson=20=E7=89=88=E6=9C=AC=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=20fastjson=20<=3D=201.2.80=20=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E5=8F=8D=E5=BA=8F=E5=88=97=E5=8C=96=E4=BB=BB=E6=84=8F=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=89=A7=E8=A1=8C=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 62605294..e1730cb2 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 2.3.2 2.2.2 1.4.1 - 1.2.80 + 1.2.83 6.1.6 2.11.0 1.4 From 9fa3eac3aae9d29558c48acd0396b3f655706fb1 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 26 May 2022 09:02:32 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E5=8D=87=E7=BA=A7fastjson=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=882.0.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 ++--- ruoyi-common/pom.xml | 4 ++-- .../common/core/domain/model/LoginUser.java | 2 +- .../file/InvalidExtensionException.java | 2 +- .../ruoyi/common/utils/ip/AddressUtils.java | 5 ++-- .../ruoyi/framework/aspectj/LogAspect.java | 2 +- .../config/FastJson2JsonRedisSerializer.java | 23 ++++++++----------- .../interceptor/RepeatSubmitInterceptor.java | 4 ++-- .../impl/SameUrlDataInterceptor.java | 4 ++-- .../handle/AuthenticationEntryPointImpl.java | 2 +- .../handle/LogoutSuccessHandlerImpl.java | 2 +- .../service/GenTableServiceImpl.java | 8 +++---- .../ruoyi/generator/util/VelocityUtils.java | 9 ++++---- 13 files changed, 35 insertions(+), 38 deletions(-) diff --git a/pom.xml b/pom.xml index e1730cb2..053fdf7c 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 2.3.2 2.2.2 1.4.1 - 1.2.83 + 2.0.4 6.1.6 2.11.0 1.4 @@ -132,8 +132,8 @@ - com.alibaba - fastjson + com.alibaba.fastjson2 + fastjson2 ${fastjson.version} diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index 9999a26f..0e687a7d 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -61,8 +61,8 @@ - com.alibaba - fastjson + com.alibaba.fastjson2 + fastjson2 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java index 993ca226..41490e77 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -4,7 +4,7 @@ import java.util.Collection; import java.util.Set; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; -import com.alibaba.fastjson.annotation.JSONField; +import com.alibaba.fastjson2.annotation.JSONField; import com.ruoyi.common.core.domain.entity.SysUser; /** diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java index a483f46b..e70f6261 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java @@ -18,7 +18,7 @@ public class InvalidExtensionException extends FileUploadException public InvalidExtensionException(String[] allowedExtension, String extension, String filename) { - super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传 [" + Arrays.toString(allowedExtension) + "]格式文件"); + super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式"); this.allowedExtension = allowedExtension; this.extension = extension; this.filename = filename; diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java index 8b18da9f..f95766e4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java @@ -2,7 +2,8 @@ package com.ruoyi.common.utils.ip; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.utils.StringUtils; @@ -40,7 +41,7 @@ public class AddressUtils log.error("获取地理位置异常 {}", ip); return UNKNOWN; } - JSONObject obj = JSONObject.parseObject(rspStr); + JSONObject obj = JSON.parseObject(rspStr); String region = obj.getString("pro"); String city = obj.getString("city"); return String.format("%s %s", region, city); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index c9ce3225..3eb48065 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -14,7 +14,7 @@ import org.springframework.stereotype.Component; import org.springframework.validation.BindingResult; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.HandlerMapping; -import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson2.JSON; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.BusinessStatus; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java index 56bbdbfa..10902599 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java @@ -1,15 +1,15 @@ package com.ruoyi.framework.config; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.serializer.SerializerFeature; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; +import java.nio.charset.Charset; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; -import com.alibaba.fastjson.parser.ParserConfig; import org.springframework.util.Assert; -import java.nio.charset.Charset; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONReader; +import com.alibaba.fastjson2.JSONWriter; +import com.fasterxml.jackson.databind.JavaType; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; /** * Redis使用FastJson序列化 @@ -25,11 +25,6 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer private Class clazz; - static - { - ParserConfig.getGlobalInstance().setAutoTypeSupport(true); - } - public FastJson2JsonRedisSerializer(Class clazz) { super(); @@ -43,7 +38,7 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer { return new byte[0]; } - return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET); + return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET); } @Override @@ -55,7 +50,7 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer } String str = new String(bytes, DEFAULT_CHARSET); - return JSON.parseObject(str, clazz); + return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); } public void setObjectMapper(ObjectMapper objectMapper) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index 509e2873..05fff7bd 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -6,7 +6,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.ServletUtils; @@ -32,7 +32,7 @@ public abstract class RepeatSubmitInterceptor implements HandlerInterceptor if (this.isRepeatSubmit(request, annotation)) { AjaxResult ajaxResult = AjaxResult.error(annotation.message()); - ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); + ServletUtils.renderString(response, JSON.toJSONString(ajaxResult)); return false; } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java index b956b3f2..0c5a40d1 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.redis.RedisCache; @@ -50,7 +50,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor // body参数为空,获取Parameter的数据 if (StringUtils.isEmpty(nowParams)) { - nowParams = JSONObject.toJSONString(request.getParameterMap()); + nowParams = JSON.toJSONString(request.getParameterMap()); } Map nowDataMap = new HashMap(); nowDataMap.put(REPEAT_PARAMS, nowParams); diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java index bf9965d3..9d86feab 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java @@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; -import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson2.JSON; import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.ServletUtils; diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java index 1d5b1f9c..e58c332b 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java @@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; -import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson2.JSON; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.domain.AjaxResult; diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java index 71f2f8a5..1620995f 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java @@ -21,8 +21,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.GenConstants; import com.ruoyi.common.core.text.CharsetKit; @@ -401,7 +401,7 @@ public class GenTableServiceImpl implements IGenTableService if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { String options = JSON.toJSONString(genTable.getParams()); - JSONObject paramsObj = JSONObject.parseObject(options); + JSONObject paramsObj = JSON.parseObject(options); if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) { throw new ServiceException("树编码字段不能为空"); @@ -485,7 +485,7 @@ public class GenTableServiceImpl implements IGenTableService */ public void setTableFromOptions(GenTable genTable) { - JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions()); + JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); if (StringUtils.isNotNull(paramsObj)) { String treeCode = paramsObj.getString(GenConstants.TREE_CODE); diff --git a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java index 9ddf2650..733c7148 100644 --- a/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java @@ -5,7 +5,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.velocity.VelocityContext; -import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; import com.ruoyi.common.constant.GenConstants; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; @@ -75,7 +76,7 @@ public class VelocityUtils public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) { String options = genTable.getOptions(); - JSONObject paramsObj = JSONObject.parseObject(options); + JSONObject paramsObj = JSON.parseObject(options); String parentMenuId = getParentMenuId(paramsObj); context.put("parentMenuId", parentMenuId); } @@ -83,7 +84,7 @@ public class VelocityUtils public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) { String options = genTable.getOptions(); - JSONObject paramsObj = JSONObject.parseObject(options); + JSONObject paramsObj = JSON.parseObject(options); String treeCode = getTreecode(paramsObj); String treeParentCode = getTreeParentCode(paramsObj); String treeName = getTreeName(paramsObj); @@ -381,7 +382,7 @@ public class VelocityUtils public static int getExpandColumn(GenTable genTable) { String options = genTable.getOptions(); - JSONObject paramsObj = JSONObject.parseObject(options); + JSONObject paramsObj = JSON.parseObject(options); String treeName = paramsObj.getString(GenConstants.TREE_NAME); int num = 0; for (GenTableColumn column : genTable.getColumns()) From 63d471ec94ee540a1956fb5854bae679f66d8460 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 27 May 2022 08:37:14 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=BA=8F=E5=88=97=E5=8C=96=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/common/utils/DictUtils.java | 34 +++++++++++-------- .../config/FastJson2JsonRedisSerializer.java | 18 ---------- .../ruoyi/framework/config/RedisConfig.java | 10 ------ ruoyi-ui/src/utils/dict/DictMeta.js | 2 +- 4 files changed, 20 insertions(+), 44 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java index a6200f01..5a8554b4 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -2,6 +2,7 @@ package com.ruoyi.common.utils; import java.util.Collection; import java.util.List; +import com.alibaba.fastjson2.JSONArray; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.redis.RedisCache; @@ -38,10 +39,10 @@ public class DictUtils */ public static List getDictCache(String key) { - Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); - if (StringUtils.isNotNull(cacheObj)) + JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); + if (StringUtils.isNotNull(arrayCache)) { - return StringUtils.cast(cacheObj); + return arrayCache.toList(SysDictData.class); } return null; } @@ -83,27 +84,30 @@ public class DictUtils StringBuilder propertyString = new StringBuilder(); List datas = getDictCache(dictType); - if (StringUtils.containsAny(separator, dictValue) && StringUtils.isNotEmpty(datas)) + if (StringUtils.isNotNull(datas)) { - for (SysDictData dict : datas) + if (StringUtils.containsAny(separator, dictValue)) { - for (String value : dictValue.split(separator)) + for (SysDictData dict : datas) { - if (value.equals(dict.getDictValue())) + for (String value : dictValue.split(separator)) { - propertyString.append(dict.getDictLabel()).append(separator); - break; + if (value.equals(dict.getDictValue())) + { + propertyString.append(dict.getDictLabel()).append(separator); + break; + } } } } - } - else - { - for (SysDictData dict : datas) + else { - if (dictValue.equals(dict.getDictValue())) + for (SysDictData dict : datas) { - return dict.getDictLabel(); + if (dictValue.equals(dict.getDictValue())) + { + return dict.getDictLabel(); + } } } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java index 10902599..9503f258 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java @@ -3,13 +3,9 @@ package com.ruoyi.framework.config; import java.nio.charset.Charset; import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; -import org.springframework.util.Assert; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONReader; import com.alibaba.fastjson2.JSONWriter; -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.type.TypeFactory; /** * Redis使用FastJson序列化 @@ -18,9 +14,6 @@ import com.fasterxml.jackson.databind.type.TypeFactory; */ public class FastJson2JsonRedisSerializer implements RedisSerializer { - @SuppressWarnings("unused") - private ObjectMapper objectMapper = new ObjectMapper(); - public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); private Class clazz; @@ -52,15 +45,4 @@ public class FastJson2JsonRedisSerializer implements RedisSerializer return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); } - - public void setObjectMapper(ObjectMapper objectMapper) - { - Assert.notNull(objectMapper, "'objectMapper' must not be null"); - this.objectMapper = objectMapper; - } - - protected JavaType getJavaType(Class clazz) - { - return TypeFactory.defaultInstance().constructType(clazz); - } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java index fe1822f7..b188ac29 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java @@ -8,11 +8,6 @@ import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.data.redis.serializer.StringRedisSerializer; -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; /** * redis配置 @@ -32,11 +27,6 @@ public class RedisConfig extends CachingConfigurerSupport FastJson2JsonRedisSerializer serializer = new FastJson2JsonRedisSerializer(Object.class); - ObjectMapper mapper = new ObjectMapper(); - mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); - mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); - serializer.setObjectMapper(mapper); - // 使用StringRedisSerializer来序列化和反序列化redis的key值 template.setKeySerializer(new StringRedisSerializer()); template.setValueSerializer(serializer); diff --git a/ruoyi-ui/src/utils/dict/DictMeta.js b/ruoyi-ui/src/utils/dict/DictMeta.js index 8ae6133e..2ae08273 100644 --- a/ruoyi-ui/src/utils/dict/DictMeta.js +++ b/ruoyi-ui/src/utils/dict/DictMeta.js @@ -11,7 +11,7 @@ import DictOptions from './DictOptions' export default class DictMeta { constructor(options) { this.type = options.type - this.request = options.request, + this.request = options.request this.responseConverter = options.responseConverter this.labelField = options.labelField this.valueField = options.valueField From a29a0648ad1e51739eafb522685e2c2d7a66930f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 27 May 2022 08:37:34 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E5=8D=87=E7=BA=A7spring-boot=E5=88=B0?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC2.5.14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 053fdf7c..2992b837 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ org.springframework.boot spring-boot-dependencies - 2.5.13 + 2.5.14 pom import From 8a2e3d13f244e5eaabc649a8f02871363e66dd0c Mon Sep 17 00:00:00 2001 From: RuoYi Date: Fri, 27 May 2022 09:18:26 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/views/tool/build/RightPanel.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruoyi-ui/src/views/tool/build/RightPanel.vue b/ruoyi-ui/src/views/tool/build/RightPanel.vue index 88013a54..863d74c0 100644 --- a/ruoyi-ui/src/views/tool/build/RightPanel.vue +++ b/ruoyi-ui/src/views/tool/build/RightPanel.vue @@ -486,7 +486,7 @@ -