Skip to content

Commit

Permalink
[hotfix]: 자료집 수정 api 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
qogustj committed Oct 13, 2024
1 parent eb5e699 commit d99b1c9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,12 @@ public ResponseEntity<ApiResponse<?>> editBoardPost(@Parameter(hidden = true) @U
@Operation(summary = "자료집 게시물 수정 api", description = """
자료집 게시물을 수정하는 api 입니다.
""")
@PatchMapping("/data/{fileCategory}/{fileType}/posts/{postId}")
@PatchMapping("/data/{fileCategory}/posts/{postId}")
public ResponseEntity<ApiResponse<?>> editBoardDataPost(@Parameter(hidden = true) @UserId Long userId,
@PathVariable(name = "fileCategory") String fileCategory,
@PathVariable(name = "fileType") String fileType,
@PathVariable(name = "postId") Long postId,
@RequestBody PostUpdateRequest postUpdateRequest) {
return ApiResponse.success(postManageService.editBoardDatePost(fileCategory, fileType, postId, postUpdateRequest));
return ApiResponse.success(postManageService.editBoardDatePost(fileCategory, postId, postUpdateRequest));
}

@Operation(summary = "게시물 삭제 api", description = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ public Long editBoardPost(String boardCode, Long postId, PostUpdateRequest postU
return post.getId();
}
@Transactional
public Long editBoardDatePost(String fileCategory, String fileType, Long postId, PostUpdateRequest postUpdateRequest){
public Long editBoardDatePost(String fileCategory, Long postId, PostUpdateRequest postUpdateRequest){
Post post = postReader.getPostWithId(postId);
Post newPost = postModifier.updateDataPost(post, fileType);
Post newPost = postModifier.updateDataPost(post, fileCategory);
postFileAppender.updatePostIdForIds(postUpdateRequest.postFileList(), newPost.getId());
return post.getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface PostRepository {
Page<Post> findBySearchCriteria(Pageable pageable,String boardCode, String q, String categoryCode);
Page<SimplePostResponse> findPostDtoListByBoardCode(String boardCode, Pageable pageable);
List<Post> findAllByCategory(List<String> statuses);
Post updatePostCategory(Post post, String category);
Post updatePostCategory(Post post, Category category);
// Page<Post> findAllByGroupCodeAndMemberCodeAndSubCategory(GroupCode groupCode, MemberCode memberCode, String subCategory, Pageable pageable);
Page<Post> findAllByFileCategories(List<FileCategory> fileCategories, Pageable pageable);
Page<Post> findAllByBoardIdAndGroupCodeAndMemberCode(Long boarId, GroupCode groupCode, MemberCode memberCode, Pageable pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private Boolean isAnsweredByAdmin(Post post) {
* 해당 로직은 실제 청원게시물의 OnGoingStatus를 변경하는 로직
*/
public void updatePostCategoryAndOngoingStatus(Post post, String category) {
postRepository.updatePostCategory(post, category);
postRepository.updatePostCategory(post, Category.getEnumCategoryCodeFromStringCategoryCode(category));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Post updatePost(Post post){
}

public Post updateDataPost(Post post, String category){
return postRepository.updatePostCategory(post, category);
return postRepository.updatePostCategory(post, Category.getEnumCategoryCodeFromStringCategoryCode(category));
}

public void deletePost(String boardCode, Long postId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ public List<Post> findAllByCategory(List<String> statuses) {
}

@Override
public Post updatePostCategory(Post post, String category) {
public Post updatePostCategory(Post post, Category category) {
PostEntity postEntity = postMapper.toEntity(post);
postEntity.updateCategory(Category.getEnumCategoryCodeFromStringCategoryCode(category));
postEntity.updateCategory(category);
return postMapper.toDomain(postJpaRepository.save(postEntity));
}

Expand Down

0 comments on commit d99b1c9

Please sign in to comment.