use of com.ctrip.platform.dal.daogen.entity.UserGroup in project dal by ctripcorp.
the class FileResource method validatePermission.
private boolean validatePermission(HttpServletRequest request, Integer projectGroupId) throws Exception {
boolean result = false;
LoginUser user = RequestUtil.getUserInfo(request);
if (user == null)
return result;
try {
List<UserGroup> userGroups = BeanGetter.getDalUserGroupDao().getUserGroupByUserId(user.getId());
if (userGroups == null || userGroups.size() == 0)
return result;
for (UserGroup group : userGroups) {
if (group.getGroup_id().intValue() == projectGroupId.intValue()) {
result |= true;
break;
}
}
} catch (Throwable e) {
}
return result;
}
use of com.ctrip.platform.dal.daogen.entity.UserGroup in project dal by ctripcorp.
the class UserGroupDao method insertUserGroup.
public int insertUserGroup(Integer user_id, Integer group_id, Integer role, Integer adduser) throws SQLException {
UserGroup userGroup = new UserGroup();
userGroup.setUser_id(user_id);
userGroup.setGroup_id(group_id);
userGroup.setRole(role);
userGroup.setAdduser(adduser);
DalHints hints = DalHints.createIfAbsent(null);
return client.insert(hints, userGroup);
}
use of com.ctrip.platform.dal.daogen.entity.UserGroup 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;
}
Aggregations