禁止注册和添加admin用户

This commit is contained in:
季圣华
2019-04-13 20:21:36 +08:00
parent 40fc728e58
commit 491e44b0b2
4 changed files with 117 additions and 95 deletions

View File

@@ -75,7 +75,7 @@
if (res && res.code === 200) { if (res && res.code === 200) {
alert("注册成功!"); alert("注册成功!");
} else { } else {
alert("注册失败!"); alert(res.msg);
} }
}, },
//此处添加错误处理 //此处添加错误处理

View File

@@ -208,6 +208,11 @@ public class BusinessConstants {
public static final String DELETE_TYPE_NORMAL = "1"; public static final String DELETE_TYPE_NORMAL = "1";
public static final String DELETE_TYPE_FORCE = "2"; public static final String DELETE_TYPE_FORCE = "2";
/**
* 默认管理员账号
*/
public static final String DEFAULT_MANAGER = "admin";

View File

@@ -56,6 +56,9 @@ public class ExceptionConstants {
//用户录入数量超出限制 //用户录入数量超出限制
public static final int USER_OVER_LIMIT_FAILED_CODE = 500004; public static final int USER_OVER_LIMIT_FAILED_CODE = 500004;
public static final String USER_OVER_LIMIT_FAILED_MSG = "用户录入数量超出限制,请联系管理员续费"; 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 = "此用户名限制使用";
/** /**
* 角色信息 * 角色信息

View File

@@ -223,6 +223,10 @@ public class UserService {
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void addUserAndOrgUserRel(UserEx ue) throws Exception{ 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, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
BusinessConstants.LOG_OPERATION_TYPE_ADD, BusinessConstants.LOG_OPERATION_TYPE_ADD,
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
@@ -257,6 +261,7 @@ public class UserService {
ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG); ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
} }
} }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx addUser(UserEx ue) throws Exception{ public UserEx addUser(UserEx ue) throws Exception{
/** /**
@@ -288,6 +293,10 @@ public class UserService {
* description: * 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.setPassword(Tools.md5Encryp(ue.getPassword()));
ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM); ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
if (ue.getIsmanager() == null) { if (ue.getIsmanager() == null) {
@@ -313,6 +322,7 @@ public class UserService {
} }
return null; return null;
} }
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateUserTenant(User user) throws Exception{ public void updateUserTenant(User user) throws Exception{
@@ -323,6 +333,10 @@ public class UserService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public void updateUserAndOrgUserRel(UserEx ue) throws Exception{ 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, logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_USER,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ue.getId()).toString(), new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ue.getId()).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
@@ -363,7 +377,7 @@ public class UserService {
throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE, throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE,
ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG); ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
} }
}
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public UserEx updateUser(UserEx ue){ public UserEx updateUser(UserEx ue){