cambios
This commit is contained in:
+3
-1
@@ -3,6 +3,7 @@ import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import {ConfigModule} from '@nestjs/config'
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { UsuariosModule } from './usuarios/usuarios.module';
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +25,8 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
synchronize:true,
|
||||
|
||||
|
||||
})
|
||||
}),
|
||||
UsuariosModule
|
||||
],
|
||||
controllers: [],
|
||||
providers: [AppService],
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateUsuarioDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateUsuarioDto } from './create-usuario.dto';
|
||||
|
||||
export class UpdateUsuarioDto extends PartialType(CreateUsuarioDto) {}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
|
||||
|
||||
@Entity()
|
||||
export class Usuario {
|
||||
@PrimaryGeneratedColumn()
|
||||
id_usuario: number
|
||||
|
||||
@Column({nullable:true})
|
||||
id_tipo_usuario:number
|
||||
|
||||
@Column({length:100, nullable:true})
|
||||
nombre:string
|
||||
|
||||
@Column({length:100,nullable:true})
|
||||
contraseña:string
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@Entity()
|
||||
export class Tipo_Usuario{
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id_tipo_usuario:number
|
||||
@Column({nullable:true})
|
||||
tipo_usuario:string
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsuariosController } from './usuarios.controller';
|
||||
import { UsuariosService } from './usuarios.service';
|
||||
|
||||
describe('UsuariosController', () => {
|
||||
let controller: UsuariosController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [UsuariosController],
|
||||
providers: [UsuariosService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<UsuariosController>(UsuariosController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { UsuariosService } from './usuarios.service';
|
||||
import { CreateUsuarioDto } from './dto/create-usuario.dto';
|
||||
import { UpdateUsuarioDto } from './dto/update-usuario.dto';
|
||||
|
||||
@Controller('usuarios')
|
||||
export class UsuariosController {
|
||||
constructor(private readonly usuariosService: UsuariosService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createUsuarioDto: CreateUsuarioDto) {
|
||||
return this.usuariosService.create(createUsuarioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.usuariosService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.usuariosService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateUsuarioDto: UpdateUsuarioDto) {
|
||||
return this.usuariosService.update(+id, updateUsuarioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.usuariosService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UsuariosService } from './usuarios.service';
|
||||
import { UsuariosController } from './usuarios.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [UsuariosController],
|
||||
providers: [UsuariosService],
|
||||
})
|
||||
export class UsuariosModule {}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UsuariosService } from './usuarios.service';
|
||||
|
||||
describe('UsuariosService', () => {
|
||||
let service: UsuariosService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [UsuariosService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<UsuariosService>(UsuariosService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateUsuarioDto } from './dto/create-usuario.dto';
|
||||
import { UpdateUsuarioDto } from './dto/update-usuario.dto';
|
||||
|
||||
@Injectable()
|
||||
export class UsuariosService {
|
||||
create(createUsuarioDto: CreateUsuarioDto) {
|
||||
return 'This action adds a new usuario';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all usuarios`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} usuario`;
|
||||
}
|
||||
|
||||
update(id: number, updateUsuarioDto: UpdateUsuarioDto) {
|
||||
return `This action updates a #${id} usuario`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} usuario`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user