|
@@ -9,6 +9,7 @@ import api.common.pojo.vo.system.UserVO;
|
|
import api.common.util.EncryptUtil;
|
|
import api.common.util.EncryptUtil;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.ObjectUtil;
|
|
import api.common.util.StringUtil;
|
|
import api.common.util.StringUtil;
|
|
|
|
+import api.common.util.TencentSMSUtil;
|
|
import com.css.simulation.resource.common.oauth.OauthParameter;
|
|
import com.css.simulation.resource.common.oauth.OauthParameter;
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
import com.css.simulation.resource.common.utils.AuthUtil;
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
import com.css.simulation.resource.common.utils.PageUtil;
|
|
@@ -75,25 +76,26 @@ public class UserService {
|
|
return new PageInfo<>(list);
|
|
return new PageInfo<>(list);
|
|
}
|
|
}
|
|
|
|
|
|
- public UserPO saveUser(UserPO userPO) throws NoSuchAlgorithmException {
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
|
+ public UserPO saveUser(UserPO userPO) {
|
|
//权限校验
|
|
//权限校验
|
|
String currentUserRoleCode = AuthUtil.getCurrentUserRoleCode();
|
|
String currentUserRoleCode = AuthUtil.getCurrentUserRoleCode();
|
|
- if (DictConstants.ROLE_CODE_SYSADMIN.equals(currentUserRoleCode)) {//超级管理员
|
|
|
|
|
|
+ if (DictConstants.ROLE_CODE_SYSADMIN.equals(currentUserRoleCode)) {// 超级管理员
|
|
if (DictConstants.ROLE_CODE_ADMIN.equals(userPO.getRoleCode())) {
|
|
if (DictConstants.ROLE_CODE_ADMIN.equals(userPO.getRoleCode())) {
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_ADMIN);
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_ADMIN);
|
|
} else {
|
|
} else {
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_UESR);
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_UESR);
|
|
}
|
|
}
|
|
- } else if (DictConstants.ROLE_CODE_ADMIN.equals(currentUserRoleCode)) {//子管理员
|
|
|
|
|
|
+ } else if (DictConstants.ROLE_CODE_ADMIN.equals(currentUserRoleCode)) {// 子管理员
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_UESR);
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_UESR);
|
|
- } else if (DictConstants.ROLE_CODE_UESR.equals(currentUserRoleCode)) {//普通用户
|
|
|
|
|
|
+ } else if (DictConstants.ROLE_CODE_UESR.equals(currentUserRoleCode)) { //普通用户
|
|
//新增参数校验
|
|
//新增参数校验
|
|
if (ObjectUtil.isNull(userPO.getId())) {
|
|
if (ObjectUtil.isNull(userPO.getId())) {
|
|
ParameterVO parameter = parameterService.getParameterByUserId();
|
|
ParameterVO parameter = parameterService.getParameterByUserId();
|
|
if (ObjectUtil.isNull(parameter)) {
|
|
if (ObjectUtil.isNull(parameter)) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- int num = parameter.getNumCreateUser();//最大用户数
|
|
|
|
|
|
+ int num = parameter.getNumCreateUser(); // 最大用户数
|
|
int subUserNum = 0;
|
|
int subUserNum = 0;
|
|
String userId = AuthUtil.getCurrentUserId();
|
|
String userId = AuthUtil.getCurrentUserId();
|
|
List<UserPO> subUsers = userMapper.getSubUser(userId);
|
|
List<UserPO> subUsers = userMapper.getSubUser(userId);
|
|
@@ -106,7 +108,7 @@ public class UserService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
|
|
userPO.setRoleCode(DictConstants.ROLE_CODE_SUBUESR);
|
|
- //普通用户创建子账户时,占用类型继承
|
|
|
|
|
|
+ // 普通用户创建子账户时,占用类型继承
|
|
userPO.setUseType(AuthUtil.getCurrentUseType());
|
|
userPO.setUseType(AuthUtil.getCurrentUseType());
|
|
} else {
|
|
} else {
|
|
return null;
|
|
return null;
|
|
@@ -121,16 +123,28 @@ public class UserService {
|
|
String id = userPO.getId();
|
|
String id = userPO.getId();
|
|
if (ObjectUtil.isNull(id)) {//新增
|
|
if (ObjectUtil.isNull(id)) {//新增
|
|
userPO.setId(StringUtil.getRandomUUID());
|
|
userPO.setId(StringUtil.getRandomUUID());
|
|
- //初始密码
|
|
|
|
|
|
+ // 初始密码
|
|
userPO.setPassword(EncryptUtil.getLowerMD5(oauthParameter.getSimulationDefaultPassword()));
|
|
userPO.setPassword(EncryptUtil.getLowerMD5(oauthParameter.getSimulationDefaultPassword()));
|
|
userPO.setVisible("1");
|
|
userPO.setVisible("1");
|
|
userMapper.insert(userPO);
|
|
userMapper.insert(userPO);
|
|
logService.logUser(LogConstants.SYS_LOG_USER_INSERT, userPO);
|
|
logService.logUser(LogConstants.SYS_LOG_USER_INSERT, userPO);
|
|
|
|
+
|
|
|
|
+ // 发送短信
|
|
|
|
+ TencentSMSUtil.send(
|
|
|
|
+ smsConfiguration.getSecretId(),
|
|
|
|
+ smsConfiguration.getSecretKey(),
|
|
|
|
+ smsConfiguration.getSdkAppId(),
|
|
|
|
+ smsConfiguration.getSignName(),
|
|
|
|
+ smsConfiguration.getTemplateIdForCreate(),
|
|
|
|
+ new String[]{},
|
|
|
|
+ new String[]{userPO.getPhone()}
|
|
|
|
+ );
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
userMapper.update(userPO);
|
|
userMapper.update(userPO);
|
|
logService.logUser(LogConstants.SYS_LOG_USER_UPDATE, userPO);
|
|
logService.logUser(LogConstants.SYS_LOG_USER_UPDATE, userPO);
|
|
}
|
|
}
|
|
- //密码清空
|
|
|
|
|
|
+ // 密码清空
|
|
userPO.setPassword(null);
|
|
userPO.setPassword(null);
|
|
return userPO;
|
|
return userPO;
|
|
}
|
|
}
|
|
@@ -143,7 +157,15 @@ public class UserService {
|
|
logService.logUser(LogConstants.SYS_LOG_USER_RESET, userPO);
|
|
logService.logUser(LogConstants.SYS_LOG_USER_RESET, userPO);
|
|
|
|
|
|
// 发送短信
|
|
// 发送短信
|
|
-
|
|
|
|
|
|
+ TencentSMSUtil.send(
|
|
|
|
+ smsConfiguration.getSecretId(),
|
|
|
|
+ smsConfiguration.getSecretKey(),
|
|
|
|
+ smsConfiguration.getSdkAppId(),
|
|
|
|
+ smsConfiguration.getSignName(),
|
|
|
|
+ smsConfiguration.getTemplateIdForReset(),
|
|
|
|
+ new String[]{},
|
|
|
|
+ new String[]{userPO.getPhone()}
|
|
|
|
+ );
|
|
}
|
|
}
|
|
|
|
|
|
public void saveVisible(UserPO userPO) {
|
|
public void saveVisible(UserPO userPO) {
|