Skip to content

Conversation

@CheorHyeon
Copy link
Owner

@CheorHyeon CheorHyeon commented Jul 26, 2023

점프투스프링부트 3-15 추가기능

첫 번째로 조회수 기능을 구현했습니다.

src/main/resources/templates/question/question_list.html + question_detail

  • th:text="${question.view}" 로 조회수 표시

src/main/resources/templates/question/question_detail.html

  • Ajax 통신을 이용 -> 브라우저의 로케이션 스토리지를 활용하여 동일한 질문에 대해서는 1개만 증가하도록 구현
  • 방문한 적이 있다면 조회수 증가가 불가능 하니 Ajax 요청을 보내지 않음
  • 응답 받은 String값으로 text를 대체

src/main/java/com/ll/spring_additional/boundedContext/question/controller/QuestionController.java

  • increaseView 메서드의 경우 Ajax 요청이 왔을 때 조건을 검사하고 조회수 증가하고 View를 String화 하여 반환

util/Ut

  • AjaxUtils 클래스 : Ajax 요청이 있는지 검사 // 현재 쓰이진 않음

@CheorHyeon CheorHyeon added the enhancement New feature or request label Jul 26, 2023
@CheorHyeon CheorHyeon self-assigned this Jul 26, 2023
@CheorHyeon CheorHyeon merged commit 8eb7797 into main Jul 27, 2023
@CheorHyeon CheorHyeon changed the title Enhancement3 추가 기능 4) 카테고리 구현 Jul 31, 2023
@CheorHyeon CheorHyeon changed the title 추가 기능 4) 카테고리 구현 추가 기능 1) 조회수 구현 Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants