Commit db7f9b02 authored by 施翔轲's avatar 施翔轲

优化新增租户时自动生成密码为八位数,大小写英文加数字

parent 4398f203
...@@ -136,8 +136,8 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -136,8 +136,8 @@ public class ISysTenantServiceImpl implements ISysTenantService {
@Override @Override
public boolean checkCompanyNameUnique(SysTenantBo bo) { public boolean checkCompanyNameUnique(SysTenantBo bo) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysTenant>() boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysTenant>()
.eq(SysTenant::getCompanyName, bo.getCompanyName()) .eq(SysTenant::getCompanyName, bo.getCompanyName())
.ne(ObjectUtil.isNotNull(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId())); .ne(ObjectUtil.isNotNull(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId()));
return !exist; return !exist;
} }
...@@ -151,7 +151,7 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -151,7 +151,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
// 获取所有租户编号 // 获取所有租户编号
List<String> tenantIds = baseMapper.selectObjs( List<String> tenantIds = baseMapper.selectObjs(
new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), Convert::toStr); new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), Convert::toStr);
String tenantId = generateTenantId(tenantIds); String tenantId = generateTenantId(tenantIds);
add.setTenantId(tenantId); add.setTenantId(tenantId);
boolean flag = baseMapper.insert(add) > 0; boolean flag = baseMapper.insert(add) > 0;
...@@ -204,9 +204,9 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -204,9 +204,9 @@ public class ISysTenantServiceImpl implements ISysTenantService {
String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID; String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID;
List<SysDictType> dictTypeList = dictTypeMapper.selectList( List<SysDictType> dictTypeList = dictTypeMapper.selectList(
new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getTenantId, defaultTenantId)); new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getTenantId, defaultTenantId));
List<SysDictData> dictDataList = dictDataMapper.selectList( List<SysDictData> dictDataList = dictDataMapper.selectList(
new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getTenantId, defaultTenantId)); new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getTenantId, defaultTenantId));
for (SysDictType dictType : dictTypeList) { for (SysDictType dictType : dictTypeList) {
dictType.setDictId(null); dictType.setDictId(null);
dictType.setTenantId(tenantId); dictType.setTenantId(tenantId);
...@@ -219,7 +219,7 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -219,7 +219,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
dictDataMapper.insertBatch(dictDataList); dictDataMapper.insertBatch(dictDataList);
List<SysConfig> sysConfigList = configMapper.selectList( List<SysConfig> sysConfigList = configMapper.selectList(
new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getTenantId, defaultTenantId)); new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getTenantId, defaultTenantId));
for (SysConfig config : sysConfigList) { for (SysConfig config : sysConfigList) {
config.setConfigId(null); config.setConfigId(null);
config.setTenantId(tenantId); config.setTenantId(tenantId);
...@@ -228,7 +228,11 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -228,7 +228,11 @@ public class ISysTenantServiceImpl implements ISysTenantService {
//租户新增成功,发送短信通知租户 //租户新增成功,发送短信通知租户
//此处暂用钉钉机器人模拟发送短信 //此处暂用钉钉机器人模拟发送短信
String content = "【央企数字经营管理系统通知】:" + bo.getCompanyName() + "您好,您已经成功注册央企数字经营管理系统,请使用手机号码登录,初始密码为" + password + "。友情提示:为了您的账号安全,请勿泄露密码。若需要修改密码,请联系管理员。"; String content = "【央企数字经营管理系统通知】:"
+ bo.getCompanyName()
+ "您好,您已经成功注册央企数字经营管理系统,请使用手机号码登录,初始密码为"
+ password
+ "。友情提示:为了您的账号安全,请勿泄露密码。若需要修改密码,请联系管理员。";
DingTalkUtil.sendDingTalkMsg(content); DingTalkUtil.sendDingTalkMsg(content);
System.out.println("👉🏻:" + content); System.out.println("👉🏻:" + content);
return true; return true;
...@@ -236,7 +240,7 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -236,7 +240,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
// 生成随机密码 // 生成随机密码
public static String generatePassword(int length) { public static String generatePassword(int length) {
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*_+="; String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
StringBuilder password = new StringBuilder(); StringBuilder password = new StringBuilder();
Random random = new Random(); Random random = new Random();
...@@ -359,7 +363,7 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -359,7 +363,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
public Boolean syncTenantPackage(String tenantId, Long packageId) { public Boolean syncTenantPackage(String tenantId, Long packageId) {
SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId); SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId);
List<SysRole> roles = roleMapper.selectList( List<SysRole> roles = roleMapper.selectList(
new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, tenantId)); new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, tenantId));
List<Long> roleIds = new ArrayList<>(roles.size() - 1); List<Long> roleIds = new ArrayList<>(roles.size() - 1);
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong); List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
roles.forEach(item -> { roles.forEach(item -> {
...@@ -379,7 +383,7 @@ public class ISysTenantServiceImpl implements ISysTenantService { ...@@ -379,7 +383,7 @@ public class ISysTenantServiceImpl implements ISysTenantService {
}); });
if (!roleIds.isEmpty()) { if (!roleIds.isEmpty()) {
roleMenuMapper.delete( roleMenuMapper.delete(
new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds)); new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds));
} }
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment