增加仓库和角色类型的数据权限控制
This commit is contained in:
@@ -37,15 +37,9 @@ public class DepotController {
|
||||
@Resource
|
||||
private DepotService depotService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
|
||||
@Resource
|
||||
private MaterialService materialService;
|
||||
|
||||
@@ -126,29 +120,7 @@ public class DepotController {
|
||||
public BaseResponseInfo findDepotByCurrentUser(HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
JSONArray arr = new JSONArray();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
JSONArray arr = depotService.findDepotByCurrentUser();
|
||||
res.code = 200;
|
||||
res.data = arr;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -326,7 +326,7 @@ public class DepotHeadController {
|
||||
String rows = body.getRows();
|
||||
Long billsNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"billsNumLimit").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) {
|
||||
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
|
||||
ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_MSG);
|
||||
|
||||
@@ -96,8 +96,8 @@ public class SystemConfigController {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try{
|
||||
List<SystemConfig> list = systemConfigService.getSystemConfig();
|
||||
res.code = 200;
|
||||
if(list.size()>0) {
|
||||
res.code = 200;
|
||||
res.data = list.get(0);
|
||||
}
|
||||
} catch(Exception e){
|
||||
|
||||
@@ -112,8 +112,6 @@ public class UserController {
|
||||
token = token + "_" + user.getTenantId();
|
||||
}
|
||||
redisService.storageObjectBySession(token,"userId",user.getId());
|
||||
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
||||
redisService.storageObjectBySession(token,"roleType",roleType);
|
||||
if(user.getTenantId()!=null) {
|
||||
Tenant tenant = tenantService.getTenantByTenantId(user.getTenantId());
|
||||
if(tenant!=null) {
|
||||
@@ -136,6 +134,8 @@ public class UserController {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("msgTip", msgTip);
|
||||
if(user!=null){
|
||||
String roleType = userService.getRoleTypeByUserId(user.getId()); //角色类型
|
||||
redisService.storageObjectBySession(token,"roleType",roleType);
|
||||
redisService.storageObjectBySession(token,"token", token);
|
||||
logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
|
||||
@@ -145,6 +145,7 @@ public class UserController {
|
||||
data.put("user", user);
|
||||
//用户的按钮权限
|
||||
data.put("userBtn", btnStrArr);
|
||||
data.put("roleType", roleType);
|
||||
}
|
||||
res.code = 200;
|
||||
res.data = data;
|
||||
@@ -366,8 +367,14 @@ public class UserController {
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
@GetMapping("/getRoleTypeByUserId")
|
||||
public BaseResponseInfo getRoleTypeByUserId(HttpServletRequest request) {
|
||||
|
||||
/**
|
||||
* 获取当前用户的角色类型
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRoleTypeByCurrentUser")
|
||||
public BaseResponseInfo getRoleTypeByCurrentUser(HttpServletRequest request) {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
try {
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
|
||||
Reference in New Issue
Block a user