Repository
public class CustomerDaoImpl implements CustomerDao (
êAutowired
private JdbcTemplate jdbcTemplate;
7/添加客户信息
public int saveCustomer (Customer customer) {
String sql="insert into tb customer (jobNo, name , departMent) values (?, ?,?) ';
int result=jdbcTemplate. update (sql, new Object[1
(customer.getJobNO () , customer.getName () , customer. getDepartment ()}) ;
return result;
//获取所有客户信息
public List<Customer> getAllCustomer() {
String sq1="select *from tb customer";
return jdbcTemplate.query (sql,
new BeanPropertyRowMapper<> (Customer.class)) ;
1
//根据id查询客户信息
public Customer getCustomerById (Integer id) {
String sql="select *from tb customer where id=?"; return jdbcTemplate .queryForObject (sql,
new BeanPropertyRowMapper<> (Customer.class) , id) ;
2______________
/修改客户信息
public int updateCustomer (Customer customer) (
String sql="update tb_customer set jobNo=? , name=?, departMent=?
where id=?";
return jdbcTemplate . update (sql, customer.getJobNo () ,customer.getName (),
customer. getDepartment () , customer.getId()) ;
1/删除客户信息
public int deleteCustomer (Integer id) し
String sql="delete from tb customer where id=?" ;
return jdbcTemplate. update (sql, id) ;