use of com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation in project tis by qlangtech.
the class RoleAction method createRelation.
private void createRelation(final List<Integer> funcids, Role role) {
FuncRoleRelation relation = null;
com.qlangtech.tis.manage.biz.dal.pojo.Func func = null;
for (Integer id : funcids) {
func = this.getFuncDAO().loadFromWriteDB(id);
if (func == null) {
continue;
}
relation = new FuncRoleRelation();
relation.setFuncId(func.getFunId());
relation.setFuncKey(func.getFunKey());
relation.setFuncName(func.getFuncName());
relation.setGmtCreate(new Date());
relation.setGmtModified(new Date());
relation.setrId(role.getrId());
relation.setRoleName(role.getRoleName());
this.getFuncRoleRelationDAO().insertSelective(relation);
}
}
use of com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation in project tis by qlangtech.
the class FuncRoleRelationDAOImpl method loadFromWriteDB.
public FuncRoleRelation loadFromWriteDB(Integer id) {
FuncRoleRelation key = new FuncRoleRelation();
key.setId(id);
FuncRoleRelation record = this.loadFromWriterDB("func_role_relation.ibatorgenerated_selectByPrimaryKey", key);
return record;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation in project tis by qlangtech.
the class FuncRoleRelationDAOImpl method selectByPrimaryKey.
public FuncRoleRelation selectByPrimaryKey(Integer id) {
FuncRoleRelation key = new FuncRoleRelation();
key.setId(id);
FuncRoleRelation record = this.load("func_role_relation.ibatorgenerated_selectByPrimaryKey", key);
return record;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation in project tis by qlangtech.
the class FuncRoleRelationDAOImpl method deleteByPrimaryKey.
public int deleteByPrimaryKey(Integer id) {
FuncRoleRelation key = new FuncRoleRelation();
key.setId(id);
return this.deleteRecords("func_role_relation.ibatorgenerated_deleteByPrimaryKey", key);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation in project tis by qlangtech.
the class RoleAction method doUpdateRole.
/**
* 更新角色
*
* @param context
*/
@Func(PermissionConstant.AUTHORITY_ROLE_UPDATE)
public void doUpdateRole(Context context) {
// 用户选中的func功能集合
final List<Integer> funcids = Arrays.asList(this.getIntAry("funcid"));
final Role role = this.getRoleDAO().loadFromWriteDB(this.getInt("roleid"));
String roleName = this.getString("rolename");
role.setRoleName(roleName);
context.put("role", role);
context.put(selfuncidKEY, Collections.unmodifiableCollection(funcids));
if (StringUtils.isBlank(roleName)) {
this.addErrorMessage(context, "请添写角色名称");
return;
}
RoleCriteria criteria = new RoleCriteria();
criteria.createCriteria().andRoleNameEqualTo(roleName).andRIdNotEqualTo(role.getrId());
if (this.getRoleDAO().countByExample(criteria) > 0) {
this.addErrorMessage(context, "角色名称:“" + roleName + "”已经创建");
return;
}
if (funcids.size() < 1) {
this.addErrorMessage(context, "请为新添加的角色设置相应的功能");
return;
}
FuncRoleRelationCriteria fcriteria = new FuncRoleRelationCriteria();
fcriteria.createCriteria().andRIdEqualTo(role.getrId());
List<FuncRoleRelation> rellist = this.getFuncRoleRelationDAO().selectByExample(fcriteria);
List<Integer> orignfunclist = new ArrayList<Integer>();
for (FuncRoleRelation rel : rellist) {
orignfunclist.add(rel.getFuncId());
}
List<Integer> addfuncs = new ArrayList<Integer>();
// 需要删除的
for (Integer funcid : funcids) {
if (orignfunclist.contains(funcid)) {
orignfunclist.remove(funcid);
} else {
addfuncs.add(funcid);
}
}
for (Integer funcid : orignfunclist) {
fcriteria = new FuncRoleRelationCriteria();
fcriteria.createCriteria().andRIdEqualTo(role.getrId()).andFuncIdEqualTo(funcid);
this.getFuncRoleRelationDAO().deleteByExample(fcriteria);
}
Role update = new Role();
update.setRoleName(roleName);
RoleCriteria rcriteria = new RoleCriteria();
rcriteria.createCriteria().andRIdEqualTo(role.getrId());
this.getRoleDAO().updateByExampleSelective(update, rcriteria);
// 需要添加的
createRelation(addfuncs, role);
this.addActionMessage(context, "成功更新角色:“" + role.getRoleName() + "”");
}
Aggregations