Skip to content

Commit

Permalink
[fix] #90 api 수정 및 댓글 paging시에 total page 계산 수정 및 삭제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
myhyun0002 committed Feb 8, 2023
1 parent 084193e commit 9bb5740
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ResponseTemplate<CommentResponseDto.Body> getCommentByCommentId(@PathVari
@ResponseBody
@GetMapping("")
public ResponsePageTemplate<List<CommentResponseDto.Body>> getAllCommentByForumId(@PathVariable("forum-id") Long forum_id,
@PageableDefault(size=1, sort="createdDate", direction = Sort.Direction.DESC) Pageable pageable) throws ResponseException {
@PageableDefault(size=10, sort="createdDate", direction = Sort.Direction.DESC) Pageable pageable) throws ResponseException {
return commentService.getAllByForumId(forum_id,pageable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public ResponseTemplate<ForumResponseDto.LikeResponseDto> getForumLike(@PathVari
return forumService.getLike(forum_id);
}

@GetMapping("/bestForum")
@GetMapping("/bestforum")
public ResponseTemplate<List<ForumResponseDto.ForumDataToGetResult>> getSixForumByLikeDesc(){
return forumService.getSixForumByLikeDesc();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class InterviewResultController {
private final InterviewParagraphResultService interviewParagraphResultService;

@ApiOperation(value = "interview paragraph result 생성", notes = "질문 후 결과 create한다.")
@PostMapping("/interviewParagraph/{paragraph-id}/result/new")
@PostMapping("/interviewparagraph/{paragraph-id}/result/new")
public ResponseTemplate<String> createInterviewResult(@PathVariable("paragraph-id") Long paragraph_id
, @ModelAttribute InterviewResultRequestDto.createInterviewResult request) throws IOException {
interviewParagraphResultService.deleteInterviewParagraphResult(paragraph_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ public ResponsePageTemplate<List<CommentResponseDto.Body>> getAllByForumId(Long
.collect(Collectors.toList());
// commentPage.getPageable().getPageNumber()
long total_page = commentPage.getTotalPages();
int totalPage = (int)Math.ceil( (double)total_page / pageable.getPageSize() );
return new ResponsePageTemplate<>(commentDataToGetResults,totalPage,pageable.getPageNumber()+1);
// System.out.println(total_page);
//// int totalPage = (int)Math.ceil( (double)total_page / pageable.getPageSize() );
// System.out.println(totalPage);
// System.out.println(pageable.getPageSize());
return new ResponsePageTemplate<>(commentDataToGetResults,(int)total_page,pageable.getPageNumber()+1);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public ResponseTemplate<String> remove(Long paragraph_id){
);
interviewParagraph.deleted_status_true();
InterviewParagraphResult interviewParagraphResultByInterviewParagraphId = interviewParagraphResultRepository.findInterviewParagraphResultByInterviewParagraphId(paragraph_id);
interviewParagraphResultRepository.delete(interviewParagraphResultByInterviewParagraphId);
if(interviewParagraphResultByInterviewParagraphId != null){
interviewParagraphResultRepository.delete(interviewParagraphResultByInterviewParagraphId);
}
return new ResponseTemplate<>(paragraph_id+" deleted success");
}

Expand Down

0 comments on commit 9bb5740

Please sign in to comment.