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

[ADD] 조회수 카운팅 추가

- guide get 요청 시 view count +1
parent c4bd6995
......@@ -12,9 +12,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.*;
@Service
@AllArgsConstructor
......@@ -39,6 +37,11 @@ public class GuideTestService {
@Transactional
public GuideTest findGuideById(String guideId) throws Exception{
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<>();
// for(Guide guide : guideRepository.findAllByParentIdOrderByOrderAsc("")) {
// sortedGuideList.add(guide);
......
......@@ -31,6 +31,14 @@
color:#fff;
background-color: #1E88E5;
.view-count {
position: absolute;
right: 0;
top: 0;
padding: 5px 10px;
font-size: 1rem;
}
.v-breadcrumbs{
color:#ddd;
font-size:0.95rem;
......
......@@ -15,6 +15,7 @@
style="width:100%;"
></v-skeleton-loader>
<span v-if="!loading && guide">
<span class="view-count">{{guide.view.toLocaleString()}} viewd</span>
<v-breadcrumbs
class="ma-0 px-0 py-2 "
: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