|
@@ -79,7 +79,8 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
* @return WebPage
|
|
* @return WebPage
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public WebPage list(long page, long pageSize, String keyword, Integer userState,Long companyId) {
|
|
|
|
|
|
+ public WebPage list(long page, long pageSize, String keyword, Integer userState) {
|
|
|
|
+ Long companyId = AdminUserContext.getCompanyId();
|
|
IPage<AdminUserDTO> iPage = adminUserMapper.selectPageDto(new Page<>(page, pageSize), keyword, userState, AdminUserContext.getCompanyId());
|
|
IPage<AdminUserDTO> iPage = adminUserMapper.selectPageDto(new Page<>(page, pageSize), keyword, userState, AdminUserContext.getCompanyId());
|
|
|
|
|
|
return PageConvert.convert(iPage);
|
|
return PageConvert.convert(iPage);
|
|
@@ -92,7 +93,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
* @return AdminUser 平台管理员
|
|
* @return AdminUser 平台管理员
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public AdminUser add(AdminUserVO adminUserVO) {
|
|
public AdminUser add(AdminUserVO adminUserVO) {
|
|
// //校验密码格式
|
|
// //校验密码格式
|
|
// boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
// boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
@@ -131,7 +132,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
AdminUser adminUser = new AdminUser();
|
|
AdminUser adminUser = new AdminUser();
|
|
adminUser.setCompanyId(company.getId());
|
|
adminUser.setCompanyId(company.getId());
|
|
BeanUtil.copyProperties(adminUserVO, adminUser);
|
|
BeanUtil.copyProperties(adminUserVO, adminUser);
|
|
- adminUser.setPassword(StringUtil.md5(adminUserVO.getUsername()+password).toLowerCase());
|
|
|
|
|
|
+ adminUser.setPassword(StringUtil.md5(adminUserVO.getUsername() + password + company.getId()).toLowerCase());
|
|
adminUser.setDateLine(DateUtil.getDateline());
|
|
adminUser.setDateLine(DateUtil.getDateline());
|
|
adminUser.setUserState(0);
|
|
adminUser.setUserState(0);
|
|
adminUser.setFirstPassword(psd);
|
|
adminUser.setFirstPassword(psd);
|
|
@@ -139,15 +140,15 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
adminUserMapper.insert(adminUser);
|
|
adminUserMapper.insert(adminUser);
|
|
//发消息
|
|
//发消息
|
|
List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
|
|
List<String> companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(adminUser.getCompanyId());
|
|
- 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(),psd);
|
|
|
|
|
|
+ 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(), psd);
|
|
}
|
|
}
|
|
- if (companyBandMsg.contains(MsgContant.CREATE_USER_SMS)){
|
|
|
|
- msgUtilClient.sendSms(MsgContant.CREATE_USER_SMS, adminUser, adminUser.getUsername(),psd);
|
|
|
|
|
|
+ if (companyBandMsg.contains(MsgContant.CREATE_USER_SMS)) {
|
|
|
|
+ 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(),psd);
|
|
|
|
|
|
+ if (companyBandMsg.contains(MsgContant.CREATE_USER_OFFICIAL)) {
|
|
|
|
+ msgUtilClient.sendOfficial(MsgContant.CREATE_USER_OFFICIAL, adminUser, adminUser.getUsername(), psd);
|
|
}
|
|
}
|
|
return adminUser;
|
|
return adminUser;
|
|
}
|
|
}
|
|
@@ -160,7 +161,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
* @return AdminUser 平台管理员
|
|
* @return AdminUser 平台管理员
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public AdminUser edit(AdminUserVO adminUserVO, Long id) {
|
|
public AdminUser edit(AdminUserVO adminUserVO, Long id) {
|
|
//对要修改的管理员是否存在进行校验
|
|
//对要修改的管理员是否存在进行校验
|
|
AdminUser adminUser = this.getModel(id);
|
|
AdminUser adminUser = this.getModel(id);
|
|
@@ -172,36 +173,36 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
// }
|
|
// }
|
|
//管理员原密码
|
|
//管理员原密码
|
|
String password = adminUser.getPassword();
|
|
String password = adminUser.getPassword();
|
|
- String newPassword ;
|
|
|
|
|
|
+ String newPassword;
|
|
//对管理员是否修改密码进行校验
|
|
//对管理员是否修改密码进行校验
|
|
if (!StringUtil.isEmpty(adminUserVO.getPassword())) {
|
|
if (!StringUtil.isEmpty(adminUserVO.getPassword())) {
|
|
- boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
|
|
- if (!bool) {
|
|
|
|
- throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
|
|
|
|
- }
|
|
|
|
- adminUserVO.setPassword(StringUtil.md5(adminUserVO.getPassword()));
|
|
|
|
|
|
+// boolean bool = Pattern.matches("[a-fA-F0-9]{32}", adminUserVO.getPassword());
|
|
|
|
+// if (!bool) {
|
|
|
|
+// throw new ServiceException(SystemErrorCode.E917.code(), "密码格式不正确");
|
|
|
|
+// }
|
|
|
|
+ adminUserVO.setPassword(StringUtil.md5(adminUser.getUsername() + adminUserVO.getPassword() + adminUser.getCompanyId()));
|
|
adminUserVO.setFirstPassword(adminUserVO.getPassword());
|
|
adminUserVO.setFirstPassword(adminUserVO.getPassword());
|
|
- newPassword=adminUserVO.getPassword();
|
|
|
|
|
|
+ newPassword = adminUserVO.getPassword();
|
|
} else {
|
|
} else {
|
|
- newPassword=adminUser.getFirstPassword();
|
|
|
|
|
|
+ newPassword = adminUser.getFirstPassword();
|
|
adminUserVO.setPassword(password);
|
|
adminUserVO.setPassword(password);
|
|
}
|
|
}
|
|
//修改管理员名称
|
|
//修改管理员名称
|
|
adminUserVO.setUsername(adminUser.getUsername());
|
|
adminUserVO.setUsername(adminUser.getUsername());
|
|
//发消息
|
|
//发消息
|
|
- List<String> companyBandMsg =new ArrayList<>();
|
|
|
|
- if (ObjectUtil.isNotNull(adminUser.getCompanyId())){
|
|
|
|
|
|
+ List<String> companyBandMsg = new ArrayList<>();
|
|
|
|
+ if (ObjectUtil.isNotNull(adminUser.getCompanyId())) {
|
|
companyBandMsg = companyBandMsgManager.getCompanyBandMsgCode(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) || AdminUserContext.hasFound()){
|
|
|
|
- msgUtilClient.sendMail(MsgContant.UPDATE_USER_MAIL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
|
|
|
|
|
|
+ msgUtilClient.sendSys(MsgContant.UPDATE_USER_SYSTEM, adminUser, 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) || 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_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) || AdminUserContext.hasFound()){
|
|
|
|
- msgUtilClient.sendOfficial(MsgContant.UPDATE_USER_OFFICIAL, adminUser,LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE), adminUser.getUsername(),newPassword);
|
|
|
|
|
|
+ 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);
|
|
BeanUtil.copyProperties(adminUserVO, adminUser);
|
|
adminUserMapper.updateById(adminUser);
|
|
adminUserMapper.updateById(adminUser);
|
|
@@ -215,7 +216,7 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
* @param id 平台管理员主键
|
|
* @param id 平台管理员主键
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- @Transactional( propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
public void delete(Long id) {
|
|
public void delete(Long id) {
|
|
//校验当前管理员是否存在
|
|
//校验当前管理员是否存在
|
|
AdminUser adminUser = this.getModel(id);
|
|
AdminUser adminUser = this.getModel(id);
|
|
@@ -273,12 +274,16 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
@Override
|
|
@Override
|
|
public AdminLoginVO login(String name, String password, Long companyId, String type) {
|
|
public AdminLoginVO login(String name, String password, Long companyId, String type) {
|
|
|
|
|
|
|
|
+ String lowerCase = StringUtil.md5(name + password + companyId).toLowerCase();
|
|
//查询管理员信息
|
|
//查询管理员信息
|
|
LambdaQueryWrapper<AdminUser> queryWrapper = new LambdaQueryWrapper<AdminUser>()
|
|
LambdaQueryWrapper<AdminUser> queryWrapper = new LambdaQueryWrapper<AdminUser>()
|
|
.eq(AdminUser::getUsername, name)
|
|
.eq(AdminUser::getUsername, name)
|
|
- .eq(AdminUser::getPassword, StringUtil.md5(name+password).toLowerCase()).eq(AdminUser::getUserState, 0);
|
|
|
|
|
|
+ .eq(AdminUser::getUserState, 0);
|
|
if ("com".equals(type) && ObjectUtil.isNotNull(companyId)) {
|
|
if ("com".equals(type) && ObjectUtil.isNotNull(companyId)) {
|
|
queryWrapper.eq(AdminUser::getCompanyId, companyId);
|
|
queryWrapper.eq(AdminUser::getCompanyId, companyId);
|
|
|
|
+ queryWrapper.eq(AdminUser::getPassword, StringUtil.md5(name + password + companyId).toLowerCase());
|
|
|
|
+ } else {
|
|
|
|
+ queryWrapper.eq(AdminUser::getPassword, StringUtil.md5(name + password).toLowerCase());
|
|
}
|
|
}
|
|
AdminUser adminUser = adminUserMapper.selectOne(queryWrapper);
|
|
AdminUser adminUser = adminUserMapper.selectOne(queryWrapper);
|
|
//管理员信息不存在
|
|
//管理员信息不存在
|
|
@@ -294,6 +299,10 @@ public class AdminUserManagerImpl implements AdminUserManager {
|
|
if (ObjectUtil.isNull(company)) {
|
|
if (ObjectUtil.isNull(company)) {
|
|
throw new ServiceException("该公司未注册");
|
|
throw new ServiceException("该公司未注册");
|
|
}
|
|
}
|
|
|
|
+ if (!company.getStatus()) {
|
|
|
|
+ throw new ServiceException("公司状态异常,限制登录,联系管理员申请解除限制");
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!adminUser.getCompanyId().equals(company.getId())) {
|
|
if (!adminUser.getCompanyId().equals(company.getId())) {
|
|
throw new ServiceException("此账号不属于该公司");
|
|
throw new ServiceException("此账号不属于该公司");
|
|
}
|
|
}
|