diff --git a/src/controller/operador/create.js b/src/controller/operador/create.js index 5e7efbd..56b98f4 100644 --- a/src/controller/operador/create.js +++ b/src/controller/operador/create.js @@ -12,9 +12,7 @@ const create = (body) => { console.log(res) return { mensaje: 'Se creo un operador correctamente' } }) - .catch((err) => { - throw new Error(err) - }) + .catch((err) => {}) } module.exports = create diff --git a/src/controller/usuario/create.js b/src/controller/usuario/create.js index 7605ea9..7000636 100644 --- a/src/controller/usuario/create.js +++ b/src/controller/usuario/create.js @@ -20,9 +20,7 @@ const create = (body) => { console.log(res) return { mensaje: 'Se creo un usuario correctamente' } }) - .catch((err) => { - throw new Error(err) - }) + .catch((err) => {}) } module.exports = create diff --git a/src/db/install.js b/src/db/install.js index 00fd5fa..c8adbb9 100644 --- a/src/db/install.js +++ b/src/db/install.js @@ -1,16 +1,21 @@ const colors = require('colors') -const Carrito = require('./tables/Carrito') const Carrera = require('./tables/Carrera') const CarreraPlantel = require('./tables/CarreraPlantel') -const Plantel = require('./tables/Plantel') +const Carrito = require('./tables/Carrito') +// const Entidad = require('./tables/Entidad') const Equipo = require('./tables/Equipo') const Horario = require('./tables/Horario') const Mesa = require('./tables/Mesa') const Multa = require('./tables/Multa') const Operador = require('./tables/Operador') const Parte = require('./tables/Parte') +const Plantel = require('./tables/Plantel') const Prestamo = require('./tables/Prestamo') +// const Programa = require('./tables/Programa') +// const ProgramaEntidad = require('./tables/ProgramaEntidad') +// const ProgramaNivel = require('./tables/ProgramaNivel') const Reporte = require('./tables/Reporte') +const ReporteParte = require('./tables/ReporteParte') const Salon = require('./tables/Salon') const Status = require('./tables/Status') const TipoCarrito = require('./tables/TipoCarrito') @@ -28,6 +33,9 @@ const drop = async () => { await TipoMulta.drop() console.log('La tabla TipoMulta se desinstalo correctamente.'.magenta) + await ReporteParte.drop() + console.log('La tabla ReporteParte se desinstalo correctamente.'.magenta) + await Reporte.drop() console.log('La tabla Reporte se desinstalo correctamente.'.magenta) @@ -134,6 +142,9 @@ const sync = async () => { await Reporte.sync() console.log('La tabla Reporte se instalo correctamente.'.magenta) + await ReporteParte.sync() + console.log('La tabla ReporteParte se instalo correctamente.'.magenta) + await TipoMulta.sync() console.log('La tabla TipoMulta se instalo correctamente.'.magenta) diff --git a/src/db/tables/Entidad.js b/src/db/tables/Entidad.js new file mode 100644 index 0000000..f750bbb --- /dev/null +++ b/src/db/tables/Entidad.js @@ -0,0 +1,26 @@ +const { DataTypes, Model } = require('sequelize') +const sequelize = require('../../config/sequelize.conf') + +class Entidad extends Model {} +Entidad.init( + { + idEntidad: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + }, + entidad: { + type: DataTypes.STRING(100), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Entidad', + tableName: 'entidad', + timestamps: false, + } +) + +module.exports = Entidad diff --git a/src/db/tables/Programa.js b/src/db/tables/Programa.js new file mode 100644 index 0000000..491db2c --- /dev/null +++ b/src/db/tables/Programa.js @@ -0,0 +1,26 @@ +const { DataTypes, Model } = require('sequelize') +const sequelize = require('../../config/sequelize.conf') + +class Programa extends Model {} +Programa.init( + { + idPrograma: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + unique: true, + }, + programa: { + type: DataTypes.STRING(100), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'Programa', + tableName: 'programa', + timestamps: false, + } +) + +module.exports = Programa diff --git a/src/db/tables/ProgramaEntidad.js b/src/db/tables/ProgramaEntidad.js new file mode 100644 index 0000000..1bd6269 --- /dev/null +++ b/src/db/tables/ProgramaEntidad.js @@ -0,0 +1,32 @@ +const { DataTypes, Model } = require('sequelize') +const sequelize = require('../../config/sequelize.conf') +const Entidad = require('./Entidad') +const Programa = require('./Programa') + +class ProgramaEntidad extends Model {} +ProgramaEntidad.init( + { + idProgramaEntidad: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true, + unique: true, + }, + }, + { + sequelize, + modelName: 'ProgramaEntidad', + tableName: 'programa_entidad', + } +) + +ProgramaEntidad.belongsTo(Entidad, { + foreignKey: { type: DataTypes.INTEGER, name: 'idEntidad', allowNull: false }, +}) + +ProgramaEntidad.belongsTo(Programa, { + foreignKey: { type: DataTypes.INTEGER, name: 'idPrograma', allowNull: false }, +}) + +module.exports = ProgramaEntidad diff --git a/src/db/tables/ProgramaNivel.js b/src/db/tables/ProgramaNivel.js new file mode 100644 index 0000000..2cf32c6 --- /dev/null +++ b/src/db/tables/ProgramaNivel.js @@ -0,0 +1,31 @@ +const { DataTypes, Model } = require('sequelize') +const sequelize = require('../../config/sequelize.conf') +const Programa = require('./Programa') + +class ProgramaNivel extends Model {} +ProgramaNivel.init( + { + idPrograma: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + }, + nivel: { + type: DataTypes.STRING(1), + allowNull: false, + }, + }, + { + sequelize, + modelName: 'ProgramaNivel', + tableName: 'programa_nivel', + } +) + +ProgramaNivel.belongsTo(Programa, { + foreignKey: { + name: 'idPrograma', + }, +}) + +module.exports = ProgramaNivel diff --git a/src/db/tables/ReporteParte.js b/src/db/tables/ReporteParte.js new file mode 100644 index 0000000..222d1a2 --- /dev/null +++ b/src/db/tables/ReporteParte.js @@ -0,0 +1,36 @@ +const { DataTypes, Model } = require('sequelize') +const sequelize = require('../../config/sequelize.conf') +const Reporte = require('./Reporte') +const Parte = require('./Parte') + +class ReporteParte extends Model {} +ReporteParte.init( + { + idReporte: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + }, + }, + { + sequelize, + modelName: 'ReporteParte', + tableName: 'reporte_parte', + } +) + +ReporteParte.belongsTo(Reporte, { + foreignKey: { + name: 'idReporte', + }, +}) + +ReporteParte.belongsTo(Parte, { + foreignKey: { + name: 'idParte', + type: DataTypes.INTEGER, + allowNull: false, + }, +}) + +module.exports = ReporteParte