package dao.specification;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import static util.SQLDatabaseConnection.close;
import static util.SQLDatabaseConnection.getConnection;

//@TODO 重构代码 合并userDAO和merchantsDAO中重复方法
public class abstractDAO<T> {
    public static int Delete(Connection ct, PreparedStatement ps, ResultSet rs,
                             String sql, Long id) {
        int flag;
        try {
            ct = getConnection();
            ps = ct.prepareStatement(sql);
            ps.setLong(1, id);
            flag = ps.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        } finally {
            close(ct, ps, rs);
        }
        return flag;
    }
}
