Search in sources :

Example 1 with GroupRelation

use of com.ctrip.platform.dal.daogen.entity.GroupRelation in project dal by ctripcorp.

the class GroupRelationDao method getGroupRelationByCurrentGroupIdAndChildGroupId.

public GroupRelation getGroupRelationByCurrentGroupIdAndChildGroupId(Integer currentGroupId, Integer childGroupId) throws SQLException {
    FreeSelectSqlBuilder<GroupRelation> builder = new FreeSelectSqlBuilder<>(dbCategory);
    builder.setTemplate("SELECT id, current_group_id, child_group_id, child_group_role, adduser, update_user_no ,update_time FROM group_relation WHERE current_group_id = ? AND child_group_id = ?");
    StatementParameters parameters = new StatementParameters();
    int i = 1;
    parameters.set(i++, "current_group_id", Types.INTEGER, currentGroupId);
    parameters.set(i++, "child_group_id", Types.INTEGER, childGroupId);
    builder.mapWith(groupRelationRowMapper).requireFirst().nullable();
    DalHints hints = DalHints.createIfAbsent(null).allowPartial();
    return queryDao.query(builder, parameters, hints);
}
Also used : GroupRelation(com.ctrip.platform.dal.daogen.entity.GroupRelation) FreeSelectSqlBuilder(com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder) DalHints(com.ctrip.platform.dal.dao.DalHints) StatementParameters(com.ctrip.platform.dal.dao.StatementParameters)

Example 2 with GroupRelation

use of com.ctrip.platform.dal.daogen.entity.GroupRelation in project dal by ctripcorp.

the class ApproveResource method needApproveTask.

public boolean needApproveTask(int projectId, int userId) throws SQLException {
    Project prj = BeanGetter.getDaoOfProject().getProjectByID(projectId);
    if (prj == null) {
        return true;
    }
    List<UserGroup> lst = BeanGetter.getDalUserGroupDao().getUserGroupByGroupIdAndUserId(prj.getDal_group_id(), userId);
    if (lst != null && lst.size() > 0 && lst.get(0).getRole() == 1) {
        return false;
    }
    // all child group
    List<GroupRelation> grs = BeanGetter.getGroupRelationDao().getAllGroupRelationByCurrentGroupId(prj.getDal_group_id());
    if (grs == null || grs.size() < 1) {
        return true;
    }
    // check user is or not in the child group which have admin role
    Iterator<GroupRelation> ite = grs.iterator();
    while (ite.hasNext()) {
        GroupRelation gr = ite.next();
        if (gr.getChild_group_role() == 1) {
            int groupId = gr.getChild_group_id();
            List<UserGroup> test = BeanGetter.getDalUserGroupDao().getUserGroupByGroupIdAndUserId(groupId, userId);
            if (test != null && test.size() > 0) {
                return false;
            }
        }
    }
    return true;
}
Also used : GroupRelation(com.ctrip.platform.dal.daogen.entity.GroupRelation) Project(com.ctrip.platform.dal.daogen.entity.Project) UserGroup(com.ctrip.platform.dal.daogen.entity.UserGroup)

Aggregations

GroupRelation (com.ctrip.platform.dal.daogen.entity.GroupRelation)2 DalHints (com.ctrip.platform.dal.dao.DalHints)1 StatementParameters (com.ctrip.platform.dal.dao.StatementParameters)1 FreeSelectSqlBuilder (com.ctrip.platform.dal.dao.sqlbuilder.FreeSelectSqlBuilder)1 Project (com.ctrip.platform.dal.daogen.entity.Project)1 UserGroup (com.ctrip.platform.dal.daogen.entity.UserGroup)1