示例#1
0
  /** 列表 */
  @RequestMapping(value = "/list")
  public ModelAndView listUsers(HttpSession session, Page page) throws Exception {
    logBefore(logger, "特别推荐列表");
    mv.clear();
    try {
      pd = this.getPageData();

      // 检索条件================================
      String title = pd.getString("title");
      if (null != title && !"".equals(title)) {
        title = title.trim();
        pd.put("title", title);
      }
      // 检索条件================================

      page.setPd(pd);
      List<PageData> varList = featuredService.list(page);

      /*调用权限*/
      this
          .getHC(); // ================================================================================
      /*调用权限*/

      mv.setViewName("information/featured/featured_list");
      mv.addObject("varList", varList);
      mv.addObject("pd", pd);
    } catch (Exception e) {
      logger.error(e.toString(), e);
    }

    return mv;
  }
示例#2
0
 /** 列表 */
 @RequestMapping(value = "/list")
 public ModelAndView list(Page page) {
   logBefore(logger, "列表Imgmsg");
   if (!Jurisdiction.buttonJurisdiction(menuUrl, "cha")) {
     return null;
   } // 校验权限
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   try {
     pd = this.getPageData();
     String KEYWORD = pd.getString("KEYWORD");
     if (null != KEYWORD && !"".equals(KEYWORD)) {
       pd.put("KEYWORD", KEYWORD.trim());
     }
     page.setPd(pd);
     List<PageData> varList = imgmsgService.list(page); // 列出Imgmsg列表
     mv.setViewName("weixin/imgmsg/imgmsg_list");
     mv.addObject("varList", varList);
     mv.addObject("pd", pd);
     mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
   } catch (Exception e) {
     logger.error(e.toString(), e);
   }
   return mv;
 }
示例#3
0
 /**
  * 根据数据库方言,生成特定的分页sql
  *
  * @param sql
  * @param page
  * @return
  */
 private String generatePageSql(String sql, Page page) {
   if (page != null && Tools.notEmpty(dialect)) {
     StringBuffer pageSql = new StringBuffer();
     if ("mysql".equals(dialect)) {
       pageSql.append(sql);
       pageSql.append(" limit " + page.getCurrentResult() + "," + page.getShowCount());
     } else if ("oracle".equals(dialect)) {
       pageSql.append("select * from (select tmp_tb.*,ROWNUM row_id from (");
       pageSql.append(sql);
       // pageSql.append(") as tmp_tb where ROWNUM<=");
       pageSql.append(") tmp_tb where ROWNUM<=");
       pageSql.append(page.getCurrentResult() + page.getShowCount());
       pageSql.append(") where row_id>");
       pageSql.append(page.getCurrentResult());
     }
     return pageSql.toString();
   } else {
     return sql;
   }
 }
示例#4
0
  /** 显示用户列表(用户组) */
  @RequestMapping(value = "/listUsers")
  public ModelAndView listUsers(Page page) throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();

    String USERNAME = pd.getString("USERNAME");

    if (null != USERNAME && !"".equals(USERNAME)) {
      USERNAME = USERNAME.trim();
      pd.put("USERNAME", USERNAME);
    }

    String lastLoginStart = pd.getString("lastLoginStart");
    String lastLoginEnd = pd.getString("lastLoginEnd");

    if (lastLoginStart != null && !"".equals(lastLoginStart)) {
      lastLoginStart = lastLoginStart + " 00:00:00";
      pd.put("lastLoginStart", lastLoginStart);
    }
    if (lastLoginEnd != null && !"".equals(lastLoginEnd)) {
      lastLoginEnd = lastLoginEnd + " 00:00:00";
      pd.put("lastLoginEnd", lastLoginEnd);
    }

    // 从session获取用户信息
    Subject currentUser = SecurityUtils.getSubject();
    Session session = currentUser.getSession();
    User user = (User) session.getAttribute(Const.SESSION_USER);
    pd.put("USERID", user.getUSER_ID());
    pd.put("ROLEID", user.getROLE_ID());

    logger.info("pd:" + gson.toJson(pd));

    page.setPd(pd);
    List<PageData> userList = null;
    List<Role> roleList = null;
    if (userService.isAdmin(user.getROLE_ID())) {
      userList = userService.listPdPageUser(page); // 列出用户列表
      roleList = roleService.listAllERRoles(); // 列出所有角色

    } else if (userService.isCooper(user.getROLE_ID())) {
      userList = userService.listSubUser(page); // 列出用户列表
      roleList = roleService.listSubUserRole(userService.SUBUSER_CODE); // 列出所有二级角色
    }

    mv.setViewName("system/user/user_list");
    mv.addObject("userList", userList);
    mv.addObject("roleList", roleList);

    mv.addObject("pd", pd);
    mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
    return mv;
  }
