Ejemplo n.º 1
0
 /**
  * 查询 用户名 密码
  *
  * @param user
  */
 public User selectUsPs(User user) {
   QueryRunner queryRunner = new QueryRunner(JdbcUtils.getDataSource());
   String sql = "SELECT * FROM user WHERE username = ? AND password = ?";
   try {
     User query =
         queryRunner.query(
             sql,
             new BeanHandler<User>(User.class),
             new Object[] {user.getUsername(), user.getPassword()});
     return query;
   } catch (SQLException e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 2
0
  public void insert(User user) {
    String userId = SessionUtils.getCurrentUserId();
    if (StringUtils.isEmpty(userId)) {
      userId = user.getUserId();
    }

    user.setPassword(MD5Utils.getMD5String(user.getPassword()));

    user.setDelflag("1");

    Timestamp sysdate = new Timestamp(System.currentTimeMillis());
    user.setCreateUser(userId);
    user.setCreateTime(sysdate);
    user.setUpdateUser(userId);
    user.setUpdateTime(sysdate);
    this.userDao.insert(user);
  }
Ejemplo n.º 3
0
  @Override
  public boolean isValidUsernameAndPassword(String username, String password) {
    list = getAll();
    if (username != null || password != null) {
      LOG.log(Level.INFO, " Login: "******" Password:"******" List size: " + list.size());
      for (int i = 0; i < list.size(); i++) {

        User user = list.get(i);
        LOG.log(Level.INFO, " Users: " + user.toString());
        if (user.getUsername().equals(username) && user.getPassword().equals(password)) {
          return true;
        }
      }
    }
    return false;
  }
Ejemplo n.º 4
0
 /** 插入数据 */
 public Integer insertUser(User user) {
   QueryRunner queryRunner = new QueryRunner(JdbcUtils.getDataSource());
   try {
     String sql = "INSERT INTO user VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
     Object param[] = {
       getID(),
       user.getUsername(),
       user.getPassword(),
       user.getSex(),
       user.getProfession(),
       user.getFavourite(),
       user.getNote(),
       user.getType()
     };
     int update = queryRunner.update(sql, param);
     return update;
   } catch (SQLException e) {
     e.printStackTrace();
     return null;
   }
 }
Ejemplo n.º 5
0
  /**
   * 数据库操作 更新个人用户数据
   *
   * @param user
   */
  public void updateinfo(User user) {
    QueryRunner queryRunner = new QueryRunner(JdbcUtils.getDataSource());

    String sql =
        "UPDATE user SET username = ?, password = ?, sex = ?, profession = ?, favourite = ?, note = ?  WHERE id = ?;";

    try {
      queryRunner.update(
          sql,
          new Object[] {
            user.getUsername(),
            user.getPassword(),
            user.getSex(),
            user.getProfession(),
            user.getFavourite(),
            user.getNote(),
            user.getId()
          });
    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 6
0
 public void testGetPassword() throws Exception {
   assertEquals("1234", u.getPassword());
 }