diff --git a/backend/app/Post/UseCases/CreatePost/CreatePost.php b/backend/app/Post/UseCases/CreatePost/CreatePost.php new file mode 100644 index 0000000..0008a08 --- /dev/null +++ b/backend/app/Post/UseCases/CreatePost/CreatePost.php @@ -0,0 +1,40 @@ +title === null ? '' : trim($request->title); + $body = $request->body === null ? '' : trim($request->body); + + if ($title === '') { + throw new BadRequestException('title is required'); + } + if ($body === '') { + throw new BadRequestException('body is required'); + } + + return $this->postRepo->create(new CreatePostDto( + userId: $request->userId, + title: $title, + body: $body, + createdAt: $this->clock->now(), + )); + } +} diff --git a/backend/app/Post/UseCases/CreatePost/CreatePostRequest.php b/backend/app/Post/UseCases/CreatePost/CreatePostRequest.php new file mode 100644 index 0000000..c3aea18 --- /dev/null +++ b/backend/app/Post/UseCases/CreatePost/CreatePostRequest.php @@ -0,0 +1,12 @@ +