Exemplo n.º 1
0
 public List<User> selectByCriteria(User paramUser) {
   List userList = this.userDao.selectByCriteria(paramUser);
   List results = new ArrayList();
   if (userList != null) {
     for (int i = 0; i < userList.size(); i++) {
       User user = (User) userList.get(i);
       user.setBirthdayStr(DateUtils.formatDate2Str(user.getBirthday(), "yyyy-MM-dd"));
       user.setSex((String) Constants.SEX_MAP.get(user.getSex()));
       user.setStatus((String) Constants.USER_STATUS_MAP.get(user.getStatus()));
       user.setCreateDateStr(
           DateUtils.formatDate2Str(user.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
       results.add(user);
     }
   }
   return results;
 }
Exemplo n.º 2
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;
   }
 }
Exemplo n.º 3
0
 public List<User> selectByCriteriaForPaging(User paramUser) {
   if ("1".equals(SessionUtils.getUserRole())) paramUser.setRole("'2','3'");
   else {
     paramUser.setRole("'3'");
   }
   List userList =
       this.userDao.selectByCriteriaForPaging(
           paramUser, paramUser.getStart(), paramUser.getLimit());
   List results = new ArrayList();
   if (userList != null) {
     for (int i = 0; i < userList.size(); i++) {
       User user = (User) userList.get(i);
       user.setBirthdayStr(DateUtils.formatDate2Str(user.getBirthday(), "yyyy-MM-dd"));
       user.setRole((String) Constants.ROLE_MAP.get(user.getRole()));
       user.setSex((String) Constants.SEX_MAP.get(user.getSex()));
       user.setStatus((String) Constants.USER_STATUS_MAP.get(user.getStatus()));
       results.add(user);
     }
   }
   return results;
 }
Exemplo n.º 4
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();
    }
  }