From 5f00cf824887091e2c60c37fb61f7bca3c2bfb94 Mon Sep 17 00:00:00 2001 From: Drakthor475 Date: Fri, 17 Oct 2025 13:15:47 -0600 Subject: [PATCH] cambios --- package-lock.json | 21 +++++++++++++++ package.json | 1 + src/app.module.ts | 4 ++- src/usuarios/dto/create-usuario.dto.ts | 1 + src/usuarios/dto/update-usuario.dto.ts | 4 +++ src/usuarios/entities/usuario.entity.ts | 31 +++++++++++++++++++++ src/usuarios/usuarios.controller.spec.ts | 20 ++++++++++++++ src/usuarios/usuarios.controller.ts | 34 ++++++++++++++++++++++++ src/usuarios/usuarios.module.ts | 9 +++++++ src/usuarios/usuarios.service.spec.ts | 18 +++++++++++++ src/usuarios/usuarios.service.ts | 26 ++++++++++++++++++ 11 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/usuarios/dto/create-usuario.dto.ts create mode 100644 src/usuarios/dto/update-usuario.dto.ts create mode 100644 src/usuarios/entities/usuario.entity.ts create mode 100644 src/usuarios/usuarios.controller.spec.ts create mode 100644 src/usuarios/usuarios.controller.ts create mode 100644 src/usuarios/usuarios.module.ts create mode 100644 src/usuarios/usuarios.service.spec.ts create mode 100644 src/usuarios/usuarios.service.ts diff --git a/package-lock.json b/package-lock.json index e4b3489..5e703c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@nestjs/common": "^11.1.6", "@nestjs/core": "^11.0.1", + "@nestjs/mapped-types": "*", "@nestjs/platform-express": "^11.0.1", "@nestjs/typeorm": "^11.0.0", "class-transformer": "0.5.1", @@ -2399,6 +2400,26 @@ } } }, + "node_modules/@nestjs/mapped-types": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-2.1.0.tgz", + "integrity": "sha512-W+n+rM69XsFdwORF11UqJahn4J3xi4g/ZEOlJNL6KoW5ygWSmBB2p0S2BZ4FQeS/NDH72e6xIcu35SfJnE8bXw==", + "license": "MIT", + "peerDependencies": { + "@nestjs/common": "^10.0.0 || ^11.0.0", + "class-transformer": "^0.4.0 || ^0.5.0", + "class-validator": "^0.13.0 || ^0.14.0", + "reflect-metadata": "^0.1.12 || ^0.2.0" + }, + "peerDependenciesMeta": { + "class-transformer": { + "optional": true + }, + "class-validator": { + "optional": true + } + } + }, "node_modules/@nestjs/platform-express": { "version": "11.1.6", "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-11.1.6.tgz", diff --git a/package.json b/package.json index c6683cd..9636ed8 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "dependencies": { "@nestjs/common": "^11.1.6", "@nestjs/core": "^11.0.1", + "@nestjs/mapped-types": "*", "@nestjs/platform-express": "^11.0.1", "@nestjs/typeorm": "^11.0.0", "class-transformer": "0.5.1", diff --git a/src/app.module.ts b/src/app.module.ts index 4110f5e..24cb228 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -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], diff --git a/src/usuarios/dto/create-usuario.dto.ts b/src/usuarios/dto/create-usuario.dto.ts new file mode 100644 index 0000000..d7960fe --- /dev/null +++ b/src/usuarios/dto/create-usuario.dto.ts @@ -0,0 +1 @@ +export class CreateUsuarioDto {} diff --git a/src/usuarios/dto/update-usuario.dto.ts b/src/usuarios/dto/update-usuario.dto.ts new file mode 100644 index 0000000..a2b8fbc --- /dev/null +++ b/src/usuarios/dto/update-usuario.dto.ts @@ -0,0 +1,4 @@ +import { PartialType } from '@nestjs/mapped-types'; +import { CreateUsuarioDto } from './create-usuario.dto'; + +export class UpdateUsuarioDto extends PartialType(CreateUsuarioDto) {} diff --git a/src/usuarios/entities/usuario.entity.ts b/src/usuarios/entities/usuario.entity.ts new file mode 100644 index 0000000..c23362b --- /dev/null +++ b/src/usuarios/entities/usuario.entity.ts @@ -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 + +} \ No newline at end of file diff --git a/src/usuarios/usuarios.controller.spec.ts b/src/usuarios/usuarios.controller.spec.ts new file mode 100644 index 0000000..1b3bd8a --- /dev/null +++ b/src/usuarios/usuarios.controller.spec.ts @@ -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); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/src/usuarios/usuarios.controller.ts b/src/usuarios/usuarios.controller.ts new file mode 100644 index 0000000..a016b2e --- /dev/null +++ b/src/usuarios/usuarios.controller.ts @@ -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); + } +} diff --git a/src/usuarios/usuarios.module.ts b/src/usuarios/usuarios.module.ts new file mode 100644 index 0000000..84d0218 --- /dev/null +++ b/src/usuarios/usuarios.module.ts @@ -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 {} diff --git a/src/usuarios/usuarios.service.spec.ts b/src/usuarios/usuarios.service.spec.ts new file mode 100644 index 0000000..652da47 --- /dev/null +++ b/src/usuarios/usuarios.service.spec.ts @@ -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); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/usuarios/usuarios.service.ts b/src/usuarios/usuarios.service.ts new file mode 100644 index 0000000..ac6192c --- /dev/null +++ b/src/usuarios/usuarios.service.ts @@ -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`; + } +}