Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "cnh" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "license_plate" TEXT,
ADD COLUMN "vehicle_color" TEXT,
ADD COLUMN "vehicle_model" TEXT;
10 changes: 8 additions & 2 deletions src/strada/auth-service/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ model User {
authProvider String? @default("local")

// Informações pessoais e documentos (opcionais)
cpf String? @unique
rg String?
cpf String? @unique
rg String?
cnh String?

vehicle_model String?
vehicle_color String?
license_plate String?

birthDate DateTime?
phone String?
address String?
Expand Down
6 changes: 6 additions & 0 deletions src/strada/auth-service/src/user/core/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export class User {
// Novos campos de documentos e informações pessoais (opcionais)
cpf?: string;
rg?: string;
cnh?: string;

vehicle_model?: string;
vehicle_color?: string;
license_plate?: string;

birthDate?: Date;
phone?: string;
address?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UserType } from "@prisma/client";
import { UserType } from '@prisma/client';

export interface IUserRequest {
name?: string;
Expand All @@ -9,6 +9,7 @@ export interface IUserRequest {
authProvider?: string;
cpf?: string;
rg?: string;
cnh?: string;
birthDate?: Date;
phone?: string;
address?: string;
Expand All @@ -17,4 +18,8 @@ export interface IUserRequest {
state?: string;
userType?: UserType;
isActive?: boolean;

vehicle_model?: string;
vehicle_color?: string;
license_plate?: string;
}
7 changes: 7 additions & 0 deletions src/strada/auth-service/src/user/core/mappers/user.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export class UserMapper {
if (data.state !== undefined) partialUser.state = data.state;
if (data.userType !== undefined) partialUser.userType = data.userType;
if (data.isActive !== undefined) partialUser.isActive = data.isActive;
if (data.cnh !== undefined) partialUser.cnh = data.cnh;
if (data.vehicle_model !== undefined)
partialUser.vehicle_model = data.vehicle_model;
if (data.vehicle_color !== undefined)
partialUser.vehicle_color = data.vehicle_color;
if (data.license_plate !== undefined)
partialUser.license_plate = data.license_plate;

return partialUser;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export class UpdateUserUseCase {
async execute(id: string, dto: IUserRequest): Promise<IUserResponse> {
const existingUser = await this.findUserByIdUseCase.execute(id);

console.log('updating...');
console.log(dto);

try {
const userToUpdate = UserMapper.toPartialEntity({
...existingUser,
Expand All @@ -28,6 +31,9 @@ export class UpdateUserUseCase {
delete userToUpdate.password;
}

console.log('use to update');
console.log(userToUpdate);

return await this.userRepository.update(id, userToUpdate);
} catch (error) {
console.log(error);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Body,
Controller, Get, Param,
Post,
Put,
Query
} from '@nestjs/common';
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
import { CreateUserUseCase } from '@/src/user/core/use-cases/create-user.use-case';
import { UserRequestDto } from '../dto/user-request.dto';
import { UserResponseDto } from '../dto/user-response.dto';
Expand Down Expand Up @@ -49,5 +43,4 @@ export class UserController {
) {
return await this.findAllUseCase.execute({ name, page, limit });
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ export class UserRepository implements IUserRepository {
authProvider: user.authProvider,
cpf: user.cpf,
rg: user.rg,
cnh: user.cnh,
birthDate: user.birthDate,
phone: user.phone,
address: user.address,
cep: user.cep,
city: user.city,
state: user.state,
userType: user.userType,
vehicle_model: user.vehicle_model,
vehicle_color: user.vehicle_color,
license_plate: user.license_plate,
},
select: {
id: true,
Expand All @@ -42,6 +46,7 @@ export class UserRepository implements IUserRepository {
imgUrl: true,
cpf: true,
rg: true,
cnh: true,
birthDate: true,
phone: true,
address: true,
Expand All @@ -53,6 +58,9 @@ export class UserRepository implements IUserRepository {
isActive: true,
authProvider: false,
password: false,
vehicle_model: true,
vehicle_color: true,
license_plate: true,
},
});

Expand All @@ -70,13 +78,17 @@ export class UserRepository implements IUserRepository {
authProvider: user.authProvider,
cpf: user.cpf,
rg: user.rg,
cnh: user.cnh,
birthDate: user.birthDate,
phone: user.phone,
address: user.address,
cep: user.cep,
city: user.city,
state: user.state,
userType: user.userType,
vehicle_model: user.vehicle_model,
vehicle_color: user.vehicle_color,
license_plate: user.license_plate,
};

if (user.password) {
Expand Down
14 changes: 5 additions & 9 deletions src/strada/mobile/.env
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
EXPO_PUBLIC_BASE_DOMAIN=strada.appbr.store
EXPO_PUBLIC_USE_HTTPS=true
EXPO_PUBLIC_GOOGLE_CLIENT_ID_ANDROID=
EXPO_PUBLIC_GOOGLE_CLIENT_ID_ANDROID=
EXPO_PUBLIC_GOOGLE_CLIENT_ID_ANDROID=
EXPO_PUBLIC_GOOGLE_CLIENT_ID_ANDROID=asd
EXPO_PUBLIC_GOOGLE_CALLBACK_URL=http://localhost:3000/auth/oauth2/callback/google
EXPO_PUBLIC_GITHUB_OAUTH_URL=https://github.com/login/oauth/authorize?client_id=Ov23liUYlBuWhFrqDKRP&redirect_uri=http://localhost:3000/auth/oauth2/callback/github&scope=user
fb6979
00284c
EXPO_PUBLIC_GITHUB_OAUTH_URL=https://github.com/login/oauth/authorize?client_id=Ov23liUYlBuWhFrqDKRP&redirect_uri=http://localhost:3000/auth/oauth2/callback/github&scope=userfb697900284c

# Para produção
# EXPO_PUBLIC_USE_HTTPS=true
EXPO_PUBLIC_USE_HTTPS=true

# Para desenvolvimento
# EXPO_PUBLIC_BASE_DOMAIN=localhost:3000
# EXPO_PUBLIC_BASE_DOMAIN=10.0.2.2:3000
# EXPO_PUBLIC_USE_HTTPS=false

EXPO_PUBLIC_GOOGLE_MAPS_API_KEY=AIzaSyCYOruhSUWQavp9_pnB42oGOyIlJW0VHm4
EXPO_PUBLIC_GOOGLE_MAPS_API_KEY=a
Loading