use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRoleAction method get.
@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject req) {
Map<String, Object> ret = new HashMap<String, Object>();
UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
Long orgId = userVo.getDefaultOrgId();
Long orgRoleId = req.getLong("id");
List<OrgPrivilegeVo> orgRolePrivileges = orgRolePrivilegeService.listPrivilegesByOrgRole(orgId, orgRoleId);
List<UserVo> orgRoleUsers = orgRoleUserService.listUserByOrgRole(orgRoleId);
if (orgRoleId == null) {
ret.put("orgRole", new OrgRoleVo());
ret.put("orgRolePrivileges", orgRolePrivileges);
ret.put("orgRoleUsers", orgRoleUsers);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
TestOrgRole po = (TestOrgRole) orgRoleService.get(TestOrgRole.class, orgRoleId);
OrgRoleVo vo = orgRoleService.genVo(po);
ret.put("orgRole", vo);
ret.put("orgRolePrivileges", orgRolePrivileges);
ret.put("orgRoleUsers", orgRoleUsers);
ret.put("code", Constant.RespCode.SUCCESS.getCode());
return ret;
}
use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRoleServiceImpl method delete.
@Override
public boolean delete(Long id) {
TestOrgRole po = (TestOrgRole) get(TestOrgRole.class, id);
po.setDeleted(true);
saveOrUpdate(po);
return true;
}
use of com.ngtesting.platform.entity.TestOrgRole in project ngtesting-platform by aaronchen2k.
the class OrgRoleUserServiceImpl method saveOrgRoleUsers.
@Override
public boolean saveOrgRoleUsers(Long roleId, List<UserVo> orgUsers) {
if (orgUsers == null) {
return false;
}
TestOrgRole orgRole = (TestOrgRole) get(TestOrgRole.class, roleId);
Set<TestUser> userSet = orgRole.getUserSet();
for (Object obj : orgUsers) {
UserVo vo = JSON.parseObject(JSON.toJSONString(obj), UserVo.class);
if (vo.getSelecting() != vo.getSelected()) {
// 变化了
TestUser orgUser = (TestUser) get(TestUser.class, vo.getId());
if (vo.getSelecting() && !userSet.contains(orgUser)) {
// 勾选
userSet.add(orgUser);
} else if (orgUser != null) {
// 取消
userSet.remove(orgUser);
}
}
}
saveOrUpdate(orgRole);
return true;
}
Aggregations