You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.5 KiB
44 lines
1.5 KiB
package com.gcc.erppostdata.repo;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import javax.sql.DataSource;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@Service
|
|
public class PetLogRepo {
|
|
|
|
@Autowired
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
@Autowired
|
|
public void setDataSource (@Qualifier("mysqlerpPostData") DataSource dataSource){
|
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
|
}
|
|
|
|
public int insert(String uniqueId, String orderId,String paymentId, String status, String response) {
|
|
String sql = "INSERT INTO pet_post_data (uniqueId, orderId,paymentId, status, response) VALUES (?,?, ?, ?, ?)";
|
|
|
|
return jdbcTemplate.update(sql, uniqueId, orderId,paymentId, status, response);
|
|
|
|
}
|
|
|
|
public List<Map<String,Object>> getDataByStatus(String status) {
|
|
String sql = "SELECT * FROM pet_post_data WHERE status = ?";
|
|
return jdbcTemplate.queryForList(sql, status);
|
|
}
|
|
|
|
public int updateLog(String status,String response,String id){
|
|
String sql = "UPDATE pet_post_data SET status = ?, response = ? WHERE id = ?";
|
|
return jdbcTemplate.update(sql, status,response,id);
|
|
}
|
|
|
|
public int getLastUniqueIdInserted() {
|
|
String sql = "SELECT uniqueId FROM pet_post_data ORDER BY id DESC LIMIT 1";
|
|
return jdbcTemplate.queryForObject(sql, Integer.class);
|
|
}
|
|
}
|