할일 추가 기능
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package co.nook.app.user.dao;
|
||||
|
||||
import co.nook.app.common.Dao;
|
||||
import co.nook.app.user.service.UserMapper;
|
||||
import co.nook.app.user.service.UserService;
|
||||
import co.nook.app.user.vo.UserVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -13,70 +16,55 @@ import java.util.ArrayList;
|
||||
|
||||
@Repository("userDao")
|
||||
public class UserDao implements UserService{
|
||||
PreparedStatement psmt;
|
||||
ResultSet rs;
|
||||
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
public UserDao (JdbcTemplate jdbcTemplate){
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<UserVo> allSelect(Connection conn){
|
||||
public ArrayList<UserVo> allSelect(){
|
||||
return null;
|
||||
}
|
||||
|
||||
final String SELECT_BY_ID = "select * from user where id = ?";
|
||||
@Override
|
||||
public UserVo select(Connection conn, String id){
|
||||
|
||||
UserVo vo = null;
|
||||
try{
|
||||
conn = Dao.getConnection();
|
||||
psmt = conn.prepareStatement(SELECT_BY_ID);
|
||||
psmt.setString(1, id);
|
||||
rs = psmt.executeQuery();
|
||||
|
||||
if(rs.next()){
|
||||
vo = new UserVo();
|
||||
vo.setUserNo(rs.getInt("userno"));
|
||||
vo.setId(rs.getString("id"));
|
||||
vo.setPassword(rs.getString("password"));
|
||||
vo.setSalt(rs.getString("salt"));
|
||||
}
|
||||
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
public UserVo select( String id ){
|
||||
try {
|
||||
return jdbcTemplate.queryForObject(SELECT_BY_ID, new UserMapper(), id );
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
// EmptyResultDataAccessException 예외 발생시 null 리턴
|
||||
return null;
|
||||
}
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVo select(Connection conn, int userNo){
|
||||
public UserVo select( int userNo){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final String INSERT = "INSERT INTO user (userno, id, password, salt) VALUES ( NEXTVAL(seq_user), ?, ?, ?)";
|
||||
@Override
|
||||
public int insert(Connection conn, UserVo vo){
|
||||
int result = 0;
|
||||
try{
|
||||
psmt = conn.prepareStatement(INSERT);
|
||||
psmt.setString(1, vo.getId());
|
||||
psmt.setString(2, vo.getPassword());
|
||||
psmt.setString(3, vo.getSalt());
|
||||
result = psmt.executeUpdate();
|
||||
}catch(SQLException throwables){
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
public int insert( UserVo vo){
|
||||
int n =jdbcTemplate.update(INSERT,
|
||||
vo.getId(),
|
||||
vo.getPassword(),
|
||||
vo.getSalt()
|
||||
);
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Connection conn, UserVo vo){
|
||||
public int update( UserVo vo){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Connection conn, UserVo vo){
|
||||
public int delete( UserVo vo){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user