diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java index dc6c597f..4e1454fe 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/functions/FunctionService.java @@ -77,7 +77,9 @@ public class FunctionService { public List select(String name, String type, int offset, int rows)throws Exception { List list=null; try{ - list= functionMapperEx.selectByConditionFunction(name, type, offset, rows); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + list = functionMapperEx.selectByConditionFunction(name, type, offset, rows); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -87,7 +89,9 @@ public class FunctionService { public Long countFunction(String name, String type)throws Exception { Long result=null; try{ - result= functionMapperEx.countsByFunction(name, type); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = functionMapperEx.countsByFunction(name, type); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -99,11 +103,13 @@ public class FunctionService { Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); int result=0; try{ - functions.setState(false); - functions.setType("电脑版"); - result=functionsMapper.insertSelective(functions); - logService.insertLog("功能", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(),request); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + functions.setState(false); + functions.setType("电脑版"); + result = functionsMapper.insertSelective(functions); + logService.insertLog("功能", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(), request); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -115,9 +121,11 @@ public class FunctionService { Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class); int result=0; try{ - result=functionsMapper.updateByPrimaryKeySelective(functions); - logService.insertLog("功能", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = functionsMapper.updateByPrimaryKeySelective(functions); + logService.insertLog("功能", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -142,13 +150,15 @@ public class FunctionService { for(Function functions: list){ sb.append("[").append(functions.getName()).append("]"); } - logService.insertLog("功能", sb.toString(), - ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); User userInfo=userService.getCurrentUser(); String [] idArray=ids.split(","); int result=0; try{ - result = functionMapperEx.batchDeleteFunctionByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = functionMapperEx.batchDeleteFunctionByIds(new Date(), userInfo == null ? null : userInfo.getId(), idArray); + logService.insertLog("功能", sb.toString(), + ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); + } }catch(Exception e){ JshException.writeFail(logger, e); } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java index a239b981..0e061fc3 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/materialProperty/MaterialPropertyService.java @@ -64,7 +64,9 @@ public class MaterialPropertyService { public List select(String name, int offset, int rows)throws Exception { List list=null; try{ - list=materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + list = materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -74,7 +76,9 @@ public class MaterialPropertyService { public Long countMaterialProperty(String name)throws Exception { Long result=null; try{ - result=materialPropertyMapperEx.countsByMaterialProperty(name); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = materialPropertyMapperEx.countsByMaterialProperty(name); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -86,9 +90,11 @@ public class MaterialPropertyService { MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class); int result=0; try{ - result=materialPropertyMapper.insertSelective(materialProperty); - logService.insertLog("商品属性", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = materialPropertyMapper.insertSelective(materialProperty); + logService.insertLog("商品属性", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -100,9 +106,11 @@ public class MaterialPropertyService { MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class); int result=0; try{ - result=materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); - logService.insertLog("商品属性", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = materialPropertyMapper.updateByPrimaryKeySelective(materialProperty); + logService.insertLog("商品属性", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -121,14 +129,16 @@ public class MaterialPropertyService { @Transactional(value = "transactionManager", rollbackFor = Exception.class) 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(); String [] idArray=ids.split(","); int result=0; try{ - result=materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + 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){ JshException.writeFail(logger, e); } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/platformConfig/PlatformConfigService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/platformConfig/PlatformConfigService.java index 1e7e286c..aa6f2091 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/platformConfig/PlatformConfigService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/platformConfig/PlatformConfigService.java @@ -1,11 +1,13 @@ package com.jsh.erp.service.platformConfig; import com.alibaba.fastjson.JSONObject; +import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.datasource.entities.PlatformConfig; import com.jsh.erp.datasource.entities.PlatformConfigExample; import com.jsh.erp.datasource.mappers.PlatformConfigMapper; import com.jsh.erp.datasource.mappers.PlatformConfigMapperEx; import com.jsh.erp.exception.JshException; +import com.jsh.erp.service.user.UserService; import com.jsh.erp.utils.StringUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,6 +22,9 @@ import java.util.List; public class PlatformConfigService { private Logger logger = LoggerFactory.getLogger(PlatformConfigService.class); + @Resource + private UserService userService; + @Resource private PlatformConfigMapper platformConfigMapper; @@ -51,7 +56,9 @@ public class PlatformConfigService { public List select(String platformKey, int offset, int rows)throws Exception { List list=null; try{ - list=platformConfigMapperEx.selectByConditionPlatformConfig(platformKey, offset, rows); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + list = platformConfigMapperEx.selectByConditionPlatformConfig(platformKey, offset, rows); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -61,7 +68,9 @@ public class PlatformConfigService { public Long countPlatformConfig(String platformKey)throws Exception { Long result=null; try{ - result=platformConfigMapperEx.countsByPlatformConfig(platformKey); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = platformConfigMapperEx.countsByPlatformConfig(platformKey); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -73,7 +82,9 @@ public class PlatformConfigService { PlatformConfig platformConfig = JSONObject.parseObject(obj.toJSONString(), PlatformConfig.class); int result=0; try{ - result=platformConfigMapper.insertSelective(platformConfig); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = platformConfigMapper.insertSelective(platformConfig); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -85,7 +96,9 @@ public class PlatformConfigService { PlatformConfig platformConfig = JSONObject.parseObject(obj.toJSONString(), PlatformConfig.class); int result=0; try{ - result = platformConfigMapper.updateByPrimaryKeySelective(platformConfig); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = platformConfigMapper.updateByPrimaryKeySelective(platformConfig); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -96,7 +109,9 @@ public class PlatformConfigService { public int deletePlatformConfig(Long id, HttpServletRequest request)throws Exception { int result=0; try{ - result=platformConfigMapper.deleteByPrimaryKey(id); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = platformConfigMapper.deleteByPrimaryKey(id); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -110,7 +125,9 @@ public class PlatformConfigService { example.createCriteria().andIdIn(idList); int result=0; try{ - result=platformConfigMapper.deleteByExample(example); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = platformConfigMapper.deleteByExample(example); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -120,11 +137,13 @@ public class PlatformConfigService { public int updatePlatformConfigByKey(String platformKey, String platformValue)throws Exception { int result=0; try{ - PlatformConfig platformConfig = new PlatformConfig(); - platformConfig.setPlatformValue(platformValue); - PlatformConfigExample example = new PlatformConfigExample(); - example.createCriteria().andPlatformKeyEqualTo(platformKey); - result = platformConfigMapper.updateByExampleSelective(platformConfig, example); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + PlatformConfig platformConfig = new PlatformConfig(); + platformConfig.setPlatformValue(platformValue); + PlatformConfigExample example = new PlatformConfigExample(); + example.createCriteria().andPlatformKeyEqualTo(platformKey); + result = platformConfigMapper.updateByExampleSelective(platformConfig, example); + } }catch(Exception e){ JshException.writeFail(logger, e); } diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/tenant/TenantService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/tenant/TenantService.java index 6ac92935..7d94b5a0 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/tenant/TenantService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/tenant/TenantService.java @@ -10,6 +10,7 @@ import com.jsh.erp.datasource.mappers.UserMapperEx; import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.JshException; 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.Tools; import org.slf4j.Logger; @@ -37,6 +38,9 @@ public class TenantService { @Resource private UserMapperEx userMapperEx; + @Resource + private UserService userService; + @Resource private LogService logService; @@ -70,11 +74,13 @@ public class TenantService { public List select(String loginName, String type, String enabled, int offset, int rows)throws Exception { List list= new ArrayList<>(); try{ - list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows); - if (null != list) { - for (TenantEx tenantEx : list) { - tenantEx.setCreateTimeStr(Tools.getCenternTime(tenantEx.getCreateTime())); - tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime())); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows); + if (null != list) { + for (TenantEx tenantEx : list) { + tenantEx.setCreateTimeStr(Tools.getCenternTime(tenantEx.getCreateTime())); + tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime())); + } } } }catch(Exception e){ @@ -86,7 +92,9 @@ public class TenantService { public Long countTenant(String loginName, String type, String enabled)throws Exception { Long result=null; try{ - result=tenantMapperEx.countsByTenant(loginName, type, enabled); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = tenantMapperEx.countsByTenant(loginName, type, enabled); + } }catch(Exception e){ JshException.readFail(logger, e); } @@ -105,7 +113,9 @@ public class TenantService { if(tenant.getExpireTime()==null) { tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数 } - result=tenantMapper.insertSelective(tenant); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = tenantMapper.insertSelective(tenant); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -117,11 +127,13 @@ public class TenantService { Tenant tenant = JSONObject.parseObject(obj.toJSONString(), Tenant.class); int result=0; try{ - //如果租户下的用户限制数量为1,则将该租户之外的用户全部禁用 - if(1 == tenant.getUserNumLimit()) { - userMapperEx.disableUserByLimit(tenant.getTenantId()); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + //如果租户下的用户限制数量为1,则将该租户之外的用户全部禁用 + if (1 == tenant.getUserNumLimit()) { + userMapperEx.disableUserByLimit(tenant.getTenantId()); + } + result = tenantMapper.updateByPrimaryKeySelective(tenant); } - result=tenantMapper.updateByPrimaryKeySelective(tenant); }catch(Exception e){ JshException.writeFail(logger, e); } @@ -132,7 +144,9 @@ public class TenantService { public int deleteTenant(Long id, HttpServletRequest request)throws Exception { int result=0; try{ - result= tenantMapper.deleteByPrimaryKey(id); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = tenantMapper.deleteByPrimaryKey(id); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -146,7 +160,9 @@ public class TenantService { example.createCriteria().andIdIn(idList); int result=0; try{ - result= tenantMapper.deleteByExample(example); + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + result = tenantMapper.deleteByExample(example); + } }catch(Exception e){ JshException.writeFail(logger, e); } @@ -179,21 +195,23 @@ public class TenantService { public int batchSetStatus(Boolean status, String ids)throws Exception { int result=0; try{ - String statusStr =""; - if(status) { - statusStr ="批量启用"; - } else { - statusStr ="批量禁用"; + if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) { + String statusStr = ""; + if (status) { + statusStr = "批量启用"; + } else { + statusStr = "批量禁用"; + } + logService.insertLog("用户", + new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(), + ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); + List idList = StringUtil.strToLongList(ids); + Tenant tenant = new Tenant(); + tenant.setEnabled(status); + TenantExample example = new TenantExample(); + example.createCriteria().andIdIn(idList); + result = tenantMapper.updateByExampleSelective(tenant, example); } - logService.insertLog("用户", - new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ids).append("-").append(statusStr).toString(), - ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()); - List idList = StringUtil.strToLongList(ids); - Tenant tenant = new Tenant(); - tenant.setEnabled(status); - TenantExample example = new TenantExample(); - example.createCriteria().andIdIn(idList); - result = tenantMapper.updateByExampleSelective(tenant, example); }catch(Exception e){ JshException.writeFail(logger, e); }