add User entity, dto, repository interface
User holds email (EmailAddress vo), passwordHash, isAdmin - tide keeps password and admin flag on the user row directly (no separate profile entity like youngstartup). UserRepository exposes find, findByEmail, create. CreateUserDto is readonly with explicit isAdmin (per shared.md no-default-args rule).
This commit is contained in:
parent
f47ea1c73d
commit
533320fcac
3 changed files with 63 additions and 0 deletions
14
backend/app/User/CreateUserDto.php
Normal file
14
backend/app/User/CreateUserDto.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
readonly class CreateUserDto
|
||||
{
|
||||
public function __construct(
|
||||
public EmailAddress $email,
|
||||
public string $passwordHash,
|
||||
public bool $isAdmin,
|
||||
) {}
|
||||
}
|
||||
35
backend/app/User/User.php
Normal file
35
backend/app/User/User.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
class User
|
||||
{
|
||||
public function __construct(
|
||||
private int $id,
|
||||
private EmailAddress $email,
|
||||
private string $passwordHash,
|
||||
private bool $isAdmin,
|
||||
) {}
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmail(): EmailAddress
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getPasswordHash(): string
|
||||
{
|
||||
return $this->passwordHash;
|
||||
}
|
||||
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return $this->isAdmin;
|
||||
}
|
||||
}
|
||||
14
backend/app/User/UserRepository.php
Normal file
14
backend/app/User/UserRepository.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App\User;
|
||||
|
||||
use App\Shared\ValueObject\EmailAddress;
|
||||
|
||||
interface UserRepository
|
||||
{
|
||||
public function create(CreateUserDto $dto): User;
|
||||
|
||||
public function find(int $id): ?User;
|
||||
|
||||
public function findByEmail(EmailAddress $email): ?User;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue