package com.org.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Repository;
import com.org.JdbcTempBaseDao;
import com.org.dao.IUserDao;
import com.org.model.User;
@Repository
@SuppressWarnings("all")
public class UserDaoImpl extends JdbcTempBaseDao implements IUserDao {
@Override
public List getUserList() {
String sql="select * from user ";
final List list= new ArrayList();
jdbcTemplate.query(sql, new RowCallbackHandler(){
@Override
public void processRow(ResultSet rs) throws SQLException {
User u=new User();
u.setId(rs.getInt("id"));
u.setUsername(rs.getString("username"));
u.setPassword(rs.getString("password"));
u.setCreateDate(rs.getString("createDate"));
u.setModifyDate(rs.getString("modifyDate"));
u.setType(rs.getString("type"));
list.add(u);
}
});
return list;
}
@Override
public List getUserLists(Map map) {
return null;
}
@Override
public Integer getUserCount(Map map) {
String sql = "select count(1) from User where id=? ";
return getJdbcTemplate().queryForObject(sql, Integer.class,map);
}
@Override
public User getUserById(Integer primaryKeyId) {
String sql = "select id,username, password, createDate, modifyDate,type from User where id=?";
List userList = getJdbcTemplate().query(sql, new BeanPropertyRowMapper(User.class), primaryKeyId);
if(userList.size() == 0) {
return null;
}
return userList.get(0);
}
@Override
public void delUserById(Int
1