Skip to content

Commit

Permalink
feat: 이미지 저장 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
arkchive committed Aug 11, 2024
1 parent cf9ad21 commit 0aab179
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/java/space/space_spring/controller/PostController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}")
Expand Down Expand Up @@ -46,17 +49,16 @@ public BaseResponse<String> 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<UserSpace> 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<>("새로운 글이 작성되었습니다.");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/space/space_spring/service/PostService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class PostService {
private final PostDao postDao;
private final S3Uploader s3Uploader;

@Transactional
public List<ReadPostsResponse> getAllPosts(Long spaceId, String filter) {

// TODO 1: spaceId에 해당하는 space find
Expand Down

0 comments on commit 0aab179

Please sign in to comment.