Ejemplo n.º 1
0
  @Override
  public String input() throws Exception {
    this.sysUser = service.getUser(userid);
    set("sysUser", sysUser);

    // 也显示全国律协的以及系统层级的

    System.out.println("===================" + sysUser.getCityid());
    this.datavisible.setProvinceid(sysUser.getProvinceid());
    this.datavisible.setCityid(sysUser.getCityid());
    this.datavisible.setOfficeid(sysUser.getOfficeid());

    this.datavisible.getVisibleDatas(this.getLoginUser(), true);

    SysRole sysrole = this.getLoginUser().getSysRole();
    if (sysrole != null) {
      BasicService bs = (BasicService) this.getBean("basicService");
      DetachedCriteria dc = DetachedCriteria.forClass(SysRole.class);
      Criterion c1 = null;
      if (sysrole.getCansamegrade()) c1 = Restrictions.ge("gradeid", sysrole.getGradeid());
      else c1 = Restrictions.gt("gradeid", sysrole.getGradeid());
      Criterion c2 = Restrictions.eq("roleid", sysrole.getRoleid());
      dc.add(Restrictions.or(c1, c2));
      allroles = bs.findAllByCriteria(dc);

    } else { // 没角色的话,显示所有的角色
      SysRoleService roleService = (SysRoleService) this.getBean("sysRoleService");
      allroles = roleService.getRoles();
    }

    return INPUT;
  }
  /*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {

    // TODO Auto-generated method stub
    this.datavisible.getVisibleDatas(this.getLoginUser(), true);

    DetachedCriteria detachedCriteria = DetachedCriteria.forClass(SysLoginlog.class);

    if (loginTime != null && !loginTime.equals("")) {
      java.sql.Timestamp begin = new Timestamp(df.parse(loginTime + " 00:00:00").getTime());
      java.sql.Timestamp end = new Timestamp(df.parse(loginTime + " 23:59:59").getTime());
      detachedCriteria.add(Restrictions.between("loginTime", begin, end));
    }
    SysRole role = this.getLoginUser().getSysRole();
    if (role != null) {
      Set<SysRoleVisible> rolevisibles = role.getSysRoleVisibles();
      SysRoleVisible rolevisible = null;
      for (SysRoleVisible v : rolevisibles) {
        if (v.getThetable().equalsIgnoreCase("sys_loginlog")) {
          rolevisible = v;
          break;
        }
      }
      // 权限判断了
      if (rolevisible != null) {
        detachedCriteria.add(
            Restrictions.eq(
                rolevisible.getThefield(),
                PropertyUtils.getProperty(this.getLoginUser(), rolevisible.getThefield())));
      }
    }

    if (datavisible.getOfficeid() != 0) {
      detachedCriteria.add(Restrictions.eq("officeid", datavisible.getOfficeid()));
    } else if (datavisible.getCityid() != 0) {
      detachedCriteria.add(Restrictions.eq("cityid", datavisible.getCityid()));
    } else if (datavisible.getProvinceid() != 0) {
      detachedCriteria.add(Restrictions.eq("provinceid", datavisible.getProvinceid()));
    }

    detachedCriteria.addOrder(Order.desc("loginid"));
    BasicService service = (BasicService) getBean("basicService");
    this.page = service.findPageByCriteria(detachedCriteria, pageSize, pageNo);

    return SUCCESS;
  }