Пример #1
0
  /**
   * 查询用户数据
   *
   * @param user
   * @param page
   * @return
   */
  public List<User> listUsers(User user, PageInfo page) {
    StringBuilder sql = new StringBuilder();
    sql.append("SELECT T1.id,nickname,phone,industry,  ")
        .append("T2.name as schoolName,major,grade,T3.name AS gradeName ")
        .append("FROM USER_INFO T1 ")
        .append("LEFT JOIN SYS_SCHOOL T2 ON T2.ID=T1.schoolId ")
        .append("LEFT JOIN SYS_DICT T3 ON T3.CODE=T1.grade AND T3.groupName=? ")
        .append("WHERE 1=1 ");
    ParamInfo paramInfo = new ParamInfo();
    paramInfo.setTypeAndData(Types.VARCHAR, GloabConstant.GROUP_GRADE);
    if (!Utils.isEmpty(user.getNickname())) {
      sql.append(" AND T1.nickname like ? ");
      paramInfo.setTypeAndData(Types.VARCHAR, "%" + user.getNickname() + "%");
    }

    if (!Utils.isEmpty(user.getType())) {
      sql.append(" AND T1.type = ? ");
      paramInfo.setTypeAndData(Types.CHAR, user.getType());
    }

    //		if(!Utils.isEmpty(user.getStatus()))
    //		{
    //			sql.append(" AND status = ? ");
    //			paramInfo.setTypeAndData(Types.CHAR, user.getStatus());
    //		}
    return userDao.getRecords(sql.toString(), paramInfo, page, User.class);
  }
Пример #2
0
  /**
   * 查询用户数据的数量
   *
   * @param user
   * @return
   */
  public long getUserCount(User user) {
    StringBuilder sql = new StringBuilder();
    sql.append(" select count(1) from USER_INFO WHERE 1=1 ");
    ParamInfo paramInfo = new ParamInfo();
    if (!Utils.isEmpty(user.getName())) {
      sql.append(" AND name like ? ");
      paramInfo.setTypeAndData(Types.VARCHAR, "%" + user.getName() + "%");
    }

    if (!Utils.isEmpty(user.getType())) {
      sql.append(" AND type = ? ");
      paramInfo.setTypeAndData(Types.CHAR, user.getType());
    }

    if (!Utils.isEmpty(user.getStatus())) {
      sql.append(" AND status = ? ");
      paramInfo.setTypeAndData(Types.CHAR, user.getStatus());
    }
    return userDao.getCount(sql.toString(), paramInfo);
  }