use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRolePrivilegeServiceImpl method saveOrgRolePrivileges.
@Override
public boolean saveOrgRolePrivileges(Long roleId, List<OrgPrivilegeVo> orgPrivileges) {
if (orgPrivileges == null) {
return false;
}
TestOrgRole orgRole = (TestOrgRole) get(TestOrgRole.class, roleId);
Set<TestOrgPrivilegeDefine> privilegeSet = orgRole.getOrgPrivilegeSet();
for (Object obj : orgPrivileges) {
OrgPrivilegeVo vo = JSON.parseObject(JSON.toJSONString(obj), OrgPrivilegeVo.class);
if (vo.getSelecting() != vo.getSelected()) {
// 变化了
TestOrgPrivilegeDefine orgPrivilege = (TestOrgPrivilegeDefine) get(TestOrgPrivilegeDefine.class, vo.getId());
if (vo.getSelecting() && !privilegeSet.contains(orgPrivilege)) {
// 勾选
privilegeSet.add(orgPrivilege);
} else if (orgPrivilege != null) {
// 取消
privilegeSet.remove(orgPrivilege);
}
}
}
saveOrUpdate(orgRole);
return true;
}
use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRolePrivilegeServiceImpl method listByUser.
@Override
public Map<String, Boolean> listByUser(Long userId, Long orgId) {
String hql = "select role from TestOrgRole role" + " join role.userSet users " + " where users.id = ?" + " and role.orgId = ?" + " and role.deleted != true and role.disabled!= true " + " order by role.id asc";
List<TestOrgRole> ls = getDao().getListByHQL(hql, userId, orgId);
Map<String, Boolean> map = new HashMap();
for (TestOrgRole role : ls) {
for (TestOrgPrivilegeDefine priv : role.getOrgPrivilegeSet()) {
map.put(priv.getCode().toString(), true);
}
}
return map;
}
use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRoleServiceImpl method genVos.
@Override
public List<OrgRoleVo> genVos(List<TestOrgRole> pos) {
List<OrgRoleVo> vos = new LinkedList<OrgRoleVo>();
for (TestOrgRole po : pos) {
OrgRoleVo vo = genVo(po);
vos.add(vo);
}
return vos;
}
use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRoleServiceImpl method save.
@Override
public TestOrgRole save(OrgRoleVo vo, Long orgId) {
if (vo == null) {
return null;
}
TestOrgRole po = new TestOrgRole();
if (vo.getId() != null) {
po = (TestOrgRole) get(TestOrgRole.class, vo.getId());
}
po.setName(vo.getName());
po.setDescr(vo.getDescr());
po.setOrgId(orgId);
po.setDisabled(vo.getDisabled());
saveOrUpdate(po);
return po;
}
use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRoleAction 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();
OrgRoleVo orgRoleVo = JSON.parseObject(JSON.toJSONString(json.get("orgRole")), OrgRoleVo.class);
TestOrgRole po = orgRoleService.save(orgRoleVo, orgId);
List<OrgPrivilegeVo> orgPrivileges = (List<OrgPrivilegeVo>) json.get("orgPrivileges");
boolean success = orgRolePrivilegeService.saveOrgRolePrivileges(po.getId(), orgPrivileges);
List<UserVo> orgRoleUsers = (List<UserVo>) json.get("orgRoleUsers");
success = orgRoleUserService.saveOrgRoleUsers(po.getId(), orgRoleUsers);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
Aggregations