|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
package entgra.mailsender.DAO;
|
|
|
|
|
package entgra.mailsender.DAO.Impl;
|
|
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import entgra.mailsender.DAO.MailDAO;
|
|
|
|
|
import entgra.mailsender.DTO.MailModel;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
@ -9,15 +10,24 @@ import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.sql.*;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
|
import java.sql.Blob;
|
|
|
|
|
import java.sql.Date;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class MailDAOImpl implements MailDAO{
|
|
|
|
|
public class MailDAOImpl implements MailDAO {
|
|
|
|
|
|
|
|
|
|
Logger logger = Logger.getLogger(String.valueOf(MailDAOImpl.class));
|
|
|
|
|
|
|
|
|
@ -54,41 +64,7 @@ public void addMail(MailModel mailModel){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//@Override
|
|
|
|
|
//public List<MailModel> insertInPriorityQueue(){
|
|
|
|
|
// logger.info("came into the function");
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// try{
|
|
|
|
|
// Connection conn = this.getConnection();
|
|
|
|
|
//
|
|
|
|
|
// try (PreparedStatement stmt = conn.prepareStatement(sql);
|
|
|
|
|
// ResultSet rs = stmt.executeQuery()) {
|
|
|
|
|
// while (rs.next()) {
|
|
|
|
|
// int priority = rs.getInt("priority");
|
|
|
|
|
// int mail_id = rs.getInt("email_id");
|
|
|
|
|
// priorityQueue.add(new MailModel(mail_id,null,null,priority,null,null,null,null,null,0));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//// MailModel email = priorityQueue.poll();
|
|
|
|
|
// //assert email != null;
|
|
|
|
|
// for (Object element: priorityQueue){
|
|
|
|
|
// System.out.println("element" + element);
|
|
|
|
|
// }
|
|
|
|
|
// return priorityQueue;
|
|
|
|
|
//
|
|
|
|
|
// } catch (SQLException e) {
|
|
|
|
|
// logger.info("Error processing result set: " + e.getMessage());
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// logger.info("Error in preparing statement" + e);
|
|
|
|
|
// throw new RuntimeException(e);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<MailModel> getUnsentMessages(){
|
|
|
|
@ -137,7 +113,6 @@ public MailModel getMailDetails(Integer mail_id){
|
|
|
|
|
|
|
|
|
|
String filename = rs.getString("filename");
|
|
|
|
|
mailModel.setFilename(filename);
|
|
|
|
|
// logger.info(filename);
|
|
|
|
|
|
|
|
|
|
Blob blob = rs.getBlob("attachment");
|
|
|
|
|
logger.info(blob.toString());
|