给系统管理模块增加操作的判断条件

This commit is contained in:
季圣华
2023-02-03 19:27:21 +08:00
parent c58f519dc3
commit ca4efaa3d8
4 changed files with 120 additions and 63 deletions

View File

@@ -77,7 +77,9 @@ public class FunctionService {
public List<FunctionEx> select(String name, String type, int offset, int rows)throws Exception { public List<FunctionEx> select(String name, String type, int offset, int rows)throws Exception {
List<FunctionEx> list=null; List<FunctionEx> list=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
list = functionMapperEx.selectByConditionFunction(name, type, offset, rows); list = functionMapperEx.selectByConditionFunction(name, type, offset, rows);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -87,7 +89,9 @@ public class FunctionService {
public Long countFunction(String name, String type)throws Exception { public Long countFunction(String name, String type)throws Exception {
Long result=null; Long result=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = functionMapperEx.countsByFunction(name, type); result = functionMapperEx.countsByFunction(name, type);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -99,11 +103,13 @@ public class FunctionService {
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
functions.setState(false); functions.setState(false);
functions.setType("电脑版"); functions.setType("电脑版");
result = functionsMapper.insertSelective(functions); result = functionsMapper.insertSelective(functions);
logService.insertLog("功能", logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(), request);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -115,9 +121,11 @@ public class FunctionService {
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = functionsMapper.updateByPrimaryKeySelective(functions); result = functionsMapper.updateByPrimaryKeySelective(functions);
logService.insertLog("功能", logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -142,13 +150,15 @@ public class FunctionService {
for(Function functions: list){ for(Function functions: list){
sb.append("[").append(functions.getName()).append("]"); sb.append("[").append(functions.getName()).append("]");
} }
logService.insertLog("功能", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = functionMapperEx.batchDeleteFunctionByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray); result = functionMapperEx.batchDeleteFunctionByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
logService.insertLog("功能", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }

View File

@@ -64,7 +64,9 @@ public class MaterialPropertyService {
public List<MaterialProperty> select(String name, int offset, int rows)throws Exception { public List<MaterialProperty> select(String name, int offset, int rows)throws Exception {
List<MaterialProperty> list=null; List<MaterialProperty> list=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
list = materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows); list = materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -74,7 +76,9 @@ public class MaterialPropertyService {
public Long countMaterialProperty(String name)throws Exception { public Long countMaterialProperty(String name)throws Exception {
Long result=null; Long result=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = materialPropertyMapperEx.countsByMaterialProperty(name); result = materialPropertyMapperEx.countsByMaterialProperty(name);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -86,9 +90,11 @@ public class MaterialPropertyService {
MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class); MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = materialPropertyMapper.insertSelective(materialProperty); result = materialPropertyMapper.insertSelective(materialProperty);
logService.insertLog("商品属性", logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -100,9 +106,11 @@ public class MaterialPropertyService {
MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class); MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
logService.insertLog("商品属性", logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request); new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -121,14 +129,16 @@ public class MaterialPropertyService {
@Transactional(value = "transactionManager", rollbackFor = Exception.class) @Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialPropertyByIds(String ids) throws Exception{ public int batchDeleteMaterialPropertyByIds(String ids) throws Exception{
logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(","); String [] idArray=ids.split(",");
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray); result = materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray);
logService.insertLog("商品属性",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }

View File

@@ -1,11 +1,13 @@
package com.jsh.erp.service.platformConfig; package com.jsh.erp.service.platformConfig;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.PlatformConfig; import com.jsh.erp.datasource.entities.PlatformConfig;
import com.jsh.erp.datasource.entities.PlatformConfigExample; import com.jsh.erp.datasource.entities.PlatformConfigExample;
import com.jsh.erp.datasource.mappers.PlatformConfigMapper; import com.jsh.erp.datasource.mappers.PlatformConfigMapper;
import com.jsh.erp.datasource.mappers.PlatformConfigMapperEx; import com.jsh.erp.datasource.mappers.PlatformConfigMapperEx;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -20,6 +22,9 @@ import java.util.List;
public class PlatformConfigService { public class PlatformConfigService {
private Logger logger = LoggerFactory.getLogger(PlatformConfigService.class); private Logger logger = LoggerFactory.getLogger(PlatformConfigService.class);
@Resource
private UserService userService;
@Resource @Resource
private PlatformConfigMapper platformConfigMapper; private PlatformConfigMapper platformConfigMapper;
@@ -51,7 +56,9 @@ public class PlatformConfigService {
public List<PlatformConfig> select(String platformKey, int offset, int rows)throws Exception { public List<PlatformConfig> select(String platformKey, int offset, int rows)throws Exception {
List<PlatformConfig> list=null; List<PlatformConfig> list=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
list = platformConfigMapperEx.selectByConditionPlatformConfig(platformKey, offset, rows); list = platformConfigMapperEx.selectByConditionPlatformConfig(platformKey, offset, rows);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -61,7 +68,9 @@ public class PlatformConfigService {
public Long countPlatformConfig(String platformKey)throws Exception { public Long countPlatformConfig(String platformKey)throws Exception {
Long result=null; Long result=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = platformConfigMapperEx.countsByPlatformConfig(platformKey); result = platformConfigMapperEx.countsByPlatformConfig(platformKey);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -73,7 +82,9 @@ public class PlatformConfigService {
PlatformConfig platformConfig = JSONObject.parseObject(obj.toJSONString(), PlatformConfig.class); PlatformConfig platformConfig = JSONObject.parseObject(obj.toJSONString(), PlatformConfig.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = platformConfigMapper.insertSelective(platformConfig); result = platformConfigMapper.insertSelective(platformConfig);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -85,7 +96,9 @@ public class PlatformConfigService {
PlatformConfig platformConfig = JSONObject.parseObject(obj.toJSONString(), PlatformConfig.class); PlatformConfig platformConfig = JSONObject.parseObject(obj.toJSONString(), PlatformConfig.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = platformConfigMapper.updateByPrimaryKeySelective(platformConfig); result = platformConfigMapper.updateByPrimaryKeySelective(platformConfig);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -96,7 +109,9 @@ public class PlatformConfigService {
public int deletePlatformConfig(Long id, HttpServletRequest request)throws Exception { public int deletePlatformConfig(Long id, HttpServletRequest request)throws Exception {
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = platformConfigMapper.deleteByPrimaryKey(id); result = platformConfigMapper.deleteByPrimaryKey(id);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -110,7 +125,9 @@ public class PlatformConfigService {
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = platformConfigMapper.deleteByExample(example); result = platformConfigMapper.deleteByExample(example);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -120,11 +137,13 @@ public class PlatformConfigService {
public int updatePlatformConfigByKey(String platformKey, String platformValue)throws Exception { public int updatePlatformConfigByKey(String platformKey, String platformValue)throws Exception {
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
PlatformConfig platformConfig = new PlatformConfig(); PlatformConfig platformConfig = new PlatformConfig();
platformConfig.setPlatformValue(platformValue); platformConfig.setPlatformValue(platformValue);
PlatformConfigExample example = new PlatformConfigExample(); PlatformConfigExample example = new PlatformConfigExample();
example.createCriteria().andPlatformKeyEqualTo(platformKey); example.createCriteria().andPlatformKeyEqualTo(platformKey);
result = platformConfigMapper.updateByExampleSelective(platformConfig, example); result = platformConfigMapper.updateByExampleSelective(platformConfig, example);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }

View File

@@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.UserMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil; import com.jsh.erp.utils.StringUtil;
import com.jsh.erp.utils.Tools; import com.jsh.erp.utils.Tools;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -37,6 +38,9 @@ public class TenantService {
@Resource @Resource
private UserMapperEx userMapperEx; private UserMapperEx userMapperEx;
@Resource
private UserService userService;
@Resource @Resource
private LogService logService; private LogService logService;
@@ -70,6 +74,7 @@ public class TenantService {
public List<TenantEx> select(String loginName, String type, String enabled, int offset, int rows)throws Exception { public List<TenantEx> select(String loginName, String type, String enabled, int offset, int rows)throws Exception {
List<TenantEx> list= new ArrayList<>(); List<TenantEx> list= new ArrayList<>();
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows); list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows);
if (null != list) { if (null != list) {
for (TenantEx tenantEx : list) { for (TenantEx tenantEx : list) {
@@ -77,6 +82,7 @@ public class TenantService {
tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime())); tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime()));
} }
} }
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -86,7 +92,9 @@ public class TenantService {
public Long countTenant(String loginName, String type, String enabled)throws Exception { public Long countTenant(String loginName, String type, String enabled)throws Exception {
Long result=null; Long result=null;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = tenantMapperEx.countsByTenant(loginName, type, enabled); result = tenantMapperEx.countsByTenant(loginName, type, enabled);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }
@@ -105,7 +113,9 @@ public class TenantService {
if(tenant.getExpireTime()==null) { if(tenant.getExpireTime()==null) {
tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数 tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
} }
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = tenantMapper.insertSelective(tenant); result = tenantMapper.insertSelective(tenant);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -117,11 +127,13 @@ public class TenantService {
Tenant tenant = JSONObject.parseObject(obj.toJSONString(), Tenant.class); Tenant tenant = JSONObject.parseObject(obj.toJSONString(), Tenant.class);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
//如果租户下的用户限制数量为1则将该租户之外的用户全部禁用 //如果租户下的用户限制数量为1则将该租户之外的用户全部禁用
if (1 == tenant.getUserNumLimit()) { if (1 == tenant.getUserNumLimit()) {
userMapperEx.disableUserByLimit(tenant.getTenantId()); userMapperEx.disableUserByLimit(tenant.getTenantId());
} }
result = tenantMapper.updateByPrimaryKeySelective(tenant); result = tenantMapper.updateByPrimaryKeySelective(tenant);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -132,7 +144,9 @@ public class TenantService {
public int deleteTenant(Long id, HttpServletRequest request)throws Exception { public int deleteTenant(Long id, HttpServletRequest request)throws Exception {
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = tenantMapper.deleteByPrimaryKey(id); result = tenantMapper.deleteByPrimaryKey(id);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -146,7 +160,9 @@ public class TenantService {
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
result = tenantMapper.deleteByExample(example); result = tenantMapper.deleteByExample(example);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }
@@ -179,6 +195,7 @@ public class TenantService {
public int batchSetStatus(Boolean status, String ids)throws Exception { public int batchSetStatus(Boolean status, String ids)throws Exception {
int result=0; int result=0;
try{ try{
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
String statusStr = ""; String statusStr = "";
if (status) { if (status) {
statusStr = "批量启用"; statusStr = "批量启用";
@@ -194,6 +211,7 @@ public class TenantService {
TenantExample example = new TenantExample(); TenantExample example = new TenantExample();
example.createCriteria().andIdIn(idList); example.createCriteria().andIdIn(idList);
result = tenantMapper.updateByExampleSelective(tenant, example); result = tenantMapper.updateByExampleSelective(tenant, example);
}
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);
} }