优化系统权限逻辑
This commit is contained in:
@@ -70,6 +70,8 @@ public class DepotController {
|
|||||||
HttpServletRequest request) throws Exception{
|
HttpServletRequest request) throws Exception{
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
try {
|
try {
|
||||||
|
//获取权限信息
|
||||||
|
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
|
||||||
List<Depot> dataList = depotService.findUserDepot();
|
List<Depot> dataList = depotService.findUserDepot();
|
||||||
//开始拼接json数据
|
//开始拼接json数据
|
||||||
JSONObject outer = new JSONObject();
|
JSONObject outer = new JSONObject();
|
||||||
@@ -88,17 +90,10 @@ public class DepotController {
|
|||||||
item.put("value", depot.getId());
|
item.put("value", depot.getId());
|
||||||
item.put("title", depot.getName());
|
item.put("title", depot.getName());
|
||||||
item.put("attributes", depot.getName());
|
item.put("attributes", depot.getName());
|
||||||
//勾选判断1
|
Boolean flag = ubValue.contains("[" + depot.getId().toString() + "]");
|
||||||
Boolean flag = false;
|
if (flag) {
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + depot.getId().toString() + "]");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的仓库:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
item.put("checked", true);
|
||||||
}
|
}
|
||||||
//结束
|
|
||||||
dataArray.add(item);
|
dataArray.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ public class FunctionController {
|
|||||||
|
|
||||||
public JSONArray getFunctionList(List<Function> dataList, String type, String keyId) throws Exception {
|
public JSONArray getFunctionList(List<Function> dataList, String type, String keyId) throws Exception {
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
|
//获取权限信息
|
||||||
|
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
|
||||||
if (null != dataList) {
|
if (null != dataList) {
|
||||||
for (Function function : dataList) {
|
for (Function function : dataList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
@@ -164,13 +166,8 @@ public class FunctionController {
|
|||||||
item.put("value", function.getId());
|
item.put("value", function.getId());
|
||||||
item.put("title", function.getName());
|
item.put("title", function.getName());
|
||||||
item.put("attributes", function.getName());
|
item.put("attributes", function.getName());
|
||||||
Boolean flag = false;
|
Boolean flag = ubValue.contains("[" + function.getId().toString() + "]");
|
||||||
try {
|
if (flag) {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + function.getId().toString() + "]");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
item.put("checked", true);
|
||||||
}
|
}
|
||||||
List<Function> funList = functionService.findRoleFunction(function.getNumber());
|
List<Function> funList = functionService.findRoleFunction(function.getNumber());
|
||||||
|
|||||||
@@ -40,20 +40,16 @@ public class RoleController {
|
|||||||
HttpServletRequest request)throws Exception {
|
HttpServletRequest request)throws Exception {
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
try {
|
try {
|
||||||
|
//获取权限信息
|
||||||
|
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
|
||||||
List<Role> dataList = roleService.findUserRole();
|
List<Role> dataList = roleService.findUserRole();
|
||||||
if (null != dataList) {
|
if (null != dataList) {
|
||||||
for (Role role : dataList) {
|
for (Role role : dataList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
item.put("id", role.getId());
|
item.put("id", role.getId());
|
||||||
item.put("text", role.getName());
|
item.put("text", role.getName());
|
||||||
//勾选判断1
|
Boolean flag = ubValue.contains("[" + role.getId().toString() + "]");
|
||||||
Boolean flag = false;
|
if (flag) {
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + role.getId().toString() + "]");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的角色:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
item.put("checked", true);
|
||||||
}
|
}
|
||||||
arr.add(item);
|
arr.add(item);
|
||||||
@@ -65,8 +61,8 @@ public class RoleController {
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/list")
|
@GetMapping(value = "/allList")
|
||||||
public List<Role> list(HttpServletRequest request)throws Exception {
|
public List<Role> allList(HttpServletRequest request)throws Exception {
|
||||||
return roleService.getRole();
|
return roleService.allList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,19 +83,15 @@ public class SupplierController {
|
|||||||
try {
|
try {
|
||||||
String type = "UserCustomer";
|
String type = "UserCustomer";
|
||||||
Long userId = userService.getUserId(request);
|
Long userId = userService.getUserId(request);
|
||||||
|
//获取权限信息
|
||||||
|
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, userId.toString());
|
||||||
List<Supplier> supplierList = supplierService.findBySelectCus();
|
List<Supplier> supplierList = supplierService.findBySelectCus();
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
if (null != supplierList) {
|
if (null != supplierList) {
|
||||||
boolean customerFlag = systemConfigService.getCustomerFlag();
|
boolean customerFlag = systemConfigService.getCustomerFlag();
|
||||||
for (Supplier supplier : supplierList) {
|
for (Supplier supplier : supplierList) {
|
||||||
JSONObject item = new JSONObject();
|
JSONObject item = new JSONObject();
|
||||||
//勾选判断1
|
Boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
|
||||||
Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + supplier.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的客户:存在异常!");
|
|
||||||
}
|
|
||||||
if (!customerFlag || flag) {
|
if (!customerFlag || flag) {
|
||||||
item.put("id", supplier.getId());
|
item.put("id", supplier.getId());
|
||||||
item.put("supplier", supplier.getSupplier()); //客户名称
|
item.put("supplier", supplier.getSupplier()); //客户名称
|
||||||
@@ -197,6 +193,8 @@ public class SupplierController {
|
|||||||
HttpServletRequest request) throws Exception{
|
HttpServletRequest request) throws Exception{
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
try {
|
try {
|
||||||
|
//获取权限信息
|
||||||
|
String ubValue = userBusinessService.getUBValueByTypeAndKeyId(type, keyId);
|
||||||
List<Supplier> dataList = supplierService.findUserCustomer();
|
List<Supplier> dataList = supplierService.findUserCustomer();
|
||||||
//开始拼接json数据
|
//开始拼接json数据
|
||||||
JSONObject outer = new JSONObject();
|
JSONObject outer = new JSONObject();
|
||||||
@@ -215,17 +213,10 @@ public class SupplierController {
|
|||||||
item.put("value", supplier.getId());
|
item.put("value", supplier.getId());
|
||||||
item.put("title", supplier.getSupplier());
|
item.put("title", supplier.getSupplier());
|
||||||
item.put("attributes", supplier.getSupplier());
|
item.put("attributes", supplier.getSupplier());
|
||||||
//勾选判断1
|
Boolean flag = ubValue.contains("[" + supplier.getId().toString() + "]");
|
||||||
Boolean flag = false;
|
if (flag) {
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + supplier.getId().toString() + "]");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置用户对应的客户:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item.put("checked", true);
|
item.put("checked", true);
|
||||||
}
|
}
|
||||||
//结束
|
|
||||||
dataArray.add(item);
|
dataArray.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,49 +61,6 @@ public class SystemConfigController {
|
|||||||
@Value(value="${spring.servlet.multipart.max-request-size}")
|
@Value(value="${spring.servlet.multipart.max-request-size}")
|
||||||
private Long maxRequestSize;
|
private Long maxRequestSize;
|
||||||
|
|
||||||
@GetMapping(value = "/getDictItems/{dictCode}")
|
|
||||||
public BaseResponseInfo getDictItems(@PathVariable String dictCode,
|
|
||||||
HttpServletRequest request) {
|
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
|
||||||
try {
|
|
||||||
Long userId = userService.getUserId(request);
|
|
||||||
JSONArray arr = new JSONArray();
|
|
||||||
if(StringUtil.isNotEmpty(dictCode)) {
|
|
||||||
if (dictCode.equals("depotDict")) {
|
|
||||||
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;
|
|
||||||
String type = "UserDepot";
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + depot.getId().toString() + "]");
|
|
||||||
} catch (DataAccessException e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + userId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (!depotFlag || flag) {
|
|
||||||
item.put("value", depot.getId().toString());
|
|
||||||
item.put("text", depot.getName());
|
|
||||||
item.put("title", depot.getName());
|
|
||||||
arr.add(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.code = 200;
|
|
||||||
res.data = arr;
|
|
||||||
} catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
res.code = 500;
|
|
||||||
res.data = "获取数据失败";
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前租户的配置信息
|
* 获取当前租户的配置信息
|
||||||
* @param request
|
* @param request
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class RoleService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Role> getRole()throws Exception {
|
public List<Role> allList()throws Exception {
|
||||||
RoleExample example = new RoleExample();
|
RoleExample example = new RoleExample();
|
||||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
List<Role> list=null;
|
List<Role> list=null;
|
||||||
|
|||||||
@@ -126,11 +126,11 @@ public class UserBusinessService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<UserBusiness> getBasicData(String keyId, String type)throws Exception{
|
public List<UserBusiness> getBasicData(String keyId, String type)throws Exception{
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
|
||||||
example.createCriteria().andKeyIdEqualTo(keyId).andTypeEqualTo(type)
|
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
|
||||||
List<UserBusiness> list=null;
|
List<UserBusiness> list=null;
|
||||||
try{
|
try{
|
||||||
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
|
example.createCriteria().andKeyIdEqualTo(keyId).andTypeEqualTo(type)
|
||||||
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
list= userBusinessMapper.selectByExample(example);
|
list= userBusinessMapper.selectByExample(example);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.readFail(logger, e);
|
JshException.readFail(logger, e);
|
||||||
@@ -138,6 +138,15 @@ public class UserBusinessService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUBValueByTypeAndKeyId(String type, String keyId) throws Exception {
|
||||||
|
String ubValue = "";
|
||||||
|
List<UserBusiness> ubList = getBasicData(keyId, type);
|
||||||
|
if(ubList!=null && ubList.size()>0) {
|
||||||
|
ubValue = ubList.get(0).getValue();
|
||||||
|
}
|
||||||
|
return ubValue;
|
||||||
|
}
|
||||||
|
|
||||||
public Long checkIsValueExist(String type, String keyId)throws Exception {
|
public Long checkIsValueExist(String type, String keyId)throws Exception {
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andTypeEqualTo(type).andKeyIdEqualTo(keyId)
|
example.createCriteria().andTypeEqualTo(type).andKeyIdEqualTo(keyId)
|
||||||
@@ -155,29 +164,6 @@ public class UserBusinessService {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue)throws Exception {
|
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
|
||||||
String newVaule = "%" + UBValue + "%";
|
|
||||||
if(TypeVale !=null && KeyIdValue !=null) {
|
|
||||||
example.createCriteria().andTypeEqualTo(TypeVale).andKeyIdEqualTo(KeyIdValue).andValueLike(newVaule)
|
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
|
||||||
} else {
|
|
||||||
example.createCriteria().andValueLike(newVaule)
|
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
|
||||||
}
|
|
||||||
List<UserBusiness> list=null;
|
|
||||||
try{
|
|
||||||
list= userBusinessMapper.selectByExample(example);
|
|
||||||
}catch(Exception e){
|
|
||||||
JshException.readFail(logger, e);
|
|
||||||
}
|
|
||||||
if(list!=null&&list.size() > 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int updateBtnStr(String keyId, String type, String btnStr) throws Exception{
|
public int updateBtnStr(String keyId, String type, String btnStr) throws Exception{
|
||||||
logService.insertLog("关联关系",
|
logService.insertLog("关联关系",
|
||||||
|
|||||||
Reference in New Issue
Block a user