禁止注册和添加admin用户
This commit is contained in:
@@ -75,7 +75,7 @@
|
||||
if (res && res.code === 200) {
|
||||
alert("注册成功!");
|
||||
} else {
|
||||
alert("注册失败!");
|
||||
alert(res.msg);
|
||||
}
|
||||
},
|
||||
//此处添加错误处理
|
||||
|
||||
@@ -208,6 +208,11 @@ public class BusinessConstants {
|
||||
public static final String DELETE_TYPE_NORMAL = "1";
|
||||
public static final String DELETE_TYPE_FORCE = "2";
|
||||
|
||||
/**
|
||||
* 默认管理员账号
|
||||
*/
|
||||
public static final String DEFAULT_MANAGER = "admin";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,9 @@ public class ExceptionConstants {
|
||||
//用户录入数量超出限制
|
||||
public static final int USER_OVER_LIMIT_FAILED_CODE = 500004;
|
||||
public static final String USER_OVER_LIMIT_FAILED_MSG = "用户录入数量超出限制,请联系管理员续费";
|
||||
//此用户名限制使用
|
||||
public static final int USER_NAME_LIMIT_USE_CODE = 500004;
|
||||
public static final String USER_NAME_LIMIT_USE_MSG = "此用户名限制使用";
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
|
||||
@@ -223,6 +223,10 @@ public class UserService {
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void addUserAndOrgUserRel(UserEx ue) throws Exception{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
|
||||
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
|
||||
} else {
|
||||
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
|
||||
BusinessConstants.LOG_OPERATION_TYPE_ADD,
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
@@ -257,6 +261,7 @@ public class UserService {
|
||||
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public UserEx addUser(UserEx ue) throws Exception{
|
||||
/**
|
||||
@@ -288,6 +293,10 @@ public class UserService {
|
||||
* description:
|
||||
* 多次创建事务,事物之间无法协同,应该在入口处创建一个事务以做协调
|
||||
*/
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
|
||||
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
|
||||
} else {
|
||||
ue.setPassword(Tools.md5Encryp(ue.getPassword()));
|
||||
ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
|
||||
if (ue.getIsmanager() == null) {
|
||||
@@ -313,6 +322,7 @@ public class UserService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void updateUserTenant(User user) throws Exception{
|
||||
@@ -323,6 +333,10 @@ public class UserService {
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public void updateUserAndOrgUserRel(UserEx ue) throws Exception{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginame())) {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
|
||||
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
|
||||
} else {
|
||||
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ue.getId()).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
@@ -363,7 +377,7 @@ public class UserService {
|
||||
throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE,
|
||||
ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public UserEx updateUser(UserEx ue){
|
||||
|
||||
Reference in New Issue
Block a user