use of com.ngtesting.platform.entity.TestProjectRolePriviledgeRelation in project ngtesting-platform by aaronchen2k.
the class ProjectPrivilegeServiceImpl method saveProjectPrivileges.
@Override
public boolean saveProjectPrivileges(Long projectRoleId, Map<String, List<ProjectPrivilegeDefineVo>> map) {
if (map == null) {
return false;
}
List<TestProjectRolePriviledgeRelation> privilegeSet = listProjectRolePrivileges(projectRoleId);
List<Long> privilegeDefineIds = new LinkedList<>();
for (TestProjectRolePriviledgeRelation temp : privilegeSet) {
privilegeDefineIds.add(temp.getProjectPrivilegeDefineId());
}
for (String key : map.keySet()) {
List ls = JSON.parseObject(JSON.toJSONString(map.get(key)), List.class);
for (Object obj : ls) {
ProjectPrivilegeDefineVo vo = JSON.parseObject(JSON.toJSONString(obj), ProjectPrivilegeDefineVo.class);
if (vo.getSelecting() != vo.getSelected()) {
if (vo.getSelecting() && !privilegeDefineIds.contains(vo.getId())) {
// 勾选
TestProjectRolePriviledgeRelation temp = new TestProjectRolePriviledgeRelation(vo.getId(), projectRoleId);
saveOrUpdate(temp);
} else {
// 取消
Long id = vo.getRelationId();
TestProjectRolePriviledgeRelation temp = (TestProjectRolePriviledgeRelation) get(TestProjectRolePriviledgeRelation.class, id);
getDao().delete(temp);
}
}
}
}
return true;
}
use of com.ngtesting.platform.entity.TestProjectRolePriviledgeRelation in project ngtesting-platform by aaronchen2k.
the class ProjectPrivilegeServiceImpl method listPrivilegesByOrgAndProjectRole.
@Override
public Map<String, List<ProjectPrivilegeDefineVo>> listPrivilegesByOrgAndProjectRole(Long orgId, Long projectRoleId) {
List<TestProjectPrivilegeDefine> allPrivileges = listAllProjectPrivileges();
List<TestProjectRolePriviledgeRelation> projectRolePrivileges;
if (projectRoleId == null) {
projectRolePrivileges = new LinkedList();
} else {
projectRolePrivileges = listProjectRolePrivileges(projectRoleId);
}
Map<String, List<ProjectPrivilegeDefineVo>> map = new LinkedHashMap<String, List<ProjectPrivilegeDefineVo>>();
for (TestProjectPrivilegeDefine po1 : allPrivileges) {
String key = po1.getName();
if (!map.containsKey(key)) {
List<ProjectPrivilegeDefineVo> vos = new LinkedList();
map.put(key, vos);
}
ProjectPrivilegeDefineVo vo = genVo(orgId, po1);
vo.setSelected(false);
vo.setSelecting(false);
for (TestProjectRolePriviledgeRelation po2 : projectRolePrivileges) {
if (po1.getId().longValue() == po2.getProjectPrivilegeDefineId().longValue()) {
vo.setSelected(true);
vo.setSelecting(true);
Long relationId = po2.getId();
vo.setRelationId(relationId);
}
}
map.get(key).add(vo);
}
return map;
}
Aggregations