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