diff --git a/src/Profesor/entities/profesor.entity.ts b/src/Profesor/entities/profesor.entity.ts index 111eeba..d8bd57d 100644 --- a/src/Profesor/entities/profesor.entity.ts +++ b/src/Profesor/entities/profesor.entity.ts @@ -71,8 +71,9 @@ export class Profesor { mostrar: boolean; @Column({ - type: 'datetime', + type: 'timestamp', nullable: false, + default: () => 'CURRENT_TIMESTAMP', }) fecha_alta: Date; @@ -108,4 +109,5 @@ export class Profesor { @OneToMany(() => ProyectosAcademicos, proyectosAcademicos => proyectosAcademicos.profesor) proyectosAcademicos: ProyectosAcademicos[]; + } diff --git a/src/Profesor/profesor.controller.ts b/src/Profesor/profesor.controller.ts index 9ad13c1..85aa4fd 100644 --- a/src/Profesor/profesor.controller.ts +++ b/src/Profesor/profesor.controller.ts @@ -1,14 +1,13 @@ import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put } from '@nestjs/common'; import { ProfesorService } from './profesor.service'; import { profesorDto } from './dto/profesorDto.dto'; -import { ProfesorFilterDto } from './dto/profesorFilterDto.dto'; @Controller('profesor') export class ProfesorController { constructor(private profesorService: ProfesorService) {} @Post() - async postRegister(@Body() data: profesorDto) { + async register(@Body() data: profesorDto) { return this.profesorService.register(data); } diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index c72d9ff..d706461 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -27,7 +27,7 @@ export class AuthController { } @Post("register") - async postRegister(@Body() data: registerDto){ + async register(@Body() data: registerDto){ return this.authService.register(data) } @@ -37,12 +37,6 @@ export class AuthController { return req.user; } - @UseGuards(AuthGuard) - @Post('Alta') - async create(@Body() data: UserDto) { - return this.authService.create(data); - } - @UseGuards(AuthGuard) @Put('Modificacion/:id') async update(@Param('id') id: number, @Body() updateUserDto: Record) { diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 16ecd2d..a147f0e 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -25,7 +25,7 @@ export class AuthService { //register users async register(data: registerDto) { - const { usuario, contraseña } = data; + const { usuario, contraseña} = data; if (await this.usersService.findOne(usuario)) { throw new HttpException('User already exist', 403); @@ -65,8 +65,6 @@ export class AuthService { return { token: token }; } - async create(data) {} - async update(id, updateUserDto) {} async remove(id) {} diff --git a/src/auth/dto/registerDto.dto.ts b/src/auth/dto/registerDto.dto.ts index f465b1a..d9fad62 100644 --- a/src/auth/dto/registerDto.dto.ts +++ b/src/auth/dto/registerDto.dto.ts @@ -1,4 +1,4 @@ -import {IsString, IsNotEmpty } from "class-validator"; +import {IsString, IsNotEmpty,IsNumber,IsEmail } from "class-validator"; export class registerDto{ @@ -10,5 +10,12 @@ export class registerDto{ @IsNotEmpty() contraseña: string; + @IsNumber() + @IsNotEmpty() + id_tipo_usuario:number; + + @IsString() + @IsNotEmpty() + correo: string; } \ No newline at end of file diff --git a/src/categoria/entities/categoria.entity.ts b/src/categoria/entities/categoria.entity.ts index 432252f..0d110e9 100644 --- a/src/categoria/entities/categoria.entity.ts +++ b/src/categoria/entities/categoria.entity.ts @@ -1,5 +1,4 @@ import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm'; -import { Profesor } from '../../Profesor/entities/profesor.entity'; @Entity() export class Categoria { @@ -9,6 +8,6 @@ export class Categoria { @Column({ type: 'varchar', length: 256, nullable: false }) categoria: string; - @OneToMany(() => Profesor, (profesor) => profesor.categoria) - profesores: Profesor[]; + @OneToMany(() => Categoria, (categoria) => categoria.profesores) + profesores: Categoria[]; } diff --git a/src/edificio/entities/edificio.entity.ts b/src/edificio/entities/edificio.entity.ts index ebbc4ec..0619d94 100644 --- a/src/edificio/entities/edificio.entity.ts +++ b/src/edificio/entities/edificio.entity.ts @@ -1,5 +1,4 @@ import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm'; -import { Profesor } from "../../Profesor/entities/profesor.entity"; @Entity() export class Edificio { @@ -9,6 +8,6 @@ export class Edificio { @Column({ type: 'varchar', length: 256, nullable: false }) edificio: string; - @OneToMany(() => Profesor, profesor => profesor.edificio) - profesores: Profesor[]; + @OneToMany(() => Edificio, edificio => edificio.profesores) + profesores: Edificio[]; } diff --git a/src/users/dto/userDto.dto.ts b/src/users/dto/userDto.dto.ts index 0f1ba81..54d8644 100644 --- a/src/users/dto/userDto.dto.ts +++ b/src/users/dto/userDto.dto.ts @@ -1,4 +1,4 @@ -import { IsEmail, IsNotEmpty, IsString} from "class-validator"; +import { IsEmail, IsNotEmpty, IsString,IsNumber} from "class-validator"; export class UserDto{ @IsString() @@ -9,4 +9,12 @@ export class UserDto{ @IsNotEmpty() contraseña: string; + @IsNumber() + @IsNotEmpty() + id_tipo_usuario:number; + + @IsEmail() + @IsNotEmpty() + correo: string; + } \ No newline at end of file diff --git a/src/users/entities/user.entity.ts b/src/users/entities/user.entity.ts index 8497616..40f82b7 100644 --- a/src/users/entities/user.entity.ts +++ b/src/users/entities/user.entity.ts @@ -1,11 +1,11 @@ -import { Entity, PrimaryColumn, Column, ManyToOne, JoinColumn, OneToMany } from 'typeorm'; +import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, OneToMany } from 'typeorm'; import { TipoUsuario } from "../../tipo_usuario/entities/tipo_usuario.entity"; import { Profesor } from 'src/Profesor/entities/profesor.entity'; @Entity({ name: 'usuario' }) export class User { - @PrimaryColumn({ type: 'int', nullable: false }) + @PrimaryGeneratedColumn() id_usuario: number; @Column({ type: 'int', nullable: false }) diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 107753a..bf6736b 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -19,10 +19,10 @@ export class UsersService { const newUser = this.users.create(user); return this.users.save(newUser); } - //TODO Validar Esta funcion - // async update(userId: number, updateUserDto: UserDto): Promise { - // return await this.users.update(userId, updateUserDto); - // } + + //async update(userId: number, updateUserDto: UserDto): Promise { + //return await this.users.update(userId, updateUserDto); + //} async remove(userId: number): Promise { await this.users.delete(userId);