|
@@ -33,21 +33,19 @@ public class DataService extends ServiceImpl<DataMapper, Data> {
|
|
|
/**
|
|
|
* 根据登录ID 和 功能ID获得DataRule并转为JsonObject
|
|
|
*/
|
|
|
- public List<JSONObject> getJsonObjectById(Integer loginId, String functionId) {
|
|
|
- List<Integer> dataIds = roleFunctionDataService.getDataIdsForRule(loginId, functionId);
|
|
|
- List<JSONObject> jsonObjs = new ArrayList<>();
|
|
|
+ public List<String> getJsonObjectById(List<Integer> dataIds) {
|
|
|
+ List<String> rules = new ArrayList<>();
|
|
|
if (dataIds.size() > 0) {
|
|
|
LambdaQueryWrapper<Data> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.in(Data::getId, dataIds);
|
|
|
List<Data> dataList = this.list(queryWrapper);
|
|
|
for (Data data : dataList) {
|
|
|
if (data.getId() != 0) {
|
|
|
- JSONObject jsonObj = JSONObject.parseObject(data.getDataRule());
|
|
|
- jsonObjs.add(jsonObj);
|
|
|
+ rules.add(data.getDataRule());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return jsonObjs;
|
|
|
+ return rules;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -107,33 +105,39 @@ public class DataService extends ServiceImpl<DataMapper, Data> {
|
|
|
return Response.success(setDataToVO(dataList));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据登录人id和功能id查询
|
|
|
+ * @param loginId 登录人id
|
|
|
+ * @param functionId 功能id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public List<String> queryDataRule(Integer loginId, String functionId) {
|
|
|
List<String> rules = new ArrayList<>();
|
|
|
+ //根据登录人id和功能id查询规则记录
|
|
|
List<Integer> dataIds = roleFunctionDataService.getDataIdsForRule(loginId, functionId);
|
|
|
+ //当规则id列表的大小为0时返回-1
|
|
|
if (dataIds.size() == 0) {
|
|
|
rules.add("-1");
|
|
|
return rules;
|
|
|
}
|
|
|
-
|
|
|
- if (dataIds.contains(0) && dataIds.size() == 1) {
|
|
|
+ //根据规则记录id查询规则
|
|
|
+ List<String> ruleStrs = this.getJsonObjectById(dataIds);
|
|
|
+ //当未查到规则时
|
|
|
+ if (ruleStrs.size()==0) {
|
|
|
+ //查询功能的默认规则
|
|
|
LambdaQueryWrapper<Function> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(Function::getFunctionPath, functionId);
|
|
|
Function function = functionService.getOne(wrapper);
|
|
|
if (function.getDefaultRule() != null) {
|
|
|
rules.add(function.getDefaultRule());
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ //当无默认规则时,把0放到列表里并返回
|
|
|
+ else {
|
|
|
rules.add("0");
|
|
|
}
|
|
|
return rules;
|
|
|
}
|
|
|
-
|
|
|
- List<JSONObject> jsonObjects = this.getJsonObjectById(loginId, functionId);
|
|
|
- for (JSONObject jsonObject : jsonObjects) {
|
|
|
- String tem = jsonObject.toJSONString();
|
|
|
- rules.add(tem);
|
|
|
-
|
|
|
- }
|
|
|
- return rules;
|
|
|
+ return ruleStrs;
|
|
|
}
|
|
|
|
|
|
private List<DataVO> setDataToVO(List<Data> dataList) {
|