From 73a3acd39fba481c928395188077a07fa8fda939 Mon Sep 17 00:00:00 2001 From: yisroel Date: Wed, 6 May 2026 15:19:00 +0300 Subject: [PATCH] add Post entity, dto, repository interface Post: id, userId (fk -> User), title, body, createdAt as DateTimeImmutable. CreatePostDto readonly with explicit createdAt (use case supplies it via Clock; entity remains pure). PostRepository: create, find, findByUserId, findRecent (limit), delete. --- backend/app/Post/CreatePostDto.php | 15 +++++++++++ backend/app/Post/Post.php | 41 +++++++++++++++++++++++++++++ backend/app/Post/PostRepository.php | 22 ++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 backend/app/Post/CreatePostDto.php create mode 100644 backend/app/Post/Post.php create mode 100644 backend/app/Post/PostRepository.php diff --git a/backend/app/Post/CreatePostDto.php b/backend/app/Post/CreatePostDto.php new file mode 100644 index 0000000..255f2e9 --- /dev/null +++ b/backend/app/Post/CreatePostDto.php @@ -0,0 +1,15 @@ +id; + } + + public function getUserId(): int + { + return $this->userId; + } + + public function getTitle(): string + { + return $this->title; + } + + public function getBody(): string + { + return $this->body; + } + + public function getCreatedAt(): DateTimeImmutable + { + return $this->createdAt; + } +} diff --git a/backend/app/Post/PostRepository.php b/backend/app/Post/PostRepository.php new file mode 100644 index 0000000..a00827b --- /dev/null +++ b/backend/app/Post/PostRepository.php @@ -0,0 +1,22 @@ +