Search in sources :

Example 1 with Role

use of com.qlangtech.tis.manage.biz.dal.pojo.Role in project tis by qlangtech.

the class RoleAction method doSelectRole.

/**
 * 用户选择角色
 *
 * @param context
 */
@Func(PermissionConstant.AUTHORITY_USER_ROLE_SET)
public void doSelectRole(Context context) {
    String usrid = this.getString("usrid");
    Integer roleid = this.getInt("roleid");
    Role role = this.getRoleDAO().loadFromWriteDB(roleid);
    Assert.assertNotNull(role);
    UsrDptRelationCriteria ucriteria = new UsrDptRelationCriteria();
    ucriteria.createCriteria().andUsrIdEqualTo(usrid);
    UsrDptRelation record = new UsrDptRelation();
    record.setRoleName(role.getRoleName());
    record.setrId(role.getrId());
    this.getUsrDptRelationDAO().updateByExampleSelective(record, ucriteria);
    addActionMessage(context, "用户选择了新的角色:“" + role.getRoleName() + "”");
}
Also used : Role(com.qlangtech.tis.manage.biz.dal.pojo.Role) UsrDptRelationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelationCriteria) UsrDptRelation(com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelation) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 2 with Role

use of com.qlangtech.tis.manage.biz.dal.pojo.Role in project tis by qlangtech.

the class RoleDAOImpl method deleteByPrimaryKey.

public int deleteByPrimaryKey(Integer rId) {
    Role key = new Role();
    key.setrId(rId);
    return this.deleteRecords("role.ibatorgenerated_deleteByPrimaryKey", key);
}
Also used : Role(com.qlangtech.tis.manage.biz.dal.pojo.Role)

Example 3 with Role

use of com.qlangtech.tis.manage.biz.dal.pojo.Role in project tis by qlangtech.

the class RoleDAOImpl method loadFromWriteDB.

public Role loadFromWriteDB(Integer rId) {
    Role key = new Role();
    key.setrId(rId);
    Role record = this.loadFromWriterDB("role.ibatorgenerated_selectByPrimaryKey", key);
    return record;
}
Also used : Role(com.qlangtech.tis.manage.biz.dal.pojo.Role)

Example 4 with Role

use of com.qlangtech.tis.manage.biz.dal.pojo.Role in project tis by qlangtech.

the class RoleDAOImpl method selectByPrimaryKey.

public Role selectByPrimaryKey(Integer rId) {
    Role key = new Role();
    key.setrId(rId);
    Role record = this.load("role.ibatorgenerated_selectByPrimaryKey", key);
    return record;
}
Also used : Role(com.qlangtech.tis.manage.biz.dal.pojo.Role)

Example 5 with Role

use of com.qlangtech.tis.manage.biz.dal.pojo.Role 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() + "”");
}
Also used : Role(com.qlangtech.tis.manage.biz.dal.pojo.Role) RoleCriteria(com.qlangtech.tis.manage.biz.dal.pojo.RoleCriteria) FuncRoleRelationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelationCriteria) ArrayList(java.util.ArrayList) FuncRoleRelation(com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Role (com.qlangtech.tis.manage.biz.dal.pojo.Role)6 Func (com.qlangtech.tis.manage.spring.aop.Func)3 RoleCriteria (com.qlangtech.tis.manage.biz.dal.pojo.RoleCriteria)2 FuncRoleRelation (com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelation)1 FuncRoleRelationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.FuncRoleRelationCriteria)1 UsrDptRelation (com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelation)1 UsrDptRelationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelationCriteria)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1