From adc00c163c917b9b021bc2036454cbc4480512ef Mon Sep 17 00:00:00 2001 From: Giovanna Esmeralda Chavez Espino <79319097+gio-gigi@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:13:06 -0600 Subject: [PATCH] =?UTF-8?q?Correcci=C3=B3n=20del=20error=20de=20la=20conex?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/admin/admin.controller.ts | 9 +-------- backend/src/auth-user/auth-user.controller.ts | 2 ++ backend/src/auth-user/auth-user.module.ts | 4 ++++ backend/src/auth-user/dto/registrer.dto.ts | 12 ++++++------ .../auth/auth-admin/auth-admin.controller.ts | 16 ++++------------ .../src/auth/auth-admin/auth-admin.service.ts | 12 ++---------- backend/src/main.ts | 1 + backend/src/user/dto/create-user.dto.ts | 2 +- backend/src/user/entities/user.entity.ts | 6 +++--- backend/src/user/user.controller.ts | 17 +++-------------- backend/src/user/user.module.ts | 3 ++- backend/src/user/user.service.ts | 1 - fronted/aplicacionrutasturisticas/.gitignore | 3 +++ .../lib/config/dio.dart | 17 +++++++++-------- fronted/aplicacionrutasturisticas/lib/main.dart | 4 ++-- .../lib/pages/register.dart | 4 ++-- 16 files changed, 45 insertions(+), 68 deletions(-) diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index 0d0350c..16e65b9 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -18,13 +18,6 @@ export class AdminController { return this.adminService.findOne(id.toString()); } - @Patch(':id') - update(@Param('id') id: string, @Body() updateAdminDto: UpdateAdminDto) { - return this.adminService.update(+id, updateAdminDto); - } - @Delete(':id') - remove(@Param('id') id: string) { - return this.adminService.remove(+id); - } + } diff --git a/backend/src/auth-user/auth-user.controller.ts b/backend/src/auth-user/auth-user.controller.ts index 02b71d9..8d32ba8 100644 --- a/backend/src/auth-user/auth-user.controller.ts +++ b/backend/src/auth-user/auth-user.controller.ts @@ -10,7 +10,9 @@ export class AuthUserController { @Post('register') register(@Body() registerUser: RegisterDto) { + console.log(registerUser); return this.authUserService.register(registerUser); + } @HttpCode(HttpStatus.OK) diff --git a/backend/src/auth-user/auth-user.module.ts b/backend/src/auth-user/auth-user.module.ts index fbb0b35..f59d9c5 100644 --- a/backend/src/auth-user/auth-user.module.ts +++ b/backend/src/auth-user/auth-user.module.ts @@ -2,9 +2,13 @@ import { Module } from '@nestjs/common'; import { AuthUserService } from './auth-user.service'; import { AuthUserController } from './auth-user.controller'; import { UserService } from 'src/user/user.service'; +import { TypeOrmModule } from '@nestjs/typeorm'; +import { User } from 'src/user/entities/user.entity'; @Module({ + imports: [TypeOrmModule.forFeature([User])], controllers: [AuthUserController], providers: [AuthUserService, UserService], + exports: [UserService], }) export class AuthUserModule {} diff --git a/backend/src/auth-user/dto/registrer.dto.ts b/backend/src/auth-user/dto/registrer.dto.ts index c00276f..1ec1e11 100644 --- a/backend/src/auth-user/dto/registrer.dto.ts +++ b/backend/src/auth-user/dto/registrer.dto.ts @@ -3,22 +3,22 @@ import { IsEmail, IsNumber, IsString, MinLength } from "class-validator"; export class RegisterDto { @IsString() - @MinLength(1) + @MinLength(30) name: string; @IsString() - @MinLength(1) + @MinLength(30) lastname: string; @IsEmail() email: string; - @IsNumber() - @MinLength(1) - phone: number; + @IsString() + @MinLength(10) + phone: string; @IsString() - @MinLength(6) + @MinLength(8) @Transform(({ value }) => value.trim()) password: string; diff --git a/backend/src/auth/auth-admin/auth-admin.controller.ts b/backend/src/auth/auth-admin/auth-admin.controller.ts index 56da9cd..b886107 100644 --- a/backend/src/auth/auth-admin/auth-admin.controller.ts +++ b/backend/src/auth/auth-admin/auth-admin.controller.ts @@ -1,15 +1,15 @@ import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; import { AuthAdminService } from './auth-admin.service'; -import { CreateAuthAdminDto } from './dto/login-admin.dto'; -import { UpdateAuthAdminDto } from './dto/update-auth-admin.dto'; +import { loginAdmin } from './dto/login-admin.dto'; + @Controller('auth-admin') export class AuthAdminController { constructor(private readonly authAdminService: AuthAdminService) {} @Post() - create(@Body() createAuthAdminDto: CreateAuthAdminDto) { - return this.authAdminService.create(createAuthAdminDto); + create(@Body() loginAdmin: loginAdmin) { + return this.authAdminService.create(loginAdmin); } @Get() @@ -22,13 +22,5 @@ export class AuthAdminController { return this.authAdminService.findOne(+id); } - @Patch(':id') - update(@Param('id') id: string, @Body() updateAuthAdminDto: UpdateAuthAdminDto) { - return this.authAdminService.update(+id, updateAuthAdminDto); - } - @Delete(':id') - remove(@Param('id') id: string) { - return this.authAdminService.remove(+id); - } } diff --git a/backend/src/auth/auth-admin/auth-admin.service.ts b/backend/src/auth/auth-admin/auth-admin.service.ts index 54bee0b..d740eb9 100644 --- a/backend/src/auth/auth-admin/auth-admin.service.ts +++ b/backend/src/auth/auth-admin/auth-admin.service.ts @@ -1,10 +1,9 @@ import { Injectable } from '@nestjs/common'; -import { CreateAuthAdminDto } from './dto/login-admin.dto'; -import { UpdateAuthAdminDto } from './dto/update-auth-admin.dto'; +import { loginAdmin } from './dto/login-admin.dto'; @Injectable() export class AuthAdminService { - create(createAuthAdminDto: CreateAuthAdminDto) { + create(loginAdmin: loginAdmin) { return 'This action adds a new authAdmin'; } @@ -16,11 +15,4 @@ export class AuthAdminService { return `This action returns a #${id} authAdmin`; } - update(id: number, updateAuthAdminDto: UpdateAuthAdminDto) { - return `This action updates a #${id} authAdmin`; - } - - remove(id: number) { - return `This action removes a #${id} authAdmin`; - } } diff --git a/backend/src/main.ts b/backend/src/main.ts index 13cad38..da5451c 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -3,6 +3,7 @@ import { AppModule } from './app.module'; async function bootstrap() { const app = await NestFactory.create(AppModule); + app.enableCors(); await app.listen(3000); } bootstrap(); diff --git a/backend/src/user/dto/create-user.dto.ts b/backend/src/user/dto/create-user.dto.ts index b9f5a75..5a592ab 100644 --- a/backend/src/user/dto/create-user.dto.ts +++ b/backend/src/user/dto/create-user.dto.ts @@ -3,5 +3,5 @@ export class CreateUserDto { lastname: string; password: string; email: string; - phone: number; + phone: string; } diff --git a/backend/src/user/entities/user.entity.ts b/backend/src/user/entities/user.entity.ts index 4f58986..c8acdd8 100644 --- a/backend/src/user/entities/user.entity.ts +++ b/backend/src/user/entities/user.entity.ts @@ -1,8 +1,8 @@ -import { Column, Entity, PrimaryColumn } from "typeorm"; +import { Column, Entity, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm"; @Entity() export class User { - @PrimaryColumn() + @PrimaryGeneratedColumn() idUser: number @Column() @@ -18,5 +18,5 @@ export class User { email: string @Column() - phone: number + phone: string } diff --git a/backend/src/user/user.controller.ts b/backend/src/user/user.controller.ts index cbc95ae..78f2942 100644 --- a/backend/src/user/user.controller.ts +++ b/backend/src/user/user.controller.ts @@ -12,20 +12,9 @@ export class UserController { return this.userService.create(createUserDto); } - @Get() - @Get(':id') - findOne(@Param('id') id: string) { - return this.userService.findOne(id.toString()); - } + - @Patch(':id') - update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) { - return this.userService.update(+id, updateUserDto); - } + - @Delete(':id') - remove(@Param('id') id: string) { - - return this.userService.remove(+id); - } + } diff --git a/backend/src/user/user.module.ts b/backend/src/user/user.module.ts index c20f6ad..2693fa5 100644 --- a/backend/src/user/user.module.ts +++ b/backend/src/user/user.module.ts @@ -3,10 +3,11 @@ import { UserService } from './user.service'; import { UserController } from './user.controller'; import { TypeOrmModule } from '@nestjs/typeorm'; import { User } from './entities/user.entity'; +import { AuthUserService } from 'src/auth-user/auth-user.service'; @Module({ imports: [TypeOrmModule.forFeature([User])], controllers: [UserController], - providers: [UserService], + providers: [UserService, AuthUserService], exports: [UserService], }) export class UserModule {} diff --git a/backend/src/user/user.service.ts b/backend/src/user/user.service.ts index 2deda19..96a338d 100644 --- a/backend/src/user/user.service.ts +++ b/backend/src/user/user.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@nestjs/common'; import { CreateUserDto } from './dto/create-user.dto'; -import { UpdateUserDto } from './dto/update-user.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { User } from './entities/user.entity'; import { Repository } from 'typeorm'; diff --git a/fronted/aplicacionrutasturisticas/.gitignore b/fronted/aplicacionrutasturisticas/.gitignore index 29a3a50..e62807c 100644 --- a/fronted/aplicacionrutasturisticas/.gitignore +++ b/fronted/aplicacionrutasturisticas/.gitignore @@ -41,3 +41,6 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release + +pubspec.lock +pubspec.yaml diff --git a/fronted/aplicacionrutasturisticas/lib/config/dio.dart b/fronted/aplicacionrutasturisticas/lib/config/dio.dart index 6b9ecbe..a583352 100644 --- a/fronted/aplicacionrutasturisticas/lib/config/dio.dart +++ b/fronted/aplicacionrutasturisticas/lib/config/dio.dart @@ -1,16 +1,17 @@ import 'package:dio/dio.dart'; final dio = Dio(); -void Registro_Datos(String nombre, String lastname, String email, int phone, +void Registro_Datos(String nombre, String lastname, String email, String phone, String password) async { Response response; - response = await dio.post("http://localhost:3306", data: { - 'name': nombre, - 'lastname': lastname, - 'email': email, - 'phone': phone, - 'password': password + //response = await dio.get("http://172.26.128.1:3000") + response = await dio.post("http://10.2.81.72:3000/auth-user/register", data: { + "name": nombre, + "lastname": lastname, + "password": password, + "email": email, + "phone": phone, + }); - print("Hola\n"); print(response.data.toString()); } diff --git a/fronted/aplicacionrutasturisticas/lib/main.dart b/fronted/aplicacionrutasturisticas/lib/main.dart index 65f821a..0987623 100644 --- a/fronted/aplicacionrutasturisticas/lib/main.dart +++ b/fronted/aplicacionrutasturisticas/lib/main.dart @@ -15,9 +15,9 @@ class MyApp extends StatelessWidget { primarySwatch: Colors.indigo, visualDensity: VisualDensity.adaptivePlatformDensity, ), - initialRoute: TextFielEjemploLogin.id, + initialRoute: RegistroPage.id, routes: { - TextFielEjemploLogin.id: (_) => const TextFielEjemploLogin(), + RegistroPage.id: (_) => const RegistroPage(), }, ); } diff --git a/fronted/aplicacionrutasturisticas/lib/pages/register.dart b/fronted/aplicacionrutasturisticas/lib/pages/register.dart index 9aa7ea2..b05dc57 100644 --- a/fronted/aplicacionrutasturisticas/lib/pages/register.dart +++ b/fronted/aplicacionrutasturisticas/lib/pages/register.dart @@ -109,7 +109,7 @@ class RegistroPageState extends State { } void precionaRegistro() { - int phoneInt = int.parse(pho); + //int phoneInt = int.parse(pho); nom = nombre.text; ape = apellido.text; ema = email.text; @@ -132,7 +132,7 @@ class RegistroPageState extends State { " \n "); if (pass == passc) { - Registro_Datos(nom, ape, ema, phoneInt, pass); + Registro_Datos(nom, ape, ema, pho, pass); } else { print("La contraseƱa es incorrecta"); } -- GitLab