롯데ON 커뮤니티는 공지, 자유, 자료실, 익명 게시판으로 나뉘어 있으며, 각 게시글을 열람 시 조회수 증가 + 글 내용 상세 조회 처리를 진행합니다. 게시판 종류에 따라 view1 ~ view4 컨트롤러 메서드가 호출되고, 조회수 증가는 트랜잭션으로 안전하게 반영됩니다.
[Controller]
└─ GET /Community/view{1~4}
├─ 게시글 번호, 카테고리(cate) 전달
├─ 조회수 증가 호출
├─ 게시글 상세 조회 → Model에 DTO 등록
[Service]
├─ increaseHit1(), increaseHit2() → 트랜잭션 기반 조회수 증가
├─ findById1(), findById2() → Entity → DTO 변환
├─ checkPassword() → 글 비밀번호 검증
└─ downloadFile() → 다운로드 수 증가 + 파일 스트림 전송
[Repository]
└─ findById() → 게시글 또는 파일 정보 조회
@GetMapping("/Community/view1")
public String view1(int no, @RequestParam("cate") String cate, Model model) {
communityService.increaseHit1(no);
Community1DTO communityDTO = communityService.findById1(no);
model.addAttribute(communityDTO);
model.addAttribute("cate", cate);
return "/Community/view/view1";
}
cate는 탭 유지, 목록으로 되돌아갈 때 사용@Transactional
public void increaseHit1(int no) {
Community1 community = community1Repository.findById(no)
.orElseThrow(() -> new RuntimeException("해당 게시글이 존재하지 않습니다."));
community.setHit(community.getHit() + 1);
}
@Transactional로 조회수 증가를 안정적으로 반영