S8
This commit is contained in:
@@ -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[];
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string, any>) {
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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 })
|
||||
|
||||
@@ -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<User> {
|
||||
// return await this.users.update(userId, updateUserDto);
|
||||
// }
|
||||
|
||||
//async update(userId: number, updateUserDto: UserDto): Promise<User> {
|
||||
//return await this.users.update(userId, updateUserDto);
|
||||
//}
|
||||
|
||||
async remove(userId: number): Promise<void> {
|
||||
await this.users.delete(userId);
|
||||
|
||||
Reference in New Issue
Block a user