This commit is contained in:
777
2025-08-12 10:01:54 +08:00
parent 3366148ca1
commit 10eea85347
3 changed files with 13 additions and 1 deletions

2
doc/2025-08-12.sql Normal file
View File

@@ -0,0 +1,2 @@
ALTER TABLE `cai_batch_add_user`
ADD COLUMN `password_type` int NOT NULL DEFAULT 1 COMMENT '1=规则生成 2-随机密码';

View File

@@ -49,6 +49,10 @@ public class BatchAddUser implements Serializable {
* 手机后缀起点(后4位)
*/
private Integer phoneSuffixStart;
/**
* 1-规则生成 2-随机密码
*/
private Integer passwordType;
/**
* 密码前缀
*/

View File

@@ -1,5 +1,6 @@
package com.ruoyi.cai.service.impl;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -82,7 +83,12 @@ public class BatchAddUserServiceImpl extends ServiceImpl<BatchAddUserMapper,Batc
log.error("新增用户:手机号非法 mobile={}",phone);
continue;
}
String password = String.format("%s%s", batchAddUser.getPasswordPrefix(), batchAddUser.getPasswordSuffixStart()+i);
String password = null;
if(batchAddUser.getPasswordType() == null || batchAddUser.getPasswordType() == 1){
password = String.format("%s%s", batchAddUser.getPasswordPrefix(), batchAddUser.getPasswordSuffixStart()+i);
}else{
password = RandomUtil.randomNumbers(8);
}
String code = systemConfigManager.getSystemConfig(SystemConfigEnum.SMS_CODE_ADMIN);
CaiRegisterUser registerUser = new CaiRegisterUser();
registerUser.setUsername(phone);