From 0aab1792b6f5442c615cbc8c62162fd9951a409a Mon Sep 17 00:00:00 2001 From: arkchive Date: Sun, 11 Aug 2024 21:14:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../space_spring/controller/PostController.java | 12 +++++++----- .../java/space/space_spring/service/PostService.java | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/space/space_spring/controller/PostController.java b/src/main/java/space/space_spring/controller/PostController.java index aa4e4a15..ec56825e 100644 --- a/src/main/java/space/space_spring/controller/PostController.java +++ b/src/main/java/space/space_spring/controller/PostController.java @@ -10,6 +10,7 @@ import space.space_spring.dto.post.request.CreatePostRequest; import space.space_spring.dto.post.response.ReadPostsResponse; import space.space_spring.entity.UserSpace; +import space.space_spring.exception.PostException; import space.space_spring.exception.SpaceException; import space.space_spring.response.BaseResponse; import space.space_spring.service.PostService; @@ -19,6 +20,8 @@ import java.util.List; import java.util.Optional; +import static space.space_spring.util.bindingResult.BindingResultUtils.getErrorMessage; + @RestController @RequiredArgsConstructor @RequestMapping("/space/{spaceId}") @@ -46,17 +49,16 @@ public BaseResponse createPost( @JwtLoginAuth Long userId, @PathVariable Long spaceId, @ModelAttribute @Validated CreatePostRequest createPostRequest, - BindingResult bindingResult) throws IOException { + BindingResult bindingResult) throws IOException{ + // TODO 1: 예외처리 if (bindingResult.hasErrors()) { - // TODO 1: 예외처리 +// throw new PostException(, getErrorMessage(bindingResult)); } // TODO 2: 유저가 스페이스에 속하는 지 검증 Optional userInSpace = userSpaceUtils.isUserInSpace(userId, spaceId); log.info("UserName = {}, UserSpaceAuth = {}", userInSpace.get().getUserName(), userInSpace.get().getUserSpaceAuth()); - // TODO 3: 게시글 이미지 s3에 upload - - // TODO 4: s3에 저장하고 받은 이미지 url과 게시글로 save 작업 수행 + // TODO 3: 작성한 게시글 save 작업 수행 postService.save(userId, spaceId, createPostRequest); return new BaseResponse<>("새로운 글이 작성되었습니다."); diff --git a/src/main/java/space/space_spring/service/PostService.java b/src/main/java/space/space_spring/service/PostService.java index 7636644f..5e0cae02 100644 --- a/src/main/java/space/space_spring/service/PostService.java +++ b/src/main/java/space/space_spring/service/PostService.java @@ -27,6 +27,7 @@ public class PostService { private final PostDao postDao; private final S3Uploader s3Uploader; + @Transactional public List getAllPosts(Long spaceId, String filter) { // TODO 1: spaceId에 해당하는 space find