示例#5
0
  public Object intercept(Invocation ivk) throws Throwable {
    // TODO Auto-generated method stub
    if (ivk.getTarget() instanceof RoutingStatementHandler) {
      RoutingStatementHandler statementHandler = (RoutingStatementHandler) ivk.getTarget();
      BaseStatementHandler delegate =
          (BaseStatementHandler) ReflectHelper.getValueByFieldName(statementHandler, "delegate");
      MappedStatement mappedStatement =
          (MappedStatement) ReflectHelper.getValueByFieldName(delegate, "mappedStatement");

      if (mappedStatement.getId().matches(pageSqlId)) { // 拦截需要分页的SQL
        BoundSql boundSql = delegate.getBoundSql();
        Object parameterObject =
            boundSql
                .getParameterObject(); // 分页SQL<select>中parameterType属性对应的实体参数,即Mapper接口中执行分页方法的参数,该参数不得为空
        if (parameterObject == null) {
          throw new NullPointerException("parameterObject尚未实例化!");
        } else {
          Connection connection = (Connection) ivk.getArgs()[0];
          String sql = boundSql.getSql();
          // String countSql = "select count(0) from (" + sql+ ") as tmp_count"; //记录统计
          String countSql =
              "select count(0) from ("
                  + sql
                  + ")  tmp_count"; // 记录统计 == oracle 加 as 报错(SQL command not properly ended)
          PreparedStatement countStmt = connection.prepareStatement(countSql);
          BoundSql countBS =
              new BoundSql(
                  mappedStatement.getConfiguration(),
                  countSql,
                  boundSql.getParameterMappings(),
                  parameterObject);
          setParameters(countStmt, mappedStatement, countBS, parameterObject);
          ResultSet rs = countStmt.executeQuery();
          int count = 0;
          if (rs.next()) {
            count = rs.getInt(1);
          }
          rs.close();
          countStmt.close();
          // System.out.println(count);
          Page page = null;
          if (parameterObject instanceof Page) { // 参数就是Page实体
            page = (Page) parameterObject;
            page.setEntityOrField(true);
            page.setTotalResult(count);
          } else { // 参数为某个实体,该实体拥有Page属性
            Field pageField = ReflectHelper.getFieldByFieldName(parameterObject, "page");
            if (pageField != null) {
              page = (Page) ReflectHelper.getValueByFieldName(parameterObject, "page");
              if (page == null) page = new Page();
              page.setEntityOrField(false);
              page.setTotalResult(count);
              ReflectHelper.setValueByFieldName(parameterObject, "page", page); // 通过反射,对实体对象设置分页对象
            } else {
              throw new NoSuchFieldException(parameterObject.getClass().getName() + "不存在 page 属性!");
            }
          }
          String pageSql = generatePageSql(sql, page);
          ReflectHelper.setValueByFieldName(boundSql, "sql", pageSql); // 将分页sql语句反射回BoundSql.
        }
      }
    }
    return ivk.proceed();
  }