Commit fa102c17 authored by 전성희's avatar 전성희

[ADD] 조회수 카운팅 추가

- guide get 요청 시 view count +1
parent c4bd6995
...@@ -12,9 +12,7 @@ import lombok.extern.log4j.Log4j2; ...@@ -12,9 +12,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.NoSuchElementException;
@Service @Service
@AllArgsConstructor @AllArgsConstructor
...@@ -39,6 +37,11 @@ public class GuideTestService { ...@@ -39,6 +37,11 @@ public class GuideTestService {
@Transactional @Transactional
public GuideTest findGuideById(String guideId) throws Exception{ public GuideTest findGuideById(String guideId) throws Exception{
GuideTest targetGuide = guideTestRepository.findById(guideId).orElseThrow(NoSuchElementException::new); GuideTest targetGuide = guideTestRepository.findById(guideId).orElseThrow(NoSuchElementException::new);
int viewCount = targetGuide.getView() != null ? targetGuide.getView() : 0;
targetGuide.setView(viewCount + 1);
guideTestRepository.save(targetGuide);
// List<Guide> sortedGuideList = new ArrayList<>(); // List<Guide> sortedGuideList = new ArrayList<>();
// for(Guide guide : guideRepository.findAllByParentIdOrderByOrderAsc("")) { // for(Guide guide : guideRepository.findAllByParentIdOrderByOrderAsc("")) {
// sortedGuideList.add(guide); // sortedGuideList.add(guide);
......
...@@ -31,6 +31,14 @@ ...@@ -31,6 +31,14 @@
color:#fff; color:#fff;
background-color: #1E88E5; background-color: #1E88E5;
.view-count {
position: absolute;
right: 0;
top: 0;
padding: 5px 10px;
font-size: 1rem;
}
.v-breadcrumbs{ .v-breadcrumbs{
color:#ddd; color:#ddd;
font-size:0.95rem; font-size:0.95rem;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
style="width:100%;" style="width:100%;"
></v-skeleton-loader> ></v-skeleton-loader>
<span v-if="!loading && guide"> <span v-if="!loading && guide">
<span class="view-count">{{guide.view.toLocaleString()}} viewd</span>
<v-breadcrumbs <v-breadcrumbs
class="ma-0 px-0 py-2 " class="ma-0 px-0 py-2 "
:items="getBreadcrumbs()" :items="getBreadcrumbs()"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment