Example #1
0
 /** 根据用户名查找用户 */
 @SuppressWarnings("unchecked")
 public List<User> searchUserByUserName(String userName) {
   Object[] params = null;
   String selectHql = null;
   selectHql = "from User as u where u.userName = '******'";
   String countHql = "select count(*) " + selectHql;
   List<User> userList = PageService.searchByPage(selectHql, countHql, params, null, userDAO);
   return userList;
 }
Example #2
0
  /** 是否存在此用户,存在返回true,不存在返回false */
  @SuppressWarnings("unchecked")
  public boolean isUserNameExist(String userName) {

    Object[] params = null;
    String selectHql = "from User as u where u.userName='******'";
    // 创建获取HQL返回记录总行数语句
    String countHql = "select count(*) " + selectHql;
    List<User> userList = PageService.searchByPage(selectHql, countHql, params, null, userDAO);
    if (userList.isEmpty()) {
      return false;
    } else return true;
  }
Example #3
0
 /** 用户登录验证 */
 @SuppressWarnings("unchecked")
 public User login(String userName, String password) {
   Object[] params = null;
   String selectHql =
       "from User as u where u.userName='******' and u.password='******'";
   // 创建获取HQL返回记录总行数语句
   String countHql = "select count(*) " + selectHql;
   List<User> userList = PageService.searchByPage(selectHql, countHql, params, null, userDAO);
   if (userList.isEmpty()) {
     return null;
   } else return userList.get(0);
 }
Example #4
0
 /** 获取指定用户信息 */
 @SuppressWarnings("unchecked")
 public List<User> getUser(PageBean page, String sort, String order) {
   Object[] params = null;
   String selectHql = null;
   selectHql = "from User";
   if (sort != null && order != null) {
     selectHql = selectHql + " order by " + sort + " " + order;
   }
   String countHql = "select count(*) " + selectHql;
   List<User> list = PageService.searchByPage(selectHql, countHql, params, page, userDAO);
   return list;
 }
Example #5
0
  /**
   * 按条件查询和分页支持
   *
   * <p>根据用户名执行模糊匹配查找,通过Page对象执行分页。
   *
   * @userName:会员登录账号
   * @page:分页对象
   */
  @SuppressWarnings("unchecked")
  public List<User> searchUser(String userName, PageBean page) {
    Object[] params = null;

    // 创建HQL查询语句
    String selectHql = null;
    if ((userName == null) || (userName.equals(""))) {
      selectHql = "from User";
    } else {
      selectHql = "from User where userName like '%" + userName + "%'";
    }

    // 创建获取HQL返回记录总行数语句
    String countHql = "select count(*) " + selectHql;

    // 执行按条件查询和分页支持
    List<User> userList = PageService.searchByPage(selectHql, countHql, params, page, userDAO);
    return userList;
  }