26 lines
993 B
JavaScript
26 lines
993 B
JavaScript
import Conexion from './Conexion.js';
|
|
import Carrera from '../Model/Carrera.js';
|
|
import logger from '../utils/logger.js';
|
|
import DAORegistro from './DAORegistro.js';
|
|
|
|
class DAOCarrera {
|
|
static async dameCarreras() {
|
|
const conexion = new Conexion();
|
|
const conexionEstablecida = await conexion.conectar();
|
|
try {
|
|
const sql = "SELECT * FROM carrera";
|
|
const [rows] = await conexionEstablecida.query(sql);
|
|
const resultado = rows.map(row => new Carrera(row.id, row.nombre, row.area, row.campus, row.descripcion, row.mision, row.vision, row.objetivo));
|
|
await DAORegistro.registrar({ getMatricula: () => 'SYSTEM' }, 'Consultó carreras', new Date().toISOString());
|
|
|
|
return resultado;
|
|
} catch (error) {
|
|
logger.error(`Error al obtener carreras: ${error.message}`);
|
|
return [];
|
|
} finally {
|
|
conexion.cerrarConexion();
|
|
}
|
|
}
|
|
}
|
|
|
|
export default DAOCarrera; |