Skip to content

Commit

Permalink
[ADD] #118 - Add place top5 view
Browse files Browse the repository at this point in the history
  • Loading branch information
Jwhyee committed Sep 27, 2022
1 parent caa1132 commit 963f511
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
import org.springframework.data.jpa.repository.JpaRepository;


public interface PlaceRepository extends JpaRepository<Place,Long> {
public interface PlaceRepository extends JpaRepository<Place,Long>, PlaceRepositoryCustom {
boolean existsById(long id);
}
4 changes: 4 additions & 0 deletions src/main/java/com/matdongsan/service/PlaceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@ private void pullInfo(Place place) {
}
}

public List<Place> findTop5Place() {
return placeRepository.findByTop5Place();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.matdongsan.web.controller;

import com.matdongsan.service.PlaceService;
import com.matdongsan.service.PostService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -13,10 +14,12 @@
public class MainPageController {

private final PostService postService;
private final PlaceService placeService;

@GetMapping("/")
public String mainPageMapping(Model model) {
model.addAttribute("top5", postService.findTop5Post());
model.addAttribute("top5Post", postService.findTop5Post());
model.addAttribute("top5Place", placeService.findTop5Place());
return "index";
}

Expand Down
94 changes: 52 additions & 42 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,56 +74,66 @@ <h5 class="card-title">맛집 둘러보기</h5>
</div>
</div>-->
<h3>인기 플레이스 TOP 5</h3>
<div id="placeTop5" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item" th:each="top, status : ${top5}" th:classappend="${status.index == 0} ? active" style=" cursor: pointer;" th:onclick="'location.href=\'' + @{/post/{postId}(postId = ${top.id})} + '\''">
<img class="d-block w-100" th:src="@{${top.getPlace().mainPhotoUrl}}" style="height: 300px; opacity: 0.5;">
<div class="carousel-caption d-none d-md-block">
<h5 th:text="${top.title}">제목</h5>
<p th:utext="${top.content}">내용 조금</p>
<th:block th:if="${top5Place.size() == 0}">
<div> 플레이스가 등록되어있지 않습니다.</div>
</th:block>
<th:block th:if="${top5Place.size() != 0}">
<div id="placeTop5" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item" th:each="top, status : ${top5Place}" th:classappend="${status.index == 0} ? active" style=" cursor: pointer;" th:onclick="'location.href=\'' + @{/place/{placeId}/detail(placeId = ${top.id})} + '\''">
<img class="d-block w-100" th:src="@{${top.getMainPhotoUrl()}}" style="height: 300px; opacity: 0.5;">
<div class="carousel-caption d-none d-md-block">
<h5 th:text="${top.getPlaceName()}">장소이름</h5>
<p th:utext="${top.getCategoryName()}">분류</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#placeTop5" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#placeTop5" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<a class="carousel-control-prev" href="#placeTop5" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#placeTop5" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</th:block>
<br>
<h3>인기 포스팅 TOP 5</h3>
<div id="postingTop5" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item" th:each="top, status : ${top5}" th:classappend="${status.index == 0} ? active" style=" cursor: pointer;" th:onclick="'location.href=\'' + @{/post/{postId}(postId = ${top.id})} + '\''">
<img class="d-block w-100" th:src="@{${top.getPlace().mainPhotoUrl}}" style="height: 300px; opacity: 0.5;">
<div class="carousel-caption d-none d-md-block">
<h5 th:text="${top.title}">제목</h5>
<p th:utext="${top.content}">내용 조금</p>
<th:block th:if="${top5Post.size() == 0}">
<div> 리뷰 포스트가 등록되어있지 않습니다.</div>
</th:block>
<th:block th:if="${top5Post.size() != 0}">
<div id="postingTop5" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item" th:each="top, status : ${top5Post}" th:classappend="${status.index == 0} ? active" style=" cursor: pointer;" th:onclick="'location.href=\'' + @{/post/{postId}(postId = ${top.id})} + '\''">
<img class="d-block w-100" th:src="@{${top.getPlace().mainPhotoUrl}}" style="height: 300px; opacity: 0.5;">
<div class="carousel-caption d-none d-md-block">
<h5 th:text="${top.title}">제목</h5>
<p th:utext="${top.content}">내용 조금</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#postingTop5" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#postingTop5" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<a class="carousel-control-prev" href="#postingTop5" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#postingTop5" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</th:block>
</div>
</div>
</body>
Expand Down

0 comments on commit 963f511

Please sign in to comment.