Skip to content

Commit

Permalink
Merge pull request #115 from aelimited/feature/#112-clubNoticeSearch
Browse files Browse the repository at this point in the history
[FIX] #112 - 공지/게시판 개별 조회 수정
  • Loading branch information
aelimited authored Jun 11, 2024
2 parents 69237bb + b104dfa commit 503ed3c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ public BaseResponse<Page<ClubBoardResponse>> findAllNotice(
Page<ClubBoardResponse> response = clubBoardService.findAllBoard(clubId, member, pageable);
return BaseResponse.response(response);
}
@GetMapping("/{club_id}/board/{notice_id}")
public BaseResponse<ClubBoardResponse> findNotice(
@AuthenticationPrincipal MemberDetails member,
@PathVariable("club_id") Long clubId,
@PathVariable("notice_id") Long noticeId
) {
ClubBoardResponse response = clubBoardService.findBoard(clubId, noticeId, member.getMember());
return BaseResponse.response(response);
}

// @GetMapping("/{club_id}/board/{notice_id}")
// public BaseResponse<ClubBoardResponse> findNotice(
// @AuthenticationPrincipal MemberDetails member,
// @PathVariable("club_id") Long clubId,
// @PathVariable("notice_id") Long noticeId
// ) {
// ClubBoardResponse response = clubBoardService.findBoard(clubId, noticeId, member);
// return BaseResponse.response(response);
// }


//api/v1/club/{club_id}/notice/{notice_id}
//공지사항 수정
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BaseResponse<Page<ClubNoticeResponse>> findAllNotice(

//소모임 개별 조회
// ex) 소모임 2에 등록 된 공지사항 중에서만 조회가 가능
@GetMapping("/{club_id}/notice/{notice_id}")
@GetMapping("/{club_id}/post/{notice_id}")
public BaseResponse<ClubNoticeResponse> findNotice(
@AuthenticationPrincipal MemberDetails memberDetails,
@PathVariable("club_id") Long clubId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.Optional;

public interface ClubNoticeCustomRepository {
Page<ClubNotice> findAllNotice(Long clubId, Pageable pageable);
ClubNotice findNotice(Long clubId, Long noticeId);

Page<ClubNotice> findAllBoard(Long clubId, Pageable pageable);

Optional<ClubNotice> findBoard(Long clubId, Long noticeId);
// ClubNotice findBoard(Long clubId, Long noticeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public ClubNotice findNotice(Long clubId, Long noticeId) {

ClubNotice notice = queryFactory.selectFrom(clubNotice)
.where(clubNotice.clubId.eq(clubId)
.and(clubNotice.id.eq(noticeId))
.and(clubNotice.type.eq(NotificationType.NOTICE)))
.and(clubNotice.id.eq(noticeId)))
// .and(clubNotice.type.eq(NotificationType.NOTICE)))
.fetchOne();

if (notice == null) {
Expand Down Expand Up @@ -77,16 +77,16 @@ public Page<ClubNotice> findAllBoard(Long clubId, Pageable pageable) {
return new PageImpl<>(clubNoticeList, pageable, total);
}

@Override
public Optional<ClubNotice> findBoard(Long clubId, Long noticeId) {
QClubNotice clubNotice = QClubNotice.clubNotice;

ClubNotice notice = queryFactory.selectFrom(clubNotice)
.where(clubNotice.clubId.eq(clubId)
.and(clubNotice.id.eq(noticeId))
.and(clubNotice.type.eq(NotificationType.BOARD)))
.fetchOne();

return Optional.ofNullable(notice);
}
// @Override
// public ClubNotice findBoard(Long clubId, Long noticeId) {
// QClubNotice clubNotice = QClubNotice.clubNotice;
//
// ClubNotice notice = queryFactory.selectFrom(clubNotice)
// .where(clubNotice.clubId.eq(clubId)
// .and(clubNotice.id.eq(noticeId))
// .and(clubNotice.type.eq(NotificationType.BOARD)))
// .fetchOne();
//
// return notice;
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,14 @@ public Page<ClubBoardResponse> findAllBoard(Long clubId, MemberDetails memberDet
return new PageImpl<>(clubBoardResponseList, pageable, clubNotices.getTotalElements());
}

// 게시글 개별 조회
public ClubBoardResponse findBoard(Long clubId, Long noticeId, Member member) {
checkClubId(clubId);
ClubNotice notice = clubNoticeRepository.findNotice(clubId, noticeId);

List<ClubCommentResponse> comments = clubCommentService.findComments(member, clubId, noticeId);

return clubBoardConverter.toClubBoardResponse(notice, comments, member);
}

private Club checkClubId(Long clubId) {
Club club = clubRepository.findById(clubId)
.orElseThrow(() -> new BaseException(BaseResponseStatus.INVALID_CLUB_ID));
return club;
}
// public ClubBoardResponse findBoard(Long clubId, Long noticeId, MemberDetails memberDetails) {
// ClubNotice clubNotice = clubNoticeRepository.findBoard(clubId, noticeId);
// List<ClubCommentResponse> comments =
// clubCommentService.findComments(memberDetails.getMember(), clubId, noticeId);
//
// return clubBoardConverter.toClubBoardResponse(clubNotice, memberDetails, comments);
// }

//수정
public ClubBoardResponse updateBoard(Member member, Long clubId, Long noticeId, ClubBoardRequest request) {
Expand Down

0 comments on commit 503ed3c

Please sign in to comment.