给系统管理模块增加操作的判断条件
This commit is contained in:
@@ -77,7 +77,9 @@ public class FunctionService {
|
||||
public List<FunctionEx> select(String name, String type, int offset, int rows)throws Exception {
|
||||
List<FunctionEx> list=null;
|
||||
try{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,9 @@ public class MaterialPropertyService {
|
||||
public List<MaterialProperty> select(String name, int offset, int rows)throws Exception {
|
||||
List<MaterialProperty> list=null;
|
||||
try{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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<PlatformConfig> select(String platformKey, int offset, int rows)throws Exception {
|
||||
List<PlatformConfig> list=null;
|
||||
try{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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{
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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,6 +74,7 @@ public class TenantService {
|
||||
public List<TenantEx> select(String loginName, String type, String enabled, int offset, int rows)throws Exception {
|
||||
List<TenantEx> list= new ArrayList<>();
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
list = tenantMapperEx.selectByConditionTenant(loginName, type, enabled, offset, rows);
|
||||
if (null != list) {
|
||||
for (TenantEx tenantEx : list) {
|
||||
@@ -77,6 +82,7 @@ public class TenantService {
|
||||
tenantEx.setExpireTimeStr(Tools.getCenternTime(tenantEx.getExpireTime()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -86,7 +92,9 @@ public class TenantService {
|
||||
public Long countTenant(String loginName, String type, String enabled)throws Exception {
|
||||
Long result=null;
|
||||
try{
|
||||
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)); //租户允许试用的天数
|
||||
}
|
||||
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{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
//如果租户下的用户限制数量为1,则将该租户之外的用户全部禁用
|
||||
if (1 == tenant.getUserNumLimit()) {
|
||||
userMapperEx.disableUserByLimit(tenant.getTenantId());
|
||||
}
|
||||
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{
|
||||
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{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
result = tenantMapper.deleteByExample(example);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
@@ -179,6 +195,7 @@ public class TenantService {
|
||||
public int batchSetStatus(Boolean status, String ids)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
if(BusinessConstants.DEFAULT_MANAGER.equals(userService.getCurrentUser().getLoginName())) {
|
||||
String statusStr = "";
|
||||
if (status) {
|
||||
statusStr = "批量启用";
|
||||
@@ -194,6 +211,7 @@ public class TenantService {
|
||||
TenantExample example = new TenantExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
result = tenantMapper.updateByExampleSelective(tenant, example);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user