Ejemplo n.º 1
0
  /*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {

    DetachedCriteria detachedCriteria =
        DetachedCriteria.forClass(SysUser.class).add(Restrictions.eq("roleid", 1));

    // 这里要判断出登录帐号所属的group
    // 如果是admin,看所有的,如果不是admin,则根据登录人员的所属角色,判断角色对用户和对部门的可见性

    if (loginname != null && !"".equals(loginname))
      detachedCriteria.add(Restrictions.like("loginname", loginname, MatchMode.ANYWHERE));
    if (username != null && !"".equals(username))
      detachedCriteria.add(Restrictions.like("username", username, MatchMode.ANYWHERE));
    if (systemno != null && !"".equals(systemno))
      detachedCriteria.add(Restrictions.like("systemno", systemno, MatchMode.ANYWHERE));
    // 必须是没有删除的啊
    detachedCriteria.add(Restrictions.eq("delflag", false));
    // 取消掉自己的显示
    detachedCriteria.add(Restrictions.ne("userid", getLoginUser().getUserid()));
    SysUser sysUser = getLoginUser();
    SysGroup group = sysUser.getSysGroup();
    // 如果没有所属的group,则能查看所有的数据信息,否则只能看本部门和下级部门的数据
    if (group != null && group.getGroupid() != 1) { // 不是深圳律协的人上来的话
      int groupid = group.getGroupid();
      GroupTree tree = new GroupTree();
      List groupidlist = tree.getChildGroupIds(groupid);
      detachedCriteria
          .createAlias("sysGroup", "sysGroup")
          .add(Restrictions.in("sysGroup.groupid", groupidlist));
      if (groupname != null && !"".equals(groupname)) {
        detachedCriteria.add(
            Restrictions.like("sysGroup.groupname", groupname, MatchMode.ANYWHERE));
      }

      // detachedCriteria.add(Restrictions.in("groupid", groupidlist));
    } else if (groupname != null && !"".equals(groupname)) {
      detachedCriteria
          .createAlias("sysGroup", "sysGroup")
          .add(Restrictions.like("sysGroup.groupname", groupname, MatchMode.ANYWHERE));
    }
    detachedCriteria.setFetchMode("sysGroup", FetchMode.JOIN);

    // 按userid逆序排序
    detachedCriteria.addOrder(Order.desc("userid"));
    BasicService service = (BasicService) getBean("basicService");
    this.page = service.findPageByCriteria(detachedCriteria, pageSize, pageNo);
    // TODO Auto-generated method stub
    return SUCCESS;
  }