|
@@ -92,18 +92,19 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
|
* @return AdminUser 平台管理员
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(value = "systemTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public AdminUser add(AdminUserVO adminUserVO) {
|
|
|
- //校验密码格式
|
|
|
- boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
|
- if (!bool) {
|
|
|
- throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
|
|
|
- }
|
|
|
- DeptDO deptDO = deptMapper.selectById(adminUserVO.getDeptId());
|
|
|
- if (ObjectUtil.isNull(deptDO)) {
|
|
|
- throw new ServiceException("部门不存在");
|
|
|
- }
|
|
|
- adminUserVO.setRoleId(deptDO.getRoleId());
|
|
|
+// //校验密码格式
|
|
|
+// boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
|
+// if (!bool) {
|
|
|
+// throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
|
|
|
+// }
|
|
|
+ String psd = adminUserVO.getPassword();
|
|
|
+// DeptDO deptDO = deptMapper.selectById(adminUserVO.getDeptId());
|
|
|
+// if (ObjectUtil.isNull(deptDO)) {
|
|
|
+// throw new ServiceException("部门不存在");
|
|
|
+// }
|
|
|
+// adminUserVO.setRoleId(deptDO.getRoleId());
|
|
|
|
|
|
//校验用户名称是否重复
|
|
|
QueryWrapper<AdminUser> wrapper = new QueryWrapper<>();
|
|
@@ -130,22 +131,23 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
|
AdminUser adminUser = new AdminUser();
|
|
|
adminUser.setCompanyId(company.getId());
|
|
|
BeanUtil.copyProperties(adminUserVO, adminUser);
|
|
|
- adminUser.setPassword(StringUtil.md5(password));
|
|
|
+ adminUser.setPassword(StringUtil.md5(adminUserVO.getUsername()+password).toLowerCase());
|
|
|
adminUser.setDateLine(DateUtil.getDateline());
|
|
|
adminUser.setUserState(0);
|
|
|
+ adminUser.setFirstPassword(psd);
|
|
|
adminUser.setFounder(0);
|
|
|
adminUserMapper.insert(adminUser);
|
|
|
//发消息
|
|
|
List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
|
|
|
- msgUtilClient.sendSys(MsgContant.CREATE_USER_SYSTEM, adminUser, adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ msgUtilClient.sendSys(MsgContant.CREATE_USER_SYSTEM, adminUser, adminUser.getUsername(),psd);
|
|
|
if (companyBandMsg.contains(MsgContant.CREATE_USER_MAIL)){
|
|
|
- msgUtilClient.sendMail(MsgContant.CREATE_USER_MAIL, adminUser, adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ msgUtilClient.sendMail(MsgContant.CREATE_USER_MAIL, adminUser, adminUser.getUsername(),psd);
|
|
|
}
|
|
|
if (companyBandMsg.contains(MsgContant.CREATE_USER_SMS)){
|
|
|
- msgUtilClient.sendSms(MsgContant.CREATE_USER_SMS, adminUser, adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ msgUtilClient.sendSms(MsgContant.CREATE_USER_SMS, adminUser, adminUser.getUsername(),psd);
|
|
|
}
|
|
|
if (companyBandMsg.contains(MsgContant.CREATE_USER_OFFICIAL)){
|
|
|
- msgUtilClient.sendOfficial(MsgContant.CREATE_USER_OFFICIAL, adminUser, adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ msgUtilClient.sendOfficial(MsgContant.CREATE_USER_OFFICIAL, adminUser, adminUser.getUsername(),psd);
|
|
|
}
|
|
|
return adminUser;
|
|
|
}
|
|
@@ -165,11 +167,12 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
|
if (adminUser == null) {
|
|
|
throw new ResourceNotFoundException("需要修改的账号不存在");
|
|
|
}
|
|
|
- if ("admin".equals(adminUser.getUsername()) && !"admin".equals(adminUserVO.getUsername())) {
|
|
|
- throw new ServiceException("admin 登录名称不允许修改");
|
|
|
- }
|
|
|
+// if ("admin".equals(adminUser.getUsername()) && !"admin".equals(adminUserVO.getUsername())) {
|
|
|
+// throw new ServiceException("admin 登录名称不允许修改");
|
|
|
+// }
|
|
|
//管理员原密码
|
|
|
String password = adminUser.getPassword();
|
|
|
+ String newPassword ;
|
|
|
//对管理员是否修改密码进行校验
|
|
|
if (!StringUtil.isEmpty(adminUserVO.getPassword())) {
|
|
|
boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
@@ -177,26 +180,31 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
|
throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
|
|
|
}
|
|
|
adminUserVO.setPassword(StringUtil.md5(adminUserVO.getPassword()));
|
|
|
+ adminUserVO.setFirstPassword(adminUserVO.getPassword());
|
|
|
+ newPassword=adminUserVO.getPassword();
|
|
|
} else {
|
|
|
+ newPassword=adminUser.getFirstPassword();
|
|
|
adminUserVO.setPassword(password);
|
|
|
}
|
|
|
//修改管理员名称
|
|
|
adminUserVO.setUsername(adminUser.getUsername());
|
|
|
- BeanUtil.copyProperties(adminUserVO, adminUser);
|
|
|
- adminUserMapper.updateById(adminUser);
|
|
|
-
|
|
|
//发消息
|
|
|
- List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
|
|
|
+ List<String> companyBandMsg =new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotNull(adminUser.getCompanyId())){
|
|
|
+ companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
|
|
|
+ }
|
|
|
msgUtilClient.sendSys(MsgContant.UPDATE_USER_SYSTEM, adminUser, adminUser.getUsername(),adminUser.getPassword());
|
|
|
- if (companyBandMsg.contains(MsgContant.UPDATE_USER_MAIL)){
|
|
|
- msgUtilClient.sendMail(MsgContant.UPDATE_USER_MAIL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ if (companyBandMsg.contains(MsgContant.UPDATE_USER_MAIL) || AdminUserContext.hasFound()){
|
|
|
+ msgUtilClient.sendMail(MsgContant.UPDATE_USER_MAIL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
|
|
|
}
|
|
|
- if (companyBandMsg.contains(MsgContant.UPDATE_USER_SMS)){
|
|
|
- msgUtilClient.sendSms(MsgContant.UPDATE_USER_SMS, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ if (companyBandMsg.contains(MsgContant.UPDATE_USER_SMS) || AdminUserContext.hasFound()){
|
|
|
+ msgUtilClient.sendSms(MsgContant.UPDATE_USER_SMS, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
|
|
|
}
|
|
|
- if (companyBandMsg.contains(MsgContant.UPDATE_USER_OFFICIAL)){
|
|
|
- msgUtilClient.sendOfficial(MsgContant.UPDATE_USER_OFFICIAL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),adminUser.getPassword());
|
|
|
+ if (companyBandMsg.contains(MsgContant.UPDATE_USER_OFFICIAL) || AdminUserContext.hasFound()){
|
|
|
+ msgUtilClient.sendOfficial(MsgContant.UPDATE_USER_OFFICIAL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
|
|
|
}
|
|
|
+ BeanUtil.copyProperties(adminUserVO, adminUser);
|
|
|
+ adminUserMapper.updateById(adminUser);
|
|
|
return adminUser;
|
|
|
}
|
|
|
|
|
@@ -207,7 +215,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
|
* @param id 平台管理员主键
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(value = "systemTransactionManager", propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public void delete(Long id) {
|
|
|
//校验当前管理员是否存在
|
|
|
AdminUser adminUser = this.getModel(id);
|
|
@@ -268,7 +276,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
|
//查询管理员信息
|
|
|
LambdaQueryWrapper<AdminUser> queryWrapper = new LambdaQueryWrapper<AdminUser>()
|
|
|
.eq(AdminUser::getUsername, name)
|
|
|
- .eq(AdminUser::getPassword, password).eq(AdminUser::getUserState, 0);
|
|
|
+ .eq(AdminUser::getPassword, StringUtil.md5(name+password).toLowerCase()).eq(AdminUser::getUserState, 0);
|
|
|
if ("com".equals(type) && ObjectUtil.isNotNull(companyId)) {
|
|
|
queryWrapper.eq(AdminUser::getCompanyId, companyId);
|
|
|
}
|