use of com.ngtesting.platform.vo.ProjectPrivilegeDefineVo 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.vo.ProjectPrivilegeDefineVo 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;
}
use of com.ngtesting.platform.vo.ProjectPrivilegeDefineVo in project ngtesting-platform by aaronchen2k.
the class ProjectRoleAction method save.
@AuthPassport(validate = true)
@RequestMapping(value = "save", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> save(HttpServletRequest request, @RequestBody JSONObject json) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = userVo.getDefaultOrgId();
ProjectRoleVo projectRoleVo = JSON.parseObject(JSON.toJSONString(json.get("projectRole")), ProjectRoleVo.class);
TestProjectRoleForOrg po = projectRoleService.save(projectRoleVo, orgId);
Map<String, List<ProjectPrivilegeDefineVo>> projectPrivileges = (Map<String, List<ProjectPrivilegeDefineVo>>) json.get("projectPrivileges");
int i = 0;
boolean success = projectPrivilegeService.saveProjectPrivileges(po.getId(), projectPrivileges);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
Aggregations