const IContinenteDAO = require('../IContinenteDAO'); const pool = require('../../gestores/gestorDB'); const Continente = require('../../models/Continente'); class ContinenteDAOImpl extends IContinenteDAO { // Listar todos los continentes async listarTodos() { const [rows] = await pool.query('SELECT codigo, nombre_continente AS nombre FROM T_CONTINENTE'); return rows.map(r => new Continente(r.codigo, r.nombre)); } // Buscar por código async buscarPorCodigo(codigo) { const [rows] = await pool.query( 'SELECT codigo, nombre_continente AS nombre FROM T_CONTINENTE WHERE codigo = ?', [codigo] ); if (rows.length === 0) return null; const r = rows[0]; return new Continente(r.codigo, r.nombre); } // Buscar por nombre async buscarPorNombre(nombre) { const [rows] = await pool.query( 'SELECT codigo, nombre_continente AS nombre FROM T_CONTINENTE WHERE nombre_continente LIKE ?', [`%${nombre}%`] ); return rows.map(r => new Continente(r.codigo, r.nombre)); } } module.exports = ContinenteDAOImpl;