oauth
This commit is contained in:
parent
98c210c386
commit
0a8c2b7b0b
|
|
@ -116,213 +116,6 @@ public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
||||||
@Lazy
|
@Lazy
|
||||||
private MgrUserBurialPointBusiness mgrUserBurialPointBusiness;
|
private MgrUserBurialPointBusiness mgrUserBurialPointBusiness;
|
||||||
|
|
||||||
// @Transactional(
|
|
||||||
// rollbackFor = {Exception.class}
|
|
||||||
// )
|
|
||||||
// public void addMgrUserInfo(MgrUserAdminAddDTO mgrUserAdminAddDTO) {
|
|
||||||
// this.usernameExistCheck(mgrUserAdminAddDTO.getUsername());
|
|
||||||
// this.phoneExistCheck(mgrUserAdminAddDTO.getPhone());
|
|
||||||
// MgrRoleAddDTO roleAddDTO = new MgrRoleAddDTO();
|
|
||||||
// roleAddDTO.setRoleName(RoleCodeV2Enum.ROLE_SUPER_ADMIN.value());
|
|
||||||
// roleAddDTO.setRoleDesc(RoleCodeV2Enum.ROLE_SUPER_ADMIN.value());
|
|
||||||
// roleAddDTO.setRoleType(MgrRoleTypeV2Enum.ROLE_ADMIN.getKey());
|
|
||||||
// roleAddDTO.setMenuList(mgrUserAdminAddDTO.getMenus());
|
|
||||||
// roleAddDTO.setAppMenuList(mgrUserAdminAddDTO.getAppMenus());
|
|
||||||
// Long roleId = this.mgrRoleService.addMgrRole(roleAddDTO);
|
|
||||||
// MgrUser mgrUser = new MgrUser();
|
|
||||||
// BeanUtil.copyProperties(mgrUserAdminAddDTO, mgrUser, new String[0]);
|
|
||||||
// mgrUser.setUserId(Id.next());
|
|
||||||
// this.setPhoneSuffix(mgrUser);
|
|
||||||
// this.mgrUserMapper.insert(mgrUser);
|
|
||||||
// Executors.doInSystem((status) -> {
|
|
||||||
// MgrUserInSystem mgrUserInSystem = (MgrUserInSystem)BeanUtil.copyProperties(mgrUser, MgrUserInSystem.class, new String[0]);
|
|
||||||
// mgrUserInSystem.setTenantId(TenantContextHolder.getTenantId());
|
|
||||||
// this.mgrUserInSystemMapper.insert(mgrUserInSystem);
|
|
||||||
// });
|
|
||||||
// MgrUserRole mgrUserRole = new MgrUserRole();
|
|
||||||
// mgrUserRole.setRoleId(roleId);
|
|
||||||
// mgrUserRole.setUserId(mgrUser.getUserId());
|
|
||||||
// this.mgrUserRoleMapper.insert(mgrUserRole);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void setPhoneSuffix(MgrUser mgrUser) {
|
|
||||||
// if (CharSequenceUtil.isNotBlank(mgrUser.getPhone())) {
|
|
||||||
// mgrUser.setPhoneSuffix(mgrUser.getPhone().substring(mgrUser.getPhone().length() - 4));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void usernameExistCheck(String username) {
|
|
||||||
// boolean isExist = (Boolean)Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.exists((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, username)).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// if (isExist) {
|
|
||||||
// log.info("用户名:{} 已存在", username);
|
|
||||||
// throw new LeException(I18n.getMessage("auth_same_username", new Object[0]));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void blockMgrUser() {
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)(new UpdateWrapper()).lambda().set(MgrUser::getLockFlag, 1));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addMgrUser(MgrUserAddDTO userAddDTO) {
|
|
||||||
// String username = userAddDTO.getUsername();
|
|
||||||
// if (CharSequenceUtil.isBlank(username)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_username", new Object[0]));
|
|
||||||
// } else if (ObjectUtil.isAllEmpty(new Object[]{userAddDTO.getAdminRoleId(), userAddDTO.getOrgRoleId(), userAddDTO.getMerchantRoleId()})) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_user_role_null", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// boolean isExist = ((MgrUserMapper)this.baseMapper).exists((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUser.class).eq(MgrUser::getDelFlag, DelFlagEnum.DEL_FALSE.key())).eq(MgrUser::getCustId, userAddDTO.getCustId()));
|
|
||||||
// if (isExist) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_same_cust", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// userAddDTO.setPhone(this.aesEncryptUtil.aesDecode(userAddDTO.getPhone()));
|
|
||||||
// this.usernameExistCheck(username);
|
|
||||||
// this.phoneExistCheck(this.aesEncryptUtil.aesDecode(userAddDTO.getPhone()));
|
|
||||||
// MgrUser user = new MgrUser();
|
|
||||||
// BeanUtil.copyProperties(userAddDTO, user, new String[0]);
|
|
||||||
// user.setUserId(Id.next());
|
|
||||||
// user.setPassword((new BCryptPasswordEncoder()).encode(this.aesEncryptUtil.aesDecode(userAddDTO.getPassword())));
|
|
||||||
// user.setCrby("");
|
|
||||||
// CustInfo custInfo = this.custInfoApi.getCustInfoByCustId(userAddDTO.getCustId());
|
|
||||||
// user.setAvatar(custInfo.getCustPhotoUrl());
|
|
||||||
// user.setPhone(userAddDTO.getPhone());
|
|
||||||
// user.setRealName(custInfo.getCustName());
|
|
||||||
// this.setPhoneSuffix(user);
|
|
||||||
// ((MgrUserMapper)this.baseMapper).insert(user);
|
|
||||||
// Executors.doInSystem((status) -> {
|
|
||||||
// MgrUserInSystem mgrUserInSystem = (MgrUserInSystem)BeanUtil.copyProperties(user, MgrUserInSystem.class, new String[0]);
|
|
||||||
// mgrUserInSystem.setTenantId(TenantContextHolder.getTenantId());
|
|
||||||
// this.mgrUserInSystemMapper.insert(mgrUserInSystem);
|
|
||||||
// });
|
|
||||||
// this.insertUserRoleBatch(userAddDTO.getAdminRoleId(), userAddDTO.getOrgRoleId(), userAddDTO.getMerchantRoleId(), userAddDTO.getDefaultRole(), user.getUserId());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void phoneExistCheck(String phone) {
|
|
||||||
// boolean isExist = (Boolean)Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.exists((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getPhone, SM4EncryptUtils.sm4Encryptbyconfig(phone))).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// if (isExist) {
|
|
||||||
// log.info("手机号:{} 已存在", phone);
|
|
||||||
// throw new LeException(I18n.getMessage("auth_same_phone", new Object[0]));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Page<MgrUserPageVO> getMgrUserPage(String content) {
|
|
||||||
// PageDTO pageDTO = QueryParseHelper.getPageFromContent(content);
|
|
||||||
// MgrUserPageDTO userPageDTO = (MgrUserPageDTO)QueryParseHelper.getParamFromContent(content, MgrUserPageDTO.class);
|
|
||||||
// userPageDTO.setDelFlag(DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// userPageDTO.setRoleCode(RoleCodeV2Enum.ROLE_ADMIN.key());
|
|
||||||
// userPageDTO.setAuthAreaIdList(this.mgrAuthApi.getTenantAreaIdList());
|
|
||||||
// Page<MgrUserPageVO> resultPage = ((MgrUserMapper)this.baseMapper).selectRolePage(Page.of(pageDTO.getCurrent(), pageDTO.getSize()), userPageDTO);
|
|
||||||
// List<MgrUserPageVO> records = resultPage.getRecords();
|
|
||||||
// log.info("数据库分页查询用户列表结果records : {}", records);
|
|
||||||
// if (ObjectUtil.isEmpty(records)) {
|
|
||||||
// return resultPage;
|
|
||||||
// } else {
|
|
||||||
// MercMerchant merchant = this.mercMerchantApi.getMerchant();
|
|
||||||
// List<Long> userIdList = (List)records.stream().map(MgrUserPageVO::getUserId).collect(Collectors.toList());
|
|
||||||
// List<MgrUserRolePageVO> userRoleList = this.mgrUserRoleMapper.getUserRoleVOByUserIdList(userIdList);
|
|
||||||
// Map<Long, List<MgrUserRolePageVO>> userRoleMap = (Map)userRoleList.stream().collect(Collectors.groupingBy(MgrUserRolePageVO::getUserId));
|
|
||||||
//
|
|
||||||
// MgrUserPageVO userPageVO;
|
|
||||||
// for(Iterator var10 = records.iterator(); var10.hasNext(); userPageVO.setRoleList((List)userRoleMap.get(userPageVO.getUserId()))) {
|
|
||||||
// userPageVO = (MgrUserPageVO)var10.next();
|
|
||||||
// String lockValue = (String)this.stringRedisTemplate.opsForValue().get("user-lock-" + userPageVO.getUsername());
|
|
||||||
// if (lockValue != null && Integer.parseInt(lockValue) >= 5) {
|
|
||||||
// userPageVO.setLockStatus(MgrUserLockStatusEnum.LOCK.key());
|
|
||||||
// } else {
|
|
||||||
// userPageVO.setLockStatus(MgrUserLockStatusEnum.NORMAL.key());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// userPageVO.setPhone(this.aesEncryptUtil.aesEncrypt(userPageVO.getPhone()));
|
|
||||||
// if (ObjectUtil.isNotNull(userPageVO.getAreaId()) && ObjectUtil.isEmpty(userPageVO.getAreaName())) {
|
|
||||||
// userPageVO.setAreaName(merchant.getMerchantName());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return resultPage;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void editMgrUser(MgrUserEditDTO userEditDTO) {
|
|
||||||
// if (CharSequenceUtil.isBlank(userEditDTO.getUsername())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_username", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// boolean isExist = ((MgrUserMapper)this.baseMapper).exists((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUser.class).eq(MgrUser::getDelFlag, DelFlagEnum.DEL_FALSE.key())).eq(MgrUser::getCustId, userEditDTO.getCustId())).ne(MgrUser::getUserId, userEditDTO.getUserId()));
|
|
||||||
// if (isExist) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_same_cust", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// List<MgrUserInSystem> userList = (List)Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.selectList((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, userEditDTO.getUsername())).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key())).ne(MgrUserInSystem::getUserId, userEditDTO.getUserId()));
|
|
||||||
// });
|
|
||||||
// if (CollUtil.isNotEmpty(userList)) {
|
|
||||||
// log.error("***[基础设置_用户角色及权限]_编辑用户_输入的用户名称重复,更新失败************");
|
|
||||||
// throw new LeException(RetCodeEnum.MGR_REPEAT_USER_NAME, I18n.getMessage("auth_same_username", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// userEditDTO.setPhone(this.aesEncryptUtil.aesDecode(userEditDTO.getPhone()));
|
|
||||||
// boolean isExistPhone = (Boolean)Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.exists((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getPhone, SM4EncryptUtils.sm4Encryptbyconfig(userEditDTO.getPhone()))).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key())).ne(MgrUserInSystem::getUserId, userEditDTO.getUserId()));
|
|
||||||
// });
|
|
||||||
// if (isExistPhone) {
|
|
||||||
// log.error("***[基础设置_用户角色及权限]_编辑用户_输入的手机号重复,更新失败************");
|
|
||||||
// throw new LeException(RetCodeEnum.MGR_REPEAT_USER_NAME, I18n.getMessage("auth_same_phone", new Object[0]));
|
|
||||||
// } else if (ObjectUtil.isAllEmpty(new Object[]{userEditDTO.getAdminRoleId(), userEditDTO.getOrgRoleId(), userEditDTO.getMerchantRoleId()})) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_user_role_null", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String username = SecurityUtils.getUser().getUsername();
|
|
||||||
// MgrUser user = new MgrUser();
|
|
||||||
// BeanUtil.copyProperties(userEditDTO, user, new String[0]);
|
|
||||||
// CustInfo custInfo = this.custInfoApi.getCustInfoByCustId(userEditDTO.getCustId());
|
|
||||||
// user.setAvatar(custInfo.getCustPhotoUrl());
|
|
||||||
// user.setPhone(userEditDTO.getPhone());
|
|
||||||
// user.setRealName(custInfo.getCustName());
|
|
||||||
// user.setUpby(username);
|
|
||||||
// user.setUptime(LocalDateTime.now());
|
|
||||||
// this.setPhoneSuffix(user);
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update(user, (Wrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(MgrUser::getUserId, userEditDTO.getUserId()));
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((MgrUserInSystem)BeanUtil.copyProperties(user, MgrUserInSystem.class, new String[0]), (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, userEditDTO.getUserId())).eq(MgrUserInSystem::getTenantId, TenantContextHolder.getTenantId()));
|
|
||||||
// });
|
|
||||||
// this.mgrUserRoleMapper.delete((Wrapper)Wrappers.lambdaQuery(MgrUserRole.class).eq(MgrUserRole::getUserId, userEditDTO.getUserId()));
|
|
||||||
// this.insertUserRoleBatch(userEditDTO.getAdminRoleId(), userEditDTO.getOrgRoleId(), userEditDTO.getMerchantRoleId(), userEditDTO.getDefaultRole(), user.getUserId());
|
|
||||||
// SecureManager.clearPermission(userEditDTO.getUserId());
|
|
||||||
// SecureManager.clearRole(userEditDTO.getUserId());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void removeByUserId(Long userId) {
|
|
||||||
// if (this.checkIfDeleteUser(userId)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_already_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(MgrUser::getUserId, userId)).set(MgrUser::getDelFlag, DelFlagEnum.DEL_TRUE.key()));
|
|
||||||
// this.mgrUserRoleMapper.delete((Wrapper)Wrappers.lambdaQuery(MgrUserRole.class).eq(MgrUserRole::getUserId, userId));
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, userId)).set(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_TRUE.key()));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void removeByCustId(Long custId) {
|
|
||||||
// Long userId = this.mgrUserMapper.selectUserIdByCustId(custId);
|
|
||||||
// if (!ObjectUtil.isNull(userId)) {
|
|
||||||
// this.removeByUserId(userId);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public boolean checkIfDeleteUser(Long userId) {
|
|
||||||
// int countBasicsDining = this.mgrUserMapper.checkCountBasicsDdiningUserId(userId);
|
|
||||||
// int countBasicsShopstalls = this.mgrUserMapper.checkBasicsShopstallsUserId(userId);
|
|
||||||
// int countDrpWarehouse = this.mgrUserMapper.checkDrpWarehouse(userId);
|
|
||||||
// return countBasicsDining > 0 || countBasicsShopstalls > 0 || countDrpWarehouse > 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public MgrUserInfo getUserInfoByUsername(String realUsername) throws Exception {
|
public MgrUserInfo getUserInfoByUsername(String realUsername) throws Exception {
|
||||||
MgrUserInSystem mgrUser = (MgrUserInSystem)Executors.readInSystem(() -> {
|
MgrUserInSystem mgrUser = (MgrUserInSystem)Executors.readInSystem(() -> {
|
||||||
return null; // (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, realUsername)).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
return null; // (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, realUsername)).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
||||||
|
|
@ -396,174 +189,12 @@ public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public MgrUserOpsPO authTempOpsUser() {
|
|
||||||
// Long merchantId = TenantContextHolder.getTenantId();
|
|
||||||
// MgrUserInSystem oldUserSystem = (MgrUserInSystem)Executors.readInSystem(() -> {
|
|
||||||
// return (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, String.valueOf(merchantId))).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// String password = CustomIdGenerateUtil.getRandomDigit(8);
|
|
||||||
// MgrUser user;
|
|
||||||
// if (ObjectUtil.isNotNull(oldUserSystem)) {
|
|
||||||
// user = new MgrUser();
|
|
||||||
// user.setPassword((new BCryptPasswordEncoder()).encode(password));
|
|
||||||
// user.setUpby(SecurityUtils.getUser().getUsername());
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update(user, (Wrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(MgrUser::getUserId, oldUserSystem.getUserId()));
|
|
||||||
// MgrUserInSystem userSystem = new MgrUserInSystem();
|
|
||||||
// BeanUtil.copyProperties(user, userSystem, new String[0]);
|
|
||||||
// userSystem.setEndTime(LocalDateTime.now().plusHours(24L));
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update(userSystem, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, oldUserSystem.getUserId())).eq(MgrUserInSystem::getTenantId, merchantId));
|
|
||||||
// });
|
|
||||||
// return new MgrUserOpsPO(String.valueOf(merchantId), password);
|
|
||||||
// } else {
|
|
||||||
// user = new MgrUser();
|
|
||||||
// user.setUserId(Id.next());
|
|
||||||
// user.setUsername(String.valueOf(merchantId));
|
|
||||||
// user.setPassword((new BCryptPasswordEncoder()).encode(password));
|
|
||||||
// user.setCrby("");
|
|
||||||
// ((MgrUserMapper)this.baseMapper).insert(user);
|
|
||||||
// Executors.doInSystem((status) -> {
|
|
||||||
// MgrUserInSystem userSystem = (MgrUserInSystem)BeanUtil.copyProperties(user, MgrUserInSystem.class, new String[0]);
|
|
||||||
// userSystem.setTenantId(merchantId);
|
|
||||||
// userSystem.setEndTime(LocalDateTime.now().plusHours(24L));
|
|
||||||
// this.mgrUserInSystemMapper.insert(userSystem);
|
|
||||||
// });
|
|
||||||
// MgrRole adminRole = (MgrRole)this.mgrRoleService.getOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().eq(MgrRole::getRoleCode, RoleCodeV2Enum.ROLE_ADMIN.key())).eq(MgrRole::getDelFlag, LeConstants.COMMON_NO));
|
|
||||||
// this.insertUserRoleBatch(adminRole.getRoleId(), (Long)null, (Long)null, (Integer)null, user.getUserId());
|
|
||||||
// return new MgrUserOpsPO(String.valueOf(merchantId), password);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public List<MgrRoleUserVO> getAllDeliveryUser() {
|
|
||||||
// MgrRoleUserDTO deliveryUserDTO = new MgrRoleUserDTO();
|
|
||||||
// deliveryUserDTO.setDelFlag(DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// deliveryUserDTO.setRoleCode(DefaultJobEnum.DELIVERY.getJobCode());
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).selectAllUserByRoleCode(deliveryUserDTO);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void changeMgrUserPassword(MgrUserChangePasswordDTO content) {
|
|
||||||
// if (!SecureManager.hasRole(new String[]{RoleCodeV2Enum.ROLE_SUPER_ADMIN.key()})) {
|
|
||||||
// log.error("***[用户权限_用户]_修改指定人员密码_登录的用户不是商家管理员,不可以修改密码*****************");
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_admin", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String password = content.getPassword();
|
|
||||||
// password = this.aesEncryptUtil.aesDecode(password);
|
|
||||||
// content.setUsername(this.aesEncryptUtil.aesDecode(content.getUsername()));
|
|
||||||
// String secretPassword = (new BCryptPasswordEncoder()).encode(password);
|
|
||||||
// Long tenantId = Objects.nonNull(content.getTenantId()) ? content.getTenantId() : TenantContextHolder.getTenantId();
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(Objects.nonNull(content.getUserId()), MgrUserInSystem::getUserId, content.getUserId())).eq(Objects.nonNull(content.getUsername()), MgrUserInSystem::getUsername, content.getUsername())).eq(MgrUserInSystem::getTenantId, tenantId)).set(MgrUserInSystem::getPassword, secretPassword)).set(MgrUserInSystem::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// });
|
|
||||||
// Executors.doInTenant(tenantId, () -> {
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(Objects.nonNull(content.getUserId()), MgrUser::getUserId, content.getUserId())).eq(Objects.nonNull(content.getUsername()), MgrUser::getUsername, content.getUsername())).set(MgrUser::getPassword, secretPassword)).set(MgrUser::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void changePasswordByOld(MgrUserChangePasswordByOldDTO content) {
|
|
||||||
// MgrUserInSystem user = (MgrUserInSystem) Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.selectPasswordByUserId((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, content.getUserId())).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// if (ObjectUtil.isNull(user)) {
|
|
||||||
// log.error("***[基础设置_用户角色及权限_用户]_根据旧密码修改密码_用户不存在**************");
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String oldPassword = content.getOldPassword();
|
|
||||||
// String newPassword = content.getNewPassword();
|
|
||||||
// oldPassword = this.aesEncryptUtil.aesDecode(oldPassword);
|
|
||||||
// newPassword = this.aesEncryptUtil.aesDecode(newPassword);
|
|
||||||
// if (!encoder.matches(oldPassword, user.getPassword())) {
|
|
||||||
// log.error("***[基础设置_用户角色及权限_用户]_根据旧密码修改密码_原密码输入错误**************");
|
|
||||||
// throw new LeException(I18n.getMessage("auth_error_old_password", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String password = encoder.encode(newPassword);
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, content.getUserId())).eq(MgrUserInSystem::getTenantId, TenantContextHolder.getTenantId())).set(MgrUserInSystem::getPassword, password)).set(MgrUserInSystem::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// });
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(MgrUser::getUserId, content.getUserId())).set(MgrUser::getPassword, password)).set(MgrUser::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public MgrUserDetailVO getUserDetailInfo() {
|
|
||||||
// Long userId = SecurityUtils.getUser().getId();
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).selectUserInfoByUserId(userId, DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public List<MgrRoleUserVO> getAllKeeperUserId() {
|
|
||||||
// MgrRoleUserDTO roleUserDTO = new MgrRoleUserDTO();
|
|
||||||
// roleUserDTO.setDelFlag(DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// roleUserDTO.setRoleCode(DefaultJobEnum.KEEPER.getJobCode());
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).selectAllUserByRoleCode(roleUserDTO);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public List<MgrRoleUserVO> getAllBuyerUserId() {
|
|
||||||
// MgrRoleUserDTO roleUserDTO = new MgrRoleUserDTO();
|
|
||||||
// roleUserDTO.setDelFlag(DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// roleUserDTO.setRoleCode(DefaultJobEnum.BUYER.getJobCode());
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).selectAllUserByRoleCode(roleUserDTO);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public List<MgrRoleUserVO> getAllUserByRoleCode(MgrRoleUserListDTO content) {
|
public List<MgrRoleUserVO> getAllUserByRoleCode(MgrRoleUserListDTO content) {
|
||||||
MgrRoleUserDTO roleUserDTO = new MgrRoleUserDTO();
|
MgrRoleUserDTO roleUserDTO = new MgrRoleUserDTO();
|
||||||
roleUserDTO.setDelFlag(DelFlagEnum.DEL_FALSE.key());
|
roleUserDTO.setDelFlag(DelFlagEnum.DEL_FALSE.key());
|
||||||
roleUserDTO.setRoleCode(content.getRoleCode());
|
roleUserDTO.setRoleCode(content.getRoleCode());
|
||||||
return ((MgrUserMapper)this.baseMapper).selectAllUserByRoleCode(roleUserDTO);
|
return ((MgrUserMapper)this.baseMapper).selectAllUserByRoleCode(roleUserDTO);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// private void insertUserRoleBatch(Long adminRoleId, Long orgRoleId, Long merchantRoleId, Integer defaultRole, Long userId) {
|
|
||||||
// if (ObjectUtil.isNotNull(adminRoleId)) {
|
|
||||||
// MgrUserRole userRole = new MgrUserRole();
|
|
||||||
// userRole.setRoleId(adminRoleId);
|
|
||||||
// userRole.setUserId(userId);
|
|
||||||
// userRole.setIfDefault(LeConstants.COMMON_YES);
|
|
||||||
// this.mgrUserRoleMapper.insert(userRole);
|
|
||||||
// } else {
|
|
||||||
// int isDefault;
|
|
||||||
// MgrUserRole userRole;
|
|
||||||
// if (ObjectUtil.isNotNull(orgRoleId)) {
|
|
||||||
// isDefault = ObjectUtil.equal(MgrRoleTypeV2Enum.ROLE_ORG.getKey(), defaultRole) ? LeConstants.COMMON_YES : LeConstants.COMMON_NO;
|
|
||||||
// userRole = new MgrUserRole();
|
|
||||||
// userRole.setRoleId(orgRoleId);
|
|
||||||
// userRole.setUserId(userId);
|
|
||||||
// userRole.setIfDefault(isDefault);
|
|
||||||
// this.mgrUserRoleMapper.insert(userRole);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (ObjectUtil.isNotNull(merchantRoleId)) {
|
|
||||||
// isDefault = ObjectUtil.equal(MgrRoleTypeV2Enum.ROLE_MERCHANT.getKey(), defaultRole) ? LeConstants.COMMON_YES : LeConstants.COMMON_NO;
|
|
||||||
// userRole = new MgrUserRole();
|
|
||||||
// userRole.setRoleId(merchantRoleId);
|
|
||||||
// userRole.setUserId(userId);
|
|
||||||
// userRole.setIfDefault(isDefault);
|
|
||||||
// this.mgrUserRoleMapper.insert(userRole);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public PigxUser padLogin(String machineSn, MgrUserLoginDTO loginDTO) throws LeCheckedException {
|
|
||||||
// PigxUser pigxUser = this.login(loginDTO);
|
|
||||||
// DeviceInfoVO deviceInfoVO = this.deviceApi.getDeviceInfoVoBySn(machineSn);
|
|
||||||
// Long canteenId = ((DeviceInfoVO.BindVO)deviceInfoVO.getBindList().get(0)).getCanteenId();
|
|
||||||
// List<AllocCanteenTreeVO> canteenTreeVOList = this.mgrAuthApi.getTenantCanteen((Integer)null);
|
|
||||||
// if (CollUtil.isEmpty(canteenTreeVOList)) {
|
|
||||||
// return pigxUser;
|
|
||||||
// } else {
|
|
||||||
// Iterator var7 = canteenTreeVOList.iterator();
|
|
||||||
//
|
|
||||||
// AllocCanteenTreeVO allocCanteenTreeVO;
|
|
||||||
// do {
|
|
||||||
// if (!var7.hasNext()) {
|
|
||||||
// throw new LeException("您无权限操作此设备");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// allocCanteenTreeVO = (AllocCanteenTreeVO)var7.next();
|
|
||||||
// } while(!AllocCanteenTreeTypeEnum.CANTEEN.getKey().equals(allocCanteenTreeVO.getTreeType()) || !allocCanteenTreeVO.getId().equals(canteenId));
|
|
||||||
//
|
|
||||||
// return pigxUser;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public PigxUser login(MgrUserLoginDTO loginDTO) throws Exception {
|
public PigxUser login(MgrUserLoginDTO loginDTO) throws Exception {
|
||||||
String realUsername = this.mgrUserBurialPointBusiness.didBeforeLogin(loginDTO);
|
String realUsername = this.mgrUserBurialPointBusiness.didBeforeLogin(loginDTO);
|
||||||
|
|
@ -672,399 +303,4 @@ public class MgrUserService extends ServiceImpl<MgrUserMapper, MgrUser> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public MgrUserInfoVO getMgrUserInfo(Long userId) {
|
|
||||||
// MgrUserDetailVO mgrUserDetailVO = ((MgrUserMapper)this.baseMapper).selectUserInfoByUserId(userId, DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// if (ObjectUtil.isNull(mgrUserDetailVO)) {
|
|
||||||
// return null;
|
|
||||||
// } else {
|
|
||||||
// MgrUserInfoVO infoVO = new MgrUserInfoVO();
|
|
||||||
// BeanUtil.copyProperties(mgrUserDetailVO, infoVO, new String[0]);
|
|
||||||
// infoVO.setPhone(this.aesEncryptUtil.aesEncrypt(infoVO.getPhone()));
|
|
||||||
// List<MgrUserRoleInfoVO> mgrUserRoleList = this.mgrUserRoleMapper.getMgrUserRoleListByUserId(userId);
|
|
||||||
// if (ObjectUtil.isEmpty(mgrUserRoleList)) {
|
|
||||||
// return infoVO;
|
|
||||||
// } else {
|
|
||||||
// Map<Integer, MgrUserRoleInfoVO> userRoleMap = (Map)mgrUserRoleList.stream().collect(Collectors.toMap(MgrUserRoleInfoVO::getRoleType, Function.identity(), (key1, key2) -> {
|
|
||||||
// return key2;
|
|
||||||
// }));
|
|
||||||
// Integer defaultRole = null;
|
|
||||||
// Iterator var7 = userRoleMap.entrySet().iterator();
|
|
||||||
//
|
|
||||||
// while(var7.hasNext()) {
|
|
||||||
// Map.Entry<Integer, MgrUserRoleInfoVO> entry = (Map.Entry)var7.next();
|
|
||||||
// Integer roleType = (Integer)entry.getKey();
|
|
||||||
// MgrUserRoleInfoVO role = (MgrUserRoleInfoVO)entry.getValue();
|
|
||||||
// if (ObjectUtil.equal(MgrRoleTypeV2Enum.ROLE_ADMIN.getKey(), roleType)) {
|
|
||||||
// infoVO.setAdminRoleId(role.getRoleId());
|
|
||||||
// } else {
|
|
||||||
// if (ObjectUtil.equal(MgrRoleTypeV2Enum.ROLE_ORG.getKey(), roleType)) {
|
|
||||||
// infoVO.setOrgRoleId(role.getRoleId());
|
|
||||||
// } else if (ObjectUtil.equal(MgrRoleTypeV2Enum.ROLE_MERCHANT.getKey(), roleType)) {
|
|
||||||
// infoVO.setMerchantRoleId(role.getRoleId());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (ObjectUtil.equal(LeConstants.COMMON_YES, role.getIfDefault())) {
|
|
||||||
// defaultRole = roleType;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// infoVO.setDefaultRole(defaultRole);
|
|
||||||
// return infoVO;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void updateDefaultRole(String roleCode) {
|
|
||||||
// Long userId = SecurityUtils.getUser().getId();
|
|
||||||
// if (!ObjectUtil.isNull(userId)) {
|
|
||||||
// this.mgrUserRoleMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserRole.class).set(MgrUserRole::getIfDefault, LeConstants.COMMON_NO)).eq(MgrUserRole::getUserId, userId));
|
|
||||||
// this.mgrUserRoleMapper.updateDefaultByRoleCode(roleCode, userId, LeConstants.COMMON_YES);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void changeRole(String roleCode) {
|
|
||||||
// Long userId = SecurityUtils.getUser().getId();
|
|
||||||
// if (!ObjectUtil.isNull(userId)) {
|
|
||||||
// List<MgrUserRoleInfoVO> userRoleList = this.mgrUserRoleMapper.getMgrUserRoleListByUserId(userId);
|
|
||||||
// if (ObjectUtil.isEmpty(userRoleList)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_role", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// List<String> roleCodeList = (List)userRoleList.stream().map(MgrUserRoleInfoVO::getRoleCode).collect(Collectors.toList());
|
|
||||||
// if (!roleCodeList.contains(roleCode)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_role_code", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// SecureManager.attachData("roleCode", roleCode);
|
|
||||||
// long subjectId = (Long)SecureManager.getSubjectId().orElse(LeConstants.DATA_DEFAULT_LONG);
|
|
||||||
// SecureManager.clearPermission(subjectId);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void updateMgrUserInfoByCustId(Long custId) {
|
|
||||||
// MgrUser user = (MgrUser)((MgrUserMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUser.class).select(new SFunction[]{MgrUser::getUserId}).eq(MgrUser::getCustId, custId)).eq(MgrUser::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// if (!ObjectUtil.isNull(user)) {
|
|
||||||
// CustInfo custInfo = this.custInfoApi.getCustInfoByCustId(custId);
|
|
||||||
// user.setAvatar(custInfo.getCustPhotoUrl());
|
|
||||||
// user.setPhone(custInfo.getMobile());
|
|
||||||
// user.setRealName(custInfo.getCustName());
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update(user, (Wrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(MgrUser::getCustId, custId));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public PigxUser webSingleSignOn(Long tenantId, MgrUserSsoDTO mgrUserSsoDTO) {
|
|
||||||
// try {
|
|
||||||
// WebSsoExtensionService webSsoExtensionService = this.customBizApi.getWebSsoExtensionService(tenantId);
|
|
||||||
// if (webSsoExtensionService == null) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_web_sso_adapter_empty", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// if (!webSsoExtensionService.ifSupportGetThirdWebUserInfoByCustomParams().support()) {
|
|
||||||
// JsonNode thirdTokenNode = ((GetThirdTokenVO)Optional.ofNullable(webSsoExtensionService.getThirdWebToken(mgrUserSsoDTO)).orElseThrow(() -> {
|
|
||||||
// return new LeException(I18n.getMessage("auth_web_sso_third_error", new Object[0]));
|
|
||||||
// })).getToken();
|
|
||||||
// mgrUserSsoDTO.setParams(thirdTokenNode);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// WebSsoVO webSsoVO = (WebSsoVO)Optional.ofNullable(webSsoExtensionService.getThirdWebUserInfo(mgrUserSsoDTO)).orElseThrow(() -> {
|
|
||||||
// return new LeException(I18n.getMessage("auth_web_sso_third_error", new Object[0]));
|
|
||||||
// });
|
|
||||||
// List<MgrUser> mgrUserList = (List)Optional.ofNullable(this.getMgrUserInSystemByParam(tenantId, webSsoVO)).orElseThrow(() -> {
|
|
||||||
// return new LeException(I18n.getMessage("auth_web_sso_user_empty", new Object[0]));
|
|
||||||
// });
|
|
||||||
// if (CollUtil.isEmpty(mgrUserList)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_web_sso_user_empty", new Object[0]));
|
|
||||||
// } else if (mgrUserList.size() > 1) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_web_sso_user_multiple", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// return this.getPigxUser(((MgrUser)mgrUserList.get(0)).getUsername());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (Throwable var6) {
|
|
||||||
// throw var6;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private List<MgrUser> getMgrUserInSystemByParam(Long tenantId, WebSsoVO webSsoVO) {
|
|
||||||
// if (ObjectUtil.isNull(webSsoVO) && CharSequenceUtil.isAllBlank(new CharSequence[]{webSsoVO.getMobile(), webSsoVO.getUsername()})) {
|
|
||||||
// return ListUtil.empty();
|
|
||||||
// } else {
|
|
||||||
// List<MgrUser> mgrUserList = (List)Executors.readInTenant(tenantId, () -> {
|
|
||||||
// return this.mgrUserMapper.selectList((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUser.class).eq(CharSequenceUtil.isNotBlank(webSsoVO.getMobile()), MgrUser::getPhone, SM4EncryptUtils.sm4Encryptbyconfig(webSsoVO.getMobile()))).eq(CharSequenceUtil.isNotBlank(webSsoVO.getUsername()), MgrUser::getUsername, webSsoVO.getUsername())).eq(MgrUser::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// return ObjectUtil.isNull(mgrUserList) ? ListUtil.empty() : mgrUserList;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public List<MgrRoleUserVO> getUserExcludeSupplier() {
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).getUserExcludeSupplier(DelFlagEnum.DEL_FALSE.key());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public JSONObject appAccountLogin(MgrUserLoginDTO loginDTO) throws LeCheckedException {
|
|
||||||
// PigxUser user = this.mgrUserBurialPointBusiness.didBeforeAppAccountLogin(loginDTO);
|
|
||||||
// if (ObjectUtil.isNull(user)) {
|
|
||||||
// user = this.login(loginDTO);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return this.appLoginDataHandler(user);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public JSONObject appMobileLogin(AppMobileUserLoginDTO loginDTO) throws LeCheckedException {
|
|
||||||
// String mobile = this.verifyCode(loginDTO);
|
|
||||||
// MgrUserInSystem mgrUser = this.getUserAndCheckMobile(mobile, false);
|
|
||||||
// TenantContextHolder.setTenantId(mgrUser.getTenantId());
|
|
||||||
// PigxUser user = this.getPigxUser(mgrUser.getUsername());
|
|
||||||
// return this.appLoginDataHandler(user);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public MgrUserInSystem getUserAndCheckMobile(String mobile, boolean ifNeedDecodeFlag) {
|
|
||||||
// if (ifNeedDecodeFlag) {
|
|
||||||
// mobile = this.aesEncryptUtil.aesDecode(mobile);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// MgrUserInSystem mgrUser = (MgrUserInSystem)Executors.readInSystem(() -> {
|
|
||||||
// return (MgrUserInSystem)this.mgrUserInSystemMapper.selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).and((i) -> {
|
|
||||||
// ((LambdaQueryWrapper)((LambdaQueryWrapper)i.eq(MgrUserInSystem::getPhone, mobile)).or()).eq(MgrUserInSystem::getPhone, SM4EncryptUtils.sm4Encryptbyconfig(mobile));
|
|
||||||
// })).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// if (ObjectUtil.isNull(mgrUser)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_mobile_not_exist", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// return mgrUser;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private String verifyCode(AppMobileUserLoginDTO loginDTO) {
|
|
||||||
// String mobile = this.aesEncryptUtil.aesDecode(loginDTO.getTelephoneNumber());
|
|
||||||
// String key = "code_" + mobile;
|
|
||||||
// String code = RedisUtil.getString(key);
|
|
||||||
// log.info("redis缓存验证码code : {}", code);
|
|
||||||
// if (code != null && code.equals(loginDTO.getCode())) {
|
|
||||||
// return mobile;
|
|
||||||
// } else {
|
|
||||||
// throw new LeException(I18n.getMessage("notice_verify_sms_code_exception", new Object[0]));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private JSONObject appLoginDataHandler(PigxUser user) {
|
|
||||||
// JSONObject object = JSON.parseObject(JSON.toJSONString(user));
|
|
||||||
// List<AllocCanteenAppVO> canteenList = this.allocCanteenApi.listAuthAppCanteen();
|
|
||||||
// if (CollUtil.isNotEmpty(canteenList)) {
|
|
||||||
// object.put("canteenId", ((AllocCanteenAppVO)canteenList.get(0)).getCanteenId());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// object.put("merchantName", this.mercMerchantApi.getMerchantName());
|
|
||||||
// return object;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public MrgUserAppVO getAppUserInfo(Long userId) {
|
|
||||||
// MrgUserAppVO appVO = new MrgUserAppVO();
|
|
||||||
// appVO.setUserId(userId);
|
|
||||||
// MgrUser mgrUser = (MgrUser)this.getOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().eq(MgrUser::getUserId, userId)).eq(MgrUser::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// CustInfo custInfo = this.custInfoApi.getCustInfoByCustId(mgrUser.getCustId());
|
|
||||||
// if (ObjectUtil.isNotNull(custInfo)) {
|
|
||||||
// appVO.setCustName(custInfo.getCustName());
|
|
||||||
// appVO.setCustPhotoUrl(custInfo.getCustPhotoUrl());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (CharSequenceUtil.isNotBlank(mgrUser.getAvatar())) {
|
|
||||||
// appVO.setCustPhotoUrl(mgrUser.getAvatar());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (CharSequenceUtil.isNotBlank(mgrUser.getPhone())) {
|
|
||||||
// appVO.setMobile(this.aesEncryptUtil.aesEncrypt(SM4EncryptUtils.desensitizedByConfig(mgrUser.getPhone(), DesensitizedType.MOBILE_PHONE)));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return appVO;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void modifyAppUserMobile(AppMobileUserLoginDTO mobileDTO) {
|
|
||||||
// String mobile = this.verifyCode(mobileDTO);
|
|
||||||
// Long userId = SecurityUtils.getUser().getId();
|
|
||||||
// this.update((Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).set(MgrUser::getPhone, SM4EncryptUtils.sm4Encryptbyconfig(mobile))).eq(MgrUser::getUserId, userId));
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).set(MgrUserInSystem::getPhone, SM4EncryptUtils.sm4Encryptbyconfig(mobile))).eq(MgrUserInSystem::getUserId, userId));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void modifyAppUserAvatar(AuthAppModifyAvatarDTO modifyDTO) {
|
|
||||||
// this.update((Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).set(MgrUser::getAvatar, modifyDTO.getCustPhotoUrl())).eq(MgrUser::getUserId, modifyDTO.getUserId()));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void appResetPassword(AuthAppResetPasswordDTO passwordDTO) {
|
|
||||||
// String password = passwordDTO.getPassword();
|
|
||||||
// password = this.aesEncryptUtil.aesDecode(password);
|
|
||||||
// String secretPassword = (new BCryptPasswordEncoder()).encode(password);
|
|
||||||
// Long tenantId = TenantContextHolder.getTenantId();
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(Objects.nonNull(passwordDTO.getUserId()), MgrUserInSystem::getUserId, passwordDTO.getUserId())).eq(MgrUserInSystem::getTenantId, tenantId)).set(MgrUserInSystem::getPassword, secretPassword)).set(MgrUserInSystem::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// });
|
|
||||||
// Executors.doInTenant(tenantId, () -> {
|
|
||||||
// return ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(Objects.nonNull(passwordDTO.getUserId()), MgrUser::getUserId, passwordDTO.getUserId())).set(MgrUser::getPassword, secretPassword)).set(MgrUser::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void appModifyPassword(AuthAppModifyPasswordDTO passwordDTO) {
|
|
||||||
// MgrUserInSystem user = (MgrUserInSystem)Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.selectPasswordByUserId((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, passwordDTO.getUserId())).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
|
||||||
// });
|
|
||||||
// if (ObjectUtil.isNull(user)) {
|
|
||||||
// log.error("***[基础设置_用户角色及权限_用户]_根据旧密码修改密码_用户不存在**************");
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String oldPassword = passwordDTO.getOldPassword();
|
|
||||||
// String newPassword = passwordDTO.getNewPassword();
|
|
||||||
// oldPassword = this.aesEncryptUtil.aesDecode(oldPassword);
|
|
||||||
// newPassword = this.aesEncryptUtil.aesDecode(newPassword);
|
|
||||||
// if (!encoder.matches(oldPassword, user.getPassword())) {
|
|
||||||
// log.error("***[基础设置_用户角色及权限_用户]_根据旧密码修改密码_原密码输入错误**************");
|
|
||||||
// throw new LeException(I18n.getMessage("auth_error_old_password", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String password = encoder.encode(newPassword);
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).eq(MgrUserInSystem::getUserId, passwordDTO.getUserId())).eq(MgrUserInSystem::getTenantId, TenantContextHolder.getTenantId())).set(MgrUserInSystem::getPassword, password)).set(MgrUserInSystem::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// });
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).eq(MgrUser::getUserId, passwordDTO.getUserId())).set(MgrUser::getPassword, password)).set(MgrUser::getEditFlag, LeConstants.COMMON_YES));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public List<String> getUserNameOrRoleName(List<String> userInfo) {
|
|
||||||
// List<String> listUser = CollUtil.newArrayList(new String[0]);
|
|
||||||
// List<String> userIds = (List)userInfo.stream().filter(CharSequenceUtil::isNumeric).collect(Collectors.toList());
|
|
||||||
// List mgrRoles;
|
|
||||||
// if (CollUtil.isNotEmpty(userIds)) {
|
|
||||||
// mgrRoles = this.mgrUserMapper.selectList((Wrapper)Wrappers.lambdaQuery(MgrUser.class).in(MgrUser::getUserId, userIds));
|
|
||||||
// listUser = (List)mgrRoles.stream().map(MgrUser::getUsername).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// mgrRoles = this.mgrRoleMapper.selectList((Wrapper)Wrappers.lambdaQuery(MgrRole.class).in(MgrRole::getRoleCode, userInfo));
|
|
||||||
// List<String> listRole = (List)mgrRoles.stream().map(MgrRole::getRoleName).collect(Collectors.toList());
|
|
||||||
// return (List)Stream.concat(((List)listUser).stream(), listRole.stream()).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public PigxUser deviceLogin(String machineSn, MgrDeviceUserLoginDTO loginDTO) throws LeCheckedException {
|
|
||||||
// if (ObjectUtil.equal(loginDTO.getGrant_type(), UserLoginGrantTypeEnum.PASSWORD.getType())) {
|
|
||||||
// if (CharSequenceUtil.isBlank(loginDTO.getUsername())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_login_username_is_null", new Object[0]));
|
|
||||||
// } else if (CharSequenceUtil.isBlank(loginDTO.getPassword())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_login_password_is_null", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// MgrUserLoginDTO mgrUserLoginDTO = new MgrUserLoginDTO();
|
|
||||||
// BeanUtil.copyProperties(loginDTO, mgrUserLoginDTO, new String[0]);
|
|
||||||
// return this.login(mgrUserLoginDTO);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// Long custId = this.checkOtherLoginParam(loginDTO);
|
|
||||||
// if (ObjectUtil.isNull(custId)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String realUserName = ((MgrUserMapper)this.baseMapper).selectUserNameIdByCustId(custId);
|
|
||||||
// if (ObjectUtil.isNull(realUserName)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// return this.getPigxUser(realUserName);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// protected Long checkOtherLoginParam(MgrDeviceUserLoginDTO loginDTO) {
|
|
||||||
// return UserLoginScopeEnum.isBackend(loginDTO.getScope()) ? this.checkBackendOtherLoginParam(loginDTO) : this.checkCustomerOtherLoginParam(loginDTO);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// protected Long checkCustomerOtherLoginParam(MgrDeviceUserLoginDTO loginDTO) {
|
|
||||||
// if (ObjectUtil.equal(loginDTO.getGrant_type(), UserLoginGrantTypeEnum.CREDIT.getType())) {
|
|
||||||
// if (CharSequenceUtil.isBlank(loginDTO.getSerialNum())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_serial_num_null", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// AccCard accCard = this.cardInfoServiceV4Api.getCardBaseInfoBySerialNum(loginDTO.getSerialNum());
|
|
||||||
// if (ObjectUtil.isNull(accCard)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_serial_num_null", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// return accCard.getCustId();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else if (ObjectUtil.equal(loginDTO.getGrant_type(), UserLoginGrantTypeEnum.FACE_RECOGNITION.getType())) {
|
|
||||||
// if (ObjectUtil.isNull(loginDTO.getCustId())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// return loginDTO.getCustId();
|
|
||||||
// }
|
|
||||||
// } else if (ObjectUtil.equal(loginDTO.getGrant_type(), UserLoginGrantTypeEnum.QRCODE.getType())) {
|
|
||||||
// if (CharSequenceUtil.isBlank(loginDTO.getAuthCode())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_auth_code_null", new Object[0]));
|
|
||||||
// } else if (LeCodeUtil.isLeCode(loginDTO.getAuthCode())) {
|
|
||||||
// OrdLeCodeDTO ordLeCodeDTO = LeCodeUtil.readLeCode(loginDTO.getAuthCode());
|
|
||||||
// return LeCodeUtil.getPlatformId(ordLeCodeDTO);
|
|
||||||
// } else {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_auth_code_nonrecognition", new Object[0]));
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_nuclear_mode_error", new Object[0]));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// protected Long checkBackendOtherLoginParam(MgrDeviceUserLoginDTO loginDTO) {
|
|
||||||
// Long staffId;
|
|
||||||
// if (ObjectUtil.equal(loginDTO.getGrant_type(), UserLoginGrantTypeEnum.CREDIT.getType())) {
|
|
||||||
// if (CharSequenceUtil.isBlank(loginDTO.getSerialNum())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_serial_num_null", new Object[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// BackStaffCard backStaffCard = this.backStaffApi.getBySerialNum(loginDTO.getSerialNum());
|
|
||||||
// if (ObjectUtil.isNull(backStaffCard)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_serial_num_null", new Object[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// staffId = backStaffCard.getStaffId();
|
|
||||||
// } else {
|
|
||||||
// if (!ObjectUtil.equal(loginDTO.getGrant_type(), UserLoginGrantTypeEnum.FACE_RECOGNITION.getType())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_nuclear_mode_error", new Object[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (ObjectUtil.isNull(loginDTO.getCustId())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// staffId = loginDTO.getCustId();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (ObjectUtil.isNull(staffId)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// List<BackStaffOrgDto> backStaffList = this.backStaffApi.listStaffInfoByStaffIdList(ListUtil.toList(new Long[]{staffId}));
|
|
||||||
// if (ObjectUtil.isEmpty(backStaffList)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// String custNum = ((BackStaffOrgDto)backStaffList.get(0)).getStaffNum();
|
|
||||||
// Long custId = this.custInfoApi.getCustIdByCustNum(custNum);
|
|
||||||
// if (ObjectUtil.isNull(custId)) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_other_login_not_user", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// return custId;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void appModifyUserName(AuthAppModifyUsernameDTO usernameDTO) {
|
|
||||||
// if (CharSequenceUtil.isBlank(usernameDTO.getUsername())) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_no_username", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// Long userId = SecurityUtils.getUser().getId();
|
|
||||||
// boolean flag = (Boolean)Executors.readInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.exists((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MgrUserInSystem.class).eq(MgrUserInSystem::getUsername, usernameDTO.getUsername())).eq(MgrUserInSystem::getDelFlag, DelFlagEnum.DEL_FALSE.key())).ne(MgrUserInSystem::getUserId, userId));
|
|
||||||
// });
|
|
||||||
// if (flag) {
|
|
||||||
// throw new LeException(I18n.getMessage("auth_same_username", new Object[0]));
|
|
||||||
// } else {
|
|
||||||
// ((MgrUserMapper)this.baseMapper).update((Object)null, (Wrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUser.class).set(MgrUser::getUsername, usernameDTO.getUsername())).eq(MgrUser::getUserId, userId));
|
|
||||||
// Executors.doInSystem(() -> {
|
|
||||||
// return this.mgrUserInSystemMapper.update((Object)null, (Wrapper)((LambdaUpdateWrapper)((LambdaUpdateWrapper)Wrappers.lambdaUpdate(MgrUserInSystem.class).set(MgrUserInSystem::getUsername, usernameDTO.getUsername())).eq(MgrUserInSystem::getUserId, userId)).eq(MgrUserInSystem::getTenantId, TenantContextHolder.getTenantId()));
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue