Skip to content

Commit

Permalink
Merge pull request #44 from KOA-TF/feature/notice-error-handling
Browse files Browse the repository at this point in the history
fix: 상세조회 & 커리큘럼 조회 로직수정
  • Loading branch information
Jeongh00 authored Nov 22, 2023
2 parents c549723 + 5f54321 commit 75d839d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ public NoticeListResponse selectNoticeDetail(Long memberId, Long noticeId) {
NoticeListResponse response = noticeMapper.toNoticeDetailDTO(projection);

// 조회 여부 기록 업데이트
NoticeViewResponse viewResponse = noticeQueryService.findSingleViewYn(noticeId, memberId);
ViewType viewResponse = noticeQueryService.findSingleViewType(noticeId, memberId);
Long viewId = noticeQueryService.findSingleViewId(noticeId, memberId);

if (viewResponse.viewType().equals(ViewType.NONE)) {
noticeQueryService.updateSingleViewYn(viewResponse.id(), memberId, ViewType.VIEWED);
if (viewResponse.equals(ViewType.NONE)) {
noticeQueryService.updateSingleViewYn(viewId, memberId, ViewType.VIEWED);
}

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public List<CurriculumProjection> findByCurriculum() {
@Override
public List<Notice> selectNoticeByCurriculum(Long curriculumId) {
return jpaQueryFactory.selectFrom(notice)
.join(curriculum).on(notice.id.eq(curriculumId))
.join(curriculum).on(notice.curriculum.id.eq(curriculumId))
.orderBy(notice.createdAt.desc())
.fetch();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public interface NoticeRepository extends JpaRepository<Notice, Long>, NoticeDyn
@Query("update Notice n set n.title = :title, n.content = :content where n.id = :noticeId")
void updateNotice(Long noticeId, String title, String content);

@Query("select v.id, v.view from Notice n join NoticeView v on n.noticeView.id = v.id where n.id = :noticeId and v.member.id = :memberId")
NoticeViewResponse findSingleViewYn(Long memberId, Long noticeId);
@Query("select v.id from Notice n join NoticeView v on n.noticeView.id = v.id where n.id = :noticeId and v.member.id = :memberId")
Long findSingleViewId(Long memberId, Long noticeId);

@Query("select v.view from Notice n join NoticeView v on n.noticeView.id = v.id where n.id = :noticeId and v.member.id = :memberId")
ViewType findSingleViewType(Long memberId, Long noticeId);

@Modifying
@Query("update NoticeView v set v.view = :viewType where v.member.id = :memberId and v.id = :noticeViewId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ public String findImageByNoticeId(Long noticeId) {
return noticeRepository.findImageByNoticeId(noticeId);
}

public NoticeViewResponse findSingleViewYn(Long noticeId, Long memberId) {
return noticeRepository.findSingleViewYn(memberId, noticeId);
public Long findSingleViewId(Long noticeId, Long memberId) {
return noticeRepository.findSingleViewId(memberId, noticeId);
}

public ViewType findSingleViewType(Long noticeId, Long memberId) {
return noticeRepository.findSingleViewType(memberId, noticeId);
}

public void updateSingleViewYn(Long noticeViewId, Long memberId, ViewType viewType) {
Expand Down

0 comments on commit 75d839d

Please sign in to comment.