Merge branch 'lemuel' of https://repositorio.acatlan.unam.mx/CIDWA/pcpuma_acatlan_api into dev
This commit is contained in:
@@ -4,10 +4,13 @@ const encriptar = require('../helper/encriptar');
|
||||
const Carrera = require('./tablas/Carrera');
|
||||
const Carrito = require('./tablas/Carrito');
|
||||
const Equipo = require('./tablas/Equipo');
|
||||
const Infraccion = require('./tablas/Infraccion');
|
||||
const Modulo = require('./tablas/Modulo');
|
||||
const Multa = require('./tablas/Multa');
|
||||
const Operador = require('./tablas/Operador');
|
||||
const Prestamo = require('./tablas/Prestamo');
|
||||
const Programa = require('./tablas/Programa');
|
||||
const Reporte = require('./tablas/Reporte');
|
||||
const Status = require('./tablas/Status');
|
||||
const TipoCarrito = require('./tablas/TipoCarrito');
|
||||
const TipoUsuario = require('./tablas/TipoUsuario');
|
||||
@@ -16,6 +19,15 @@ const Usuario = require('./tablas/Usuario');
|
||||
const drop = async () => {
|
||||
console.log('\nPaso 1) Desinstalando la db.'.bold.blue);
|
||||
|
||||
await Reporte.drop();
|
||||
console.log('La tabla Reporte se desinstalo correctamente.'.magenta);
|
||||
|
||||
await Multa.drop();
|
||||
console.log('La tabla Multa se desinstalo correctamente.'.magenta);
|
||||
|
||||
await Infraccion.drop();
|
||||
console.log('La tabla Infraccion se desinstalo correctamente.'.magenta);
|
||||
|
||||
await Prestamo.drop();
|
||||
console.log('La tabla Prestamo se desinstalo correctamente.'.magenta);
|
||||
|
||||
@@ -85,6 +97,15 @@ const sync = async () => {
|
||||
|
||||
await Prestamo.sync();
|
||||
console.log('La tabla Prestamo se instalo correctamente.'.magenta);
|
||||
|
||||
await Infraccion.sync();
|
||||
console.log('La tabla Infraccion se instalo correctamente.'.magenta);
|
||||
|
||||
await Multa.sync();
|
||||
console.log('La tabla Multa se instalo correctamente.'.magenta);
|
||||
|
||||
await Reporte.sync();
|
||||
console.log('La tabla Reporte se instalo correctamente.'.magenta);
|
||||
};
|
||||
|
||||
const dataTipoUsuario = async () => {
|
||||
@@ -156,6 +177,36 @@ const dataAdmin = async () => {
|
||||
});
|
||||
};
|
||||
|
||||
const dataInfraccion = async () => {
|
||||
const data = [
|
||||
{ infraccion: 'Manchas de suciedad', gravedad: '1' },
|
||||
{ infraccion: 'Etiquetas Removidas', gravedad: '1' },
|
||||
{ infraccion: 'Rayon en carcasa', gravedad: '1' },
|
||||
{ infraccion: 'Golpe en carcasa', gravedad: '1' },
|
||||
// { infraccion: '', gravedad: '1' },
|
||||
{ infraccion: 'Daño impacto', gravedad: '2' },
|
||||
{ infraccion: 'Derrame liquido', gravedad: '2' },
|
||||
{ infraccion: 'Trackpad dañado', gravedad: '2' },
|
||||
{ infraccion: 'Equipo abierto', gravedad: '2' },
|
||||
{ infraccion: 'Pantalla estrellada', gravedad: '2' },
|
||||
{ infraccion: 'Teclas faltantes', gravedad: '2' },
|
||||
{ infraccion: 'Teclas dañadas', gravedad: '2' },
|
||||
{ infraccion: 'Puertos dañados', gravedad: '2' },
|
||||
{ infraccion: 'Falta de hardware', gravedad: '2' },
|
||||
{ infraccion: 'Cambio de piezas', gravedad: '2' },
|
||||
// { infraccion: '', gravedad: '2' },
|
||||
];
|
||||
|
||||
console.log('\nPaso 9) Insertando data infraccion.'.bold.blue);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
await Infraccion.create({
|
||||
infraccion: data[i].infraccion,
|
||||
gravedad: data[i].gravedad,
|
||||
});
|
||||
console.log(`Se agrego la infraccion ${data[i].infraccion}.`.magenta);
|
||||
}
|
||||
};
|
||||
|
||||
const exe = async () => {
|
||||
await drop();
|
||||
await sync();
|
||||
@@ -165,6 +216,7 @@ const exe = async () => {
|
||||
await dataStatus();
|
||||
await dataPrograma();
|
||||
await dataAdmin();
|
||||
await dataInfraccion();
|
||||
|
||||
console.log(
|
||||
'\nSe ha instalado exitosamente la base de datos.\n'.underline.bold.green
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
|
||||
class Infraccion extends Model {}
|
||||
Infraccion.init(
|
||||
{
|
||||
idInfraccion: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
infraccion: {
|
||||
type: DataTypes.STRING(100),
|
||||
allowNull: false,
|
||||
},
|
||||
gravedad: {
|
||||
type: DataTypes.STRING(1),
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Infraccion',
|
||||
tableName: 'infraccion',
|
||||
timestamps: false,
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = Infraccion;
|
||||
@@ -0,0 +1,51 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const Infraccion = require('./Infraccion');
|
||||
const Prestamo = require('./Prestamo');
|
||||
|
||||
class Multa extends Model {}
|
||||
Multa.init(
|
||||
{
|
||||
idMulta: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
descripcion: {
|
||||
type: DataTypes.STRING(500),
|
||||
allowNull: false,
|
||||
},
|
||||
fechaFin: {
|
||||
type: DataTypes.DATE,
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Multa',
|
||||
tableName: 'multa',
|
||||
timestamps: true,
|
||||
createdAt: true,
|
||||
updatedAt: false,
|
||||
}
|
||||
);
|
||||
|
||||
Multa.belongsTo(Infraccion, {
|
||||
foreignKey: {
|
||||
name: 'idInfraccion',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
Multa.belongsTo(Prestamo, {
|
||||
foreignKey: {
|
||||
name: 'idPrestamo',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = Multa;
|
||||
@@ -0,0 +1,47 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const Equipo = require('./Equipo');
|
||||
const Prestamo = require('./Prestamo');
|
||||
|
||||
class Reporte extends Model {}
|
||||
Reporte.init(
|
||||
{
|
||||
idReporte: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
descripcion: {
|
||||
type: DataTypes.STRING(500),
|
||||
allowNull: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'Reporte',
|
||||
tableName: 'reporte',
|
||||
timestamps: true,
|
||||
createdAt: true,
|
||||
updatedAt: false,
|
||||
}
|
||||
);
|
||||
|
||||
Reporte.belongsTo(Equipo, {
|
||||
foreignKey: {
|
||||
name: 'idEquipo',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
});
|
||||
|
||||
Reporte.belongsTo(Prestamo, {
|
||||
foreignKey: {
|
||||
name: 'idPrestamo',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = Reporte;
|
||||
Reference in New Issue
Block a user