mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 18:28:43 +08:00 
			
		
		
		
	Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into develop
This commit is contained in:
		| @@ -23,9 +23,9 @@ public interface OperateLogApi { | ||||
|     /** | ||||
|      * 获取指定模块的指定数据的操作日志分页 | ||||
|      * | ||||
|      * @param pageReqVO 请求 | ||||
|      * @param pageReqDTO 请求 | ||||
|      * @return 操作日志分页 | ||||
|      */ | ||||
|     PageResult<OperateLogRespDTO> getOperateLogPage(OperateLogPageReqDTO pageReqVO); | ||||
|     PageResult<OperateLogRespDTO> getOperateLogPage(OperateLogPageReqDTO pageReqDTO); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.api.oauth2.dto; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| @@ -34,5 +35,9 @@ public class OAuth2AccessTokenCheckRespDTO implements Serializable { | ||||
|      * 授权范围的数组 | ||||
|      */ | ||||
|     private List<String> scopes; | ||||
|     /** | ||||
|      * 过期时间 | ||||
|      */ | ||||
|     private LocalDateTime expiresTime; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -14,7 +14,6 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode AUTH_LOGIN_USER_DISABLED = new ErrorCode(1_002_000_001, "登录失败,账号被禁用"); | ||||
|     ErrorCode AUTH_LOGIN_CAPTCHA_CODE_ERROR = new ErrorCode(1_002_000_004, "验证码不正确,原因:{}"); | ||||
|     ErrorCode AUTH_THIRD_LOGIN_NOT_BIND = new ErrorCode(1_002_000_005, "未绑定账号,需要进行绑定"); | ||||
|     ErrorCode AUTH_TOKEN_EXPIRED = new ErrorCode(1_002_000_006, "Token 已经过期"); | ||||
|     ErrorCode AUTH_MOBILE_NOT_EXISTS = new ErrorCode(1_002_000_007, "手机号不存在"); | ||||
|  | ||||
|     // ========== 菜单模块 1-002-001-000 ========== | ||||
| @@ -42,6 +41,7 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode USER_PASSWORD_FAILED = new ErrorCode(1_002_003_005, "用户密码校验失败"); | ||||
|     ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "名字为【{}】的用户已被禁用"); | ||||
|     ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过租户最大租户配额({})!"); | ||||
|     ErrorCode USER_IMPORT_INIT_PASSWORD = new ErrorCode(1_002_003_009, "初始密码不能为空"); | ||||
|  | ||||
|     // ========== 部门模块 1-002-004-000 ========== | ||||
|     ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门"); | ||||
| @@ -49,7 +49,6 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode DEPT_NOT_FOUND = new ErrorCode(1_002_004_002, "当前部门不存在"); | ||||
|     ErrorCode DEPT_EXITS_CHILDREN = new ErrorCode(1_002_004_003, "存在子部门,无法删除"); | ||||
|     ErrorCode DEPT_PARENT_ERROR = new ErrorCode(1_002_004_004, "不能设置自己为父部门"); | ||||
|     ErrorCode DEPT_EXISTS_USER = new ErrorCode(1_002_004_005, "部门中存在员工,无法删除"); | ||||
|     ErrorCode DEPT_NOT_ENABLE = new ErrorCode(1_002_004_006, "部门({})不处于开启状态,不允许选择"); | ||||
|     ErrorCode DEPT_PARENT_IS_CHILD = new ErrorCode(1_002_004_007, "不能设置自己的子部门为父部门"); | ||||
|  | ||||
| @@ -96,11 +95,8 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode SMS_CODE_NOT_FOUND = new ErrorCode(1_002_014_000, "验证码不存在"); | ||||
|     ErrorCode SMS_CODE_EXPIRED = new ErrorCode(1_002_014_001, "验证码已过期"); | ||||
|     ErrorCode SMS_CODE_USED = new ErrorCode(1_002_014_002, "验证码已使用"); | ||||
|     ErrorCode SMS_CODE_NOT_CORRECT = new ErrorCode(1_002_014_003, "验证码不正确"); | ||||
|     ErrorCode SMS_CODE_EXCEED_SEND_MAXIMUM_QUANTITY_PER_DAY = new ErrorCode(1_002_014_004, "超过每日短信发送数量"); | ||||
|     ErrorCode SMS_CODE_SEND_TOO_FAST = new ErrorCode(1_002_014_005, "短信发送过于频繁"); | ||||
|     ErrorCode SMS_CODE_IS_EXISTS = new ErrorCode(1_002_014_006, "手机号已被使用"); | ||||
|     ErrorCode SMS_CODE_IS_UNUSED = new ErrorCode(1_002_014_007, "验证码未被使用"); | ||||
|  | ||||
|     // ========== 租户信息 1-002-015-000 ========== | ||||
|     ErrorCode TENANT_NOT_EXISTS = new ErrorCode(1_002_015_000, "租户不存在"); | ||||
| @@ -140,7 +136,6 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode OAUTH2_GRANT_CLIENT_ID_MISMATCH = new ErrorCode(1_002_021_000, "client_id 不匹配"); | ||||
|     ErrorCode OAUTH2_GRANT_REDIRECT_URI_MISMATCH = new ErrorCode(1_002_021_001, "redirect_uri 不匹配"); | ||||
|     ErrorCode OAUTH2_GRANT_STATE_MISMATCH = new ErrorCode(1_002_021_002, "state 不匹配"); | ||||
|     ErrorCode OAUTH2_GRANT_CODE_NOT_EXISTS = new ErrorCode(1_002_021_003, "code 不存在"); | ||||
|  | ||||
|     // ========== OAuth2 授权 1-002-022-000 ========= | ||||
|     ErrorCode OAUTH2_CODE_NOT_EXISTS = new ErrorCode(1_002_022_000, "code 不存在"); | ||||
|   | ||||
| @@ -33,8 +33,8 @@ public class OperateLogApiImpl implements OperateLogApi { | ||||
|  | ||||
|     @Override | ||||
|     @TransMethodResult | ||||
|     public PageResult<OperateLogRespDTO> getOperateLogPage(OperateLogPageReqDTO pageReqVO) { | ||||
|         PageResult<OperateLogDO> operateLogPage = operateLogService.getOperateLogPage(pageReqVO); | ||||
|     public PageResult<OperateLogRespDTO> getOperateLogPage(OperateLogPageReqDTO pageReqDTO) { | ||||
|         PageResult<OperateLogDO> operateLogPage = operateLogService.getOperateLogPage(pageReqDTO); | ||||
|         return BeanUtils.toBean(operateLogPage, OperateLogRespDTO.class); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -74,8 +74,12 @@ public class SocialClientServiceImpl implements SocialClientService { | ||||
|  | ||||
|     /** | ||||
|      * 小程序版本 | ||||
|      * | ||||
|      * 1. release:正式版 | ||||
|      * 2. trial:体验版 | ||||
|      * 3. developer:开发版 | ||||
|      */ | ||||
|     @Value("${yudao.wxa-code.env-version}") | ||||
|     @Value("${yudao.wxa-code.env-version:release}") | ||||
|     public String envVersion; | ||||
|  | ||||
|     @Resource | ||||
|   | ||||
| @@ -9,7 +9,9 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; | ||||
| import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils; | ||||
| import cn.iocoder.yudao.module.infra.api.config.ConfigApi; | ||||
| import cn.iocoder.yudao.module.infra.api.file.FileApi; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; | ||||
| @@ -31,8 +33,8 @@ import com.mzt.logapi.context.LogRecordContext; | ||||
| import com.mzt.logapi.service.impl.DiffParseFunction; | ||||
| import com.mzt.logapi.starter.annotation.LogRecord; | ||||
| import jakarta.annotation.Resource; | ||||
| import jakarta.validation.ConstraintViolationException; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.security.crypto.password.PasswordEncoder; | ||||
| import org.springframework.stereotype.Service; | ||||
| @@ -57,8 +59,7 @@ import static cn.iocoder.yudao.module.system.enums.LogRecordConstants.*; | ||||
| @Slf4j | ||||
| public class AdminUserServiceImpl implements AdminUserService { | ||||
|  | ||||
|     @Value("${sys.user.init-password:yudaoyuanma}") | ||||
|     private String userInitPassword; | ||||
|     static final String USER_INIT_PASSWORD_KEY = "system.user.init-password"; | ||||
|  | ||||
|     @Resource | ||||
|     private AdminUserMapper userMapper; | ||||
| @@ -80,6 +81,8 @@ public class AdminUserServiceImpl implements AdminUserService { | ||||
|  | ||||
|     @Resource | ||||
|     private FileApi fileApi; | ||||
|     @Resource | ||||
|     private ConfigApi configApi; | ||||
|  | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) | ||||
| @@ -428,13 +431,28 @@ public class AdminUserServiceImpl implements AdminUserService { | ||||
|     @Override | ||||
|     @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入 | ||||
|     public UserImportRespVO importUserList(List<UserImportExcelVO> importUsers, boolean isUpdateSupport) { | ||||
|         // 1.1 参数校验 | ||||
|         if (CollUtil.isEmpty(importUsers)) { | ||||
|             throw exception(USER_IMPORT_LIST_IS_EMPTY); | ||||
|         } | ||||
|         // 1.2 初始化密码不能为空 | ||||
|         String initPassword = configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY); | ||||
|         if (StrUtil.isEmpty(initPassword)) { | ||||
|             throw exception(USER_IMPORT_INIT_PASSWORD); | ||||
|         } | ||||
|  | ||||
|         // 2. 遍历,逐个创建 or 更新 | ||||
|         UserImportRespVO respVO = UserImportRespVO.builder().createUsernames(new ArrayList<>()) | ||||
|                 .updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build(); | ||||
|         importUsers.forEach(importUser -> { | ||||
|             // 校验,判断是否有不符合的原因 | ||||
|             // 2.1.1 校验字段是否符合要求 | ||||
|             try { | ||||
|                 ValidationUtils.validate(BeanUtils.toBean(importUser, UserSaveReqVO.class).setPassword(initPassword)); | ||||
|             } catch (ConstraintViolationException ex){ | ||||
|                 respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage()); | ||||
|                 return; | ||||
|             } | ||||
|             // 2.1.2 校验,判断是否有不符合的原因 | ||||
|             try { | ||||
|                 validateUserForCreateOrUpdate(null, null, importUser.getMobile(), importUser.getEmail(), | ||||
|                         importUser.getDeptId(), null); | ||||
| @@ -442,15 +460,16 @@ public class AdminUserServiceImpl implements AdminUserService { | ||||
|                 respVO.getFailureUsernames().put(importUser.getUsername(), ex.getMessage()); | ||||
|                 return; | ||||
|             } | ||||
|             // 判断如果不存在,在进行插入 | ||||
|  | ||||
|             // 2.2.1 判断如果不存在,在进行插入 | ||||
|             AdminUserDO existUser = userMapper.selectByUsername(importUser.getUsername()); | ||||
|             if (existUser == null) { | ||||
|                 userMapper.insert(BeanUtils.toBean(importUser, AdminUserDO.class) | ||||
|                         .setPassword(encodePassword(userInitPassword)).setPostIds(new HashSet<>())); // 设置默认密码及空岗位编号数组 | ||||
|                         .setPassword(encodePassword(initPassword)).setPostIds(new HashSet<>())); // 设置默认密码及空岗位编号数组 | ||||
|                 respVO.getCreateUsernames().add(importUser.getUsername()); | ||||
|                 return; | ||||
|             } | ||||
|             // 如果存在,判断是否允许更新 | ||||
|             // 2.2.2 如果存在,判断是否允许更新 | ||||
|             if (!isUpdateSupport) { | ||||
|                 respVO.getFailureUsernames().put(importUser.getUsername(), USER_USERNAME_EXISTS.getMsg()); | ||||
|                 return; | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||
| import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||||
| import cn.iocoder.yudao.module.infra.api.config.ConfigApi; | ||||
| import cn.iocoder.yudao.module.infra.api.file.FileApi; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; | ||||
| @@ -23,6 +24,7 @@ import cn.iocoder.yudao.module.system.service.dept.DeptService; | ||||
| import cn.iocoder.yudao.module.system.service.dept.PostService; | ||||
| import cn.iocoder.yudao.module.system.service.permission.PermissionService; | ||||
| import cn.iocoder.yudao.module.system.service.tenant.TenantService; | ||||
| import org.junit.jupiter.api.BeforeEach; | ||||
| import org.junit.jupiter.api.Test; | ||||
| import org.mockito.stubbing.Answer; | ||||
| import org.springframework.boot.test.mock.mockito.MockBean; | ||||
| @@ -46,6 +48,7 @@ import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEq | ||||
| import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | ||||
| import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||||
| import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; | ||||
| import static cn.iocoder.yudao.module.system.service.user.AdminUserServiceImpl.USER_INIT_PASSWORD_KEY; | ||||
| import static java.util.Collections.singleton; | ||||
| import static java.util.Collections.singletonList; | ||||
| import static org.assertj.core.util.Lists.newArrayList; | ||||
| @@ -76,6 +79,14 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { | ||||
|     private TenantService tenantService; | ||||
|     @MockBean | ||||
|     private FileApi fileApi; | ||||
|     @MockBean | ||||
|     private ConfigApi configApi; | ||||
|  | ||||
|     @BeforeEach | ||||
|     public void before() { | ||||
|         // mock 初始化密码 | ||||
|         when(configApi.getConfigValueByKey(USER_INIT_PASSWORD_KEY)).thenReturn("yudaoyuanma"); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void testCreatUser_success() { | ||||
| @@ -419,6 +430,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { | ||||
|     public void testImportUserList_01() { | ||||
|         // 准备参数 | ||||
|         UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { | ||||
|             o.setEmail(randomEmail()); | ||||
|             o.setMobile(randomMobile()); | ||||
|         }); | ||||
|         // mock 方法,模拟失败 | ||||
|         doThrow(new ServiceException(DEPT_NOT_FOUND)).when(deptService).validateDeptList(any()); | ||||
| @@ -441,6 +454,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { | ||||
|         UserImportExcelVO importUser = randomPojo(UserImportExcelVO.class, o -> { | ||||
|             o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 | ||||
|             o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 | ||||
|             o.setEmail(randomEmail()); | ||||
|             o.setMobile(randomMobile()); | ||||
|         }); | ||||
|         // mock deptService 的方法 | ||||
|         DeptDO dept = randomPojo(DeptDO.class, o -> { | ||||
| @@ -475,6 +490,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { | ||||
|             o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 | ||||
|             o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 | ||||
|             o.setUsername(dbUser.getUsername()); | ||||
|             o.setEmail(randomEmail()); | ||||
|             o.setMobile(randomMobile()); | ||||
|         }); | ||||
|         // mock deptService 的方法 | ||||
|         DeptDO dept = randomPojo(DeptDO.class, o -> { | ||||
| @@ -505,6 +522,8 @@ public class AdminUserServiceImplTest extends BaseDbUnitTest { | ||||
|             o.setStatus(randomEle(CommonStatusEnum.values()).getStatus()); // 保证 status 的范围 | ||||
|             o.setSex(randomEle(SexEnum.values()).getSex()); // 保证 sex 的范围 | ||||
|             o.setUsername(dbUser.getUsername()); | ||||
|             o.setEmail(randomEmail()); | ||||
|             o.setMobile(randomMobile()); | ||||
|         }); | ||||
|         // mock deptService 的方法 | ||||
|         DeptDO dept = randomPojo(DeptDO.class, o -> { | ||||
|   | ||||
| @@ -46,8 +46,3 @@ mybatis: | ||||
| yudao: | ||||
|   info: | ||||
|     base-package: cn.iocoder.yudao.module | ||||
|   captcha: | ||||
|     timeout: 5m | ||||
|     width: 160 | ||||
|     height: 60 | ||||
|     enable: true | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV