增加仓库和角色类型的数据权限控制
This commit is contained in:
parent
74e8614df8
commit
f1fa71d3cc
@ -37,15 +37,9 @@ public class DepotController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DepotService depotService;
|
private DepotService depotService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private UserService userService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserBusinessService userBusinessService;
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private SystemConfigService systemConfigService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialService materialService;
|
private MaterialService materialService;
|
||||||
|
|
||||||
@ -126,29 +120,7 @@ public class DepotController {
|
|||||||
public BaseResponseInfo findDepotByCurrentUser(HttpServletRequest request) throws Exception{
|
public BaseResponseInfo findDepotByCurrentUser(HttpServletRequest request) throws Exception{
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
try {
|
try {
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = depotService.findDepotByCurrentUser();
|
||||||
String type = "UserDepot";
|
|
||||||
Long userId = userService.getUserId(request);
|
|
||||||
List<Depot> dataList = depotService.findUserDepot();
|
|
||||||
//开始拼接json数据
|
|
||||||
if (null != dataList) {
|
|
||||||
boolean depotFlag = systemConfigService.getDepotFlag();
|
|
||||||
for (Depot depot : dataList) {
|
|
||||||
JSONObject item = new JSONObject();
|
|
||||||
//勾选判断1
|
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + depot.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + userId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (!depotFlag || flag) {
|
|
||||||
item.put("id", depot.getId());
|
|
||||||
item.put("depotName", depot.getName());
|
|
||||||
arr.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.code = 200;
|
res.code = 200;
|
||||||
res.data = arr;
|
res.data = arr;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -326,7 +326,7 @@ public class DepotHeadController {
|
|||||||
String rows = body.getRows();
|
String rows = body.getRows();
|
||||||
Long billsNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"billsNumLimit").toString());
|
Long billsNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"billsNumLimit").toString());
|
||||||
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
|
||||||
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null,null);
|
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null);
|
||||||
if(count>= billsNumLimit) {
|
if(count>= billsNumLimit) {
|
||||||
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
|
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
|
||||||
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
|
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
|
||||||
|
|||||||
@ -96,8 +96,8 @@ public class SystemConfigController {
|
|||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
try{
|
try{
|
||||||
List<SystemConfig> list = systemConfigService.getSystemConfig();
|
List<SystemConfig> list = systemConfigService.getSystemConfig();
|
||||||
|
res.code = 200;
|
||||||
if(list.size()>0) {
|
if(list.size()>0) {
|
||||||
res.code = 200;
|
|
||||||
res.data = list.get(0);
|
res.data = list.get(0);
|
||||||
}
|
}
|
||||||
} catch(Exception e){
|
} catch(Exception e){
|
||||||
|
|||||||
@ -112,8 +112,6 @@ public class UserController {
|
|||||||
token = token + "_" + user.getTenantId();
|
token = token + "_" + user.getTenantId();
|
||||||
}
|
}
|
||||||
redisService.storageObjectBySession(token,"userId",user.getId());
|
redisService.storageObjectBySession(token,"userId",user.getId());
|
||||||
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
|
||||||
redisService.storageObjectBySession(token,"roleType",roleType);
|
|
||||||
if(user.getTenantId()!=null) {
|
if(user.getTenantId()!=null) {
|
||||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
||||||
if(tenant!=null) {
|
if(tenant!=null) {
|
||||||
@ -136,6 +134,8 @@ public class UserController {
|
|||||||
Map<String, Object> data = new HashMap<String, Object>();
|
Map<String, Object> data = new HashMap<String, Object>();
|
||||||
data.put("msgTip", msgTip);
|
data.put("msgTip", msgTip);
|
||||||
if(user!=null){
|
if(user!=null){
|
||||||
|
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
||||||
|
redisService.storageObjectBySession(token,"roleType",roleType);
|
||||||
redisService.storageObjectBySession(token,"token", token);
|
redisService.storageObjectBySession(token,"token", token);
|
||||||
logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
|
logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
|
||||||
@ -145,6 +145,7 @@ public class UserController {
|
|||||||
data.put("user", user);
|
data.put("user", user);
|
||||||
//用户的按钮权限
|
//用户的按钮权限
|
||||||
data.put("userBtn", btnStrArr);
|
data.put("userBtn", btnStrArr);
|
||||||
|
data.put("roleType", roleType);
|
||||||
}
|
}
|
||||||
res.code = 200;
|
res.code = 200;
|
||||||
res.data = data;
|
res.data = data;
|
||||||
@ -366,8 +367,14 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
@GetMapping("/getRoleTypeByUserId")
|
|
||||||
public BaseResponseInfo getRoleTypeByUserId(HttpServletRequest request) {
|
/**
|
||||||
|
* 获取当前用户的角色类型
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getRoleTypeByCurrentUser")
|
||||||
|
public BaseResponseInfo getRoleTypeByCurrentUser(HttpServletRequest request) {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
try {
|
try {
|
||||||
Map<String, Object> data = new HashMap<String, Object>();
|
Map<String, Object> data = new HashMap<String, Object>();
|
||||||
|
|||||||
@ -1,18 +1,24 @@
|
|||||||
package com.jsh.erp.service.depot;
|
package com.jsh.erp.service.depot;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.*;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.mappers.*;
|
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
|
||||||
|
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
|
||||||
|
import com.jsh.erp.datasource.mappers.DepotMapper;
|
||||||
|
import com.jsh.erp.datasource.mappers.DepotMapperEx;
|
||||||
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.systemConfig.SystemConfigService;
|
||||||
import com.jsh.erp.service.user.UserService;
|
import com.jsh.erp.service.user.UserService;
|
||||||
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
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;
|
||||||
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
@ -23,7 +29,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DepotService {
|
public class DepotService {
|
||||||
@ -37,6 +42,10 @@ public class DepotService {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private SystemConfigService systemConfigService;
|
||||||
|
@Resource
|
||||||
|
private UserBusinessService userBusinessService;
|
||||||
|
@Resource
|
||||||
private LogService logService;
|
private LogService logService;
|
||||||
@Resource
|
@Resource
|
||||||
private DepotHeadMapperEx depotHeadMapperEx;
|
private DepotHeadMapperEx depotHeadMapperEx;
|
||||||
@ -264,4 +273,51 @@ public class DepotService {
|
|||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONArray findDepotByCurrentUser() throws Exception {
|
||||||
|
JSONArray arr = new JSONArray();
|
||||||
|
String type = "UserDepot";
|
||||||
|
Long userId = userService.getCurrentUser().getId();
|
||||||
|
List<Depot> dataList = findUserDepot();
|
||||||
|
//开始拼接json数据
|
||||||
|
if (null != dataList) {
|
||||||
|
boolean depotFlag = systemConfigService.getDepotFlag();
|
||||||
|
for (Depot depot : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + depot.getId().toString() + "]");
|
||||||
|
} catch (DataAccessException e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + userId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (!depotFlag || flag) {
|
||||||
|
item.put("id", depot.getId());
|
||||||
|
item.put("depotName", depot.getName());
|
||||||
|
item.put("isDefault", depot.getIsDefault());
|
||||||
|
arr.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前用户有权限使用的仓库列表的id,用逗号隔开
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String findDepotStrByCurrentUser() throws Exception {
|
||||||
|
JSONArray arr = findDepotByCurrentUser();
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for(Object object: arr) {
|
||||||
|
JSONObject obj = (JSONObject)object;
|
||||||
|
sb.append(obj.getLong("id")).append(",");
|
||||||
|
}
|
||||||
|
String depotStr = sb.toString();
|
||||||
|
if(StringUtil.isNotEmpty(depotStr)){
|
||||||
|
depotStr = depotStr.substring(0, depotStr.length()-1);
|
||||||
|
}
|
||||||
|
return depotStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,8 +39,7 @@ public class DepotHeadComponent implements ICommonQuery {
|
|||||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||||
String endTime = StringUtil.getInfo(search, "endTime");
|
String endTime = StringUtil.getInfo(search, "endTime");
|
||||||
String materialParam = StringUtil.getInfo(search, "materialParam");
|
String materialParam = StringUtil.getInfo(search, "materialParam");
|
||||||
String depotIds = StringUtil.getInfo(search, "depotIds");
|
return depotHeadService.select(type, subType, roleType, status, number, beginTime, endTime, materialParam, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||||
return depotHeadService.select(type, subType, roleType, status, number, beginTime, endTime, materialParam, depotIds, QueryUtils.offset(map), QueryUtils.rows(map));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -54,8 +53,7 @@ public class DepotHeadComponent implements ICommonQuery {
|
|||||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||||
String endTime = StringUtil.getInfo(search, "endTime");
|
String endTime = StringUtil.getInfo(search, "endTime");
|
||||||
String materialParam = StringUtil.getInfo(search, "materialParam");
|
String materialParam = StringUtil.getInfo(search, "materialParam");
|
||||||
String depotIds = StringUtil.getInfo(search, "depotIds");
|
return depotHeadService.countDepotHead(type, subType, roleType, status, number, beginTime, endTime, materialParam);
|
||||||
return depotHeadService.countDepotHead(type, subType, roleType, status, number, beginTime, endTime, materialParam, depotIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
|
|||||||
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.account.AccountService;
|
import com.jsh.erp.service.account.AccountService;
|
||||||
|
import com.jsh.erp.service.depot.DepotService;
|
||||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||||
import com.jsh.erp.service.log.LogService;
|
import com.jsh.erp.service.log.LogService;
|
||||||
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
|
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
|
||||||
@ -49,6 +50,8 @@ public class DepotHeadService {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private DepotService depotService;
|
||||||
|
@Resource
|
||||||
DepotItemService depotItemService;
|
DepotItemService depotItemService;
|
||||||
@Resource
|
@Resource
|
||||||
private SupplierService supplierService;
|
private SupplierService supplierService;
|
||||||
@ -90,10 +93,11 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
|
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
|
||||||
String materialParam, String depotIds, int offset, int rows)throws Exception {
|
String materialParam, int offset, int rows)throws Exception {
|
||||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||||
List<DepotHeadVo4List> list=new ArrayList<>();
|
List<DepotHeadVo4List> list=new ArrayList<>();
|
||||||
try{
|
try{
|
||||||
|
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||||
String [] creatorArray = getCreatorArray(roleType);
|
String [] creatorArray = getCreatorArray(roleType);
|
||||||
Map<Long,String> personMap = personService.getPersonMap();
|
Map<Long,String> personMap = personService.getPersonMap();
|
||||||
Map<Long,String> accountMap = accountService.getAccountMap();
|
Map<Long,String> accountMap = accountService.getAccountMap();
|
||||||
@ -135,9 +139,10 @@ public class DepotHeadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long countDepotHead(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
|
public Long countDepotHead(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
|
||||||
String materialParam, String depotIds) throws Exception{
|
String materialParam) throws Exception{
|
||||||
Long result=null;
|
Long result=null;
|
||||||
try{
|
try{
|
||||||
|
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||||
String [] creatorArray = getCreatorArray(roleType);
|
String [] creatorArray = getCreatorArray(roleType);
|
||||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotIds);
|
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotIds);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user