use of com.ngtesting.platform.entity.TestOrgPrivilegeDefine 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.TestOrgPrivilegeDefine 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.TestOrgPrivilegeDefine in project ngtesting-platform by aaronchen2k.
the class OrgRolePrivilegeServiceImpl method listAllOrgPrivileges.
private List<TestOrgPrivilegeDefine> listAllOrgPrivileges() {
DetachedCriteria dc = DetachedCriteria.forClass(TestOrgPrivilegeDefine.class);
dc.add(Restrictions.eq("deleted", Boolean.FALSE));
dc.add(Restrictions.eq("disabled", Boolean.FALSE));
dc.addOrder(Order.asc("id"));
List<TestOrgPrivilegeDefine> ls = findAllByCriteria(dc);
return ls;
}
use of com.ngtesting.platform.entity.TestOrgPrivilegeDefine in project ngtesting-platform by aaronchen2k.
the class OrgRolePrivilegeServiceImpl method listPrivilegesByOrgRole.
@Override
public List<OrgPrivilegeVo> listPrivilegesByOrgRole(Long orgId, Long orgRoleId) {
List<TestOrgPrivilegeDefine> allPrivileges = listAllOrgPrivileges();
List<TestOrgPrivilegeDefine> orgRolePrivileges;
if (orgRoleId == null) {
orgRolePrivileges = new LinkedList<>();
} else {
orgRolePrivileges = listOrgRolePrivileges(orgId, orgRoleId);
}
List<OrgPrivilegeVo> vos = new LinkedList<OrgPrivilegeVo>();
for (TestOrgPrivilegeDefine po1 : allPrivileges) {
OrgPrivilegeVo vo = genVo(orgId, po1);
vo.setSelected(false);
vo.setSelecting(false);
for (TestOrgPrivilegeDefine po2 : orgRolePrivileges) {
if (po1.getId().longValue() == po2.getId().longValue()) {
vo.setSelected(true);
vo.setSelecting(true);
}
}
vos.add(vo);
}
return vos;
}
use of com.ngtesting.platform.entity.TestOrgPrivilegeDefine in project ngtesting-platform by aaronchen2k.
the class OrgRoleServiceImpl method getDefaultPrivByRoleCode.
// @Override
// public void initOrgRoleBasicDataPers(Long orgId) {
// for (TestOrgRole.OrgRoleCode e : TestOrgRole.OrgRoleCode.values()) {
// TestOrgRole po = new TestOrgRole();
//
// po.setName(e.name);
// po.setCode(e);
// po.setDescr("");
// po.setOrgId(orgId);
// po.getOrgPrivilegeSet().addAll(getDefaultPrivByRoleCode(e));
//
// saveOrUpdate(po);
// }
// }
@Override
public List<TestOrgPrivilegeDefine> getDefaultPrivByRoleCode(TestOrgRole.OrgRoleCode e) {
TestOrgPrivilegeDefine.OrgPrivilegeCode code = TestOrgPrivilegeDefine.OrgPrivilegeCode.valueOf(e.code);
DetachedCriteria dc = DetachedCriteria.forClass(TestOrgPrivilegeDefine.class);
dc.add(Restrictions.eq("code", code));
dc.add(Restrictions.ne("deleted", true));
dc.add(Restrictions.ne("disabled", true));
dc.addOrder(Order.asc("id"));
List<TestOrgPrivilegeDefine> ls = findAllByCriteria(dc);
return ls;
}
Aggregations