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

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
2 years ago
​
​
​
​
2 years ago
  1. package com.gcc.erppostdata.repo;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.beans.factory.annotation.Qualifier;
  4. import org.springframework.jdbc.core.JdbcTemplate;
  5. import org.springframework.stereotype.Service;
  6. import javax.sql.DataSource;
  7. import java.util.List;
  8. import java.util.Map;
  9. @Service
  10. public class PetLogRepo {
  11. @Autowired
  12. private JdbcTemplate jdbcTemplate;
  13. @Autowired
  14. public void setDataSource (@Qualifier("mysqlerpPostData") DataSource dataSource){
  15. this.jdbcTemplate = new JdbcTemplate(dataSource);
  16. }
  17. public int insert(String uniqueId, String orderId,String paymentId, String status, String response) {
  18. String sql = "INSERT INTO pet_post_data (uniqueId, orderId,paymentId, status, response) VALUES (?,?, ?, ?, ?)";
  19. return jdbcTemplate.update(sql, uniqueId, orderId,paymentId, status, response);
  20. }
  21. public List<Map<String,Object>> getDataByStatus(String status) {
  22. String sql = "SELECT * FROM pet_post_data WHERE status = ?";
  23. return jdbcTemplate.queryForList(sql, status);
  24. }
  25. public int updateLog(String status,String response,String id){
  26. String sql = "UPDATE pet_post_data SET status = ?, response = ? WHERE id = ?";
  27. return jdbcTemplate.update(sql, status,response,id);
  28. }
  29. public int getLastUniqueIdInserted() {
  30. String sql = "SELECT uniqueId FROM pet_post_data ORDER BY id DESC LIMIT 1";
  31. return jdbcTemplate.queryForObject(sql, Integer.class);
  32. }
  33. }