Merge branch 'phone' into 'main'
add phone See merge request mobicoop/lab/v3/services/user!4
This commit is contained in:
commit
a08468bddc
|
@ -0,0 +1,5 @@
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "user" ADD COLUMN "phone" TEXT,
|
||||||
|
ALTER COLUMN "firstName" DROP NOT NULL,
|
||||||
|
ALTER COLUMN "lastName" DROP NOT NULL,
|
||||||
|
ALTER COLUMN "email" DROP NOT NULL;
|
|
@ -0,0 +1,8 @@
|
||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[phone]` on the table `user` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "user_phone_key" ON "user"("phone");
|
|
@ -12,9 +12,10 @@ datasource db {
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
uuid String @id @default(uuid()) @db.Uuid
|
uuid String @id @default(uuid()) @db.Uuid
|
||||||
firstName String
|
firstName String?
|
||||||
lastName String
|
lastName String?
|
||||||
email String @unique
|
email String? @unique
|
||||||
|
phone String? @unique
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,7 @@ export class UserPresenter {
|
||||||
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
email: string;
|
email: string;
|
||||||
|
|
||||||
|
@AutoMap()
|
||||||
|
phone: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ message User {
|
||||||
string firstName = 2;
|
string firstName = 2;
|
||||||
string lastName = 3;
|
string lastName = 3;
|
||||||
string email = 4;
|
string email = 4;
|
||||||
|
string phone = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserFilter {
|
message UserFilter {
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
import { AutoMap } from '@automapper/classes';
|
import { AutoMap } from '@automapper/classes';
|
||||||
import { IsNotEmpty, IsString } from 'class-validator';
|
import { IsString } from 'class-validator';
|
||||||
|
|
||||||
export class CreateUserRequest {
|
export class CreateUserRequest {
|
||||||
@IsString()
|
@IsString()
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
uuid: string;
|
uuid?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
firstName: string;
|
firstName?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
lastName: string;
|
lastName?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
email: string;
|
email?: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@AutoMap()
|
||||||
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,8 @@ export class UpdateUserRequest {
|
||||||
@IsString()
|
@IsString()
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
email?: string;
|
email?: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@AutoMap()
|
||||||
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,14 @@ export class User {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
firstName: string;
|
firstName?: string;
|
||||||
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
lastName: string;
|
lastName?: string;
|
||||||
|
|
||||||
@AutoMap()
|
@AutoMap()
|
||||||
email: string;
|
email?: string;
|
||||||
|
|
||||||
|
@AutoMap()
|
||||||
|
phone?: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,10 @@ import { CreateUserUseCase } from '../../domain/usecases/create-user.usecase';
|
||||||
import { UserProfile } from '../../mappers/user.profile';
|
import { UserProfile } from '../../mappers/user.profile';
|
||||||
|
|
||||||
const newUserRequest: CreateUserRequest = {
|
const newUserRequest: CreateUserRequest = {
|
||||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a91',
|
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'john.doe@email.com',
|
email: 'john.doe@email.com',
|
||||||
|
phone: '0601020304',
|
||||||
};
|
};
|
||||||
const newUserCommand: CreateUserCommand = new CreateUserCommand(newUserRequest);
|
const newUserCommand: CreateUserCommand = new CreateUserCommand(newUserRequest);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ describe('CreateUserUseCase', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('execute', () => {
|
describe('execute', () => {
|
||||||
it('should create an User and returns new entity object', async () => {
|
it('should create and return a new user', async () => {
|
||||||
const newUser: User = await createUserUseCase.execute(newUserCommand);
|
const newUser: User = await createUserUseCase.execute(newUserCommand);
|
||||||
|
|
||||||
expect(newUser.lastName).toBe(newUserRequest.lastName);
|
expect(newUser.lastName).toBe(newUserRequest.lastName);
|
||||||
|
|
|
@ -9,18 +9,21 @@ const mockUsers = [
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'john.doe@email.com',
|
email: 'john.doe@email.com',
|
||||||
|
phone: '0601020304',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
||||||
firstName: 'Jane',
|
firstName: 'Jane',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'jane.doe@email.com',
|
email: 'jane.doe@email.com',
|
||||||
|
phone: '0602030405',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
||||||
firstName: 'Jimmy',
|
firstName: 'Jimmy',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'jimmy.doe@email.com',
|
email: 'jimmy.doe@email.com',
|
||||||
|
phone: '0603040506',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@ describe('DeleteUserUseCase', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('execute', () => {
|
describe('execute', () => {
|
||||||
it('should delete an User', async () => {
|
it('should delete a user', async () => {
|
||||||
const savedUuid = mockUsers[0].uuid;
|
const savedUuid = mockUsers[0].uuid;
|
||||||
const deleteUserCommand = new DeleteUserCommand(savedUuid);
|
const deleteUserCommand = new DeleteUserCommand(savedUuid);
|
||||||
await deleteUserUseCase.execute(deleteUserCommand);
|
await deleteUserUseCase.execute(deleteUserCommand);
|
||||||
|
|
|
@ -9,18 +9,21 @@ const mockUsers = [
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'john.doe@email.com',
|
email: 'john.doe@email.com',
|
||||||
|
phone: '0601020304',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
uuid: 'bb281075-1b98-4456-89d6-c643d3044a92',
|
||||||
firstName: 'Jane',
|
firstName: 'Jane',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'jane.doe@email.com',
|
email: 'jane.doe@email.com',
|
||||||
|
phone: '0602030405',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
uuid: 'bb281075-1b98-4456-89d6-c643d3044a93',
|
||||||
firstName: 'Jimmy',
|
firstName: 'Jimmy',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'jimmy.doe@email.com',
|
email: 'jimmy.doe@email.com',
|
||||||
|
phone: '0603040506',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ const mockUser = {
|
||||||
firstName: 'John',
|
firstName: 'John',
|
||||||
lastName: 'Doe',
|
lastName: 'Doe',
|
||||||
email: 'john.doe@email.com',
|
email: 'john.doe@email.com',
|
||||||
|
phone: '0601020304',
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockUserRepository = {
|
const mockUserRepository = {
|
||||||
|
|
Loading…
Reference in New Issue