file profesor
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
|
||||
export class profesorDto{
|
||||
|
||||
username:string
|
||||
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { Column, Entity, PrimaryColumn, Timestamp } from "typeorm";
|
||||
|
||||
|
||||
@Entity()
|
||||
export class profesor{
|
||||
export class Profesor{
|
||||
@PrimaryColumn({length: 11, nullable:false})
|
||||
id_profesor: number;
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import { Body, Controller, Delete, Get, Post } from '@nestjs/common';
|
||||
import { ProfesorService } from './profesor.service';
|
||||
import { profesorDto } from './dto/profesorDto.dto';
|
||||
|
||||
@Controller('profesor')
|
||||
export class profesorController {
|
||||
constructor(private profesorService: ProfesorService) {}
|
||||
|
||||
@Post("alta")
|
||||
async postRegister(@Body() data:profeDto){
|
||||
async postRegister(@Body() data:profesorDto){
|
||||
return this.profesorService.register(data);
|
||||
}
|
||||
|
||||
@Post("midificacion")
|
||||
async postModify(@Body() data:profeDto){
|
||||
return this.profesorService.modify(data);
|
||||
async postModify(@Body() data:profesorDto){
|
||||
return this.profesorService.modify();
|
||||
}
|
||||
|
||||
@Delete("borrado")
|
||||
async remove(@Body() data:profeDto){
|
||||
return this.profesorService.remove(data);
|
||||
async remove(@Body() data:profesorDto){
|
||||
return this.profesorService.remove();
|
||||
}
|
||||
|
||||
@Get("profile")
|
||||
@@ -26,8 +27,8 @@ export class profesorController {
|
||||
}
|
||||
|
||||
@Get("profile/filter")
|
||||
async filter(@Body() data:profeDto){
|
||||
return this.profesorService.filter(data);
|
||||
async filter(@Body() data:profesorDto){
|
||||
return this.profesorService.filter();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import { HttpException, Injectable } from '@nestjs/common';
|
||||
import { Profesor } from './entities/profesor.entitiy';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { profesorDto } from './dto/profesorDto.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ProfesorService {
|
||||
constructor(
|
||||
@InjectRepository(Profesor) private profesorRepository: Repository<Profesor>
|
||||
){}
|
||||
|
||||
async register(data:profesorDto){
|
||||
const{nombre}= data;
|
||||
|
||||
if(await this.profesorRepository.findOne( { where: { nombre } })){
|
||||
throw new HttpException("User already exist",403);
|
||||
}
|
||||
|
||||
return this.profesorRepository.save(
|
||||
this.profesorRepository.create()
|
||||
)
|
||||
}
|
||||
|
||||
async modify(){
|
||||
|
||||
}
|
||||
|
||||
async remove(){
|
||||
|
||||
}
|
||||
|
||||
async profile(){
|
||||
|
||||
}
|
||||
|
||||
async filter(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class ProfesorService {
|
||||
|
||||
async register(){
|
||||
|
||||
}
|
||||
|
||||
async modify(){
|
||||
|
||||
}
|
||||
|
||||
async remove(){
|
||||
|
||||
}
|
||||
|
||||
async profile(){
|
||||
|
||||
}
|
||||
|
||||
async filter(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user