fix(REQ-2300): 记录角色code
This commit is contained in:
parent
50d569df41
commit
0a00c2fb39
@ -39,6 +39,10 @@ public class DataObjectRuleBO {
|
||||
* 岗位/角色id
|
||||
*/
|
||||
private List<Long> relationId;
|
||||
/**
|
||||
* 岗位列表
|
||||
*/
|
||||
private List<JobInfo> jobs;
|
||||
|
||||
/**
|
||||
* 行级数据权限(单选) 1:仅本人数据 2:本人及下属数据 3:仅本部门数据 4:本部门及以下数据
|
||||
@ -51,4 +55,12 @@ public class DataObjectRuleBO {
|
||||
*/
|
||||
private List<AttributePermissionBO> attributePermissionBOList;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class JobInfo{
|
||||
private Long id;
|
||||
private String code;
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,4 +36,8 @@ public class DataObjectRuleScope extends BaseOperatorEntity<DataObjectRuleScope>
|
||||
* 岗位id/角色id
|
||||
*/
|
||||
private Long relationId;
|
||||
/**
|
||||
* 岗位编码
|
||||
*/
|
||||
private String relationCode;
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import groovy.lang.Tuple2;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -92,6 +93,7 @@ public class DataObjectServiceImpl implements DataObjectService {
|
||||
}
|
||||
|
||||
List<DataObjectRule> dataObjectRules = DataObjectMapper.INSTANCE.ruleBOs2Rules(req.getDataObjectRuleBOList());
|
||||
handleJobs(dataObjectRules, req.getDataObjectRuleBOList());
|
||||
|
||||
int size = (CollUtil.isNotEmpty(defaultDataObjectRules) ? defaultDataObjectRules.size() : 0)
|
||||
+ (CollUtil.isNotEmpty(dataObjectRules) ? dataObjectRules.size() : 0);
|
||||
@ -200,6 +202,7 @@ public class DataObjectServiceImpl implements DataObjectService {
|
||||
}
|
||||
|
||||
List<DataObjectRule> dataObjectRules = DataObjectMapper.INSTANCE.ruleBOs2Rules(req.getDataObjectRuleBOList());
|
||||
handleJobs(dataObjectRules, req.getDataObjectRuleBOList());
|
||||
int size = (CollUtil.isNotEmpty(defaultDataObjectRules) ? defaultDataObjectRules.size() : 0)
|
||||
+ (CollUtil.isNotEmpty(dataObjectRules) ? dataObjectRules.size() : 0);
|
||||
List<DataObjectRule> generalObjectRuleList = new ArrayList<>(size);
|
||||
@ -451,4 +454,29 @@ public class DataObjectServiceImpl implements DataObjectService {
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void handleJobs(List<DataObjectRule> dataObjectRules, List<DataObjectRuleBO> dataObjectRuleBOList) {
|
||||
if (CollectionUtils.isEmpty(dataObjectRules) || CollectionUtils.isEmpty(dataObjectRuleBOList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<Long, DataObjectRuleBO.JobInfo> jobInfoMap = Maps.newHashMap();
|
||||
for (DataObjectRuleBO ruleBO : dataObjectRuleBOList) {
|
||||
if (1 == ruleBO.getRuleScopeType() && CollectionUtils.isNotEmpty(ruleBO.getJobs())) {
|
||||
ruleBO.getJobs().forEach(e -> {
|
||||
jobInfoMap.put(e.getId(), e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (DataObjectRule rule : dataObjectRules) {
|
||||
if (1 == rule.getRuleScopeType() && CollectionUtils.isNotEmpty(rule.getDataObjectRuleScopeList())) {
|
||||
rule.getDataObjectRuleScopeList().forEach(e -> {
|
||||
if (Objects.nonNull(e.getRelationId()) && jobInfoMap.containsKey(e.getRelationId())) {
|
||||
e.setRelationCode(jobInfoMap.get(e.getRelationId()).getCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user