Files
api/dist/entity/Usuario.js
T
2020-09-11 10:24:48 -05:00

120 lines
4.5 KiB
JavaScript

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const bcrypt = require("bcrypt");
const typeorm_1 = require("typeorm");
const class_validator_1 = require("class-validator");
const Reservacion_1 = require("./Reservacion");
const Prestamo_1 = require("./Prestamo");
const Log_1 = require("./Log");
let Usuario = class Usuario {
hashPassword() {
this.secreto = bcrypt.hashSync(this.secreto, 10);
}
checkIfUnencryptedPasswordIsValid(unencryptedPassword) {
return bcrypt.compareSync(unencryptedPassword, this.secreto);
}
};
__decorate([
typeorm_1.PrimaryGeneratedColumn(),
__metadata("design:type", String)
], Usuario.prototype, "id", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.IsString(),
__metadata("design:type", String)
], Usuario.prototype, "nombre", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.IsString(),
__metadata("design:type", String)
], Usuario.prototype, "apellidoPaterno", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.IsString(),
__metadata("design:type", String)
], Usuario.prototype, "apellidoMaterno", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.IsEmail(),
__metadata("design:type", String)
], Usuario.prototype, "correoAlternativo", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.Length(10),
__metadata("design:type", String)
], Usuario.prototype, "numeroTelefonico", void 0);
__decorate([
typeorm_1.Column({ type: 'text' }),
class_validator_1.IsString(),
__metadata("design:type", String)
], Usuario.prototype, "identificacion", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.IsString(),
__metadata("design:type", String)
], Usuario.prototype, "institucion", void 0);
__decorate([
typeorm_1.Column(),
class_validator_1.IsString(),
__metadata("design:type", String)
], Usuario.prototype, "secreto", void 0);
__decorate([
typeorm_1.Column({ type: 'date', default: '1996-11-07' }),
class_validator_1.IsDate(),
class_validator_1.IsOptional(),
__metadata("design:type", String)
], Usuario.prototype, "multa", void 0);
__decorate([
typeorm_1.Column({ type: 'date', default: '1996-11-07' }),
class_validator_1.IsDate(),
class_validator_1.IsOptional(),
__metadata("design:type", String)
], Usuario.prototype, "multaRed", void 0);
__decorate([
typeorm_1.Column({ default: false }),
class_validator_1.IsBoolean(),
class_validator_1.IsOptional(),
__metadata("design:type", Boolean)
], Usuario.prototype, "baja", void 0);
__decorate([
typeorm_1.Column({ default: false }),
class_validator_1.IsBoolean(),
__metadata("design:type", Boolean)
], Usuario.prototype, "interno", void 0);
__decorate([
typeorm_1.Column(),
typeorm_1.CreateDateColumn(),
__metadata("design:type", Date)
], Usuario.prototype, "createdAt", void 0);
__decorate([
typeorm_1.Column(),
typeorm_1.UpdateDateColumn(),
__metadata("design:type", Date)
], Usuario.prototype, "updatedAt", void 0);
__decorate([
typeorm_1.OneToMany((type) => Reservacion_1.Reservacion, (reservacion) => reservacion.usuario),
__metadata("design:type", Array)
], Usuario.prototype, "reservaciones", void 0);
__decorate([
typeorm_1.OneToMany((type) => Prestamo_1.Prestamo, (prestamo) => prestamo.usuario),
__metadata("design:type", Array)
], Usuario.prototype, "prestamos", void 0);
__decorate([
typeorm_1.OneToMany((type) => Log_1.Log, (log) => log.usuario),
__metadata("design:type", Array)
], Usuario.prototype, "logs", void 0);
Usuario = __decorate([
typeorm_1.Entity(),
typeorm_1.Unique(['id', 'correoAlternativo'])
], Usuario);
exports.Usuario = Usuario;
//# sourceMappingURL=Usuario.js.map