给系统移除演示用户的逻辑
This commit is contained in:
@@ -30,17 +30,9 @@ import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
|||||||
public class PlatformConfigController {
|
public class PlatformConfigController {
|
||||||
private Logger logger = LoggerFactory.getLogger(PlatformConfigController.class);
|
private Logger logger = LoggerFactory.getLogger(PlatformConfigController.class);
|
||||||
|
|
||||||
@Value("${demonstrate.open}")
|
|
||||||
private boolean demonstrateOpen;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PlatformConfigService platformConfigService;
|
private PlatformConfigService platformConfigService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
private static final String TEST_USER = "jsh";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取平台名称
|
* 获取平台名称
|
||||||
* @param request
|
* @param request
|
||||||
|
|||||||
@@ -48,9 +48,6 @@ public class UserController {
|
|||||||
@Value("${manage.roleId}")
|
@Value("${manage.roleId}")
|
||||||
private Integer manageRoleId;
|
private Integer manageRoleId;
|
||||||
|
|
||||||
@Value("${demonstrate.open}")
|
|
||||||
private boolean demonstrateOpen;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@@ -232,10 +229,7 @@ public class UserController {
|
|||||||
String password = jsonObject.getString("password");
|
String password = jsonObject.getString("password");
|
||||||
User user = userService.getUser(userId);
|
User user = userService.getUser(userId);
|
||||||
//必须和原始密码一致才可以更新密码
|
//必须和原始密码一致才可以更新密码
|
||||||
if(demonstrateOpen && user.getLoginName().equals(TEST_USER)){
|
if (oldpwd.equalsIgnoreCase(user.getPassword())) {
|
||||||
flag = 3; //jsh用户不能修改密码
|
|
||||||
info = "jsh用户不能修改密码";
|
|
||||||
} else if (oldpwd.equalsIgnoreCase(user.getPassword())) {
|
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
flag = userService.updateUserByObj(user); //1-成功
|
flag = userService.updateUserByObj(user); //1-成功
|
||||||
info = "修改成功";
|
info = "修改成功";
|
||||||
|
|||||||
@@ -88,13 +88,9 @@ public class SystemConfigService {
|
|||||||
SystemConfig systemConfig = JSONObject.parseObject(obj.toJSONString(), SystemConfig.class);
|
SystemConfig systemConfig = JSONObject.parseObject(obj.toJSONString(), SystemConfig.class);
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
if(userService.checkIsTestUser()) {
|
|
||||||
result=-1;
|
|
||||||
} else {
|
|
||||||
result=systemConfigMapper.insertSelective(systemConfig);
|
result=systemConfigMapper.insertSelective(systemConfig);
|
||||||
logService.insertLog("系统配置",
|
logService.insertLog("系统配置",
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
|
||||||
}
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
@@ -106,13 +102,9 @@ public class SystemConfigService {
|
|||||||
SystemConfig systemConfig = JSONObject.parseObject(obj.toJSONString(), SystemConfig.class);
|
SystemConfig systemConfig = JSONObject.parseObject(obj.toJSONString(), SystemConfig.class);
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
if(userService.checkIsTestUser()) {
|
|
||||||
result=-1;
|
|
||||||
} else {
|
|
||||||
result = systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
|
result = systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
|
||||||
logService.insertLog("系统配置",
|
logService.insertLog("系统配置",
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
|
||||||
}
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
@@ -138,11 +130,7 @@ public class SystemConfigService {
|
|||||||
String [] idArray=ids.split(",");
|
String [] idArray=ids.split(",");
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
if(userService.checkIsTestUser()) {
|
|
||||||
result=-1;
|
|
||||||
} else {
|
|
||||||
result = systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
|
result = systemConfigMapperEx.batchDeleteSystemConfigByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
|
||||||
}
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ import java.util.*;
|
|||||||
public class UserService {
|
public class UserService {
|
||||||
private Logger logger = LoggerFactory.getLogger(UserService.class);
|
private Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||||
|
|
||||||
private static final String TEST_USER = "jsh";
|
|
||||||
|
|
||||||
@Value("${demonstrate.open}")
|
|
||||||
private boolean demonstrateOpen;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@@ -106,9 +101,6 @@ public class UserService {
|
|||||||
list=userMapperEx.selectByConditionUser(userName, loginName, offset, rows);
|
list=userMapperEx.selectByConditionUser(userName, loginName, offset, rows);
|
||||||
for(UserEx ue: list){
|
for(UserEx ue: list){
|
||||||
String userType = "";
|
String userType = "";
|
||||||
if(demonstrateOpen && TEST_USER.equals(ue.getLoginName())){
|
|
||||||
userType = "演示用户";
|
|
||||||
} else {
|
|
||||||
if (ue.getId().equals(ue.getTenantId())) {
|
if (ue.getId().equals(ue.getTenantId())) {
|
||||||
userType = "租户";
|
userType = "租户";
|
||||||
} else if(ue.getTenantId() == null){
|
} else if(ue.getTenantId() == null){
|
||||||
@@ -116,7 +108,6 @@ public class UserService {
|
|||||||
} else {
|
} else {
|
||||||
userType = "普通";
|
userType = "普通";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ue.setUserType(userType);
|
ue.setUserType(userType);
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
@@ -257,12 +248,6 @@ public class UserService {
|
|||||||
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
|
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
|
||||||
List<User> list = getUserListByIds(ids);
|
List<User> list = getUserListByIds(ids);
|
||||||
for(User user: list){
|
for(User user: list){
|
||||||
if(demonstrateOpen && user.getLoginName().equals(TEST_USER)){
|
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
|
|
||||||
ExceptionConstants.USER_LIMIT_DELETE_CODE,ExceptionConstants.USER_LIMIT_DELETE_MSG,ids);
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_DELETE_CODE,
|
|
||||||
ExceptionConstants.USER_LIMIT_DELETE_MSG);
|
|
||||||
}
|
|
||||||
if(user.getId().equals(user.getTenantId())) {
|
if(user.getId().equals(user.getTenantId())) {
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
|
logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
|
||||||
ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG,ids);
|
ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG,ids);
|
||||||
@@ -375,25 +360,6 @@ public class UserService {
|
|||||||
return getUser(userId);
|
return getUser(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查当前用户是否是演示用户
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Boolean checkIsTestUser() throws Exception{
|
|
||||||
Boolean result = false;
|
|
||||||
try {
|
|
||||||
if (demonstrateOpen) {
|
|
||||||
User user = getCurrentUser();
|
|
||||||
if (TEST_USER.equals(user.getLoginName())) {
|
|
||||||
result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
JshException.readFail(logger, e);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户名查询id
|
* 根据用户名查询id
|
||||||
* @param loginName
|
* @param loginName
|
||||||
@@ -557,12 +523,6 @@ public class UserService {
|
|||||||
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
|
||||||
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
|
ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
|
||||||
} else {
|
} else {
|
||||||
if(demonstrateOpen && ue.getLoginName().equals(TEST_USER)){
|
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,obj:[{}]",
|
|
||||||
ExceptionConstants.USER_LIMIT_UPDATE_CODE,ExceptionConstants.USER_LIMIT_UPDATE_MSG, TEST_USER);
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_UPDATE_CODE,
|
|
||||||
ExceptionConstants.USER_LIMIT_UPDATE_MSG);
|
|
||||||
}
|
|
||||||
logService.insertLog("用户",
|
logService.insertLog("用户",
|
||||||
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());
|
||||||
@@ -820,14 +780,10 @@ public class UserService {
|
|||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchSetStatus(Byte status, String ids)throws Exception {
|
public int batchSetStatus(Byte status, String ids)throws Exception {
|
||||||
int result=0;
|
int result=0;
|
||||||
|
StringBuilder userStr = new StringBuilder();
|
||||||
List<User> list = getUserListByIds(ids);
|
List<User> list = getUserListByIds(ids);
|
||||||
for(User user: list) {
|
for(User user: list) {
|
||||||
if (demonstrateOpen && user.getLoginName().equals(TEST_USER)) {
|
userStr.append(user.getLoginName()).append(" ");
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,obj:[{}]",
|
|
||||||
ExceptionConstants.USER_LIMIT_UPDATE_CODE, ExceptionConstants.USER_LIMIT_UPDATE_MSG, TEST_USER);
|
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_UPDATE_CODE,
|
|
||||||
ExceptionConstants.USER_LIMIT_UPDATE_MSG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
String statusStr ="";
|
String statusStr ="";
|
||||||
if(status == 0) {
|
if(status == 0) {
|
||||||
@@ -836,7 +792,7 @@ public class UserService {
|
|||||||
statusStr ="批量禁用";
|
statusStr ="批量禁用";
|
||||||
}
|
}
|
||||||
logService.insertLog("用户",
|
logService.insertLog("用户",
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(),
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userStr).append("-").append(statusStr).toString(),
|
||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
User user = new User();
|
User user = new User();
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ manage.roleId=10
|
|||||||
tenant.userNumLimit=1000000
|
tenant.userNumLimit=1000000
|
||||||
#租户允许试用的天数
|
#租户允许试用的天数
|
||||||
tenant.tryDayLimit=3000
|
tenant.tryDayLimit=3000
|
||||||
#演示模式开关-默认关闭:false
|
|
||||||
demonstrate.open=false
|
|
||||||
#插件配置
|
#插件配置
|
||||||
plugin.runMode=prod
|
plugin.runMode=prod
|
||||||
plugin.pluginPath=plugins
|
plugin.pluginPath=plugins
|
||||||
|
|||||||
Reference in New Issue
Block a user