mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	Merge branch 'dev' into 2.0.x
# Conflicts: # README.md
This commit is contained in:
		| @@ -56,6 +56,7 @@ ContiNew Admin 中后台管理框架/脚手架,Continue New Admin,持续以 | |||||||
|  |  | ||||||
| - [x] 依赖升级:升级并适配 Spring Boot 3.x | - [x] 依赖升级:升级并适配 Spring Boot 3.x | ||||||
| - [x] 依赖升级:其他依赖升级 | - [x] 依赖升级:其他依赖升级 | ||||||
|  | - [x] 适配 Java 8 => Java 17 新 API 及特性 | ||||||
| - [ ] 计划对接 <a href="https://gitee.com/aizuda/flowlong" target="_blank">FlowLong</a> 纯国产工作流引擎 | - [ ] 计划对接 <a href="https://gitee.com/aizuda/flowlong" target="_blank">FlowLong</a> 纯国产工作流引擎 | ||||||
| - [ ] 其他需求汇集中... | - [ ] 其他需求汇集中... | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,9 +16,8 @@ | |||||||
|  |  | ||||||
| package top.charles7c.cnadmin.common.config.properties; | package top.charles7c.cnadmin.common.config.properties; | ||||||
|  |  | ||||||
| import lombok.Data; | import lombok.AccessLevel; | ||||||
|  | import lombok.NoArgsConstructor; | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
|  |  | ||||||
| import cn.hutool.extra.spring.SpringUtil; | import cn.hutool.extra.spring.SpringUtil; | ||||||
|  |  | ||||||
| @@ -29,8 +28,7 @@ import cn.hutool.extra.spring.SpringUtil; | |||||||
|  * @author Charles7c |  * @author Charles7c | ||||||
|  * @since 2022/12/21 20:21 |  * @since 2022/12/21 20:21 | ||||||
|  */ |  */ | ||||||
| @Data | @NoArgsConstructor(access = AccessLevel.PRIVATE) | ||||||
| @Component |  | ||||||
| public class RsaProperties { | public class RsaProperties { | ||||||
|  |  | ||||||
|     /** 私钥 */ |     /** 私钥 */ | ||||||
|   | |||||||
| @@ -20,11 +20,11 @@ import java.util.concurrent.ScheduledExecutorService; | |||||||
| import java.util.concurrent.ScheduledThreadPoolExecutor; | import java.util.concurrent.ScheduledThreadPoolExecutor; | ||||||
| import java.util.concurrent.ThreadPoolExecutor; | import java.util.concurrent.ThreadPoolExecutor; | ||||||
|  |  | ||||||
| import lombok.RequiredArgsConstructor; |  | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
|  |  | ||||||
| import org.apache.commons.lang3.concurrent.BasicThreadFactory; | import org.apache.commons.lang3.concurrent.BasicThreadFactory; | ||||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||||||
|  | import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||||||
| import org.springframework.context.annotation.Bean; | import org.springframework.context.annotation.Bean; | ||||||
| import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||||
| import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||||||
| @@ -40,10 +40,9 @@ import top.charles7c.cnadmin.common.util.ExceptionUtils; | |||||||
|  */ |  */ | ||||||
| @Slf4j | @Slf4j | ||||||
| @Configuration | @Configuration | ||||||
| @RequiredArgsConstructor | @EnableConfigurationProperties(ThreadPoolProperties.class) | ||||||
| public class ThreadPoolConfiguration { | public class ThreadPoolConfiguration { | ||||||
|  |  | ||||||
|     private final ThreadPoolProperties threadPoolProperties; |  | ||||||
|     /** 核心(最小)线程数 = CPU 核心数 + 1 */ |     /** 核心(最小)线程数 = CPU 核心数 + 1 */ | ||||||
|     private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1; |     private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1; | ||||||
|  |  | ||||||
| @@ -52,7 +51,7 @@ public class ThreadPoolConfiguration { | |||||||
|      */ |      */ | ||||||
|     @Bean |     @Bean | ||||||
|     @ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true") |     @ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true") | ||||||
|     public ThreadPoolTaskExecutor threadPoolTaskExecutor() { |     public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) { | ||||||
|         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||||||
|         // 核心(最小)线程数 |         // 核心(最小)线程数 | ||||||
|         executor.setCorePoolSize(corePoolSize); |         executor.setCorePoolSize(corePoolSize); | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package top.charles7c.cnadmin.common.config.threadpool; | |||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  |  | ||||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | import org.springframework.boot.context.properties.ConfigurationProperties; | ||||||
| import org.springframework.stereotype.Component; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 线程池配置属性 |  * 线程池配置属性 | ||||||
| @@ -29,7 +28,6 @@ import org.springframework.stereotype.Component; | |||||||
|  * @since 2022/12/23 23:06 |  * @since 2022/12/23 23:06 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| @Component |  | ||||||
| @ConfigurationProperties(prefix = "thread-pool") | @ConfigurationProperties(prefix = "thread-pool") | ||||||
| public class ThreadPoolProperties { | public class ThreadPoolProperties { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -45,6 +45,11 @@ public class StringConsts implements StrPool { | |||||||
|      */ |      */ | ||||||
|     public static final String ASTERISK = "*"; |     public static final String ASTERISK = "*"; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 问号 | ||||||
|  |      */ | ||||||
|  |     public static final String QUESTION_MARK = "?"; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 中文逗号 |      * 中文逗号 | ||||||
|      */ |      */ | ||||||
|   | |||||||
| @@ -25,6 +25,8 @@ import lombok.AccessLevel; | |||||||
| import lombok.NoArgsConstructor; | import lombok.NoArgsConstructor; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
|  |  | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 异常工具类 |  * 异常工具类 | ||||||
|  * |  * | ||||||
| @@ -98,7 +100,7 @@ public class ExceptionUtils { | |||||||
|      * @return / |      * @return / | ||||||
|      */ |      */ | ||||||
|     public static String exToBlank(ExSupplier<String> exSupplier) { |     public static String exToBlank(ExSupplier<String> exSupplier) { | ||||||
|         return exToDefault(exSupplier, ""); |         return exToDefault(exSupplier, StringConsts.EMPTY); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j; | |||||||
|  |  | ||||||
| import cn.hutool.core.util.StrUtil; | import cn.hutool.core.util.StrUtil; | ||||||
|  |  | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
| import top.charles7c.cnadmin.common.exception.ServiceException; | import top.charles7c.cnadmin.common.exception.ServiceException; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -52,8 +53,8 @@ public class CheckUtils extends Validator { | |||||||
|      *            字段值 |      *            字段值 | ||||||
|      */ |      */ | ||||||
|     public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) { |     public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) { | ||||||
|         String message = |         String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, | ||||||
|             String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil.replace(entityName, "DO", "")); |             StrUtil.replace(entityName, "DO", StringConsts.EMPTY)); | ||||||
|         throwIfNull(obj, message, EXCEPTION_TYPE); |         throwIfNull(obj, message, EXCEPTION_TYPE); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -47,6 +47,7 @@ import cn.hutool.http.HttpStatus; | |||||||
| import cn.hutool.json.JSONUtil; | import cn.hutool.json.JSONUtil; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.auth.model.request.LoginRequest; | import top.charles7c.cnadmin.auth.model.request.LoginRequest; | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
| import top.charles7c.cnadmin.common.constant.SysConsts; | import top.charles7c.cnadmin.common.constant.SysConsts; | ||||||
| import top.charles7c.cnadmin.common.model.dto.LogContext; | import top.charles7c.cnadmin.common.model.dto.LogContext; | ||||||
| import top.charles7c.cnadmin.common.util.ExceptionUtils; | import top.charles7c.cnadmin.common.util.ExceptionUtils; | ||||||
| @@ -170,7 +171,8 @@ public class LogInterceptor implements HandlerInterceptor { | |||||||
|         // (本框架代码规范)例如:@Tag(name = "部门管理 API") -> 部门管理 |         // (本框架代码规范)例如:@Tag(name = "部门管理 API") -> 部门管理 | ||||||
|         if (classTag != null) { |         if (classTag != null) { | ||||||
|             String name = classTag.name(); |             String name = classTag.name(); | ||||||
|             logDO.setModule(StrUtil.isNotBlank(name) ? name.replace("API", "").trim() : "请在该接口类上指定所属模块"); |             logDO | ||||||
|  |                 .setModule(StrUtil.isNotBlank(name) ? name.replace("API", StringConsts.EMPTY).trim() : "请在该接口类上指定所属模块"); | ||||||
|         } |         } | ||||||
|         // 例如:@Log(module = "部门管理") -> 部门管理 |         // 例如:@Log(module = "部门管理") -> 部门管理 | ||||||
|         if (classLog != null && StrUtil.isNotBlank(classLog.module())) { |         if (classLog != null && StrUtil.isNotBlank(classLog.module())) { | ||||||
| @@ -213,7 +215,7 @@ public class LogInterceptor implements HandlerInterceptor { | |||||||
|      */ |      */ | ||||||
|     private void logRequest(LogDO logDO, HttpServletRequest request) { |     private void logRequest(LogDO logDO, HttpServletRequest request) { | ||||||
|         logDO.setRequestUrl(StrUtil.isBlank(request.getQueryString()) ? request.getRequestURL().toString() |         logDO.setRequestUrl(StrUtil.isBlank(request.getQueryString()) ? request.getRequestURL().toString() | ||||||
|             : request.getRequestURL().append("?").append(request.getQueryString()).toString()); |             : request.getRequestURL().append(StringConsts.QUESTION_MARK).append(request.getQueryString()).toString()); | ||||||
|         logDO.setRequestMethod(request.getMethod()); |         logDO.setRequestMethod(request.getMethod()); | ||||||
|         logDO.setRequestHeaders(this.desensitize(JakartaServletUtil.getHeaderMap(request))); |         logDO.setRequestHeaders(this.desensitize(JakartaServletUtil.getHeaderMap(request))); | ||||||
|         String requestBody = this.getRequestBody(request); |         String requestBody = this.getRequestBody(request); | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ import org.springdoc.core.annotations.ParameterObject; | |||||||
| import org.springframework.format.annotation.DateTimeFormat; | import org.springframework.format.annotation.DateTimeFormat; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.common.annotation.Query; | import top.charles7c.cnadmin.common.annotation.Query; | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 登录日志查询条件 |  * 登录日志查询条件 | ||||||
| @@ -56,6 +57,6 @@ public class LoginLogQuery implements Serializable { | |||||||
|      */ |      */ | ||||||
|     @Schema(description = "登录时间") |     @Schema(description = "登录时间") | ||||||
|     @Query(type = Query.Type.BETWEEN) |     @Query(type = Query.Type.BETWEEN) | ||||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |     @DateTimeFormat(pattern = StringConsts.NORM_DATE_TIME_PATTERN) | ||||||
|     private List<Date> createTime; |     private List<Date> createTime; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ import org.springdoc.core.annotations.ParameterObject; | |||||||
| import org.springframework.format.annotation.DateTimeFormat; | import org.springframework.format.annotation.DateTimeFormat; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.common.annotation.Query; | import top.charles7c.cnadmin.common.annotation.Query; | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 操作日志查询条件 |  * 操作日志查询条件 | ||||||
| @@ -63,7 +64,7 @@ public class OperationLogQuery implements Serializable { | |||||||
|      */ |      */ | ||||||
|     @Schema(description = "操作时间") |     @Schema(description = "操作时间") | ||||||
|     @Query(type = Query.Type.BETWEEN) |     @Query(type = Query.Type.BETWEEN) | ||||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |     @DateTimeFormat(pattern = StringConsts.NORM_DATE_TIME_PATTERN) | ||||||
|     private List<Date> createTime; |     private List<Date> createTime; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ import org.springdoc.core.annotations.ParameterObject; | |||||||
| import org.springframework.format.annotation.DateTimeFormat; | import org.springframework.format.annotation.DateTimeFormat; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.common.annotation.Query; | import top.charles7c.cnadmin.common.annotation.Query; | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 系统日志查询条件 |  * 系统日志查询条件 | ||||||
| @@ -49,6 +50,6 @@ public class SystemLogQuery implements Serializable { | |||||||
|      */ |      */ | ||||||
|     @Schema(description = "创建时间") |     @Schema(description = "创建时间") | ||||||
|     @Query(type = Query.Type.BETWEEN) |     @Query(type = Query.Type.BETWEEN) | ||||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |     @DateTimeFormat(pattern = StringConsts.NORM_DATE_TIME_PATTERN) | ||||||
|     private List<Date> createTime; |     private List<Date> createTime; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -147,7 +147,7 @@ public class SaTokenRedisDaoImpl implements SaTokenDao { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) { |     public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) { | ||||||
|         Collection<String> keys = RedisUtils.keys(prefix + "*" + keyword + "*"); |         Collection<String> keys = RedisUtils.keys(String.format("%s*%s*", prefix, keyword)); | ||||||
|         List<String> list = new ArrayList<>(keys); |         List<String> list = new ArrayList<>(keys); | ||||||
|         return SaFoxUtil.searchList(list, start, size, sortType); |         return SaFoxUtil.searchList(list, start, size, sortType); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -28,6 +28,8 @@ import io.swagger.v3.oas.annotations.media.Schema; | |||||||
| import org.springdoc.core.annotations.ParameterObject; | import org.springdoc.core.annotations.ParameterObject; | ||||||
| import org.springframework.format.annotation.DateTimeFormat; | import org.springframework.format.annotation.DateTimeFormat; | ||||||
|  |  | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 在线用户查询条件 |  * 在线用户查询条件 | ||||||
|  * |  * | ||||||
| @@ -52,6 +54,6 @@ public class OnlineUserQuery implements Serializable { | |||||||
|      * 登录时间 |      * 登录时间 | ||||||
|      */ |      */ | ||||||
|     @Schema(description = "登录时间") |     @Schema(description = "登录时间") | ||||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |     @DateTimeFormat(pattern = StringConsts.NORM_DATE_TIME_PATTERN) | ||||||
|     private List<Date> loginTime; |     private List<Date> loginTime; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ import org.springdoc.core.annotations.ParameterObject; | |||||||
| import org.springframework.format.annotation.DateTimeFormat; | import org.springframework.format.annotation.DateTimeFormat; | ||||||
|  |  | ||||||
| import top.charles7c.cnadmin.common.annotation.Query; | import top.charles7c.cnadmin.common.annotation.Query; | ||||||
|  | import top.charles7c.cnadmin.common.constant.StringConsts; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 用户查询条件 |  * 用户查询条件 | ||||||
| @@ -63,7 +64,7 @@ public class UserQuery implements Serializable { | |||||||
|      */ |      */ | ||||||
|     @Schema(description = "创建时间") |     @Schema(description = "创建时间") | ||||||
|     @Query(type = Query.Type.BETWEEN) |     @Query(type = Query.Type.BETWEEN) | ||||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |     @DateTimeFormat(pattern = StringConsts.NORM_DATE_TIME_PATTERN) | ||||||
|     private List<Date> createTime; |     private List<Date> createTime; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -38,13 +38,12 @@ public interface RoleDeptService { | |||||||
|     boolean save(List<Long> deptIds, Long roleId); |     boolean save(List<Long> deptIds, Long roleId); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据角色 ID 查询 |      * 根据角色 ID 删除 | ||||||
|      * |      * | ||||||
|      * @param roleId |      * @param roleIds | ||||||
|      *            角色 ID |      *            角色 ID 列表 | ||||||
|      * @return 部门 ID 列表 |  | ||||||
|      */ |      */ | ||||||
|     List<Long> listDeptIdByRoleId(Long roleId); |     void deleteByRoleIds(List<Long> roleIds); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据部门 ID 删除 |      * 根据部门 ID 删除 | ||||||
| @@ -55,10 +54,11 @@ public interface RoleDeptService { | |||||||
|     void deleteByDeptIds(List<Long> deptIds); |     void deleteByDeptIds(List<Long> deptIds); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据角色 ID 删除 |      * 根据角色 ID 查询 | ||||||
|      * |      * | ||||||
|      * @param roleIds |      * @param roleId | ||||||
|      *            角色 ID 列表 |      *            角色 ID | ||||||
|  |      * @return 部门 ID 列表 | ||||||
|      */ |      */ | ||||||
|     void deleteByRoleIds(List<Long> roleIds); |     List<Long> listDeptIdByRoleId(Long roleId); | ||||||
| } | } | ||||||
| @@ -37,6 +37,14 @@ public interface RoleMenuService { | |||||||
|      */ |      */ | ||||||
|     boolean save(List<Long> menuIds, Long roleId); |     boolean save(List<Long> menuIds, Long roleId); | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 根据角色 ID 删除 | ||||||
|  |      * | ||||||
|  |      * @param roleIds | ||||||
|  |      *            角色 ID 列表 | ||||||
|  |      */ | ||||||
|  |     void deleteByRoleIds(List<Long> roleIds); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据角色 ID 查询 |      * 根据角色 ID 查询 | ||||||
|      * |      * | ||||||
| @@ -45,12 +53,4 @@ public interface RoleMenuService { | |||||||
|      * @return 菜单 ID 列表 |      * @return 菜单 ID 列表 | ||||||
|      */ |      */ | ||||||
|     List<Long> listMenuIdByRoleIds(List<Long> roleIds); |     List<Long> listMenuIdByRoleIds(List<Long> roleIds); | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 根据角色 ID 删除 |  | ||||||
|      * |  | ||||||
|      * @param roleIds |  | ||||||
|      *            角色 ID 列表 |  | ||||||
|      */ |  | ||||||
|     void deleteByRoleIds(List<Long> roleIds); |  | ||||||
| } | } | ||||||
| @@ -38,13 +38,12 @@ public interface UserRoleService { | |||||||
|     boolean save(List<Long> roleIds, Long userId); |     boolean save(List<Long> roleIds, Long userId); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据角色 ID 列表查询 |      * 根据用户 ID 删除 | ||||||
|      * |      * | ||||||
|      * @param roleIds |      * @param userIds | ||||||
|      *            角色 ID 列表 |      *            用户 ID 列表 | ||||||
|      * @return 总记录数 |  | ||||||
|      */ |      */ | ||||||
|     Long countByRoleIds(List<Long> roleIds); |     void deleteByUserIds(List<Long> userIds); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据用户 ID 查询 |      * 根据用户 ID 查询 | ||||||
| @@ -56,10 +55,11 @@ public interface UserRoleService { | |||||||
|     List<Long> listRoleIdByUserId(Long userId); |     List<Long> listRoleIdByUserId(Long userId); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * 根据用户 ID 删除 |      * 根据角色 ID 列表查询 | ||||||
|      * |      * | ||||||
|      * @param userIds |      * @param roleIds | ||||||
|      *            用户 ID 列表 |      *            角色 ID 列表 | ||||||
|  |      * @return 总记录数 | ||||||
|      */ |      */ | ||||||
|     void deleteByUserIds(List<Long> userIds); |     Long countByRoleIds(List<Long> roleIds); | ||||||
| } | } | ||||||
| @@ -22,6 +22,7 @@ import java.util.stream.Collectors; | |||||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||||
|  |  | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
| import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||||
|  |  | ||||||
| @@ -42,6 +43,7 @@ public class RoleDeptServiceImpl implements RoleDeptService { | |||||||
|     private final RoleDeptMapper roleDeptMapper; |     private final RoleDeptMapper roleDeptMapper; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public boolean save(List<Long> deptIds, Long roleId) { |     public boolean save(List<Long> deptIds, Long roleId) { | ||||||
|         // 检查是否有变更 |         // 检查是否有变更 | ||||||
|         List<Long> oldDeptIdList = roleDeptMapper.lambdaQuery().select(RoleDeptDO::getDeptId) |         List<Long> oldDeptIdList = roleDeptMapper.lambdaQuery().select(RoleDeptDO::getDeptId) | ||||||
| @@ -58,17 +60,19 @@ public class RoleDeptServiceImpl implements RoleDeptService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<Long> listDeptIdByRoleId(Long roleId) { |     @Transactional(rollbackFor = Exception.class) | ||||||
|         return roleDeptMapper.selectDeptIdByRoleId(roleId); |     public void deleteByRoleIds(List<Long> roleIds) { | ||||||
|  |         roleDeptMapper.lambdaUpdate().in(RoleDeptDO::getRoleId, roleIds).remove(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void deleteByDeptIds(List<Long> deptIds) { |     public void deleteByDeptIds(List<Long> deptIds) { | ||||||
|         roleDeptMapper.lambdaUpdate().in(RoleDeptDO::getDeptId, deptIds).remove(); |         roleDeptMapper.lambdaUpdate().in(RoleDeptDO::getDeptId, deptIds).remove(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void deleteByRoleIds(List<Long> roleIds) { |     public List<Long> listDeptIdByRoleId(Long roleId) { | ||||||
|         roleDeptMapper.lambdaUpdate().in(RoleDeptDO::getRoleId, roleIds).remove(); |         return roleDeptMapper.selectDeptIdByRoleId(roleId); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -23,6 +23,7 @@ import java.util.stream.Collectors; | |||||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||||
|  |  | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
| import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||||
|  |  | ||||||
| @@ -43,6 +44,7 @@ public class RoleMenuServiceImpl implements RoleMenuService { | |||||||
|     private final RoleMenuMapper roleMenuMapper; |     private final RoleMenuMapper roleMenuMapper; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public boolean save(List<Long> menuIds, Long roleId) { |     public boolean save(List<Long> menuIds, Long roleId) { | ||||||
|         // 检查是否有变更 |         // 检查是否有变更 | ||||||
|         List<Long> oldMenuIdList = roleMenuMapper.lambdaQuery().select(RoleMenuDO::getMenuId) |         List<Long> oldMenuIdList = roleMenuMapper.lambdaQuery().select(RoleMenuDO::getMenuId) | ||||||
| @@ -58,6 +60,12 @@ public class RoleMenuServiceImpl implements RoleMenuService { | |||||||
|         return roleMenuMapper.insertBatch(roleMenuList); |         return roleMenuMapper.insertBatch(roleMenuList); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|  |     public void deleteByRoleIds(List<Long> roleIds) { | ||||||
|  |         roleMenuMapper.lambdaUpdate().in(RoleMenuDO::getRoleId, roleIds).remove(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public List<Long> listMenuIdByRoleIds(List<Long> roleIds) { |     public List<Long> listMenuIdByRoleIds(List<Long> roleIds) { | ||||||
|         if (CollUtil.isEmpty(roleIds)) { |         if (CollUtil.isEmpty(roleIds)) { | ||||||
| @@ -65,9 +73,4 @@ public class RoleMenuServiceImpl implements RoleMenuService { | |||||||
|         } |         } | ||||||
|         return roleMenuMapper.selectMenuIdByRoleIds(roleIds); |         return roleMenuMapper.selectMenuIdByRoleIds(roleIds); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void deleteByRoleIds(List<Long> roleIds) { |  | ||||||
|         roleMenuMapper.lambdaUpdate().in(RoleMenuDO::getRoleId, roleIds).remove(); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ import java.util.stream.Collectors; | |||||||
| import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||||
|  |  | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
| import cn.hutool.core.collection.CollUtil; | import cn.hutool.core.collection.CollUtil; | ||||||
|  |  | ||||||
| @@ -42,6 +43,7 @@ public class UserRoleServiceImpl implements UserRoleService { | |||||||
|     private final UserRoleMapper userRoleMapper; |     private final UserRoleMapper userRoleMapper; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public boolean save(List<Long> roleIds, Long userId) { |     public boolean save(List<Long> roleIds, Long userId) { | ||||||
|         // 检查是否有变更 |         // 检查是否有变更 | ||||||
|         List<Long> oldRoleIdList = userRoleMapper.lambdaQuery().select(UserRoleDO::getRoleId) |         List<Long> oldRoleIdList = userRoleMapper.lambdaQuery().select(UserRoleDO::getRoleId) | ||||||
| @@ -58,8 +60,9 @@ public class UserRoleServiceImpl implements UserRoleService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public Long countByRoleIds(List<Long> roleIds) { |     @Transactional(rollbackFor = Exception.class) | ||||||
|         return userRoleMapper.lambdaQuery().in(UserRoleDO::getRoleId, roleIds).count(); |     public void deleteByUserIds(List<Long> userIds) { | ||||||
|  |         userRoleMapper.lambdaUpdate().in(UserRoleDO::getUserId, userIds).remove(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -68,7 +71,7 @@ public class UserRoleServiceImpl implements UserRoleService { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void deleteByUserIds(List<Long> userIds) { |     public Long countByRoleIds(List<Long> roleIds) { | ||||||
|         userRoleMapper.lambdaUpdate().in(UserRoleDO::getUserId, userIds).remove(); |         return userRoleMapper.lambdaQuery().in(UserRoleDO::getRoleId, roleIds).count(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -185,6 +185,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void updateBasicInfo(UpdateBasicInfoRequest request, Long id) { |     public void updateBasicInfo(UpdateBasicInfoRequest request, Long id) { | ||||||
|         super.getById(id); |         super.getById(id); | ||||||
|         baseMapper.lambdaUpdate().set(UserDO::getNickname, request.getNickname()) |         baseMapper.lambdaUpdate().set(UserDO::getNickname, request.getNickname()) | ||||||
| @@ -218,6 +219,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void resetPassword(Long id) { |     public void resetPassword(Long id) { | ||||||
|         UserDO user = super.getById(id); |         UserDO user = super.getById(id); | ||||||
|         user.setPassword(SecureUtils.md5Salt(SysConsts.DEFAULT_PASSWORD, id.toString())); |         user.setPassword(SecureUtils.md5Salt(SysConsts.DEFAULT_PASSWORD, id.toString())); | ||||||
| @@ -226,6 +228,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserVO, | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void updateRole(UpdateUserRoleRequest request, Long id) { |     public void updateRole(UpdateUserRoleRequest request, Long id) { | ||||||
|         super.getById(id); |         super.getById(id); | ||||||
|         // 保存用户和角色关联 |         // 保存用户和角色关联 | ||||||
|   | |||||||
| @@ -84,7 +84,8 @@ public class UserCenterController { | |||||||
|         String rawNewPassword = |         String rawNewPassword = | ||||||
|             ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updatePasswordRequest.getNewPassword())); |             ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(updatePasswordRequest.getNewPassword())); | ||||||
|         ValidationUtils.throwIfBlank(rawNewPassword, "新密码解密失败"); |         ValidationUtils.throwIfBlank(rawNewPassword, "新密码解密失败"); | ||||||
|         ValidationUtils.throwIf(!ReUtil.isMatch(RegexConsts.PASSWORD, rawNewPassword), "密码长度 6 到 32 位,同时包含字母和数字"); |         ValidationUtils.throwIf(!ReUtil.isMatch(RegexConsts.PASSWORD, rawNewPassword), | ||||||
|  |             "密码长度为 6 到 32 位,可以包含字母、数字、下划线,特殊字符,同时包含字母和数字"); | ||||||
|  |  | ||||||
|         // 修改密码 |         // 修改密码 | ||||||
|         userService.updatePassword(rawOldPassword, rawNewPassword, LoginHelper.getUserId()); |         userService.updatePassword(rawOldPassword, rawNewPassword, LoginHelper.getUserId()); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user