Skip to content

Commit

Permalink
Merge pull request #39 from Team-UniVoice/feat/#36-checkreatAPINO21
Browse files Browse the repository at this point in the history
feat : NO. 21 공지 읽음 체크[퀵스캔확인]
  • Loading branch information
softmoca authored Jul 14, 2024
2 parents 8f6a5c8 + b3360eb commit 74ea91b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ public ResponseEntity<SuccessStatusResponse<Object>> viewCount(@PathVariable Lon

noticeService.viewCount(noticeId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(SuccessStatusResponse.of(SuccessMessage.VIEW_NOTICE_SUCCESS, null));
.body(SuccessStatusResponse.of(SuccessMessage.VIEW_COUNT_NOTICE_SUCCESS, null));
}

@PostMapping("/view-check/{noticeId}")
public ResponseEntity<SuccessStatusResponse<Object>> viewCheck(@PathVariable Long noticeId) {

noticeService.viewCheck(noticeId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(SuccessStatusResponse.of(SuccessMessage.VIEW_CHECK_NOTICE_SUCCESS, null));
}

@GetMapping("/quickhead")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,29 @@ public void viewCount(Long noticeId) {



@Transactional
public void viewCheck(Long noticeId) {
Long memberId = principalHandler.getUserIdFromPrincipal();

// member와 notice를 가져옵니다.
Member member = authRepository.findById(memberId)
.orElseThrow(() -> new RuntimeException("회원이 존재하지 않습니다."));
Notice notice = noticeRepository.findById(noticeId)
.orElseThrow(() -> new RuntimeException("공지사항이 존재하지 않습니다."));

// viewCount를 1 증가시킵니다.

noticeRepository.save(notice);

// NoticeView에서 해당 member와 notice의 데이터를 찾아 readAt을 true로 설정합니다.
NoticeView noticeView = noticeViewRepository.findByNoticeAndMember(notice, member)
.orElseThrow(() -> new RuntimeException("조회 기록이 존재하지 않습니다."));
noticeView.setReadAt(true);
noticeViewRepository.save(noticeView);
}



@Transactional
public List<QuickQueryNoticeDTO> getQuickNoticeByUserUniversity(String affiliation) {
Long memberId = principalHandler.getUserIdFromPrincipal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public enum SuccessMessage {
SAVE_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"공지 저장에 성공하였습니다."),
SAVE_CANCLE_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"공지 저장 취소에 성공하였습니다."),
SAVE_ALL_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"공지 저장 리스트 조회에 성공하였습니다."),
VIEW_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"공지 조회 체크에 성공하였습니다."),
VIEW_COUNT_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"공지 조회 체크 후 조회수 증가 성공하였습니다."),
VIEW_CHECK_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"공지 조회 체크에 성공하였습니다."),
GET_QUCIK_HEAD_SUCCESS(HttpStatus.CREATED.value(),"퀵스캔 스토리 헤드 데이터 조회에 성공하였습니다."),
GET_ALL_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"전체 공지 조회에 성공하였습니다."),
GET_ALL_UNIVERSITY_NOTICE_SUCCESS(HttpStatus.CREATED.value(),"총학생회 공지 조회에 성공하였습니다."),
Expand Down

0 comments on commit 74ea91b

Please sign in to comment.