diff --git a/README.md b/README.md
index e514998e..26931566 100644
--- a/README.md
+++ b/README.md
@@ -1,50 +1,231 @@
-# Project : Inplace ( Team7_BE )
+# Inplace ( Team7_BE )
-## 기획 의도
-> **데이트 코스의 단조로움** 이라는 생각에서 시작한 저희의 아이디어는 인스타, 유튜브 등의 SNS 플랫폼의 성장과 함께 등장한 '인플루언서' 라는 개념에 집중하여, **인플루언서가 방문한 주변 장소에 대한 정보를 서비스 해보자!** 라는 생각으로 이어졌고, 이를 개인별 맞춤 장소 추천, 방문시 정보 발송 및 알림, 리뷰와 같은 기능으로 풀어내어 **Inplace** 라는 저희만의 웹 어플리케이션으로 구현해보았습니다.
+
+
+
+
+## Table of Contents
+> 1. [**_Project Purpose_**](#project-purpose)
+> 2. [**_Service Info_**](#service-info)
+> 3. [**_Main Function_**](#main-function)
+> 4. [**_Development Focus Points_**](#development-focus-points)
+> 5. [**_Repository Info_**](#repository-info)
+> 6. [**_Development Term_**](#development-term)
+> 7. [**_Deployment Link_**](#deployment-link)
+> 8. [**_Contributor_**](#contributor)
+> 9. [**_Program Architecture_**](#program-architecture)
+> 10. [**_Main Dependency Version_**](#main-dependency-version)
+> 11. [**_Tech Stack_**](#tech-stack)
+> 12. [**_Example Usage_**](#example-usage)
+
+## Project Purpose
+> 저희의 아이디어는 **데이트 코스의 단조로움**을 어떻게 하면 해소할 수 있을까? 라는 생각에서 시작했습니다.
+>
+> 아이디어를 구체화하는 과정에서 저희는 **장소**에 관련된 소재로 인스타, 유튜브 등의 SNS 및 동영상 플랫폼의 성장과 함께 등장한 **인플루언서** 라는 개념에 집중하게 되었습니다.
+>
+> 이는 **인플루언서가 방문한 장소에 대한 정보를 서비스 해보자!** 라는 생각으로 이어졌습니다.
+>
+> 이를 관심있는 **인플루언서를 등록하고, 이에 따른 장소 추천 및, 장소에 대한 리뷰 기능**을 통해 풀어내어 **Inplace** 라는 저희만의 웹 애플리케이션으로 구현해보았습니다.
+
+## Service Info
+> 긴 영상은 필요 없어요 인플루언서가 다녀간 쿨플, 한눈에 쏙!
+1. **회원 가입 및 로그인** 기능
+ - 카카오를 이용한 회원 가입 및 로그인
+ - 회원 닉네임 변경 가능
+2. **관심있는 인플루언서 설정** 기능
+ - 최초 로그인 시, 관심 인플루언서를 설정 가능
+ - 이후, 인플루언서 페이지에서 좋아요 버튼을 통해 설정 가능
+ - 마이 페이지에서 관심있는 인플루언서 삭제 가능
+3. **장소 검색 및 좋아요** 기능
+ - 지도를 통한 장소 검색 가능
+ - 지역, 인플루언서, 장소 태그를 통한 검색 가능
+ - 장소 세부 정보 열람 및 장소 좋아요 가능
+4. **리뷰** 기능
+ - 장소에 대한 정보를 모바일로 받기 가능 ( 카카오톡 나에게 메세지 보내기 )
+ - 정보 받은 후 3일 뒤 리뷰 페이지 전송 ( 카카오톡 나에게 메세지 보내기 )
+
+## Main Function
+> Inplace의 주요 기능
+1. **회원가입 및 로그인**
+ - Spring Security를 이용한 OAuth 2.0 카카오 로그인 기능을 사용합니다
+ - 쿠키에 Access, Refresh Token을 담아 사용하며, Refresh 동작을 수행할 수 있습니다
+2. **현재 위치 기반 서비스**
+ - 웹 페이지의 위치 정보 사용에 동의시, 카카오 API와 내 위치 정보를 사용하여 주변의 장소 정보와, 자동 지도 위치 설정을 사용할 수 있습니다
+3. **통합 검색 서비스**
+ - Elastic Search를 사용한 인플루언서, 장소, 비디오 이름에 대한 통합 검색 기능을 사용할 수 있습니다
+4. **관심 인플루언서 등록 및 이를 토대로 한 서비스**
+ - 최초 로그인 시 & 인플루언서 페이지에서 관심 인플루언서를 등록할 수 있습니다
+ - 이를 토대로 메인 페이지에서 관심 인플루언서의 최신 방문 장소를 확인할 수 있습니다
+5. **지도 기반 검색 서비스**
+ - 지도 API를 이용하여 장소를 검색할 수 있습니다
+ - 관심 등록하지 않은 인플루언서 및 주소, 장소 태그를 이용하여 세부 검색이 가능합니다
+6. **장소 세부 정보 서비스**
+ - 장소의 세부 정보를 열람할 수 있습니다
+ - 장소에 달린 다른 유저들의 리뷰를 확인할 수 있습니다
+ - 장소에 대한 좋아요 기능을 사용할 수 있습니다
+ - 장소 세부 페이지에서 장소에 대한 정보를 카카오톡 메세지로 받아 볼 수 있습니다
+7. **리뷰 기능**
+ - 장소 정보를 받은 후 3일 뒤, 해당 장소에 대한 리뷰 링크를 받아 리뷰를 작성할 수 있습니다
+ - 위 기능들은 카카오톡 메세지 보내기 API를 이용하며, 카카오톡으로 전송되는 링크는 모바일 뷰를 지원합니다
+8. **마이 페이지 기능**
+ - 좋아요 표시한 장소, 인플루언서를 관리할 수 있습니다
+ - 내가 작성한 리뷰를 관리할 수 있습니다
+ - 사용자 닉네임을 변경할 수 있습니다
+
+## Development Focus Points
+
+## Repository Info
+> **Using Language**
+>
+![GitHub language count](https://img.shields.io/github/languages/count/kakao-tech-campus-2nd-step3/Team7_BE)
+![GitHub top language](https://img.shields.io/github/languages/top/kakao-tech-campus-2nd-step3/Team7_BE)
+
+> **Repo, Code Volume**
+>
+![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/kakao-tech-campus-2nd-step3/Team7_BE)
+![GitHub repo size](https://img.shields.io/github/repo-size/kakao-tech-campus-2nd-step3/Team7_BE)
+
+> **Commit Avg**
+>
+![GitHub commit activity](https://img.shields.io/github/commit-activity/w/kakao-tech-campus-2nd-step3/Team7_BE)
+
+> **Issues**
+>
+![GitHub open issues](https://img.shields.io/github/issues/kakao-tech-campus-2nd-step3/Team7_BE)
+![GitHub closed issues](https://img.shields.io/github/issues-closed/kakao-tech-campus-2nd-step3/Team7_BE)
+
+> **PRs**
+>
+![GitHub pull requests](https://img.shields.io/github/issues-pr/kakao-tech-campus-2nd-step3/Team7_BE?label=open%20pull%20requests)
+![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/kakao-tech-campus-2nd-step3/Team7_BE?label=closed%20pull%20requests)
+
+## Development Term
+> 2024.08.22 ~ 2024.11.15
+
+## Deployment Link
+> [**BackEnd**](https://api.inplace.my) : _api.inplace.my_
+>
+> [**API Spec**](https://api.inplace.my/swagger-ui/index.html) : _api.inplace.my/swagger-ui/index.html_
>
-## 참여자
-
-[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
-
+> [**FrontEnd**](https://inplace.my) : _inplace.my_
+## Contributor
+
+
+
+ Backend
+
+
+ Backend
+
+
+ Backend
+
+
+ Backend
+
+
+ Backend
+
+
+
+
+ 이상희
+
+
+ 김동윤
+
+
+ 정수현
+
+
+ 우현서
+
+
+ 배준호
+
-## 주요 종속성 버전
-- Spring Boots 3.3.3
-- Java 17 LTS
+## Program Architecture
+- **ERD**
+
+
-## 기술 스택
+## Main Dependency Version
+> **Spring Boots 3.3.3**
+>
+> **Java 17 LTS**
+
+## Tech Stack
+> **Backend**
+>
![Spring Boot](https://img.shields.io/badge/Spring%20Boot-6DB33F?style=flat-square&logo=springboot&logoColor=white)
![Lombok](https://img.shields.io/badge/Lombok-DC382D?style=flat-square&logo=lombok&logoColor=white)
+> **Security**
+>
![Spring Security](https://img.shields.io/badge/Spring%20Security-6DB33F?style=flat-square&logo=springsecurity&logoColor=white)
![JWT](https://img.shields.io/badge/JWT-000000?style=flat-square&logo=jsonwebtokens&logoColor=white)
+> **DB**
+>
![Spring Data JPA](https://img.shields.io/badge/Spring%20Data%20JPA-6DB33F?style=flat-square&logo=spring&logoColor=white)
![QueryDSL](https://img.shields.io/badge/QueryDSL-0055a2?style=flat-square&logo=appveyor&logoColor=white)
![MySQL](https://img.shields.io/badge/MySQL-4479A1?style=flat-square&logo=mysql&logoColor=white)
![Redis](https://img.shields.io/badge/Redis-DC382D?style=flat-square&logo=redis&logoColor=white)
+> **Web**
+>
![Spring WebFlux](https://img.shields.io/badge/Spring%20WebFlux-6DB33F?style=flat-square&logo=spring&logoColor=white)
-![Thymeleaf](https://img.shields.io/badge/Thymeleaf-005F0F?style=flat-square&logo=thymeleaf&logoColor=white)
+> **Deployment**
+>
![AWS EC2](https://img.shields.io/badge/AWS%20EC2-FF9900?style=flat-square&logo=amazonaws&logoColor=white)
![Docker](https://img.shields.io/badge/Docker-2496ED?style=flat-square&logo=docker&logoColor=white)
+> **Admin Page**
+>
+![jQuery](https://img.shields.io/badge/jQuery-0769AD?style=flat-square&logo=jquery&logoColor=white)
+![Thymeleaf](https://img.shields.io/badge/Thymeleaf-005F0F?style=flat-square&logo=thymeleaf&logoColor=white)
+![AJAX](https://img.shields.io/badge/AJAX-005571?style=flat-square&logo=ajax&logoColor=white)
+
+> **Test**
+>
![JMeter](https://img.shields.io/badge/JMeter-D22128?style=flat-square&logo=apachejmeter&logoColor=white)
![JUnit](https://img.shields.io/badge/JUnit-25A162?style=flat-square&logo=junit5&logoColor=white)
+![Mockito](https://img.shields.io/badge/Mockito-FFCA28?style=flat-square&logo=mockito&logoColor=white)
+
+> **Code Maintenance**
+>
+![Git](https://img.shields.io/badge/Git-F05032?style=flat-square&logo=git&logoColor=white)
+![GitHub](https://img.shields.io/badge/GitHub-181717?style=flat-square&logo=github&logoColor=white)
+![GitHub Actions](https://img.shields.io/badge/GitHub%20Actions-2088FF?style=flat-square&logo=githubactions&logoColor=white)
+
+> **Collaboration Tool**
+>
+![Discord](https://img.shields.io/badge/Discord-5865F2?style=flat-square&logo=discord&logoColor=white)
+![Slack](https://img.shields.io/badge/Slack-4A154B?style=flat-square&logo=slack&logoColor=white)
-## 사용 예시
+## Example Usage
> 나중에 시연 영상 첨부하기
diff --git a/src/main/java/team7/inplace/InplaceApplication.java b/src/main/java/team7/inplace/InplaceApplication.java
index 887c1415..143ddd36 100644
--- a/src/main/java/team7/inplace/InplaceApplication.java
+++ b/src/main/java/team7/inplace/InplaceApplication.java
@@ -11,11 +11,11 @@
@SpringBootApplication
@ConfigurationPropertiesScan
@EnableJpaRepositories(
- basePackages = "team7.inplace",
- excludeFilters = @ComponentScan.Filter(
- type = FilterType.ASSIGNABLE_TYPE,
- classes = {RefreshTokenRepository.class}
- )
+ basePackages = "team7.inplace",
+ excludeFilters = @ComponentScan.Filter(
+ type = FilterType.ASSIGNABLE_TYPE,
+ classes = {RefreshTokenRepository.class}
+ )
)
public class InplaceApplication {
diff --git a/src/main/java/team7/inplace/admin/AdminPageController.java b/src/main/java/team7/inplace/admin/AdminPageController.java
index 3fecbd75..f731c7e5 100644
--- a/src/main/java/team7/inplace/admin/AdminPageController.java
+++ b/src/main/java/team7/inplace/admin/AdminPageController.java
@@ -1,6 +1,5 @@
package team7.inplace.admin;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -16,6 +15,8 @@
import team7.inplace.video.domain.Video;
import team7.inplace.video.persistence.VideoRepository;
+import java.util.List;
+
@Controller
@RequiredArgsConstructor
@RequestMapping("/admin")
diff --git a/src/main/java/team7/inplace/admin/crawling/application/AddressUtil.java b/src/main/java/team7/inplace/admin/crawling/application/AddressUtil.java
index e41fdf16..8bddfe09 100644
--- a/src/main/java/team7/inplace/admin/crawling/application/AddressUtil.java
+++ b/src/main/java/team7/inplace/admin/crawling/application/AddressUtil.java
@@ -1,11 +1,12 @@
package team7.inplace.admin.crawling.application;
-import static lombok.AccessLevel.PRIVATE;
-
import com.fasterxml.jackson.databind.JsonNode;
+import lombok.NoArgsConstructor;
+
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import lombok.NoArgsConstructor;
+
+import static lombok.AccessLevel.PRIVATE;
@NoArgsConstructor(access = PRIVATE)
public final class AddressUtil {
diff --git a/src/main/java/team7/inplace/admin/crawling/application/VideoCrawlingService.java b/src/main/java/team7/inplace/admin/crawling/application/VideoCrawlingService.java
index e6ff1227..261df0a7 100644
--- a/src/main/java/team7/inplace/admin/crawling/application/VideoCrawlingService.java
+++ b/src/main/java/team7/inplace/admin/crawling/application/VideoCrawlingService.java
@@ -1,6 +1,5 @@
package team7.inplace.admin.crawling.application;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -9,6 +8,8 @@
import team7.inplace.admin.crawling.client.YoutubeClient;
import team7.inplace.video.persistence.VideoRepository;
+import java.util.List;
+
@Service
@RequiredArgsConstructor
public class VideoCrawlingService {
diff --git a/src/main/java/team7/inplace/admin/crawling/application/YoutubeCrawlingService.java b/src/main/java/team7/inplace/admin/crawling/application/YoutubeCrawlingService.java
index 090ac988..3d1322b7 100644
--- a/src/main/java/team7/inplace/admin/crawling/application/YoutubeCrawlingService.java
+++ b/src/main/java/team7/inplace/admin/crawling/application/YoutubeCrawlingService.java
@@ -1,7 +1,5 @@
package team7.inplace.admin.crawling.application;
-import java.util.List;
-import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -13,6 +11,9 @@
import team7.inplace.global.exception.InplaceException;
import team7.inplace.global.exception.code.ChannelErrorCode;
+import java.util.List;
+import java.util.Objects;
+
@Slf4j
@Service
@RequiredArgsConstructor
diff --git a/src/main/java/team7/inplace/admin/crawling/client/KakaoMapClient.java b/src/main/java/team7/inplace/admin/crawling/client/KakaoMapClient.java
index d233b3c1..95d952e1 100644
--- a/src/main/java/team7/inplace/admin/crawling/client/KakaoMapClient.java
+++ b/src/main/java/team7/inplace/admin/crawling/client/KakaoMapClient.java
@@ -1,7 +1,6 @@
package team7.inplace.admin.crawling.client;
import com.fasterxml.jackson.databind.JsonNode;
-import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
@@ -15,6 +14,8 @@
import team7.inplace.global.exception.code.PlaceErrorCode;
import team7.inplace.global.kakao.config.KakaoApiProperties;
+import java.util.Objects;
+
@Slf4j
@Component
@RequiredArgsConstructor
diff --git a/src/main/java/team7/inplace/admin/crawling/client/YoutubeClient.java b/src/main/java/team7/inplace/admin/crawling/client/YoutubeClient.java
index c32e990b..152e4bb8 100644
--- a/src/main/java/team7/inplace/admin/crawling/client/YoutubeClient.java
+++ b/src/main/java/team7/inplace/admin/crawling/client/YoutubeClient.java
@@ -1,14 +1,15 @@
package team7.inplace.admin.crawling.client;
import com.fasterxml.jackson.databind.JsonNode;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
@Slf4j
@Component
public class YoutubeClient {
diff --git a/src/main/java/team7/inplace/admin/crawling/domain/YoutubeChannel.java b/src/main/java/team7/inplace/admin/crawling/domain/YoutubeChannel.java
index 4dd4d3fb..1b023d47 100644
--- a/src/main/java/team7/inplace/admin/crawling/domain/YoutubeChannel.java
+++ b/src/main/java/team7/inplace/admin/crawling/domain/YoutubeChannel.java
@@ -1,16 +1,12 @@
package team7.inplace.admin.crawling.domain;
-import static jakarta.persistence.EnumType.STRING;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Enumerated;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
+import static jakarta.persistence.EnumType.STRING;
+
@Getter
@Entity(name = "youtube_channel")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
diff --git a/src/main/java/team7/inplace/admin/crawling/persistence/YoutubeChannelRepository.java b/src/main/java/team7/inplace/admin/crawling/persistence/YoutubeChannelRepository.java
index 4332a5dc..b015a0cb 100644
--- a/src/main/java/team7/inplace/admin/crawling/persistence/YoutubeChannelRepository.java
+++ b/src/main/java/team7/inplace/admin/crawling/persistence/YoutubeChannelRepository.java
@@ -1,9 +1,10 @@
package team7.inplace.admin.crawling.persistence;
-import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import team7.inplace.admin.crawling.domain.YoutubeChannel;
+import java.util.Optional;
+
public interface YoutubeChannelRepository extends JpaRepository {
Optional findYoutubeChannelByPlayListUUID(String playListUUID);
}
diff --git a/src/main/java/team7/inplace/admin/error/ErrorLog.java b/src/main/java/team7/inplace/admin/error/ErrorLog.java
index c5183e91..28cef11b 100644
--- a/src/main/java/team7/inplace/admin/error/ErrorLog.java
+++ b/src/main/java/team7/inplace/admin/error/ErrorLog.java
@@ -1,10 +1,6 @@
package team7.inplace.admin.error;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
diff --git a/src/main/java/team7/inplace/admin/error/ErrorLogRepository.java b/src/main/java/team7/inplace/admin/error/ErrorLogRepository.java
index 4cc4f4d4..163ddff0 100644
--- a/src/main/java/team7/inplace/admin/error/ErrorLogRepository.java
+++ b/src/main/java/team7/inplace/admin/error/ErrorLogRepository.java
@@ -1,8 +1,9 @@
package team7.inplace.admin.error;
-import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
+import java.util.List;
+
public interface ErrorLogRepository extends JpaRepository {
List findByIsResolvedFalse();
}
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/application/FavoriteInfluencerService.java b/src/main/java/team7/inplace/favoriteInfluencer/application/FavoriteInfluencerService.java
index b54bb2ad..0b37fb99 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/application/FavoriteInfluencerService.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/application/FavoriteInfluencerService.java
@@ -1,6 +1,5 @@
package team7.inplace.favoriteInfluencer.application;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -19,6 +18,8 @@
import team7.inplace.security.util.AuthorizationUtil;
import team7.inplace.user.domain.User;
+import java.util.List;
+
@RequiredArgsConstructor
@Service
public class FavoriteInfluencerService {
@@ -55,8 +56,8 @@ public void likeToManyInfluencer(FavoriteInfluencerListCommand command) {
private void processFavoriteInfluencer(User user, Influencer influencer, Boolean likes) {
FavoriteInfluencer favorite = favoriteRepository
- .findByUserIdAndInfluencerId(user.getId(), influencer.getId())
- .orElseGet(() -> new FavoriteInfluencer(user, influencer)); // 존재하지 않으면 새로 생성
+ .findByUserIdAndInfluencerId(user.getId(), influencer.getId())
+ .orElseGet(() -> new FavoriteInfluencer(user, influencer)); // 존재하지 않으면 새로 생성
favorite.updateLike(likes);
if (favorite.getId() == null) {
@@ -67,10 +68,10 @@ private void processFavoriteInfluencer(User user, Influencer influencer, Boolean
@Transactional(readOnly = true)
public Page getFavoriteInfluencers(Long userId, Pageable pageable) {
Page influencerPage = favoriteRepository.findByUserIdAndIsLikedTrue(
- userId, pageable);
+ userId, pageable);
return influencerPage.map(
- favorite -> InfluencerInfo.from(favorite.getInfluencer(), favorite.isLiked()));
+ favorite -> InfluencerInfo.from(favorite.getInfluencer(), favorite.isLiked()));
}
}
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerCommand.java b/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerCommand.java
index e9f4bc8f..f2f318c0 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerCommand.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerCommand.java
@@ -1,8 +1,8 @@
package team7.inplace.favoriteInfluencer.application.dto;
public record FavoriteInfluencerCommand(
- Long influencerId,
- Boolean likes
+ Long influencerId,
+ Boolean likes
) {
}
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerListCommand.java b/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerListCommand.java
index ebf7dd67..3a167412 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerListCommand.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/application/dto/FavoriteInfluencerListCommand.java
@@ -3,8 +3,8 @@
import java.util.List;
public record FavoriteInfluencerListCommand(
- List influencerIds,
- Boolean likes
+ List influencerIds,
+ Boolean likes
) {
}
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/domain/FavoriteInfluencer.java b/src/main/java/team7/inplace/favoriteInfluencer/domain/FavoriteInfluencer.java
index 5d0fa4f2..0b8612f9 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/domain/FavoriteInfluencer.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/domain/FavoriteInfluencer.java
@@ -1,14 +1,6 @@
package team7.inplace.favoriteInfluencer.domain;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
+import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@@ -16,6 +8,9 @@
import team7.inplace.influencer.domain.Influencer;
import team7.inplace.user.domain.User;
+import static jakarta.persistence.GenerationType.IDENTITY;
+import static lombok.AccessLevel.PROTECTED;
+
@Getter
@RequiredArgsConstructor
@NoArgsConstructor(access = PROTECTED)
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/persistent/FavoriteInfluencerRepository.java b/src/main/java/team7/inplace/favoriteInfluencer/persistent/FavoriteInfluencerRepository.java
index c8e8f5ee..ead22138 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/persistent/FavoriteInfluencerRepository.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/persistent/FavoriteInfluencerRepository.java
@@ -1,8 +1,5 @@
package team7.inplace.favoriteInfluencer.persistent;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
@@ -10,6 +7,10 @@
import org.springframework.data.repository.query.Param;
import team7.inplace.favoriteInfluencer.domain.FavoriteInfluencer;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
public interface FavoriteInfluencerRepository extends JpaRepository {
List findByUserId(Long userId);
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/presentation/FavoriteInfluencerController.java b/src/main/java/team7/inplace/favoriteInfluencer/presentation/FavoriteInfluencerController.java
index f60c8576..72baebb8 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/presentation/FavoriteInfluencerController.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/presentation/FavoriteInfluencerController.java
@@ -29,7 +29,7 @@ public ResponseEntity likeToInfluencer(@RequestBody InfluencerLikeRequest
@PostMapping("/multiple/likes")
public ResponseEntity likeToManyInfluencer(
- @RequestBody InfluencerListLikeRequest request) {
+ @RequestBody InfluencerListLikeRequest request) {
FavoriteInfluencerListCommand command = request.toCommand();
favoriteInfluencerService.likeToManyInfluencer(command);
return new ResponseEntity<>(HttpStatus.OK);
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerLikeRequest.java b/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerLikeRequest.java
index 0ee70a78..5c2f9fc1 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerLikeRequest.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerLikeRequest.java
@@ -3,8 +3,8 @@
import team7.inplace.favoriteInfluencer.application.dto.FavoriteInfluencerCommand;
public record InfluencerLikeRequest(
- Long influencerId,
- Boolean likes
+ Long influencerId,
+ Boolean likes
) {
public FavoriteInfluencerCommand toCommand() {
diff --git a/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerListLikeRequest.java b/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerListLikeRequest.java
index 6f5fa80a..ec4406f2 100644
--- a/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerListLikeRequest.java
+++ b/src/main/java/team7/inplace/favoriteInfluencer/presentation/dto/InfluencerListLikeRequest.java
@@ -1,11 +1,12 @@
package team7.inplace.favoriteInfluencer.presentation.dto;
-import java.util.List;
import team7.inplace.favoriteInfluencer.application.dto.FavoriteInfluencerListCommand;
+import java.util.List;
+
public record InfluencerListLikeRequest(
- List influencerIds,
- Boolean likes
+ List influencerIds,
+ Boolean likes
) {
public FavoriteInfluencerListCommand toCommand() {
diff --git a/src/main/java/team7/inplace/global/annotation/Facade.java b/src/main/java/team7/inplace/global/annotation/Facade.java
index 1b0f2071..70fe10e2 100644
--- a/src/main/java/team7/inplace/global/annotation/Facade.java
+++ b/src/main/java/team7/inplace/global/annotation/Facade.java
@@ -1,13 +1,10 @@
package team7.inplace.global.annotation;
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Component;
+import java.lang.annotation.*;
+
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
diff --git a/src/main/java/team7/inplace/global/exception/InplaceExceptionHandler.java b/src/main/java/team7/inplace/global/exception/InplaceExceptionHandler.java
index f3cf56de..49219fea 100644
--- a/src/main/java/team7/inplace/global/exception/InplaceExceptionHandler.java
+++ b/src/main/java/team7/inplace/global/exception/InplaceExceptionHandler.java
@@ -1,7 +1,6 @@
package team7.inplace.global.exception;
import jakarta.servlet.http.HttpServletRequest;
-import java.net.URI;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
@@ -12,6 +11,8 @@
import team7.inplace.admin.error.ErrorLog;
import team7.inplace.admin.error.ErrorLogRepository;
+import java.net.URI;
+
@Slf4j
@RestControllerAdvice
@RequiredArgsConstructor
diff --git a/src/main/java/team7/inplace/global/exception/code/VideoErrorCode.java b/src/main/java/team7/inplace/global/exception/code/VideoErrorCode.java
index a1c6ea37..855ff964 100644
--- a/src/main/java/team7/inplace/global/exception/code/VideoErrorCode.java
+++ b/src/main/java/team7/inplace/global/exception/code/VideoErrorCode.java
@@ -6,7 +6,7 @@
@AllArgsConstructor
@Getter
-public enum VideoErrorCode implements ErrorCode{
+public enum VideoErrorCode implements ErrorCode {
NOT_FOUND(HttpStatus.NOT_FOUND, "V001", "Can't find such video info");
private final HttpStatus httpStatus;
diff --git a/src/main/java/team7/inplace/global/kakao/config/KakaoApiProperties.java b/src/main/java/team7/inplace/global/kakao/config/KakaoApiProperties.java
index 13778fb7..32285510 100644
--- a/src/main/java/team7/inplace/global/kakao/config/KakaoApiProperties.java
+++ b/src/main/java/team7/inplace/global/kakao/config/KakaoApiProperties.java
@@ -4,9 +4,9 @@
@ConfigurationProperties(prefix = "kakao.api")
public record KakaoApiProperties(
- String key,
- String jsKey,
- String sendMessageToMeUrl
+ String key,
+ String jsKey,
+ String sendMessageToMeUrl
) {
public String getAuthorization() {
diff --git a/src/main/java/team7/inplace/global/rest/WebClientConfig.java b/src/main/java/team7/inplace/global/rest/WebClientConfig.java
index b8a62531..b968aaa5 100644
--- a/src/main/java/team7/inplace/global/rest/WebClientConfig.java
+++ b/src/main/java/team7/inplace/global/rest/WebClientConfig.java
@@ -1,22 +1,23 @@
package team7.inplace.global.rest;
-import java.time.Duration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;
+import java.time.Duration;
+
@Configuration
public class WebClientConfig {
@Bean
public WebClient webClient() {
return WebClient.builder()
- .clientConnector(new ReactorClientHttpConnector(
- HttpClient.create().responseTimeout(Duration.ofMillis(60000))
- ))
- .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(2 * 1024 * 1024))
- .build();
+ .clientConnector(new ReactorClientHttpConnector(
+ HttpClient.create().responseTimeout(Duration.ofMillis(60000))
+ ))
+ .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(2 * 1024 * 1024))
+ .build();
}
}
diff --git a/src/main/java/team7/inplace/global/scheduler/ScheduledExecutorConfig.java b/src/main/java/team7/inplace/global/scheduler/ScheduledExecutorConfig.java
index afcc36c0..097a65ca 100644
--- a/src/main/java/team7/inplace/global/scheduler/ScheduledExecutorConfig.java
+++ b/src/main/java/team7/inplace/global/scheduler/ScheduledExecutorConfig.java
@@ -1,10 +1,11 @@
package team7.inplace.global.scheduler;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
@Configuration
public class ScheduledExecutorConfig {
diff --git a/src/main/java/team7/inplace/influencer/application/InfluencerService.java b/src/main/java/team7/inplace/influencer/application/InfluencerService.java
index e8ec9cf9..c8a03cb4 100644
--- a/src/main/java/team7/inplace/influencer/application/InfluencerService.java
+++ b/src/main/java/team7/inplace/influencer/application/InfluencerService.java
@@ -1,7 +1,5 @@
package team7.inplace.influencer.application;
-import java.util.List;
-import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
@@ -17,6 +15,9 @@
import team7.inplace.security.util.AuthorizationUtil;
import team7.inplace.user.persistence.UserRepository;
+import java.util.List;
+import java.util.Set;
+
@RequiredArgsConstructor
@Service
public class InfluencerService {
@@ -39,12 +40,12 @@ public Page getAllInfluencers(Pageable pageable) {
Set likedInfluencerIds = favoriteRepository.findLikedInfluencerIdsByUserId(userId);
List influencerInfos = influencersPage.stream()
- .map(influencer -> {
- boolean isLiked = likedInfluencerIds.contains(influencer.getId());
- return InfluencerInfo.from(influencer, isLiked);
- })
- .sorted((a, b) -> Boolean.compare(b.likes(), a.likes()))
- .toList();
+ .map(influencer -> {
+ boolean isLiked = likedInfluencerIds.contains(influencer.getId());
+ return InfluencerInfo.from(influencer, isLiked);
+ })
+ .sorted((a, b) -> Boolean.compare(b.likes(), a.likes()))
+ .toList();
return new PageImpl<>(influencerInfos, pageable, influencersPage.getTotalElements());
}
@@ -53,8 +54,8 @@ public Page getAllInfluencers(Pageable pageable) {
public List getAllInfluencerNames() {
List names = influencerRepository.findAllInfluencerNames();
return names.stream()
- .map(InfluencerNameInfo::new)
- .toList();
+ .map(InfluencerNameInfo::new)
+ .toList();
}
@Transactional
@@ -67,7 +68,7 @@ public Long createInfluencer(InfluencerCommand command) {
public Long updateInfluencer(Long id, InfluencerCommand command) {
Influencer influencer = influencerRepository.findById(id).orElseThrow();
influencer.update(command.influencerName(), command.influencerImgUrl(),
- command.influencerJob());
+ command.influencerJob());
return influencer.getId();
}
diff --git a/src/main/java/team7/inplace/influencer/application/dto/InfluencerCommand.java b/src/main/java/team7/inplace/influencer/application/dto/InfluencerCommand.java
index c0ac6e03..99e0e9bd 100644
--- a/src/main/java/team7/inplace/influencer/application/dto/InfluencerCommand.java
+++ b/src/main/java/team7/inplace/influencer/application/dto/InfluencerCommand.java
@@ -3,16 +3,16 @@
import team7.inplace.influencer.domain.Influencer;
public record InfluencerCommand(
- String influencerName,
- String influencerImgUrl,
- String influencerJob
+ String influencerName,
+ String influencerImgUrl,
+ String influencerJob
) {
public static Influencer to(InfluencerCommand influencerCommand) {
return new Influencer(
- influencerCommand.influencerName,
- influencerCommand.influencerImgUrl,
- influencerCommand.influencerJob
+ influencerCommand.influencerName,
+ influencerCommand.influencerImgUrl,
+ influencerCommand.influencerJob
);
}
}
diff --git a/src/main/java/team7/inplace/influencer/application/dto/InfluencerInfo.java b/src/main/java/team7/inplace/influencer/application/dto/InfluencerInfo.java
index ca82957f..7f65194a 100644
--- a/src/main/java/team7/inplace/influencer/application/dto/InfluencerInfo.java
+++ b/src/main/java/team7/inplace/influencer/application/dto/InfluencerInfo.java
@@ -3,20 +3,20 @@
import team7.inplace.influencer.domain.Influencer;
public record InfluencerInfo(
- Long influencerId,
- String influencerName,
- String influencerImgUrl,
- String influencerJob,
- boolean likes
+ Long influencerId,
+ String influencerName,
+ String influencerImgUrl,
+ String influencerJob,
+ boolean likes
) {
public static InfluencerInfo from(Influencer influencer, boolean isLiked) {
return new InfluencerInfo(
- influencer.getId(),
- influencer.getName(),
- influencer.getImgUrl(),
- influencer.getJob(),
- isLiked
+ influencer.getId(),
+ influencer.getName(),
+ influencer.getImgUrl(),
+ influencer.getJob(),
+ isLiked
);
}
}
diff --git a/src/main/java/team7/inplace/influencer/domain/Influencer.java b/src/main/java/team7/inplace/influencer/domain/Influencer.java
index e35d1899..69154ac6 100644
--- a/src/main/java/team7/inplace/influencer/domain/Influencer.java
+++ b/src/main/java/team7/inplace/influencer/domain/Influencer.java
@@ -1,16 +1,12 @@
package team7.inplace.influencer.domain;
-import static lombok.AccessLevel.PROTECTED;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
+import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
+import static lombok.AccessLevel.PROTECTED;
+
@Getter
@NoArgsConstructor(access = PROTECTED)
@AllArgsConstructor
diff --git a/src/main/java/team7/inplace/influencer/persistence/InfluencerRepository.java b/src/main/java/team7/inplace/influencer/persistence/InfluencerRepository.java
index 8a620738..40b4e5f5 100644
--- a/src/main/java/team7/inplace/influencer/persistence/InfluencerRepository.java
+++ b/src/main/java/team7/inplace/influencer/persistence/InfluencerRepository.java
@@ -1,12 +1,13 @@
package team7.inplace.influencer.persistence;
-import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import team7.inplace.influencer.domain.Influencer;
+import java.util.List;
+
public interface InfluencerRepository extends JpaRepository {
@Override
diff --git a/src/main/java/team7/inplace/influencer/presentation/InfluencerController.java b/src/main/java/team7/inplace/influencer/presentation/InfluencerController.java
index 23cacb42..f9738682 100644
--- a/src/main/java/team7/inplace/influencer/presentation/InfluencerController.java
+++ b/src/main/java/team7/inplace/influencer/presentation/InfluencerController.java
@@ -1,26 +1,20 @@
package team7.inplace.influencer.presentation;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import team7.inplace.influencer.application.InfluencerService;
import team7.inplace.influencer.application.dto.InfluencerCommand;
import team7.inplace.influencer.presentation.dto.InfluencerNameResponse;
import team7.inplace.influencer.presentation.dto.InfluencerRequest;
import team7.inplace.influencer.presentation.dto.InfluencerResponse;
+import java.util.List;
+
@RequiredArgsConstructor
@RestController
@RequestMapping("/influencers")
@@ -30,9 +24,9 @@ public class InfluencerController implements InfluencerControllerApiSpec {
@GetMapping()
public ResponseEntity> getAllInfluencers(
- @PageableDefault(page = 0, size = 10) Pageable pageable) {
+ @PageableDefault(page = 0, size = 10) Pageable pageable) {
Page influencers = influencerService.getAllInfluencers(pageable)
- .map(InfluencerResponse::from);
+ .map(InfluencerResponse::from);
return new ResponseEntity<>(influencers, HttpStatus.OK);
}
@@ -40,8 +34,8 @@ public ResponseEntity> getAllInfluencers(
@GetMapping("/names")
public ResponseEntity> getAllInfluencerNames() {
List names = influencerService.getAllInfluencerNames().stream()
- .map(InfluencerNameResponse::from)
- .toList();
+ .map(InfluencerNameResponse::from)
+ .toList();
return new ResponseEntity<>(names, HttpStatus.OK);
}
@@ -55,13 +49,13 @@ public ResponseEntity createInfluencer(@RequestBody InfluencerRequest requ
@PutMapping("/{id}")
public ResponseEntity updateInfluencer(
- @PathVariable Long id,
- @RequestBody InfluencerRequest request
+ @PathVariable Long id,
+ @RequestBody InfluencerRequest request
) {
InfluencerCommand influencerCommand = new InfluencerCommand(
- request.influencerName(),
- request.influencerImgUrl(),
- request.influencerJob()
+ request.influencerName(),
+ request.influencerImgUrl(),
+ request.influencerJob()
);
Long updatedId = influencerService.updateInfluencer(id, influencerCommand);
diff --git a/src/main/java/team7/inplace/influencer/presentation/InfluencerControllerApiSpec.java b/src/main/java/team7/inplace/influencer/presentation/InfluencerControllerApiSpec.java
index 520853b7..dccc9b7c 100644
--- a/src/main/java/team7/inplace/influencer/presentation/InfluencerControllerApiSpec.java
+++ b/src/main/java/team7/inplace/influencer/presentation/InfluencerControllerApiSpec.java
@@ -1,7 +1,6 @@
package team7.inplace.influencer.presentation;
import io.swagger.v3.oas.annotations.Operation;
-import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
@@ -11,6 +10,8 @@
import team7.inplace.influencer.presentation.dto.InfluencerRequest;
import team7.inplace.influencer.presentation.dto.InfluencerResponse;
+import java.util.List;
+
public interface InfluencerControllerApiSpec {
@Operation(summary = "인플루언서들 반환", description = "토큰이 있는 경우 좋아요된 인플루언서가 먼저 반환됩니다.")
@@ -24,7 +25,7 @@ public interface InfluencerControllerApiSpec {
@Operation(summary = "인플루언서 수정", description = "인플루언서를 수정합니다.")
ResponseEntity updateInfluencer(@PathVariable Long id,
- @RequestBody InfluencerRequest request);
+ @RequestBody InfluencerRequest request);
@Operation(summary = "인플루언서 삭제", description = "인플루언서를 삭제합니다.")
ResponseEntity deleteInfluencer(@PathVariable Long id);
diff --git a/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerNameResponse.java b/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerNameResponse.java
index e5c06660..fc821427 100644
--- a/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerNameResponse.java
+++ b/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerNameResponse.java
@@ -3,12 +3,12 @@
import team7.inplace.influencer.application.dto.InfluencerNameInfo;
public record InfluencerNameResponse(
- String influencerName
+ String influencerName
) {
public static InfluencerNameResponse from(InfluencerNameInfo influencerNameInfo) {
return new InfluencerNameResponse(
- influencerNameInfo.name()
+ influencerNameInfo.name()
);
}
}
diff --git a/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerRequest.java b/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerRequest.java
index a5ca7a26..2ac73abe 100644
--- a/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerRequest.java
+++ b/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerRequest.java
@@ -3,16 +3,16 @@
import team7.inplace.influencer.application.dto.InfluencerCommand;
public record InfluencerRequest(
- String influencerName,
- String influencerImgUrl,
- String influencerJob
+ String influencerName,
+ String influencerImgUrl,
+ String influencerJob
) {
public static InfluencerCommand to(InfluencerRequest request) {
return new InfluencerCommand(
- request.influencerName(),
- request.influencerImgUrl(),
- request.influencerJob()
+ request.influencerName(),
+ request.influencerImgUrl(),
+ request.influencerJob()
);
}
}
diff --git a/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerResponse.java b/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerResponse.java
index 12729aad..a2eb53a2 100644
--- a/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerResponse.java
+++ b/src/main/java/team7/inplace/influencer/presentation/dto/InfluencerResponse.java
@@ -3,20 +3,20 @@
import team7.inplace.influencer.application.dto.InfluencerInfo;
public record InfluencerResponse(
- Long influencerId,
- String influencerName,
- String influencerImgUrl,
- String influencerJob,
- boolean likes
+ Long influencerId,
+ String influencerName,
+ String influencerImgUrl,
+ String influencerJob,
+ boolean likes
) {
public static InfluencerResponse from(InfluencerInfo influencerInfo) {
return new InfluencerResponse(
- influencerInfo.influencerId(),
- influencerInfo.influencerName(),
- influencerInfo.influencerImgUrl(),
- influencerInfo.influencerJob(),
- influencerInfo.likes()
+ influencerInfo.influencerId(),
+ influencerInfo.influencerName(),
+ influencerInfo.influencerImgUrl(),
+ influencerInfo.influencerJob(),
+ influencerInfo.likes()
);
}
}
diff --git a/src/main/java/team7/inplace/likedPlace/domain/LikedPlace.java b/src/main/java/team7/inplace/likedPlace/domain/LikedPlace.java
index 35cdab35..ed31817c 100644
--- a/src/main/java/team7/inplace/likedPlace/domain/LikedPlace.java
+++ b/src/main/java/team7/inplace/likedPlace/domain/LikedPlace.java
@@ -1,15 +1,6 @@
package team7.inplace.likedPlace.domain;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
+import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
@@ -17,6 +8,9 @@
import team7.inplace.place.domain.Place;
import team7.inplace.user.domain.User;
+import static jakarta.persistence.GenerationType.IDENTITY;
+import static lombok.AccessLevel.PROTECTED;
+
@Getter
@RequiredArgsConstructor
@NoArgsConstructor(access = PROTECTED)
diff --git a/src/main/java/team7/inplace/likedPlace/persistence/LikedPlaceRepository.java b/src/main/java/team7/inplace/likedPlace/persistence/LikedPlaceRepository.java
index 66f17eac..0ae36e7f 100644
--- a/src/main/java/team7/inplace/likedPlace/persistence/LikedPlaceRepository.java
+++ b/src/main/java/team7/inplace/likedPlace/persistence/LikedPlaceRepository.java
@@ -1,14 +1,23 @@
package team7.inplace.likedPlace.persistence;
import java.util.Optional;
+import java.util.Set;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import team7.inplace.likedPlace.domain.LikedPlace;
public interface LikedPlaceRepository extends JpaRepository {
Optional findByUserIdAndPlaceId(Long userId, Long placeId);
- Page findByUserIdAndIsLikedTrue(Long userId, Pageable pageable);
+ @Query("SELECT l.place.id FROM LikedPlace l WHERE l.user.id = :userId AND l.isLiked = true")
+ Set findPlaceIdsByUserIdAndIsLikedTrue(@Param("userId") Long userId);
+
+ @Query("SELECT lp FROM LikedPlace lp JOIN FETCH lp.place WHERE lp.user.id = :userId AND lp.isLiked = true")
+ Page findByUserIdAndIsLikedTrueWithPlace(@Param("userId") Long userId,
+ Pageable pageable);
+
}
diff --git a/src/main/java/team7/inplace/oauthToken/application/OauthTokenService.java b/src/main/java/team7/inplace/oauthToken/application/OauthTokenService.java
index aec4df0b..5a031c4f 100644
--- a/src/main/java/team7/inplace/oauthToken/application/OauthTokenService.java
+++ b/src/main/java/team7/inplace/oauthToken/application/OauthTokenService.java
@@ -23,17 +23,17 @@ public class OauthTokenService {
@Transactional(readOnly = true)
public String findOAuthTokenByUserId(Long userId) throws InplaceException {
return tokenEncryptionUtil.decrypt(oauthTokenRepository.findByUserId(userId)
- .orElseThrow(() -> InplaceException.of(UserErrorCode.OAUTH_TOKEN_NOT_FOUND))
- .getOauthToken());
+ .orElseThrow(() -> InplaceException.of(UserErrorCode.OAUTH_TOKEN_NOT_FOUND))
+ .getOauthToken());
}
@Transactional
public void insertOauthToken(OauthTokenCommand oauthTokenCommand) throws InplaceException {
User userProxy = entityManager.getReference(User.class, oauthTokenCommand.userId());
OauthToken oauthToken = OauthToken.of(
- tokenEncryptionUtil.encrypt(oauthTokenCommand.oauthToken()),
- oauthTokenCommand.expiresAt(),
- userProxy
+ tokenEncryptionUtil.encrypt(oauthTokenCommand.oauthToken()),
+ oauthTokenCommand.expiresAt(),
+ userProxy
);
oauthTokenRepository.save(oauthToken);
@@ -42,11 +42,11 @@ public void insertOauthToken(OauthTokenCommand oauthTokenCommand) throws Inplace
@Transactional
public void updateOauthToken(OauthTokenCommand oauthTokenCommand) throws InplaceException {
OauthToken oauthToken = oauthTokenRepository.findByUserId(oauthTokenCommand.userId())
- .orElseThrow(() -> InplaceException.of(UserErrorCode.OAUTH_TOKEN_NOT_FOUND));
+ .orElseThrow(() -> InplaceException.of(UserErrorCode.OAUTH_TOKEN_NOT_FOUND));
oauthToken.updateInfo(
- tokenEncryptionUtil.encrypt(oauthTokenCommand.oauthToken()),
- oauthTokenCommand.expiresAt()
+ tokenEncryptionUtil.encrypt(oauthTokenCommand.oauthToken()),
+ oauthTokenCommand.expiresAt()
);
}
diff --git a/src/main/java/team7/inplace/oauthToken/application/command/OauthTokenCommand.java b/src/main/java/team7/inplace/oauthToken/application/command/OauthTokenCommand.java
index c8b53f54..5b1aa3e9 100644
--- a/src/main/java/team7/inplace/oauthToken/application/command/OauthTokenCommand.java
+++ b/src/main/java/team7/inplace/oauthToken/application/command/OauthTokenCommand.java
@@ -3,9 +3,9 @@
import java.time.Instant;
public record OauthTokenCommand(
- String oauthToken,
- Instant expiresAt,
- Long userId
+ String oauthToken,
+ Instant expiresAt,
+ Long userId
) {
public static OauthTokenCommand of(String oauthToken, Instant expiresAt, Long userId) {
diff --git a/src/main/java/team7/inplace/oauthToken/domain/OauthToken.java b/src/main/java/team7/inplace/oauthToken/domain/OauthToken.java
index cc9c77a5..8e4eadfb 100644
--- a/src/main/java/team7/inplace/oauthToken/domain/OauthToken.java
+++ b/src/main/java/team7/inplace/oauthToken/domain/OauthToken.java
@@ -1,20 +1,15 @@
package team7.inplace.oauthToken.domain;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.OneToOne;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import team7.inplace.user.domain.User;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
diff --git a/src/main/java/team7/inplace/oauthToken/persistence/OauthTokenRepository.java b/src/main/java/team7/inplace/oauthToken/persistence/OauthTokenRepository.java
index 4bb2c499..bf09ccd5 100644
--- a/src/main/java/team7/inplace/oauthToken/persistence/OauthTokenRepository.java
+++ b/src/main/java/team7/inplace/oauthToken/persistence/OauthTokenRepository.java
@@ -1,10 +1,11 @@
package team7.inplace.oauthToken.persistence;
-import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import team7.inplace.oauthToken.domain.OauthToken;
+import java.util.Optional;
+
@Repository
public interface OauthTokenRepository extends JpaRepository {
diff --git a/src/main/java/team7/inplace/place/application/CategoryService.java b/src/main/java/team7/inplace/place/application/CategoryService.java
index e3103751..f8ad2ff6 100644
--- a/src/main/java/team7/inplace/place/application/CategoryService.java
+++ b/src/main/java/team7/inplace/place/application/CategoryService.java
@@ -1,13 +1,14 @@
package team7.inplace.place.application;
-import java.util.Arrays;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import team7.inplace.place.application.dto.CategoryInfo;
import team7.inplace.place.domain.Category;
import team7.inplace.place.persistence.PlaceRepository;
+import java.util.Arrays;
+import java.util.List;
+
@Service
@RequiredArgsConstructor
public class CategoryService {
@@ -16,6 +17,6 @@ public class CategoryService {
public List getCategories() {
return Arrays.stream(Category.values()).map(category -> new CategoryInfo(category.name()))
- .toList();
+ .toList();
}
}
diff --git a/src/main/java/team7/inplace/place/application/PlaceService.java b/src/main/java/team7/inplace/place/application/PlaceService.java
index 9c464ff8..c8b061ab 100644
--- a/src/main/java/team7/inplace/place/application/PlaceService.java
+++ b/src/main/java/team7/inplace/place/application/PlaceService.java
@@ -28,6 +28,7 @@
import team7.inplace.place.domain.Place;
import team7.inplace.place.persistence.PlaceRepository;
import team7.inplace.placeMessage.application.command.PlaceMessageCommand;
+import team7.inplace.review.persistence.ReviewRepository;
import team7.inplace.security.util.AuthorizationUtil;
import team7.inplace.user.domain.User;
import team7.inplace.user.persistence.UserRepository;
@@ -46,6 +47,8 @@ public class PlaceService {
private final LikedPlaceRepository likedPlaceRepository;
+ private final ReviewRepository reviewRepository;
+
public Page getPlacesWithinRadius(
PlacesCoordinateCommand placesCoordinateCommand,
PlacesFilterParamsCommand placesFilterParamsCommand) {
@@ -133,7 +136,11 @@ public PlaceDetailInfo getPlaceDetailInfo(Long placeId) {
video = videos.get(0);
}
Influencer influencer = (video != null) ? video.getInfluencer() : null;
- return PlaceDetailInfo.from(place, influencer, video, isLikedPlace(place.getId()));
+
+ Integer numOfLikes = reviewRepository.countByPlaceIdAndIsLikedTrue(placeId);
+ Integer numOfDislikes = reviewRepository.countByPlaceIdAndIsLikedFalse(placeId);
+ return PlaceDetailInfo.from(place, influencer, video, isLikedPlace(place.getId()),
+ numOfLikes, numOfDislikes);
}
public List createPlaces(List placeCommands) {
@@ -218,10 +225,10 @@ public PlaceMessageCommand getPlaceMessageCommand(Long placeId) {
}
public Page getLikedPlaceInfo(Long userId, Pageable pageable) {
- Page placePage = likedPlaceRepository.findByUserIdAndIsLikedTrue(userId,
- pageable);
+ Page placePage = likedPlaceRepository.findByUserIdAndIsLikedTrueWithPlace(
+ userId, pageable);
List placeIds = placePage.map(likedPlace -> likedPlace.getPlace().getId()).toList();
- List videos = videoRepository.findByPlaceIdIn(placeIds);
+ List videos = videoRepository.findByPlaceIdInWithInfluencer(placeIds);
Map placeIdToInfluencerName = getMapPlaceIdToInfluencerName(videos);
List likedPlaceInfos = placePage.getContent().stream()
diff --git a/src/main/java/team7/inplace/place/application/command/PlaceLikeCommand.java b/src/main/java/team7/inplace/place/application/command/PlaceLikeCommand.java
index 18e59c31..4433405b 100644
--- a/src/main/java/team7/inplace/place/application/command/PlaceLikeCommand.java
+++ b/src/main/java/team7/inplace/place/application/command/PlaceLikeCommand.java
@@ -1,8 +1,8 @@
package team7.inplace.place.application.command;
public record PlaceLikeCommand(
- Long placeId,
- Boolean likes
+ Long placeId,
+ Boolean likes
) {
}
diff --git a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java
index d441274d..c2dfaa02 100644
--- a/src/main/java/team7/inplace/place/application/command/PlacesCommand.java
+++ b/src/main/java/team7/inplace/place/application/command/PlacesCommand.java
@@ -2,13 +2,14 @@
import com.fasterxml.jackson.databind.JsonNode;
import io.micrometer.common.util.StringUtils;
+import org.springframework.data.domain.Pageable;
+import team7.inplace.place.domain.Place;
+import team7.inplace.video.presentation.dto.VideoSearchParams;
+
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
-import org.springframework.data.domain.Pageable;
-import team7.inplace.place.domain.Place;
-import team7.inplace.video.presentation.dto.VideoSearchParams;
public class PlacesCommand {
diff --git a/src/main/java/team7/inplace/place/application/dto/LikedPlaceInfo.java b/src/main/java/team7/inplace/place/application/dto/LikedPlaceInfo.java
index 2e31566f..59e5da13 100644
--- a/src/main/java/team7/inplace/place/application/dto/LikedPlaceInfo.java
+++ b/src/main/java/team7/inplace/place/application/dto/LikedPlaceInfo.java
@@ -4,20 +4,20 @@
import team7.inplace.likedPlace.domain.LikedPlace;
public record LikedPlaceInfo(
- Long placeId,
- String placeName,
- String imageUrl,
- String influencerName,
- boolean likes
+ Long placeId,
+ String placeName,
+ String imageUrl,
+ String influencerName,
+ boolean likes
) {
public static LikedPlaceInfo of(LikedPlace likedPlace, String influencerName) {
return new LikedPlaceInfo(
- likedPlace.getPlace().getId(),
- likedPlace.getPlace().getName(),
- likedPlace.getPlace().getMenuImgUrl(),
- influencerName,
- likedPlace.isLiked()
+ likedPlace.getPlace().getId(),
+ likedPlace.getPlace().getName(),
+ likedPlace.getPlace().getMenuImgUrl(),
+ influencerName,
+ likedPlace.isLiked()
);
}
}
diff --git a/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java b/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java
index c577b9c3..f4b75e44 100644
--- a/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java
+++ b/src/main/java/team7/inplace/place/application/dto/PlaceDetailInfo.java
@@ -23,7 +23,7 @@ public record PlaceDetailInfo(
) {
public static PlaceDetailInfo from(Place place, Influencer influencer, Video video,
- boolean isLiked) {
+ boolean isLiked, int numOfLikes, int numOfDislikes) {
String influencerName = (influencer != null) ? influencer.getName() : "";
String videoUrl = (video != null) ? video.getVideoUrl() : "";
@@ -35,7 +35,7 @@ public static PlaceDetailInfo from(Place place, Influencer influencer, Video vid
place.getMenus(),
place.getMenuUpdatedAt()),
OpenHour.of(place.getOpenPeriods(), place.getOffDays()),
- PlaceLikes.of(isLiked),
+ PlaceLikes.of(numOfLikes, numOfDislikes),
videoUrl
);
}
@@ -129,14 +129,8 @@ public record PlaceLikes(
Integer dislike
) {
- public static PlaceLikes of(Boolean likes) {
- if (likes == null) {
- return new PlaceLikes(0, 0);
- }
- if (likes) {
- return new PlaceLikes(1, 0);
- }
- return new PlaceLikes(0, 1);
+ public static PlaceLikes of(Integer numOfLikes, Integer numOfDislikes) {
+ return new PlaceLikes(numOfLikes, numOfDislikes);
}
}
}
diff --git a/src/main/java/team7/inplace/place/application/dto/PlaceInfo.java b/src/main/java/team7/inplace/place/application/dto/PlaceInfo.java
index 6ad51b18..c3814fd2 100644
--- a/src/main/java/team7/inplace/place/application/dto/PlaceInfo.java
+++ b/src/main/java/team7/inplace/place/application/dto/PlaceInfo.java
@@ -5,45 +5,45 @@
import team7.inplace.place.domain.Place;
public record PlaceInfo(
- Long placeId,
- String placeName,
- AddressInfo address,
- String category,
- String influencerName,
- String menuImgUrl,
- String longitude,
- String latitude,
- Boolean likes
+ Long placeId,
+ String placeName,
+ AddressInfo address,
+ String category,
+ String influencerName,
+ String menuImgUrl,
+ String longitude,
+ String latitude,
+ Boolean likes
) {
// influencer, likes 추가 예정
public record AddressInfo(
- String address1,
- String address2,
- String address3
+ String address1,
+ String address2,
+ String address3
) {
public static AddressInfo of(Address address) {
return new PlaceInfo.AddressInfo(
- address.getAddress1(),
- address.getAddress2(),
- address.getAddress3()
+ address.getAddress1(),
+ address.getAddress2(),
+ address.getAddress3()
);
}
}
public static PlaceInfo of(Place place, String influencerName, boolean likes) {
return new PlaceInfo(
- place.getId(),
- place.getName(),
- AddressInfo.of(place.getAddress()),
- place.getCategory().toString(),
- influencerName,
- place.getMenuImgUrl(),
- place.getCoordinate().getLongitude(),
- place.getCoordinate().getLatitude(),
- likes
+ place.getId(),
+ place.getName(),
+ AddressInfo.of(place.getAddress()),
+ place.getCategory().toString(),
+ influencerName,
+ place.getMenuImgUrl(),
+ place.getCoordinate().getLongitude(),
+ place.getCoordinate().getLatitude(),
+ likes
);
}
}
diff --git a/src/main/java/team7/inplace/place/domain/Address.java b/src/main/java/team7/inplace/place/domain/Address.java
index 3ba26140..acd58a50 100644
--- a/src/main/java/team7/inplace/place/domain/Address.java
+++ b/src/main/java/team7/inplace/place/domain/Address.java
@@ -1,14 +1,15 @@
package team7.inplace.place.domain;
-import static lombok.AccessLevel.PROTECTED;
-
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
-import java.util.Arrays;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
+import java.util.Arrays;
+
+import static lombok.AccessLevel.PROTECTED;
+
@Getter
@Embeddable
@NoArgsConstructor(access = PROTECTED)
diff --git a/src/main/java/team7/inplace/place/domain/Coordinate.java b/src/main/java/team7/inplace/place/domain/Coordinate.java
index 6fd50b6b..cab8df2d 100644
--- a/src/main/java/team7/inplace/place/domain/Coordinate.java
+++ b/src/main/java/team7/inplace/place/domain/Coordinate.java
@@ -1,13 +1,13 @@
package team7.inplace.place.domain;
-import static lombok.AccessLevel.PROTECTED;
-
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
+import static lombok.AccessLevel.PROTECTED;
+
@Embeddable
@NoArgsConstructor(access = PROTECTED)
@EqualsAndHashCode
diff --git a/src/main/java/team7/inplace/place/domain/Place.java b/src/main/java/team7/inplace/place/domain/Place.java
index fa00ab2a..ecb77e8c 100644
--- a/src/main/java/team7/inplace/place/domain/Place.java
+++ b/src/main/java/team7/inplace/place/domain/Place.java
@@ -1,20 +1,13 @@
package team7.inplace.place.domain;
-import jakarta.persistence.Column;
-import jakarta.persistence.ElementCollection;
-import jakarta.persistence.Embedded;
-import jakarta.persistence.Entity;
-import jakarta.persistence.EnumType;
-import jakarta.persistence.Enumerated;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
-import java.time.LocalDateTime;
-import java.util.List;
+import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
+import java.time.LocalDateTime;
+import java.util.List;
+
@Getter
@Entity(name = "places")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
diff --git a/src/main/java/team7/inplace/place/persistence/PlaceCustomRepository.java b/src/main/java/team7/inplace/place/persistence/PlaceCustomRepository.java
index ad6a2bb6..e0ed4c0e 100644
--- a/src/main/java/team7/inplace/place/persistence/PlaceCustomRepository.java
+++ b/src/main/java/team7/inplace/place/persistence/PlaceCustomRepository.java
@@ -1,27 +1,28 @@
package team7.inplace.place.persistence;
-import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import team7.inplace.place.domain.Place;
+import java.util.List;
+
public interface PlaceCustomRepository {
Page findPlacesByDistance(
- @Param("longitude") String longitude,
- @Param("latitude") String latitude,
- Pageable pageable);
+ @Param("longitude") String longitude,
+ @Param("latitude") String latitude,
+ Pageable pageable);
Page findPlacesByDistanceAndFilters(
- @Param("topLeftLongitude") String topLeftLongitude,
- @Param("topLeftLatitude") String topLeftLatitude,
- @Param("bottomRightLongitude") String bottomRightLongitude,
- @Param("bottomRightLatitude") String bottomRightLatitude,
- @Param("longitude") String longitude,
- @Param("latitude") String latitude,
- @Param("categories") List categories,
- @Param("influencers") List influencers,
- Pageable pageable);
+ @Param("topLeftLongitude") String topLeftLongitude,
+ @Param("topLeftLatitude") String topLeftLatitude,
+ @Param("bottomRightLongitude") String bottomRightLongitude,
+ @Param("bottomRightLatitude") String bottomRightLatitude,
+ @Param("longitude") String longitude,
+ @Param("latitude") String latitude,
+ @Param("categories") List categories,
+ @Param("influencers") List influencers,
+ Pageable pageable);
}
diff --git a/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java b/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java
index 6d6688aa..5278d07d 100644
--- a/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java
+++ b/src/main/java/team7/inplace/place/persistence/PlaceCustomRepositoryImpl.java
@@ -5,11 +5,8 @@
import com.querydsl.core.types.dsl.NumberTemplate;
import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory;
-import java.util.List;
-import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.support.PageableExecutionUtils;
import org.springframework.stereotype.Repository;
@@ -19,6 +16,9 @@
import team7.inplace.place.domain.QPlace;
import team7.inplace.video.domain.QVideo;
+import java.util.List;
+import java.util.stream.Collectors;
+
@Repository
@AllArgsConstructor
public class PlaceCustomRepositoryImpl implements PlaceCustomRepository {
@@ -30,85 +30,88 @@ public Page findPlacesByDistance(String longitude, String latitude, Pagea
QPlace place = QPlace.place;
NumberTemplate distanceExpression = Expressions.numberTemplate(Double.class,
- "6371 * acos(cos(radians({0})) * cos(radians(CAST({1} AS DOUBLE))) * cos(radians(CAST({2} AS DOUBLE)) - radians({3})) + sin(radians({0})) * sin(radians(CAST({1} AS DOUBLE))))",
- Double.parseDouble(latitude), place.coordinate.latitude, place.coordinate.longitude,
- Double.parseDouble(longitude));
+ "6371 * acos(cos(radians({0})) * cos(radians(CAST({1} AS DOUBLE))) * cos(radians(CAST({2} AS DOUBLE)) - radians({3})) + sin(radians({0})) * sin(radians(CAST({1} AS DOUBLE))))",
+ Double.parseDouble(latitude), place.coordinate.latitude, place.coordinate.longitude,
+ Double.parseDouble(longitude));
List places = jpaQueryFactory.selectFrom(place)
- .orderBy(distanceExpression.asc())
- .offset(pageable.getOffset())
- .limit(pageable.getPageSize())
- .fetch();
+ .orderBy(distanceExpression.asc())
+ .offset(pageable.getOffset())
+ .limit(pageable.getPageSize())
+ .fetch();
+
+ JPAQuery countQuery = jpaQueryFactory.select(place.id.count()) // 중복 제거
+ .from(place);
- return new PageImpl<>(places, pageable, places.size());
+ return PageableExecutionUtils.getPage(places, pageable, countQuery::fetchOne);
}
@Override
public Page findPlacesByDistanceAndFilters(String topLeftLongitude,
- String topLeftLatitude, String bottomRightLongitude, String bottomRightLatitude,
- String longitude, String latitude, List categories, List influencers,
- Pageable pageable) {
+ String topLeftLatitude, String bottomRightLongitude, String bottomRightLatitude,
+ String longitude, String latitude, List categories, List influencers,
+ Pageable pageable) {
QPlace place = QPlace.place;
QVideo video = QVideo.video;
QInfluencer influencer = QInfluencer.influencer;
NumberTemplate distanceExpression = Expressions.numberTemplate(Double.class,
- "6371 * acos(cos(radians({0})) * cos(radians(CAST({1} AS DOUBLE))) * cos(radians(CAST({2} AS DOUBLE)) - radians({3})) + sin(radians({0})) * sin(radians(CAST({1} AS DOUBLE))))",
- Double.parseDouble(latitude), place.coordinate.latitude, place.coordinate.longitude,
- Double.parseDouble(longitude));
+ "6371 * acos(cos(radians({0})) * cos(radians(CAST({1} AS DOUBLE))) * cos(radians(CAST({2} AS DOUBLE)) - radians({3})) + sin(radians({0})) * sin(radians(CAST({1} AS DOUBLE))))",
+ Double.parseDouble(latitude), place.coordinate.latitude, place.coordinate.longitude,
+ Double.parseDouble(longitude));
// 1. content를 가져오는 fetch() 쿼리
List content = jpaQueryFactory.selectFrom(place)
- .leftJoin(video).on(video.place.eq(place))
- .leftJoin(influencer).on(video.influencer.eq(influencer))
- .where(
- withinBoundary(
- place,
- Double.parseDouble(topLeftLongitude),
- Double.parseDouble(topLeftLatitude),
- Double.parseDouble(bottomRightLongitude),
- Double.parseDouble(bottomRightLatitude)
- ),
- placeCategoryIn(categories),
- placeInfluencerIn(influencers)
- )
- .orderBy(distanceExpression.asc())
- .offset(pageable.getOffset())
- .limit(pageable.getPageSize())
- .fetch();
+ .leftJoin(video).on(video.place.eq(place))
+ .leftJoin(influencer).on(video.influencer.eq(influencer))
+ .where(
+ withinBoundary(
+ place,
+ Double.parseDouble(topLeftLongitude),
+ Double.parseDouble(topLeftLatitude),
+ Double.parseDouble(bottomRightLongitude),
+ Double.parseDouble(bottomRightLatitude)
+ ),
+ placeCategoryIn(categories),
+ placeInfluencerIn(influencers)
+ )
+ .orderBy(distanceExpression.asc())
+ .offset(pageable.getOffset())
+ .limit(pageable.getPageSize())
+ .fetch();
// 2. countQuery를 따로 선언하여 필요할 때만 실행
JPAQuery countQuery = jpaQueryFactory.select(place.id.count()) // 중복 제거
- .from(place)
- .leftJoin(video).on(video.place.eq(place))
- .leftJoin(influencer).on(video.influencer.eq(influencer))
- .where(
- withinBoundary(
- place,
- Double.parseDouble(topLeftLongitude),
- Double.parseDouble(topLeftLatitude),
- Double.parseDouble(bottomRightLongitude),
- Double.parseDouble(bottomRightLatitude)
- ),
- placeCategoryIn(categories),
- placeInfluencerIn(influencers)
- );
+ .from(place)
+ .leftJoin(video).on(video.place.eq(place))
+ .leftJoin(influencer).on(video.influencer.eq(influencer))
+ .where(
+ withinBoundary(
+ place,
+ Double.parseDouble(topLeftLongitude),
+ Double.parseDouble(topLeftLatitude),
+ Double.parseDouble(bottomRightLongitude),
+ Double.parseDouble(bottomRightLatitude)
+ ),
+ placeCategoryIn(categories),
+ placeInfluencerIn(influencers)
+ );
// 3. PageableExecutionUtils를 사용하여 필요할 때 countQuery 실행
return PageableExecutionUtils.getPage(content, pageable, countQuery::fetchOne);
}
private BooleanExpression withinBoundary(QPlace place, double topLeftLongitude,
- double topLeftLatitude,
- double bottomRightLongitude, double bottomRightLatitude) {
+ double topLeftLatitude,
+ double bottomRightLongitude, double bottomRightLatitude) {
NumberTemplate longitude = Expressions.numberTemplate(Double.class,
- "CAST({0} AS DOUBLE)", place.coordinate.longitude);
+ "CAST({0} AS DOUBLE)", place.coordinate.longitude);
NumberTemplate latitude = Expressions.numberTemplate(Double.class,
- "CAST({0} AS DOUBLE)", place.coordinate.latitude);
+ "CAST({0} AS DOUBLE)", place.coordinate.latitude);
return longitude.between(topLeftLongitude, bottomRightLongitude)
- .and(latitude.between(bottomRightLatitude, topLeftLatitude));
+ .and(latitude.between(bottomRightLatitude, topLeftLatitude));
}
private BooleanExpression placeCategoryIn(List categories) {
@@ -117,8 +120,8 @@ private BooleanExpression placeCategoryIn(List categories) {
}
List enumCategories = categories.stream()
- .map(Category::of) // Category.of() 메서드로 직접 매핑
- .collect(Collectors.toList());
+ .map(Category::of) // Category.of() 메서드로 직접 매핑
+ .collect(Collectors.toList());
return QPlace.place.category.in(enumCategories);
}
diff --git a/src/main/java/team7/inplace/place/presentation/PlaceController.java b/src/main/java/team7/inplace/place/presentation/PlaceController.java
index 3d6464ff..12d909d6 100644
--- a/src/main/java/team7/inplace/place/presentation/PlaceController.java
+++ b/src/main/java/team7/inplace/place/presentation/PlaceController.java
@@ -1,19 +1,12 @@
package team7.inplace.place.presentation;
-import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import team7.inplace.place.application.CategoryService;
import team7.inplace.place.application.PlaceService;
import team7.inplace.place.application.command.PlaceLikeCommand;
@@ -21,15 +14,12 @@
import team7.inplace.place.application.command.PlacesCommand.PlacesFilterParamsCommand;
import team7.inplace.place.application.dto.CategoryInfo;
import team7.inplace.place.application.dto.PlaceInfo;
-import team7.inplace.place.presentation.dto.CategoriesResponse;
-import team7.inplace.place.presentation.dto.PlaceDetailResponse;
-import team7.inplace.place.presentation.dto.PlaceLikeRequest;
-import team7.inplace.place.presentation.dto.PlacesResponse;
-import team7.inplace.place.presentation.dto.ReviewRequest;
-import team7.inplace.place.presentation.dto.ReviewResponse;
+import team7.inplace.place.presentation.dto.*;
import team7.inplace.review.application.ReviewService;
import team7.inplace.review.application.dto.ReviewCommand;
+import java.util.List;
+
@RestController
@RequiredArgsConstructor
@RequestMapping("/places")
@@ -41,31 +31,31 @@ public class PlaceController implements PlaceControllerApiSpec {
@GetMapping
public ResponseEntity getPlaces(
- @RequestParam String longitude,
- @RequestParam String latitude,
- @RequestParam String topLeftLongitude,
- @RequestParam String topLeftLatitude,
- @RequestParam String bottomRightLongitude,
- @RequestParam String bottomRightLatitude,
- @RequestParam(required = false) String categories,
- @RequestParam(required = false) String influencers,
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @RequestParam String longitude,
+ @RequestParam String latitude,
+ @RequestParam String topLeftLongitude,
+ @RequestParam String topLeftLatitude,
+ @RequestParam String bottomRightLongitude,
+ @RequestParam String bottomRightLatitude,
+ @RequestParam(required = false) String categories,
+ @RequestParam(required = false) String influencers,
+ @PageableDefault(page = 0, size = 10) Pageable pageable
) {
// 위치기반 조회
Page placeInfos = placeService.getPlacesWithinRadius(
- new PlacesCoordinateCommand(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- pageable
- ),
- new PlacesFilterParamsCommand(
- categories,
- influencers
- )
+ new PlacesCoordinateCommand(
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ pageable
+ ),
+ new PlacesFilterParamsCommand(
+ categories,
+ influencers
+ )
);
return new ResponseEntity<>(PlacesResponse.of(placeInfos), HttpStatus.OK);
}
@@ -80,10 +70,10 @@ public ResponseEntity getCategories() {
@GetMapping("/{id}")
public ResponseEntity getPlaceDetail(
- @PathVariable("id") Long placeId
+ @PathVariable("id") Long placeId
) {
PlaceDetailResponse response = PlaceDetailResponse.from(
- placeService.getPlaceDetailInfo(placeId));
+ placeService.getPlaceDetailInfo(placeId));
return new ResponseEntity<>(response, HttpStatus.OK);
}
@@ -96,7 +86,7 @@ public ResponseEntity likeToPlace(@RequestBody PlaceLikeRequest param) {
@PostMapping("/{id}/reviews")
public ResponseEntity createReview(@PathVariable("id") Long placeId,
- @RequestBody ReviewRequest request) {
+ @RequestBody ReviewRequest request) {
ReviewCommand reviewCommand = request.toCommand();
reviewService.createReview(placeId, reviewCommand);
@@ -105,11 +95,11 @@ public ResponseEntity createReview(@PathVariable("id") Long placeId,
@GetMapping("/{id}/reviews")
public ResponseEntity> getReviews(
- @PathVariable("id") Long placeId,
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PathVariable("id") Long placeId,
+ @PageableDefault(page = 0, size = 10) Pageable pageable
) {
Page reviews = reviewService.getReviews(placeId, pageable)
- .map(ReviewResponse::from);
+ .map(ReviewResponse::from);
return new ResponseEntity<>(reviews, HttpStatus.OK);
}
}
diff --git a/src/main/java/team7/inplace/place/presentation/PlaceControllerApiSpec.java b/src/main/java/team7/inplace/place/presentation/PlaceControllerApiSpec.java
index bb9daba4..35fbbff3 100644
--- a/src/main/java/team7/inplace/place/presentation/PlaceControllerApiSpec.java
+++ b/src/main/java/team7/inplace/place/presentation/PlaceControllerApiSpec.java
@@ -8,50 +8,45 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
-import team7.inplace.place.presentation.dto.CategoriesResponse;
-import team7.inplace.place.presentation.dto.PlaceDetailResponse;
-import team7.inplace.place.presentation.dto.PlaceLikeRequest;
-import team7.inplace.place.presentation.dto.PlacesResponse;
-import team7.inplace.place.presentation.dto.ReviewRequest;
-import team7.inplace.place.presentation.dto.ReviewResponse;
+import team7.inplace.place.presentation.dto.*;
public interface PlaceControllerApiSpec {
@Operation(summary = "장소 조회", description = "위치 기반으로 반경 내의 장소 목록을 조회합니다.")
- public ResponseEntity getPlaces(
- @RequestParam String longitude,
- @RequestParam String latitude,
- @RequestParam String topLeftLongitude,
- @RequestParam String topLeftLatitude,
- @RequestParam String bottomRightLongitude,
- @RequestParam String bottomRightLatitude,
- @RequestParam(required = false) String categories,
- @RequestParam(required = false) String influencers,
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ ResponseEntity getPlaces(
+ @RequestParam String longitude,
+ @RequestParam String latitude,
+ @RequestParam String topLeftLongitude,
+ @RequestParam String topLeftLatitude,
+ @RequestParam String bottomRightLongitude,
+ @RequestParam String bottomRightLatitude,
+ @RequestParam(required = false) String categories,
+ @RequestParam(required = false) String influencers,
+ @PageableDefault(page = 0, size = 10) Pageable pageable
);
@Operation(summary = "카테고리 조회", description = "장소의 카테고리 목록을 조회합니다.")
- public ResponseEntity getCategories();
+ ResponseEntity getCategories();
@Operation(summary = "장소 상세 조회", description = "장소 ID를 통해 특정 장소의 상세 정보를 조회합니다.")
- public ResponseEntity getPlaceDetail(
- @PathVariable("id") Long placeId
+ ResponseEntity getPlaceDetail(
+ @PathVariable("id") Long placeId
);
@Operation(summary = "장소에 좋아요 누르기", description = "userId와 placeId를 연동하여 장소에 좋아요를 표시합니다.")
- public ResponseEntity likeToPlace(
- @RequestBody PlaceLikeRequest param
+ ResponseEntity likeToPlace(
+ @RequestBody PlaceLikeRequest param
);
@Operation(summary = "특정 장소 리뷰 추가", description = "특정 장소에 리뷰를 추가합니다. 사용자 별로 한 장소에 하나의 리뷰만 가능합니다.")
- public ResponseEntity createReview(
- @PathVariable("id") Long placeId,
- @RequestBody ReviewRequest request
+ ResponseEntity createReview(
+ @PathVariable("id") Long placeId,
+ @RequestBody ReviewRequest request
);
@Operation(summary = "특정 장소 리뷰 조회", description = "페이지네이션이 적용된 특정 장소 리뷰를 조회합니다.")
- public ResponseEntity> getReviews(
- @PathVariable("id") Long placeId,
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ ResponseEntity> getReviews(
+ @PathVariable("id") Long placeId,
+ @PageableDefault(page = 0, size = 10) Pageable pageable
);
}
diff --git a/src/main/java/team7/inplace/place/presentation/dto/CategoriesResponse.java b/src/main/java/team7/inplace/place/presentation/dto/CategoriesResponse.java
index 4fbee8db..539f6871 100644
--- a/src/main/java/team7/inplace/place/presentation/dto/CategoriesResponse.java
+++ b/src/main/java/team7/inplace/place/presentation/dto/CategoriesResponse.java
@@ -1,8 +1,9 @@
package team7.inplace.place.presentation.dto;
-import java.util.List;
import team7.inplace.place.application.dto.CategoryInfo;
+import java.util.List;
+
public record CategoriesResponse(List categories) {
}
diff --git a/src/main/java/team7/inplace/place/presentation/dto/PlaceDetailResponse.java b/src/main/java/team7/inplace/place/presentation/dto/PlaceDetailResponse.java
index 655bfe4d..53400bbd 100644
--- a/src/main/java/team7/inplace/place/presentation/dto/PlaceDetailResponse.java
+++ b/src/main/java/team7/inplace/place/presentation/dto/PlaceDetailResponse.java
@@ -8,36 +8,36 @@
import team7.inplace.place.application.dto.PlaceInfo.AddressInfo;
public record PlaceDetailResponse(
- Long placeId,
- String placeName,
- AddressInfo address,
- String category,
- String influencerName,
- String longitude,
- String latitude,
- Boolean likes,
- JsonNode facilityInfo,
- MenuInfos menuInfos,
- OpenHour openHour,
- PlaceLikes placeLikes,
- String videoUrl
+ Long placeId,
+ String placeName,
+ AddressInfo address,
+ String category,
+ String influencerName,
+ String longitude,
+ String latitude,
+ Boolean likes,
+ JsonNode facilityInfo,
+ MenuInfos menuInfos,
+ OpenHour openHour,
+ PlaceLikes placeLikes,
+ String videoUrl
) {
public static PlaceDetailResponse from(PlaceDetailInfo info) {
return new PlaceDetailResponse(
- info.placeInfo().placeId(),
- info.placeInfo().placeName(),
- info.placeInfo().address(),
- info.placeInfo().category(),
- info.placeInfo().influencerName(),
- info.placeInfo().longitude(),
- info.placeInfo().latitude(),
- info.placeInfo().likes(),
- info.facilityInfo(),
- info.menuInfos(),
- info.openHour(),
- info.placeLikes(),
- info.videoUrl()
+ info.placeInfo().placeId(),
+ info.placeInfo().placeName(),
+ info.placeInfo().address(),
+ info.placeInfo().category(),
+ info.placeInfo().influencerName(),
+ info.placeInfo().longitude(),
+ info.placeInfo().latitude(),
+ info.placeInfo().likes(),
+ info.facilityInfo(),
+ info.menuInfos(),
+ info.openHour(),
+ info.placeLikes(),
+ info.videoUrl()
);
}
}
diff --git a/src/main/java/team7/inplace/place/presentation/dto/PlaceLikeRequest.java b/src/main/java/team7/inplace/place/presentation/dto/PlaceLikeRequest.java
index 1819c76a..b008e522 100644
--- a/src/main/java/team7/inplace/place/presentation/dto/PlaceLikeRequest.java
+++ b/src/main/java/team7/inplace/place/presentation/dto/PlaceLikeRequest.java
@@ -1,8 +1,8 @@
package team7.inplace.place.presentation.dto;
public record PlaceLikeRequest(
- Long placeId,
- Boolean likes
+ Long placeId,
+ Boolean likes
) {
}
diff --git a/src/main/java/team7/inplace/place/presentation/dto/ReviewRequest.java b/src/main/java/team7/inplace/place/presentation/dto/ReviewRequest.java
index c84cfc74..4688a60f 100644
--- a/src/main/java/team7/inplace/place/presentation/dto/ReviewRequest.java
+++ b/src/main/java/team7/inplace/place/presentation/dto/ReviewRequest.java
@@ -3,8 +3,8 @@
import team7.inplace.review.application.dto.ReviewCommand;
public record ReviewRequest(
- boolean likes,
- String comments
+ boolean likes,
+ String comments
) {
public ReviewCommand toCommand() {
diff --git a/src/main/java/team7/inplace/place/presentation/dto/ReviewResponse.java b/src/main/java/team7/inplace/place/presentation/dto/ReviewResponse.java
index 28759c4d..c1191dbd 100644
--- a/src/main/java/team7/inplace/place/presentation/dto/ReviewResponse.java
+++ b/src/main/java/team7/inplace/place/presentation/dto/ReviewResponse.java
@@ -1,25 +1,26 @@
package team7.inplace.place.presentation.dto;
-import java.util.Date;
import team7.inplace.review.application.dto.ReviewInfo;
+import java.util.Date;
+
public record ReviewResponse(
- Long reviewId,
- boolean likes,
- String comment,
- String userNickname,
- Date createdDate,
- boolean mine
+ Long reviewId,
+ boolean likes,
+ String comment,
+ String userNickname,
+ Date createdDate,
+ boolean mine
) {
public static ReviewResponse from(ReviewInfo reviewInfo) {
return new ReviewResponse(
- reviewInfo.reviewId(),
- reviewInfo.likes(),
- reviewInfo.comment(),
- reviewInfo.userNickname(),
- reviewInfo.createdDate(),
- reviewInfo.mine()
+ reviewInfo.reviewId(),
+ reviewInfo.likes(),
+ reviewInfo.comment(),
+ reviewInfo.userNickname(),
+ reviewInfo.createdDate(),
+ reviewInfo.mine()
);
}
}
diff --git a/src/main/java/team7/inplace/placeMessage/application/KakaoMessageService.java b/src/main/java/team7/inplace/placeMessage/application/KakaoMessageService.java
index f89796bb..e92b26be 100644
--- a/src/main/java/team7/inplace/placeMessage/application/KakaoMessageService.java
+++ b/src/main/java/team7/inplace/placeMessage/application/KakaoMessageService.java
@@ -1,6 +1,5 @@
package team7.inplace.placeMessage.application;
-import java.net.URI;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
@@ -10,6 +9,8 @@
import team7.inplace.placeMessage.application.command.PlaceMessageCommand;
import team7.inplace.placeMessage.util.KakaoMessageMaker;
+import java.net.URI;
+
@Service
@RequiredArgsConstructor
public class KakaoMessageService {
@@ -19,28 +20,28 @@ public class KakaoMessageService {
private final WebClient webClient;
public void sendLocationMessageToMe(String oauthToken,
- PlaceMessageCommand placeMessageCommand) {
+ PlaceMessageCommand placeMessageCommand) {
webClient.post()
- .uri(URI.create(kakaoApiProperties.sendMessageToMeUrl()))
- .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE)
- .header("Authorization", "Bearer " + oauthToken)
- .body(BodyInserters.fromFormData(
- kakaoMessageMaker.createLocationTemplate(placeMessageCommand)))
- .retrieve()
- .bodyToMono(String.class)
- .subscribe();
+ .uri(URI.create(kakaoApiProperties.sendMessageToMeUrl()))
+ .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+ .header("Authorization", "Bearer " + oauthToken)
+ .body(BodyInserters.fromFormData(
+ kakaoMessageMaker.createLocationTemplate(placeMessageCommand)))
+ .retrieve()
+ .bodyToMono(String.class)
+ .subscribe();
}
public void sendFeedMessageToMe(String oauthToken,
- PlaceMessageCommand placeMessageCommand) {
+ PlaceMessageCommand placeMessageCommand) {
webClient.post()
- .uri(URI.create(kakaoApiProperties.sendMessageToMeUrl()))
- .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE)
- .header("Authorization", "Bearer " + oauthToken)
- .body(BodyInserters.fromFormData(
- kakaoMessageMaker.createFeedTemplate(placeMessageCommand)))
- .retrieve()
- .bodyToMono(String.class)
- .subscribe();
+ .uri(URI.create(kakaoApiProperties.sendMessageToMeUrl()))
+ .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+ .header("Authorization", "Bearer " + oauthToken)
+ .body(BodyInserters.fromFormData(
+ kakaoMessageMaker.createFeedTemplate(placeMessageCommand)))
+ .retrieve()
+ .bodyToMono(String.class)
+ .subscribe();
}
}
diff --git a/src/main/java/team7/inplace/placeMessage/application/PlaceMessageFacade.java b/src/main/java/team7/inplace/placeMessage/application/PlaceMessageFacade.java
index 8cb03902..2d02ca3f 100644
--- a/src/main/java/team7/inplace/placeMessage/application/PlaceMessageFacade.java
+++ b/src/main/java/team7/inplace/placeMessage/application/PlaceMessageFacade.java
@@ -29,7 +29,7 @@ public void sendPlaceMessage(Long placeId) throws InplaceException {
PlaceMessageCommand placeMessageCommand = placeService.getPlaceMessageCommand(placeId);
kakaoMessageService.sendLocationMessageToMe(oauthToken, placeMessageCommand);
scheduledExecutorService.schedule(
- () -> kakaoMessageService.sendFeedMessageToMe(oauthToken, placeMessageCommand), 3,
- TimeUnit.DAYS);
+ () -> kakaoMessageService.sendFeedMessageToMe(oauthToken, placeMessageCommand), 1,
+ TimeUnit.MINUTES);
}
}
diff --git a/src/main/java/team7/inplace/placeMessage/application/command/PlaceMessageCommand.java b/src/main/java/team7/inplace/placeMessage/application/command/PlaceMessageCommand.java
index 455af336..0d934d0f 100644
--- a/src/main/java/team7/inplace/placeMessage/application/command/PlaceMessageCommand.java
+++ b/src/main/java/team7/inplace/placeMessage/application/command/PlaceMessageCommand.java
@@ -6,25 +6,25 @@
import team7.inplace.video.domain.Video;
public record PlaceMessageCommand(
- Long placeId,
- String title,
- String address,
- String imageUrl,
- String description
+ Long placeId,
+ String title,
+ String address,
+ String imageUrl,
+ String description
) {
public static PlaceMessageCommand of(Place place, Influencer influencer, Video video) {
String influencerName = influencer != null ? influencer.getName() : null;
String videoUUID = video != null ? video.getVideoUUID() : null;
return new PlaceMessageCommand(
- place.getId(),
- place.getName(),
- place.getAddress().toString(),
- String.format("https://img.youtube.com/vi/%s/maxresdefault.jpg", videoUUID),
- AliasUtil.makeAlias(
- influencerName,
- place.getCategory()
- )
+ place.getId(),
+ place.getName(),
+ place.getAddress().toString(),
+ String.format("https://img.youtube.com/vi/%s/maxresdefault.jpg", videoUUID),
+ AliasUtil.makeAlias(
+ influencerName,
+ place.getCategory()
+ )
);
}
}
diff --git a/src/main/java/team7/inplace/placeMessage/presentation/PlaceMessageControllerApiSpec.java b/src/main/java/team7/inplace/placeMessage/presentation/PlaceMessageControllerApiSpec.java
index 84a2de98..f813a842 100644
--- a/src/main/java/team7/inplace/placeMessage/presentation/PlaceMessageControllerApiSpec.java
+++ b/src/main/java/team7/inplace/placeMessage/presentation/PlaceMessageControllerApiSpec.java
@@ -7,8 +7,8 @@
public interface PlaceMessageControllerApiSpec {
@Operation(
- summary = "장소 정보 보내기",
- description = "장소 정보에 대한 메세지를 토큰을 사용하여 보냄."
+ summary = "장소 정보 보내기",
+ description = "장소 정보에 대한 메세지를 토큰을 사용하여 보냄."
)
ResponseEntity test(@PathVariable("place-id") Long placeId);
}
diff --git a/src/main/java/team7/inplace/placeMessage/util/Button.java b/src/main/java/team7/inplace/placeMessage/util/Button.java
index 78281760..61c2c634 100644
--- a/src/main/java/team7/inplace/placeMessage/util/Button.java
+++ b/src/main/java/team7/inplace/placeMessage/util/Button.java
@@ -1,8 +1,8 @@
package team7.inplace.placeMessage.util;
public record Button(
- String title,
- Link link
+ String title,
+ Link link
) {
public static Button of(String buttonName, Link link) {
diff --git a/src/main/java/team7/inplace/placeMessage/util/Content.java b/src/main/java/team7/inplace/placeMessage/util/Content.java
index f8697bfc..365f0e6d 100644
--- a/src/main/java/team7/inplace/placeMessage/util/Content.java
+++ b/src/main/java/team7/inplace/placeMessage/util/Content.java
@@ -6,25 +6,25 @@
import team7.inplace.placeMessage.application.command.PlaceMessageCommand;
public record Content(
- @NonNull String title,
- @NonNull @JsonProperty("image_url") String imageUrl,
- @Nullable @JsonProperty("image_width") Integer imageWidth,
- @Nullable @JsonProperty("image_height") Integer imageHeight,
- @NonNull String description,
- @NonNull Link link
+ @NonNull String title,
+ @NonNull @JsonProperty("image_url") String imageUrl,
+ @Nullable @JsonProperty("image_width") Integer imageWidth,
+ @Nullable @JsonProperty("image_height") Integer imageHeight,
+ @NonNull String description,
+ @NonNull Link link
) {
private static final Integer DEFAULT_IMAGE_WIDTH = 1280;
private static final Integer DEFAULT_IMAGE_HEIGHT = 720;
public static Content of(PlaceMessageCommand placeMessageCommand, String description,
- Link link) {
+ Link link) {
return new Content(
- placeMessageCommand.title(),
- placeMessageCommand.imageUrl(),
- DEFAULT_IMAGE_WIDTH,
- DEFAULT_IMAGE_HEIGHT,
- description,
- link);
+ placeMessageCommand.title(),
+ placeMessageCommand.imageUrl(),
+ DEFAULT_IMAGE_WIDTH,
+ DEFAULT_IMAGE_HEIGHT,
+ description,
+ link);
}
}
diff --git a/src/main/java/team7/inplace/placeMessage/util/FeedTemplate.java b/src/main/java/team7/inplace/placeMessage/util/FeedTemplate.java
index 7c369377..fae7181b 100644
--- a/src/main/java/team7/inplace/placeMessage/util/FeedTemplate.java
+++ b/src/main/java/team7/inplace/placeMessage/util/FeedTemplate.java
@@ -1,13 +1,14 @@
package team7.inplace.placeMessage.util;
import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.List;
import team7.inplace.placeMessage.application.command.PlaceMessageCommand;
+import java.util.List;
+
public record FeedTemplate(
- @JsonProperty("object_type") String objectType,
- Content content,
- @JsonProperty("buttons") List buttons
+ @JsonProperty("object_type") String objectType,
+ Content content,
+ @JsonProperty("buttons") List buttons
) {
private final static String BUTTON_NAME = "리뷰 남기기";
@@ -16,10 +17,10 @@ public record FeedTemplate(
public static FeedTemplate of(String frontEndUrl, PlaceMessageCommand placeMessageCommand) {
Link link = Link.of(frontEndUrl + "/places/" + placeMessageCommand.placeId() + "/reviews");
return new FeedTemplate(
- OBJECT_TYPE,
- Content.of(placeMessageCommand, "함께 해주셔서 감사합니다! 리뷰 부탁드려요.",
- link),
- List.of(Button.of(BUTTON_NAME, link))
+ OBJECT_TYPE,
+ Content.of(placeMessageCommand, "함께 해주셔서 감사합니다! 리뷰 부탁드려요.",
+ link),
+ List.of(Button.of(BUTTON_NAME, link))
);
}
}
diff --git a/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java b/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java
index a7598b4a..da825c60 100644
--- a/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java
+++ b/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java
@@ -20,11 +20,11 @@ public class KakaoMessageMaker {
private final ObjectMapper objectMapper;
public MultiValueMap createLocationTemplate(
- PlaceMessageCommand placeMessageCommand) {
+ PlaceMessageCommand placeMessageCommand) {
try {
LinkedMultiValueMap body = new LinkedMultiValueMap<>();
body.add(TEMPLATE_OBJECT, objectMapper.writeValueAsString(
- LocationTemplate.of(frontEndUrl, placeMessageCommand)));
+ LocationTemplate.of(frontEndUrl, placeMessageCommand)));
return body;
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
@@ -32,11 +32,11 @@ public MultiValueMap createLocationTemplate(
}
public MultiValueMap createFeedTemplate(
- PlaceMessageCommand placeMessageCommand) {
+ PlaceMessageCommand placeMessageCommand) {
try {
LinkedMultiValueMap body = new LinkedMultiValueMap<>();
body.add(TEMPLATE_OBJECT, objectMapper.writeValueAsString(
- FeedTemplate.of(frontEndUrl, placeMessageCommand)));
+ FeedTemplate.of(frontEndUrl, placeMessageCommand)));
return body;
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
diff --git a/src/main/java/team7/inplace/placeMessage/util/Link.java b/src/main/java/team7/inplace/placeMessage/util/Link.java
index e2d84bb6..efe2cfac 100644
--- a/src/main/java/team7/inplace/placeMessage/util/Link.java
+++ b/src/main/java/team7/inplace/placeMessage/util/Link.java
@@ -3,10 +3,10 @@
import com.fasterxml.jackson.annotation.JsonProperty;
public record Link(
- @JsonProperty("web_url") String webUrl,
- @JsonProperty("mobile_web_url") String mobileWebUrl,
- @JsonProperty("android_execution_params") String androidExecutionParams,
- @JsonProperty("ios_execution_params") String iosExecutionParams
+ @JsonProperty("web_url") String webUrl,
+ @JsonProperty("mobile_web_url") String mobileWebUrl,
+ @JsonProperty("android_execution_params") String androidExecutionParams,
+ @JsonProperty("ios_execution_params") String iosExecutionParams
) {
public static Link of(String url) {
diff --git a/src/main/java/team7/inplace/placeMessage/util/LocationTemplate.java b/src/main/java/team7/inplace/placeMessage/util/LocationTemplate.java
index 7f980da9..5989f830 100644
--- a/src/main/java/team7/inplace/placeMessage/util/LocationTemplate.java
+++ b/src/main/java/team7/inplace/placeMessage/util/LocationTemplate.java
@@ -1,17 +1,18 @@
package team7.inplace.placeMessage.util;
import com.fasterxml.jackson.annotation.JsonProperty;
-import java.util.List;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import team7.inplace.placeMessage.application.command.PlaceMessageCommand;
+import java.util.List;
+
public record LocationTemplate(
- @NonNull @JsonProperty("object_type") String objectType,
- @NonNull String address,
- @Nullable @JsonProperty("address_title") String addressTitle,
- @NonNull Content content,
- @Nullable @JsonProperty("buttons") List buttons
+ @NonNull @JsonProperty("object_type") String objectType,
+ @NonNull String address,
+ @Nullable @JsonProperty("address_title") String addressTitle,
+ @NonNull Content content,
+ @Nullable @JsonProperty("buttons") List buttons
) {
private final static String BUTTON_NAME = "자세히 보기";
@@ -20,11 +21,11 @@ public record LocationTemplate(
public static LocationTemplate of(String frontEndUrl, PlaceMessageCommand placeMessageCommand) {
Link link = Link.of(frontEndUrl + "/detail/" + placeMessageCommand.placeId());
return new LocationTemplate(
- OBJECT_TYPE,
- placeMessageCommand.address(),
- placeMessageCommand.title(),
- Content.of(placeMessageCommand, placeMessageCommand.description(), link),
- List.of(Button.of(BUTTON_NAME, link))
+ OBJECT_TYPE,
+ placeMessageCommand.address(),
+ placeMessageCommand.title(),
+ Content.of(placeMessageCommand, placeMessageCommand.description(), link),
+ List.of(Button.of(BUTTON_NAME, link))
);
}
}
diff --git a/src/main/java/team7/inplace/review/application/ReviewService.java b/src/main/java/team7/inplace/review/application/ReviewService.java
index 9068b1a0..b6b89088 100644
--- a/src/main/java/team7/inplace/review/application/ReviewService.java
+++ b/src/main/java/team7/inplace/review/application/ReviewService.java
@@ -1,6 +1,5 @@
package team7.inplace.review.application;
-import java.util.Objects;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -21,6 +20,8 @@
import team7.inplace.security.util.AuthorizationUtil;
import team7.inplace.user.domain.User;
+import java.util.Objects;
+
@RequiredArgsConstructor
@Service
public class ReviewService {
@@ -37,7 +38,7 @@ public void createReview(Long placeId, ReviewCommand command) {
User user = currentUserProvider.getCurrentUser();
Place place = placeRepository.findById(placeId)
- .orElseThrow(() -> InplaceException.of(PlaceErrorCode.NOT_FOUND));
+ .orElseThrow(() -> InplaceException.of(PlaceErrorCode.NOT_FOUND));
if (reviewRepository.existsByUserIdAndPlaceId(user.getId(), placeId)) {
throw InplaceException.of(ReviewErrorCode.REVIEW_ALREADY_EXISTS);
@@ -70,7 +71,7 @@ public void deleteReview(Long reviewId) {
Long userId = AuthorizationUtil.getUserId();
Review review = reviewRepository.findById(reviewId)
- .orElseThrow(() -> InplaceException.of(ReviewErrorCode.NOT_FOUND));
+ .orElseThrow(() -> InplaceException.of(ReviewErrorCode.NOT_FOUND));
if (!review.getUser().getId().equals(userId)) {
throw InplaceException.of(ReviewErrorCode.NOT_OWNER);
@@ -81,7 +82,7 @@ public void deleteReview(Long reviewId) {
@Transactional(readOnly = true)
public Page getMyReviews(Long userId, Pageable pageable) {
- Page reviewPage = reviewRepository.findByUserId(userId, pageable);
+ Page reviewPage = reviewRepository.findByUserIdWithPlace(userId, pageable);
return reviewPage.map(MyReviewInfo::from);
}
diff --git a/src/main/java/team7/inplace/review/application/dto/MyReviewInfo.java b/src/main/java/team7/inplace/review/application/dto/MyReviewInfo.java
index 4caed484..115976e6 100644
--- a/src/main/java/team7/inplace/review/application/dto/MyReviewInfo.java
+++ b/src/main/java/team7/inplace/review/application/dto/MyReviewInfo.java
@@ -1,41 +1,42 @@
package team7.inplace.review.application.dto;
-import java.util.Date;
import team7.inplace.place.application.dto.PlaceInfo.AddressInfo;
import team7.inplace.place.domain.Place;
import team7.inplace.review.domain.Review;
+import java.util.Date;
+
public record MyReviewInfo(
- Long reviewId,
- boolean likes,
- String comment,
- Date createdDate,
- ReviewPlaceInfo placeInfo
+ Long reviewId,
+ boolean likes,
+ String comment,
+ Date createdDate,
+ ReviewPlaceInfo placeInfo
) {
public record ReviewPlaceInfo(
- Long placeId,
- String imgUrl,
- AddressInfo address
+ Long placeId,
+ String imgUrl,
+ AddressInfo address
) {
public static ReviewPlaceInfo from(Place place) {
return new ReviewPlaceInfo(
- place.getId(),
- place.getMenuImgUrl(),
- AddressInfo.of(place.getAddress())
+ place.getId(),
+ place.getMenuImgUrl(),
+ AddressInfo.of(place.getAddress())
);
}
}
public static MyReviewInfo from(Review review) {
return new MyReviewInfo(
- review.getId(),
- review.isLiked(),
- review.getComment(),
- review.getCreatedDate(),
- ReviewPlaceInfo.from(review.getPlace())
+ review.getId(),
+ review.isLiked(),
+ review.getComment(),
+ review.getCreatedDate(),
+ ReviewPlaceInfo.from(review.getPlace())
);
}
}
diff --git a/src/main/java/team7/inplace/review/application/dto/ReviewCommand.java b/src/main/java/team7/inplace/review/application/dto/ReviewCommand.java
index cfbdd053..1c35cc85 100644
--- a/src/main/java/team7/inplace/review/application/dto/ReviewCommand.java
+++ b/src/main/java/team7/inplace/review/application/dto/ReviewCommand.java
@@ -5,16 +5,16 @@
import team7.inplace.user.domain.User;
public record ReviewCommand(
- boolean likes,
- String comments
+ boolean likes,
+ String comments
) {
public static Review toEntity(User user, Place place, ReviewCommand command) {
return new Review(
- user,
- place,
- command.likes,
- command.comments
+ user,
+ place,
+ command.likes,
+ command.comments
);
}
}
diff --git a/src/main/java/team7/inplace/review/application/dto/ReviewInfo.java b/src/main/java/team7/inplace/review/application/dto/ReviewInfo.java
index 62db885e..0d4def9c 100644
--- a/src/main/java/team7/inplace/review/application/dto/ReviewInfo.java
+++ b/src/main/java/team7/inplace/review/application/dto/ReviewInfo.java
@@ -1,25 +1,26 @@
package team7.inplace.review.application.dto;
-import java.util.Date;
import team7.inplace.review.domain.Review;
+import java.util.Date;
+
public record ReviewInfo(
- Long reviewId,
- boolean likes,
- String comment,
- String userNickname,
- Date createdDate,
- boolean mine
+ Long reviewId,
+ boolean likes,
+ String comment,
+ String userNickname,
+ Date createdDate,
+ boolean mine
) {
public static ReviewInfo from(Review review, boolean isMine) {
return new ReviewInfo(
- review.getId(),
- review.isLiked(),
- review.getComment(),
- review.getUser().getNickname(),
- review.getCreatedDate(),
- isMine
+ review.getId(),
+ review.isLiked(),
+ review.getComment(),
+ review.getUser().getNickname(),
+ review.getCreatedDate(),
+ isMine
);
}
}
diff --git a/src/main/java/team7/inplace/review/domain/Review.java b/src/main/java/team7/inplace/review/domain/Review.java
index 7b63be8f..b02a04f3 100644
--- a/src/main/java/team7/inplace/review/domain/Review.java
+++ b/src/main/java/team7/inplace/review/domain/Review.java
@@ -1,27 +1,20 @@
package team7.inplace.review.domain;
-import static lombok.AccessLevel.PROTECTED;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-import jakarta.persistence.UniqueConstraint;
-import java.util.Date;
+import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import team7.inplace.place.domain.Place;
import team7.inplace.user.domain.User;
+import java.util.Date;
+
+import static lombok.AccessLevel.PROTECTED;
+
@Getter
@NoArgsConstructor(access = PROTECTED)
@Entity
@Table(name = "review", uniqueConstraints = {
- @UniqueConstraint(columnNames = {"user_id", "place_id"})
+ @UniqueConstraint(columnNames = {"user_id", "place_id"})
})
public class Review {
diff --git a/src/main/java/team7/inplace/review/persistence/ReviewRepository.java b/src/main/java/team7/inplace/review/persistence/ReviewRepository.java
index 3ef4a7cf..c5fdc25c 100644
--- a/src/main/java/team7/inplace/review/persistence/ReviewRepository.java
+++ b/src/main/java/team7/inplace/review/persistence/ReviewRepository.java
@@ -3,6 +3,7 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
import team7.inplace.review.domain.Review;
public interface ReviewRepository extends JpaRepository {
@@ -11,5 +12,10 @@ public interface ReviewRepository extends JpaRepository {
Page findByPlaceId(Long placeId, Pageable pageable);
- Page findByUserId(Long userId, Pageable pageable);
+ Integer countByPlaceIdAndIsLikedTrue(Long placeId);
+
+ Integer countByPlaceIdAndIsLikedFalse(Long placeId);
+
+ @Query("SELECT r FROM Review r JOIN FETCH r.place WHERE r.user.id = :userId")
+ Page findByUserIdWithPlace(Long userId, Pageable pageable);
}
diff --git a/src/main/java/team7/inplace/search/application/SearchService.java b/src/main/java/team7/inplace/search/application/SearchService.java
index 288380f7..18ae87af 100644
--- a/src/main/java/team7/inplace/search/application/SearchService.java
+++ b/src/main/java/team7/inplace/search/application/SearchService.java
@@ -9,7 +9,9 @@
import org.springframework.transaction.annotation.Transactional;
import team7.inplace.favoriteInfluencer.persistent.FavoriteInfluencerRepository;
import team7.inplace.influencer.application.dto.InfluencerInfo;
+import team7.inplace.likedPlace.persistence.LikedPlaceRepository;
import team7.inplace.search.application.dto.AutoCompletionInfo;
+import team7.inplace.search.application.dto.PlaceSearchInfo;
import team7.inplace.search.application.dto.SearchType;
import team7.inplace.search.persistence.InfluencerSearchRepository;
import team7.inplace.search.persistence.PlaceSearchRepository;
@@ -28,6 +30,7 @@ public class SearchService {
private final InfluencerSearchRepository influencerSearchRepository;
private final PlaceSearchRepository placeSearchRepository;
private final FavoriteInfluencerRepository favoriteInfluencerRepository;
+ private final LikedPlaceRepository likedPlaceRepository;
public List searchAutoCompletions(String keyword) {
var influencerSearchInfo = influencerSearchRepository.searchEntityByKeywords(keyword);
@@ -46,7 +49,6 @@ public List searchAutoCompletions(String keyword) {
.toList();
}
- @Transactional(readOnly = true)
public List searchVideo(String keyword) {
var videoInfos = videoSearchRepository.searchEntityByKeywords(keyword);
@@ -57,7 +59,6 @@ public List searchVideo(String keyword) {
.toList();
}
- @Transactional(readOnly = true)
public List searchInfluencer(String keyword) {
var influencerInfos = influencerSearchRepository.searchEntityByKeywords(keyword);
Long userId = AuthorizationUtil.getUserId();
@@ -78,4 +79,24 @@ public List searchInfluencer(String keyword) {
.sorted((a, b) -> Boolean.compare(b.likes(), a.likes()))
.toList();
}
+
+ public List searchPlace(String keyword) {
+ var placeInfos = placeSearchRepository.searchEntityByKeywords(keyword);
+ Long userId = AuthorizationUtil.getUserId();
+
+ if (userId == null) {
+ return placeInfos.stream()
+ .map(placeInfo -> PlaceSearchInfo.from(placeInfo.searchResult(), false))
+ .toList();
+ }
+
+ var likedPlaceIds = likedPlaceRepository.findPlaceIdsByUserIdAndIsLikedTrue(userId);
+ return placeInfos.stream()
+ .map(placeInfo -> {
+ boolean isLiked = likedPlaceIds.contains(placeInfo.searchResult().getId());
+ return PlaceSearchInfo.from(placeInfo.searchResult(), isLiked);
+ })
+ .sorted((a, b) -> Boolean.compare(b.likes(), a.likes()))
+ .toList();
+ }
}
diff --git a/src/main/java/team7/inplace/search/application/dto/PlaceSearchInfo.java b/src/main/java/team7/inplace/search/application/dto/PlaceSearchInfo.java
new file mode 100644
index 00000000..9d85df53
--- /dev/null
+++ b/src/main/java/team7/inplace/search/application/dto/PlaceSearchInfo.java
@@ -0,0 +1,19 @@
+package team7.inplace.search.application.dto;
+
+import team7.inplace.place.domain.Place;
+
+public record PlaceSearchInfo(
+ Long placeId,
+ String placeName,
+ String imageUrl,
+ Boolean likes
+) {
+ public static PlaceSearchInfo from(Place place, Boolean likes) {
+ return new PlaceSearchInfo(
+ place.getId(),
+ place.getName(),
+ place.getMenuImgUrl(),
+ likes
+ );
+ }
+}
diff --git a/src/main/java/team7/inplace/search/presentation/SearchController.java b/src/main/java/team7/inplace/search/presentation/SearchController.java
index b3928eb2..6ce45281 100644
--- a/src/main/java/team7/inplace/search/presentation/SearchController.java
+++ b/src/main/java/team7/inplace/search/presentation/SearchController.java
@@ -11,6 +11,7 @@
import team7.inplace.influencer.presentation.dto.InfluencerResponse;
import team7.inplace.search.application.SearchService;
import team7.inplace.search.application.dto.AutoCompletionInfo;
+import team7.inplace.search.application.dto.PlaceSearchInfo;
import team7.inplace.video.presentation.dto.VideoResponse;
@RestController
@@ -48,4 +49,12 @@ public ResponseEntity> searchInfluencer(@RequestParam S
.toList();
return new ResponseEntity<>(response, HttpStatus.OK);
}
+
+ @Override
+ @GetMapping("/place")
+ public ResponseEntity> searchPlace(@RequestParam String value) {
+ var places = searchService.searchPlace(value);
+
+ return new ResponseEntity<>(places, HttpStatus.OK);
+ }
}
diff --git a/src/main/java/team7/inplace/search/presentation/SearchControllerApiSpec.java b/src/main/java/team7/inplace/search/presentation/SearchControllerApiSpec.java
index b576b87a..7ce9e0f1 100644
--- a/src/main/java/team7/inplace/search/presentation/SearchControllerApiSpec.java
+++ b/src/main/java/team7/inplace/search/presentation/SearchControllerApiSpec.java
@@ -7,6 +7,7 @@
import org.springframework.http.ResponseEntity;
import team7.inplace.influencer.presentation.dto.InfluencerResponse;
import team7.inplace.search.application.dto.AutoCompletionInfo;
+import team7.inplace.search.application.dto.PlaceSearchInfo;
import team7.inplace.video.presentation.dto.VideoResponse;
@Tag(name = "검색 API입니다.")
@@ -23,4 +24,8 @@ public interface SearchControllerApiSpec {
@Operation(summary = "인플루언서를 검색합니다.")
@ApiResponse(responseCode = "200", description = "인플루언서 검색 성공")
ResponseEntity> searchInfluencer(String value);
+
+ @Operation(summary = "장소를 검색합니다.")
+ @ApiResponse(responseCode = "200", description = "장소 검색 성공")
+ ResponseEntity> searchPlace(String value);
}
diff --git a/src/main/java/team7/inplace/security/application/CurrentUserProvider.java b/src/main/java/team7/inplace/security/application/CurrentUserProvider.java
index e2a9f04e..63423b91 100644
--- a/src/main/java/team7/inplace/security/application/CurrentUserProvider.java
+++ b/src/main/java/team7/inplace/security/application/CurrentUserProvider.java
@@ -21,6 +21,6 @@ public User getCurrentUser() {
throw InplaceException.of(AuthorizationErrorCode.TOKEN_IS_EMPTY);
}
return userRepository.findById(userId)
- .orElseThrow(() -> InplaceException.of(UserErrorCode.NOT_FOUND));
+ .orElseThrow(() -> InplaceException.of(UserErrorCode.NOT_FOUND));
}
}
diff --git a/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java b/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java
index 73f4c1b5..45f861d6 100644
--- a/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java
+++ b/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java
@@ -1,6 +1,5 @@
package team7.inplace.security.application;
-import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService;
import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest;
@@ -16,6 +15,8 @@
import team7.inplace.user.application.dto.UserCommand;
import team7.inplace.user.application.dto.UserCommand.Info;
+import java.util.Optional;
+
@RequiredArgsConstructor
public class CustomOAuth2UserService implements OAuth2UserService {
@@ -25,38 +26,38 @@ public class CustomOAuth2UserService implements OAuth2UserService userInfo = userService.findUserByUsername(
- kakaoOAuthResponse.getEmail());
+ kakaoOAuthResponse.getEmail());
if (userInfo.isPresent()) {
updateOauthToken(oAuth2AccessToken, userInfo.get());
return CustomOAuth2User.makeExistUser(userInfo.get());
}
UserCommand.Info newUser = userService.registerUser(
- UserCommand.Create.of(kakaoOAuthResponse));
+ UserCommand.Create.of(kakaoOAuthResponse));
insertOauthToken(oAuth2AccessToken, newUser);
return CustomOAuth2User.makeNewUser(newUser);
}
private void updateOauthToken(OAuth2AccessToken oAuth2AccessToken, UserCommand.Info userInfo) {
oauthTokenService.updateOauthToken(
- OauthTokenCommand.of(
- oAuth2AccessToken.getTokenValue(),
- oAuth2AccessToken.getExpiresAt(),
- userInfo.id()
- ));
+ OauthTokenCommand.of(
+ oAuth2AccessToken.getTokenValue(),
+ oAuth2AccessToken.getExpiresAt(),
+ userInfo.id()
+ ));
}
private void insertOauthToken(OAuth2AccessToken oAuth2AccessToken, Info newUser) {
oauthTokenService.insertOauthToken(
- OauthTokenCommand.of(
- oAuth2AccessToken.getTokenValue(),
- oAuth2AccessToken.getExpiresAt(),
- newUser.id()
- )
+ OauthTokenCommand.of(
+ oAuth2AccessToken.getTokenValue(),
+ oAuth2AccessToken.getExpiresAt(),
+ newUser.id()
+ )
);
}
}
diff --git a/src/main/java/team7/inplace/security/application/dto/CustomOAuth2User.java b/src/main/java/team7/inplace/security/application/dto/CustomOAuth2User.java
index 4c8f1729..328546fb 100644
--- a/src/main/java/team7/inplace/security/application/dto/CustomOAuth2User.java
+++ b/src/main/java/team7/inplace/security/application/dto/CustomOAuth2User.java
@@ -1,8 +1,5 @@
package team7.inplace.security.application.dto;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.oauth2.core.user.OAuth2User;
@@ -10,11 +7,15 @@
import team7.inplace.user.application.dto.UserCommand;
import team7.inplace.user.domain.Role;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+
public record CustomOAuth2User(
- String username,
- Long id,
- String roles,
- Collection authorities
+ String username,
+ Long id,
+ String roles,
+ Collection authorities
) implements OAuth2User {
public CustomOAuth2User(String username, Long id, String roles) {
@@ -58,11 +59,11 @@ public static CustomOAuth2User makeExistUser(UserCommand.Info user) {
public static CustomOAuth2User makeNewUser(UserCommand.Info user) {
return new CustomOAuth2User(user.username(), user.id(),
- Role.addRole(Role.USER, Role.FIRST_USER));
+ Role.addRole(Role.USER, Role.FIRST_USER));
}
public boolean isFirstUser() {
return this.authorities.stream()
- .anyMatch(authority -> authority.getAuthority().equals(Role.FIRST_USER.getRoles()));
+ .anyMatch(authority -> authority.getAuthority().equals(Role.FIRST_USER.getRoles()));
}
}
diff --git a/src/main/java/team7/inplace/security/application/dto/KakaoOAuthResponse.java b/src/main/java/team7/inplace/security/application/dto/KakaoOAuthResponse.java
index 5c20bac9..cfb55d12 100644
--- a/src/main/java/team7/inplace/security/application/dto/KakaoOAuthResponse.java
+++ b/src/main/java/team7/inplace/security/application/dto/KakaoOAuthResponse.java
@@ -3,7 +3,7 @@
import java.util.Map;
public record KakaoOAuthResponse(
- Map attribute
+ Map attribute
) {
public KakaoOAuthResponse(Map attribute) {
diff --git a/src/main/java/team7/inplace/security/config/CorsConfig.java b/src/main/java/team7/inplace/security/config/CorsConfig.java
index 424a4552..5d4d1a37 100644
--- a/src/main/java/team7/inplace/security/config/CorsConfig.java
+++ b/src/main/java/team7/inplace/security/config/CorsConfig.java
@@ -1,5 +1,6 @@
package team7.inplace.security.config;
+import java.util.Arrays;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
@@ -14,10 +15,24 @@ public CorsFilter corsFilter() {
var source = new UrlBasedCorsConfigurationSource();
var config = new CorsConfiguration();
config.setAllowCredentials(true);
- config.addAllowedOrigin("https://www.inplace.my");
+ config.addAllowedOriginPattern("https://www.inplace.my");
config.addAllowedOriginPattern("https://api.inplace.my");
- config.addAllowedHeader("*");
- config.addAllowedMethod("*");
+ config.addAllowedHeader("Origin");
+ config.addAllowedHeader("Accept");
+ config.addAllowedHeader("X-Requested-With");
+ config.addAllowedHeader("Content-Type");
+ config.addAllowedHeader("Access-Control-Request-Method");
+ config.addAllowedHeader("Access-Control-Request-Headers");
+ config.addAllowedHeader("Authorization");
+ config.addAllowedMethod("GET");
+ config.addAllowedMethod("POST");
+ config.addAllowedMethod("PUT");
+ config.addAllowedMethod("DELETE");
+ config.addAllowedMethod("OPTIONS");
+ config.addAllowedHeader("PATCH");
+ config.addAllowedMethod("HEAD");
+ config.setMaxAge(3600L);
+ config.setExposedHeaders(Arrays.asList("Location", "Set-Cookie"));
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
diff --git a/src/main/java/team7/inplace/security/config/JwtProperties.java b/src/main/java/team7/inplace/security/config/JwtProperties.java
index bf7a3969..4467eb91 100644
--- a/src/main/java/team7/inplace/security/config/JwtProperties.java
+++ b/src/main/java/team7/inplace/security/config/JwtProperties.java
@@ -4,9 +4,9 @@
@ConfigurationProperties(prefix = "spring.jwt")
public record JwtProperties(
- String secret,
- Long accessTokenExpiredTime,
- Long refreshTokenExpiredTime
+ String secret,
+ Long accessTokenExpiredTime,
+ Long refreshTokenExpiredTime
) {
}
diff --git a/src/main/java/team7/inplace/security/config/SecurityConfig.java b/src/main/java/team7/inplace/security/config/SecurityConfig.java
index f55ec51d..d569aa6e 100644
--- a/src/main/java/team7/inplace/security/config/SecurityConfig.java
+++ b/src/main/java/team7/inplace/security/config/SecurityConfig.java
@@ -35,53 +35,53 @@ public class SecurityConfig {
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http)
- throws Exception {
+ throws Exception {
//http 설정
http.csrf(AbstractHttpConfigurer::disable)
- .formLogin(AbstractHttpConfigurer::disable)
- .httpBasic(AbstractHttpConfigurer::disable)
+ .formLogin(AbstractHttpConfigurer::disable)
+ .httpBasic(AbstractHttpConfigurer::disable)
- //authentication Service, Handler 설정
- .oauth2Login((oauth2) -> oauth2
- .userInfoEndpoint((userInfoEndPointConfig) -> userInfoEndPointConfig
- .userService(customOauth2UserService)).successHandler(customSuccessHandler)
- .failureHandler(customFailureHandler))
+ //authentication Service, Handler 설정
+ .oauth2Login((oauth2) -> oauth2
+ .userInfoEndpoint((userInfoEndPointConfig) -> userInfoEndPointConfig
+ .userService(customOauth2UserService)).successHandler(customSuccessHandler)
+ .failureHandler(customFailureHandler))
- //authentication Filter 설정
- .addFilterBefore(authorizationFilter,
- UsernamePasswordAuthenticationFilter.class)
- .addFilterBefore(exceptionHandlingFilter, AuthorizationFilter.class)
+ //authentication Filter 설정
+ .addFilterBefore(authorizationFilter,
+ UsernamePasswordAuthenticationFilter.class)
+ .addFilterBefore(exceptionHandlingFilter, AuthorizationFilter.class)
- .exceptionHandling((auth) -> auth
- .authenticationEntryPoint(loginAuthenticationEntryPoint)
- .accessDeniedHandler(customAccessDeniedHandler))
- //authentication 경로 설정
- .authorizeHttpRequests((auth) -> auth
- .requestMatchers("/admin/**", "/api/error-logs/**", "/cicd", "crawling/**")
- .hasRole("ADMIN")
- .requestMatchers("/users/**").authenticated()
- .requestMatchers("/influencers/likes").authenticated()
- .requestMatchers("/influencers/multiple/likes").authenticated()
- .requestMatchers(HttpMethod.POST, "/influencers/**").hasRole("ADMIN")
- .requestMatchers(HttpMethod.PUT, "/influencers/**").hasRole("ADMIN")
- .requestMatchers(HttpMethod.DELETE, "/influencers/**").hasRole("ADMIN")
- .requestMatchers(HttpMethod.GET, "/influencers/**").permitAll()
- .requestMatchers(HttpMethod.POST, "/places/**").authenticated()
- .requestMatchers(HttpMethod.GET, "/places/**").permitAll()
- .requestMatchers("/place-message/**").authenticated()
- .requestMatchers("/reviews/**").authenticated()
- .requestMatchers("/refresh-token").authenticated()
- .requestMatchers("/videos", "videos/my").authenticated()
- .requestMatchers("/videos/**").permitAll()
- .requestMatchers(HttpMethod.DELETE, "/videos/{videoId}").authenticated()
- .anyRequest().permitAll()
- )
- //cors 설정
- .addFilter(corsFilter)
- //session 설정
- .sessionManagement((session) -> session
- .sessionCreationPolicy(SessionCreationPolicy.STATELESS));
+ .exceptionHandling((auth) -> auth
+ .authenticationEntryPoint(loginAuthenticationEntryPoint)
+ .accessDeniedHandler(customAccessDeniedHandler))
+ //authentication 경로 설정
+ .authorizeHttpRequests((auth) -> auth
+ .requestMatchers("/admin/**", "/api/error-logs/**", "/cicd", "crawling/**")
+ .hasRole("ADMIN")
+ .requestMatchers("/users/**").authenticated()
+ .requestMatchers("/influencers/likes").authenticated()
+ .requestMatchers("/influencers/multiple/likes").authenticated()
+ .requestMatchers(HttpMethod.POST, "/influencers/**").hasRole("ADMIN")
+ .requestMatchers(HttpMethod.PUT, "/influencers/**").hasRole("ADMIN")
+ .requestMatchers(HttpMethod.DELETE, "/influencers/**").hasRole("ADMIN")
+ .requestMatchers(HttpMethod.GET, "/influencers/**").permitAll()
+ .requestMatchers(HttpMethod.POST, "/places/**").authenticated()
+ .requestMatchers(HttpMethod.GET, "/places/**").permitAll()
+ .requestMatchers("/place-message/**").authenticated()
+ .requestMatchers("/reviews/**").authenticated()
+ .requestMatchers("/refresh-token").authenticated()
+ .requestMatchers("/videos", "videos/my").authenticated()
+ .requestMatchers("/videos/**").permitAll()
+ .requestMatchers(HttpMethod.DELETE, "/videos/{videoId}").authenticated()
+ .anyRequest().permitAll()
+ )
+ //cors 설정
+ .addFilter(corsFilter)
+ //session 설정
+ .sessionManagement((session) -> session
+ .sessionCreationPolicy(SessionCreationPolicy.STATELESS));
return http.build();
}
diff --git a/src/main/java/team7/inplace/security/config/SecurityHandlerConfig.java b/src/main/java/team7/inplace/security/config/SecurityHandlerConfig.java
index 964cb5cd..13044afa 100644
--- a/src/main/java/team7/inplace/security/config/SecurityHandlerConfig.java
+++ b/src/main/java/team7/inplace/security/config/SecurityHandlerConfig.java
@@ -14,8 +14,8 @@ public class SecurityHandlerConfig {
@Bean
public CustomSuccessHandler customSuccessHandler(
- JwtUtil jwtUtil,
- RefreshTokenService refreshTokenService
+ JwtUtil jwtUtil,
+ RefreshTokenService refreshTokenService
) {
return new CustomSuccessHandler(jwtUtil, refreshTokenService);
}
diff --git a/src/main/java/team7/inplace/security/config/SecurityServiceConfig.java b/src/main/java/team7/inplace/security/config/SecurityServiceConfig.java
index 4393ab9f..f0cb74e5 100644
--- a/src/main/java/team7/inplace/security/config/SecurityServiceConfig.java
+++ b/src/main/java/team7/inplace/security/config/SecurityServiceConfig.java
@@ -17,11 +17,11 @@ public DefaultOAuth2UserService defaultOAuth2UserService() {
@Bean
public CustomOAuth2UserService customOAuth2UserService(
- DefaultOAuth2UserService defaultOAuth2UserService,
- UserService userService,
- OauthTokenService oauthTokenService
+ DefaultOAuth2UserService defaultOAuth2UserService,
+ UserService userService,
+ OauthTokenService oauthTokenService
) {
return new CustomOAuth2UserService(defaultOAuth2UserService, userService,
- oauthTokenService);
+ oauthTokenService);
}
}
diff --git a/src/main/java/team7/inplace/security/filter/ExceptionHandlingFilter.java b/src/main/java/team7/inplace/security/filter/ExceptionHandlingFilter.java
index 794ba222..324bce40 100644
--- a/src/main/java/team7/inplace/security/filter/ExceptionHandlingFilter.java
+++ b/src/main/java/team7/inplace/security/filter/ExceptionHandlingFilter.java
@@ -5,13 +5,14 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.http.ProblemDetail;
import org.springframework.web.filter.OncePerRequestFilter;
import team7.inplace.global.exception.InplaceException;
+import java.io.IOException;
+
@Slf4j
public class ExceptionHandlingFilter extends OncePerRequestFilter {
@@ -23,9 +24,9 @@ public ExceptionHandlingFilter(ObjectMapper objectMapper) {
@Override
protected void doFilterInternal(
- HttpServletRequest request,
- HttpServletResponse response,
- FilterChain filterChain
+ HttpServletRequest request,
+ HttpServletResponse response,
+ FilterChain filterChain
) throws ServletException, IOException {
try {
filterChain.doFilter(request, response);
@@ -35,14 +36,14 @@ protected void doFilterInternal(
}
private void setErrorResponse(
- HttpServletResponse response,
- InplaceException inplaceException
+ HttpServletResponse response,
+ InplaceException inplaceException
) throws IOException {
log.info("ExceptionHandlingFilter.setErrorResponse");
response.setStatus(inplaceException.getHttpStatus().value());
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(
- inplaceException.getHttpStatus(), inplaceException.getMessage());
+ inplaceException.getHttpStatus(), inplaceException.getMessage());
response.getWriter().write(objectMapper.writeValueAsString(problemDetail));
}
}
diff --git a/src/main/java/team7/inplace/security/handler/CustomFailureHandler.java b/src/main/java/team7/inplace/security/handler/CustomFailureHandler.java
index 4f88fea6..e6afd50b 100644
--- a/src/main/java/team7/inplace/security/handler/CustomFailureHandler.java
+++ b/src/main/java/team7/inplace/security/handler/CustomFailureHandler.java
@@ -4,7 +4,6 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
-import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.http.ProblemDetail;
@@ -14,7 +13,6 @@
import team7.inplace.global.exception.InplaceException;
import team7.inplace.global.exception.code.AuthorizationErrorCode;
-@Slf4j
public class CustomFailureHandler implements AuthenticationFailureHandler {
@Value("${spring.redirect.front-end-url}")
diff --git a/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java b/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java
index 5594f8d5..25b53080 100644
--- a/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java
+++ b/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java
@@ -2,7 +2,6 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-import java.io.IOException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseCookie;
@@ -14,6 +13,8 @@
import team7.inplace.security.util.JwtUtil;
import team7.inplace.token.application.RefreshTokenService;
+import java.io.IOException;
+
public class CustomSuccessHandler implements AuthenticationSuccessHandler {
private final JwtUtil jwtUtil;
@@ -23,8 +24,8 @@ public class CustomSuccessHandler implements AuthenticationSuccessHandler {
private String frontEndUrl;
public CustomSuccessHandler(
- JwtUtil jwtUtil,
- RefreshTokenService refreshTokenService
+ JwtUtil jwtUtil,
+ RefreshTokenService refreshTokenService
) {
this.jwtUtil = jwtUtil;
this.refreshTokenService = refreshTokenService;
@@ -32,39 +33,39 @@ public CustomSuccessHandler(
@Override
public void onAuthenticationSuccess(
- HttpServletRequest request,
- HttpServletResponse response,
- Authentication authentication
+ HttpServletRequest request,
+ HttpServletResponse response,
+ Authentication authentication
) throws IOException {
CustomOAuth2User customOAuth2User = (CustomOAuth2User) authentication.getPrincipal();
String accessToken = jwtUtil.createAccessToken(customOAuth2User.username(),
- customOAuth2User.id(), customOAuth2User.roles());
+ customOAuth2User.id(), customOAuth2User.roles());
String refreshToken = jwtUtil.createRefreshToken(customOAuth2User.username(),
- customOAuth2User.id(), customOAuth2User.roles());
+ customOAuth2User.id(), customOAuth2User.roles());
refreshTokenService.saveRefreshToken(customOAuth2User.username(), refreshToken);
addTokenToResponse(response, accessToken, refreshToken);
setRedirectUrlToResponse(request, response, customOAuth2User);
}
private void addTokenToResponse(
- HttpServletResponse response,
- String accessToken, String refreshToken
+ HttpServletResponse response,
+ String accessToken, String refreshToken
) {
ResponseCookie accessTokenCookie = CookieUtil.createCookie(
- TokenType.ACCESS_TOKEN.getValue(),
- accessToken);
+ TokenType.ACCESS_TOKEN.getValue(),
+ accessToken);
ResponseCookie refreshTokenCookie = CookieUtil.createCookie(
- TokenType.REFRESH_TOKEN.getValue(),
- refreshToken);
+ TokenType.REFRESH_TOKEN.getValue(),
+ refreshToken);
response.addHeader(HttpHeaders.SET_COOKIE, accessTokenCookie.toString());
response.addHeader(HttpHeaders.SET_COOKIE, refreshTokenCookie.toString());
}
private void setRedirectUrlToResponse(
- HttpServletRequest request,
- HttpServletResponse response,
- CustomOAuth2User customOAuth2User
+ HttpServletRequest request,
+ HttpServletResponse response,
+ CustomOAuth2User customOAuth2User
) throws IOException {
if (customOAuth2User.isFirstUser()) {
response.sendRedirect(frontEndUrl + "/choice");
diff --git a/src/main/java/team7/inplace/security/util/CookieUtil.java b/src/main/java/team7/inplace/security/util/CookieUtil.java
index 98c2ea37..1a8087bb 100644
--- a/src/main/java/team7/inplace/security/util/CookieUtil.java
+++ b/src/main/java/team7/inplace/security/util/CookieUtil.java
@@ -10,6 +10,7 @@ public static ResponseCookie createCookie(String key, String value) {
.secure(true)
.path("/")
.httpOnly(true)
+ .domain("inplace.my")
.maxAge(60 * 60)
.build();
}
diff --git a/src/main/java/team7/inplace/security/util/JwtUtil.java b/src/main/java/team7/inplace/security/util/JwtUtil.java
index 546e8324..8139875c 100644
--- a/src/main/java/team7/inplace/security/util/JwtUtil.java
+++ b/src/main/java/team7/inplace/security/util/JwtUtil.java
@@ -5,14 +5,15 @@
import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.Jwts.SIG;
-import java.nio.charset.StandardCharsets;
-import java.util.Date;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
import team7.inplace.global.exception.InplaceException;
import team7.inplace.global.exception.code.AuthorizationErrorCode;
import team7.inplace.security.config.JwtProperties;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+
public class JwtUtil {
private final SecretKey secretKey;
@@ -22,7 +23,7 @@ public class JwtUtil {
public JwtUtil(JwtProperties jwtProperties) {
this.secretKey = new SecretKeySpec(jwtProperties.secret().getBytes(StandardCharsets.UTF_8),
- SIG.HS256.key().build().getAlgorithm());
+ SIG.HS256.key().build().getAlgorithm());
this.jwtParser = Jwts.parser().verifyWith(this.secretKey).build();
this.accessTokenExpiredTime = jwtProperties.accessTokenExpiredTime();
this.refreshTokenExpiredTime = jwtProperties.refreshTokenExpiredTime();
@@ -37,16 +38,16 @@ public String createRefreshToken(String username, Long userId, String roles) {
}
private String createToken(String username, Long userId, String roles, String tokenType,
- Long expiredTime) {
+ Long expiredTime) {
return Jwts.builder()
- .claim("username", username)
- .claim("id", userId)
- .claim("roles", roles)
- .claim("tokenType", tokenType)
- .issuedAt(new Date(System.currentTimeMillis()))
- .expiration(new Date(System.currentTimeMillis() + expiredTime))
- .signWith(secretKey)
- .compact();
+ .claim("username", username)
+ .claim("id", userId)
+ .claim("roles", roles)
+ .claim("tokenType", tokenType)
+ .issuedAt(new Date(System.currentTimeMillis()))
+ .expiration(new Date(System.currentTimeMillis() + expiredTime))
+ .signWith(secretKey)
+ .compact();
}
public String getUsername(String token) throws InplaceException {
@@ -60,7 +61,7 @@ public String getUsername(String token) throws InplaceException {
public boolean isRefreshToken(String token) throws InplaceException {
try {
return jwtParser.parseSignedClaims(token).getPayload().get("tokenType", String.class)
- .equals("refreshToken");
+ .equals("refreshToken");
} catch (JwtException | IllegalArgumentException e) {
throw InplaceException.of(AuthorizationErrorCode.INVALID_TOKEN);
}
diff --git a/src/main/java/team7/inplace/token/application/RefreshTokenFacade.java b/src/main/java/team7/inplace/token/application/RefreshTokenFacade.java
index b28c4a01..9afd9b39 100644
--- a/src/main/java/team7/inplace/token/application/RefreshTokenFacade.java
+++ b/src/main/java/team7/inplace/token/application/RefreshTokenFacade.java
@@ -21,16 +21,16 @@ public class RefreshTokenFacade {
@Transactional
public ReIssued getReIssuedRefreshTokenCookie(String username, String refreshToken)
- throws InplaceException {
+ throws InplaceException {
if (refreshTokenService.isInvalidRefreshToken(refreshToken)) {
throw InplaceException.of(AuthorizationErrorCode.INVALID_TOKEN);
}
UserCommand.Info userInfo = userService.getUserByUsername(username);
String reIssuedRefreshToken = jwtUtil
- .createRefreshToken(userInfo.username(), userInfo.id(), userInfo.role().getRoles());
+ .createRefreshToken(userInfo.username(), userInfo.id(), userInfo.role().getRoles());
String reIssuedAccessToken = jwtUtil
- .createAccessToken(userInfo.username(), userInfo.id(), userInfo.role().getRoles());
+ .createAccessToken(userInfo.username(), userInfo.id(), userInfo.role().getRoles());
refreshTokenService.saveRefreshToken(username, reIssuedRefreshToken);
return TokenCommand.ReIssued.of(reIssuedAccessToken, reIssuedRefreshToken);
diff --git a/src/main/java/team7/inplace/token/application/RefreshTokenService.java b/src/main/java/team7/inplace/token/application/RefreshTokenService.java
index 2cd94d0d..f087a793 100644
--- a/src/main/java/team7/inplace/token/application/RefreshTokenService.java
+++ b/src/main/java/team7/inplace/token/application/RefreshTokenService.java
@@ -18,8 +18,8 @@ public class RefreshTokenService {
public boolean isInvalidRefreshToken(String refreshToken) throws InplaceException {
String username = jwtUtil.getUsername(refreshToken);
return !refreshTokenRepository.findById(username)
- .orElseThrow(() -> InplaceException.of(AuthorizationErrorCode.INVALID_TOKEN))
- .getRefreshToken().equals(refreshToken);
+ .orElseThrow(() -> InplaceException.of(AuthorizationErrorCode.INVALID_TOKEN))
+ .getRefreshToken().equals(refreshToken);
}
public void saveRefreshToken(String username, String token) {
diff --git a/src/main/java/team7/inplace/token/application/dto/TokenCommand.java b/src/main/java/team7/inplace/token/application/dto/TokenCommand.java
index 0d79e2a9..63736f2e 100644
--- a/src/main/java/team7/inplace/token/application/dto/TokenCommand.java
+++ b/src/main/java/team7/inplace/token/application/dto/TokenCommand.java
@@ -3,8 +3,8 @@
public class TokenCommand {
public record ReIssued(
- String accessToken,
- String refreshToken
+ String accessToken,
+ String refreshToken
) {
public static ReIssued of(String reIssuedAccessToken, String reIssuedRefreshToken) {
diff --git a/src/main/java/team7/inplace/token/presentation/RefreshTokenController.java b/src/main/java/team7/inplace/token/presentation/RefreshTokenController.java
index deb166bd..764d93ca 100644
--- a/src/main/java/team7/inplace/token/presentation/RefreshTokenController.java
+++ b/src/main/java/team7/inplace/token/presentation/RefreshTokenController.java
@@ -25,11 +25,11 @@ public class RefreshTokenController implements RefreshTokenControllerApiSpec {
@GetMapping("/refresh-token")
public ResponseEntity refreshToken(@CookieValue(value = "refresh_token") Cookie cookie,
- HttpServletResponse response) {
+ HttpServletResponse response) {
String refreshToken = cookie.getValue();
ReIssued reIssuedToken = refreshTokenFacade.getReIssuedRefreshTokenCookie(
- jwtUtil.getUsername(refreshToken), refreshToken);
+ jwtUtil.getUsername(refreshToken), refreshToken);
addTokenToCookie(response, reIssuedToken);
return new ResponseEntity<>(HttpStatus.OK);
@@ -37,11 +37,11 @@ public ResponseEntity refreshToken(@CookieValue(value = "refresh_token") C
private void addTokenToCookie(HttpServletResponse response, ReIssued reIssuedToken) {
ResponseCookie accessTokenCookie = CookieUtil.createCookie(
- TokenType.ACCESS_TOKEN.getValue(),
- reIssuedToken.accessToken());
+ TokenType.ACCESS_TOKEN.getValue(),
+ reIssuedToken.accessToken());
ResponseCookie refreshTokenCookie = CookieUtil.createCookie(
- TokenType.REFRESH_TOKEN.getValue(),
- reIssuedToken.refreshToken());
+ TokenType.REFRESH_TOKEN.getValue(),
+ reIssuedToken.refreshToken());
response.addHeader(HttpHeaders.SET_COOKIE, accessTokenCookie.toString());
response.addHeader(HttpHeaders.SET_COOKIE, refreshTokenCookie.toString());
diff --git a/src/main/java/team7/inplace/token/presentation/RefreshTokenControllerApiSpec.java b/src/main/java/team7/inplace/token/presentation/RefreshTokenControllerApiSpec.java
index 1ea64fbf..1bfd94c5 100644
--- a/src/main/java/team7/inplace/token/presentation/RefreshTokenControllerApiSpec.java
+++ b/src/main/java/team7/inplace/token/presentation/RefreshTokenControllerApiSpec.java
@@ -9,11 +9,11 @@
public interface RefreshTokenControllerApiSpec {
@Operation(
- summary = "토큰 리프레시",
- description = "Cookie에 refreshToken을 보내면 accessToken과 refreshToken을 새로 발급함."
+ summary = "토큰 리프레시",
+ description = "Cookie에 refreshToken을 보내면 accessToken과 refreshToken을 새로 발급함."
)
- public ResponseEntity refreshToken(
- @CookieValue(value = "refresh_token") Cookie cookie,
- HttpServletResponse response
+ ResponseEntity refreshToken(
+ @CookieValue(value = "refresh_token") Cookie cookie,
+ HttpServletResponse response
);
}
diff --git a/src/main/java/team7/inplace/user/application/UserService.java b/src/main/java/team7/inplace/user/application/UserService.java
index 9774ab71..2825efa2 100644
--- a/src/main/java/team7/inplace/user/application/UserService.java
+++ b/src/main/java/team7/inplace/user/application/UserService.java
@@ -1,7 +1,5 @@
package team7.inplace.user.application;
-import java.util.List;
-import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -18,6 +16,9 @@
import team7.inplace.user.domain.User;
import team7.inplace.user.persistence.UserRepository;
+import java.util.List;
+import java.util.Optional;
+
@Service
@RequiredArgsConstructor
public class UserService {
@@ -36,7 +37,7 @@ public UserCommand.Info registerUser(UserCommand.Create userCreate) {
@Transactional(readOnly = true)
public UserCommand.Info getUserByUsername(String username) {
return UserCommand.Info.of(userRepository.findByUsername(username)
- .orElseThrow(() -> InplaceException.of(UserErrorCode.NOT_FOUND)));
+ .orElseThrow(() -> InplaceException.of(UserErrorCode.NOT_FOUND)));
}
@Transactional
@@ -49,13 +50,13 @@ public Optional findUserByUsername(String username) {
public List getInfluencerIdsByUsername(Long userId) {
List likes = favoriteInfluencerRepository.findByUserId(userId);
return likes.stream().map(FavoriteInfluencer::getInfluencer).map(Influencer::getId)
- .toList();
+ .toList();
}
@Transactional
public void updateNickname(String nickname) {
User user = userRepository.findByUsername(AuthorizationUtil.getUsername()).orElseThrow(
- () -> InplaceException.of(UserErrorCode.NOT_FOUND)
+ () -> InplaceException.of(UserErrorCode.NOT_FOUND)
);
user.updateInfo(nickname);
diff --git a/src/main/java/team7/inplace/user/application/dto/UserCommand.java b/src/main/java/team7/inplace/user/application/dto/UserCommand.java
index 55dd4d11..5fde3a0a 100644
--- a/src/main/java/team7/inplace/user/application/dto/UserCommand.java
+++ b/src/main/java/team7/inplace/user/application/dto/UserCommand.java
@@ -8,15 +8,15 @@
public class UserCommand {
public record Create(
- String username,
- String nickname,
- UserType userType,
- Role role
+ String username,
+ String nickname,
+ UserType userType,
+ Role role
) {
public static UserCommand.Create of(KakaoOAuthResponse kakaoOAuthResponse) {
return new UserCommand.Create(kakaoOAuthResponse.getEmail(),
- kakaoOAuthResponse.getNickname(), UserType.KAKAO, Role.USER);
+ kakaoOAuthResponse.getNickname(), UserType.KAKAO, Role.USER);
}
public User toEntity() {
@@ -25,9 +25,9 @@ public User toEntity() {
}
public record Info(
- Long id,
- String username,
- Role role
+ Long id,
+ String username,
+ Role role
) {
public static Info of(User user) {
diff --git a/src/main/java/team7/inplace/user/application/dto/UserInfo.java b/src/main/java/team7/inplace/user/application/dto/UserInfo.java
index 2915a3d0..9da58c57 100644
--- a/src/main/java/team7/inplace/user/application/dto/UserInfo.java
+++ b/src/main/java/team7/inplace/user/application/dto/UserInfo.java
@@ -3,12 +3,12 @@
import team7.inplace.user.domain.User;
public record UserInfo(
- String nickname
+ String nickname
) {
public static UserInfo from(User user) {
return new UserInfo(
- user.getNickname()
+ user.getNickname()
);
}
}
diff --git a/src/main/java/team7/inplace/user/domain/User.java b/src/main/java/team7/inplace/user/domain/User.java
index de717cdb..9193920e 100644
--- a/src/main/java/team7/inplace/user/domain/User.java
+++ b/src/main/java/team7/inplace/user/domain/User.java
@@ -1,13 +1,6 @@
package team7.inplace.user.domain;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.EnumType;
-import jakarta.persistence.Enumerated;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.GenerationType;
-import jakarta.persistence.Id;
-import jakarta.persistence.Table;
+import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
diff --git a/src/main/java/team7/inplace/user/persistence/UserRepository.java b/src/main/java/team7/inplace/user/persistence/UserRepository.java
index 0f687587..903c01b4 100644
--- a/src/main/java/team7/inplace/user/persistence/UserRepository.java
+++ b/src/main/java/team7/inplace/user/persistence/UserRepository.java
@@ -1,10 +1,11 @@
package team7.inplace.user.persistence;
-import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import team7.inplace.user.domain.User;
+import java.util.Optional;
+
@Repository
public interface UserRepository extends JpaRepository {
diff --git a/src/main/java/team7/inplace/user/presentation/UserController.java b/src/main/java/team7/inplace/user/presentation/UserController.java
index 12ab5742..7f70a42a 100644
--- a/src/main/java/team7/inplace/user/presentation/UserController.java
+++ b/src/main/java/team7/inplace/user/presentation/UserController.java
@@ -6,11 +6,7 @@
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PatchMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import team7.inplace.user.application.UserFacade;
import team7.inplace.user.application.UserService;
import team7.inplace.user.presentation.dto.LikedInfluencerResponse;
@@ -28,7 +24,7 @@ public class UserController implements UserControllerApiSepc {
@PatchMapping("/nickname")
public ResponseEntity updateNickname(
- @RequestParam String nickname
+ @RequestParam String nickname
) {
userService.updateNickname(nickname);
return new ResponseEntity<>(HttpStatus.OK);
@@ -36,28 +32,28 @@ public ResponseEntity updateNickname(
@GetMapping("/influencers")
public ResponseEntity> getMyFavoriteInfluencers(
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PageableDefault(page = 0, size = 10) Pageable pageable
) {
Page influencers = userFacade.getMyFavoriteInfluencers(pageable)
- .map(LikedInfluencerResponse::from);
+ .map(LikedInfluencerResponse::from);
return new ResponseEntity<>(influencers, HttpStatus.OK);
}
@GetMapping("/places")
public ResponseEntity> getMyFavoritePlaces(
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PageableDefault(page = 0, size = 10) Pageable pageable
) {
Page places = userFacade.getMyFavoritePlaces(pageable)
- .map(LikedPlaceResponse::from);
+ .map(LikedPlaceResponse::from);
return new ResponseEntity<>(places, HttpStatus.OK);
}
@GetMapping("/reviews")
public ResponseEntity> getMyReviews(
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PageableDefault(page = 0, size = 10) Pageable pageable
) {
Page reviews = userFacade.getMyReviews(pageable)
- .map(MyReviewResponse::from);
+ .map(MyReviewResponse::from);
return new ResponseEntity<>(reviews, HttpStatus.OK);
}
diff --git a/src/main/java/team7/inplace/user/presentation/UserControllerApiSepc.java b/src/main/java/team7/inplace/user/presentation/UserControllerApiSepc.java
index a528c93a..fc37a7e1 100644
--- a/src/main/java/team7/inplace/user/presentation/UserControllerApiSepc.java
+++ b/src/main/java/team7/inplace/user/presentation/UserControllerApiSepc.java
@@ -14,26 +14,26 @@
public interface UserControllerApiSepc {
@Operation(
- summary = "유저 닉네임 변경",
- description = "RequestParameter로 받은 유저 닉네임으로 닉네임 변경"
+ summary = "유저 닉네임 변경",
+ description = "RequestParameter로 받은 유저 닉네임으로 닉네임 변경"
)
ResponseEntity updateNickname(
- @RequestParam String nickname
+ @RequestParam String nickname
);
@Operation(summary = "좋아요한 인플루언서 반환", description = "좋아요한 인플루언서를 반환합니다.")
ResponseEntity> getMyFavoriteInfluencers(
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PageableDefault(page = 0, size = 10) Pageable pageable
);
@Operation(summary = "좋아요한 장소 반환", description = "좋아요한 장소를 반환합니다.")
ResponseEntity> getMyFavoritePlaces(
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PageableDefault(page = 0, size = 10) Pageable pageable
);
@Operation(summary = "작성한 리뷰 반환", description = "작성한 리뷰를 반환합니다.")
ResponseEntity> getMyReviews(
- @PageableDefault(page = 0, size = 10) Pageable pageable
+ @PageableDefault(page = 0, size = 10) Pageable pageable
);
@Operation(summary = "유저 정보 반환", description = "유저 정보를 반환합니다.")
diff --git a/src/main/java/team7/inplace/user/presentation/dto/LikedInfluencerResponse.java b/src/main/java/team7/inplace/user/presentation/dto/LikedInfluencerResponse.java
index 3b25d8c1..db122195 100644
--- a/src/main/java/team7/inplace/user/presentation/dto/LikedInfluencerResponse.java
+++ b/src/main/java/team7/inplace/user/presentation/dto/LikedInfluencerResponse.java
@@ -3,20 +3,20 @@
import team7.inplace.influencer.application.dto.InfluencerInfo;
public record LikedInfluencerResponse(
- Long influencerId,
- String InfluencerName,
- String InfluencerImgUrl,
- String influencerJob,
- boolean likes
+ Long influencerId,
+ String InfluencerName,
+ String InfluencerImgUrl,
+ String influencerJob,
+ boolean likes
) {
public static LikedInfluencerResponse from(InfluencerInfo influencerInfo) {
return new LikedInfluencerResponse(
- influencerInfo.influencerId(),
- influencerInfo.influencerName(),
- influencerInfo.influencerImgUrl(),
- influencerInfo.influencerJob(),
- influencerInfo.likes()
+ influencerInfo.influencerId(),
+ influencerInfo.influencerName(),
+ influencerInfo.influencerImgUrl(),
+ influencerInfo.influencerJob(),
+ influencerInfo.likes()
);
}
}
diff --git a/src/main/java/team7/inplace/user/presentation/dto/LikedPlaceResponse.java b/src/main/java/team7/inplace/user/presentation/dto/LikedPlaceResponse.java
index 1e442571..c2a6827f 100644
--- a/src/main/java/team7/inplace/user/presentation/dto/LikedPlaceResponse.java
+++ b/src/main/java/team7/inplace/user/presentation/dto/LikedPlaceResponse.java
@@ -3,20 +3,20 @@
import team7.inplace.place.application.dto.LikedPlaceInfo;
public record LikedPlaceResponse(
- Long placeId,
- String placeName,
- String imageUrl,
- String influencerName,
- boolean likes
+ Long placeId,
+ String placeName,
+ String imageUrl,
+ String influencerName,
+ boolean likes
) {
public static LikedPlaceResponse from(LikedPlaceInfo likedPlaceInfo) {
return new LikedPlaceResponse(
- likedPlaceInfo.placeId(),
- likedPlaceInfo.placeName(),
- likedPlaceInfo.imageUrl(),
- likedPlaceInfo.influencerName(),
- likedPlaceInfo.likes()
+ likedPlaceInfo.placeId(),
+ likedPlaceInfo.placeName(),
+ likedPlaceInfo.imageUrl(),
+ likedPlaceInfo.influencerName(),
+ likedPlaceInfo.likes()
);
}
}
diff --git a/src/main/java/team7/inplace/user/presentation/dto/MyReviewResponse.java b/src/main/java/team7/inplace/user/presentation/dto/MyReviewResponse.java
index c6583143..97015541 100644
--- a/src/main/java/team7/inplace/user/presentation/dto/MyReviewResponse.java
+++ b/src/main/java/team7/inplace/user/presentation/dto/MyReviewResponse.java
@@ -1,24 +1,25 @@
package team7.inplace.user.presentation.dto;
-import java.util.Date;
import team7.inplace.review.application.dto.MyReviewInfo;
import team7.inplace.review.application.dto.MyReviewInfo.ReviewPlaceInfo;
+import java.util.Date;
+
public record MyReviewResponse(
- Long reviewId,
- boolean likes,
- String comment,
- Date createdDate,
- ReviewPlaceInfo place
+ Long reviewId,
+ boolean likes,
+ String comment,
+ Date createdDate,
+ ReviewPlaceInfo place
) {
public static MyReviewResponse from(MyReviewInfo reviewInfo) {
return new MyReviewResponse(
- reviewInfo.reviewId(),
- reviewInfo.likes(),
- reviewInfo.comment(),
- reviewInfo.createdDate(),
- reviewInfo.placeInfo()
+ reviewInfo.reviewId(),
+ reviewInfo.likes(),
+ reviewInfo.comment(),
+ reviewInfo.createdDate(),
+ reviewInfo.placeInfo()
);
}
}
diff --git a/src/main/java/team7/inplace/user/presentation/dto/UserInfoResponse.java b/src/main/java/team7/inplace/user/presentation/dto/UserInfoResponse.java
index 2cc7d4e9..728bbd42 100644
--- a/src/main/java/team7/inplace/user/presentation/dto/UserInfoResponse.java
+++ b/src/main/java/team7/inplace/user/presentation/dto/UserInfoResponse.java
@@ -3,12 +3,12 @@
import team7.inplace.user.application.dto.UserInfo;
public record UserInfoResponse(
- String nickname
+ String nickname
) {
public static UserInfoResponse from(UserInfo userInfo) {
return new UserInfoResponse(
- userInfo.nickname()
+ userInfo.nickname()
);
}
}
diff --git a/src/main/java/team7/inplace/video/domain/Video.java b/src/main/java/team7/inplace/video/domain/Video.java
index a4a5f66a..a645b55b 100644
--- a/src/main/java/team7/inplace/video/domain/Video.java
+++ b/src/main/java/team7/inplace/video/domain/Video.java
@@ -1,19 +1,14 @@
package team7.inplace.video.domain;
-import static jakarta.persistence.GenerationType.IDENTITY;
-import static lombok.AccessLevel.PROTECTED;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
+import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import team7.inplace.influencer.domain.Influencer;
import team7.inplace.place.domain.Place;
+import static jakarta.persistence.GenerationType.IDENTITY;
+import static lombok.AccessLevel.PROTECTED;
+
@Entity
@Getter
@NoArgsConstructor(access = PROTECTED)
diff --git a/src/main/java/team7/inplace/video/persistence/VideoRepository.java b/src/main/java/team7/inplace/video/persistence/VideoRepository.java
index 83fb10da..a9e79e59 100644
--- a/src/main/java/team7/inplace/video/persistence/VideoRepository.java
+++ b/src/main/java/team7/inplace/video/persistence/VideoRepository.java
@@ -1,5 +1,7 @@
package team7.inplace.video.persistence;
+import java.util.List;
+import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
@@ -7,10 +9,8 @@
import team7.inplace.place.domain.Place;
import team7.inplace.video.domain.Video;
-import java.util.List;
-import java.util.Optional;
-
public interface VideoRepository extends JpaRepository {
+
@Query("SELECT v FROM Video v JOIN FETCH v.place JOIN FETCH v.influencer ORDER BY v.viewCountIncrease DESC")
List findTop10ByOrderByViewCountIncreaseDesc(Pageable pageable);
@@ -23,12 +23,15 @@ public interface VideoRepository extends JpaRepository {
Optional findTopByPlaceOrderByIdDesc(Place place);
@Query(
- value = "SELECT v FROM Video v JOIN FETCH v.influencer WHERE v.place IS NULL",
- countQuery = "SELECT COUNT(v) FROM Video v"
+ value = "SELECT v FROM Video v JOIN FETCH v.influencer WHERE v.place IS NULL",
+ countQuery = "SELECT COUNT(v) FROM Video v"
)
Page findAllByPlaceIsNull(Pageable pageable);
List findByPlaceIdIn(List placeIds);
List findByPlaceId(Long placeId);
+
+ @Query("SELECT v FROM Video v JOIN FETCH v.influencer WHERE v.place.id IN :placeIds")
+ List findByPlaceIdInWithInfluencer(List placeIds);
}
diff --git a/src/main/java/team7/inplace/video/presentation/VideoController.java b/src/main/java/team7/inplace/video/presentation/VideoController.java
index 805439da..f4f97e61 100644
--- a/src/main/java/team7/inplace/video/presentation/VideoController.java
+++ b/src/main/java/team7/inplace/video/presentation/VideoController.java
@@ -6,12 +6,7 @@
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import team7.inplace.video.application.VideoFacade;
import team7.inplace.video.application.VideoService;
import team7.inplace.video.presentation.dto.VideoResponse;
diff --git a/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java b/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java
index 5df95dae..8a4e4523 100644
--- a/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java
+++ b/src/main/java/team7/inplace/video/presentation/VideoControllerApiSpec.java
@@ -9,7 +9,6 @@
import org.springframework.web.bind.annotation.RequestParam;
import team7.inplace.video.presentation.dto.VideoResponse;
-
import java.util.List;
public interface VideoControllerApiSpec {
diff --git a/src/main/java/team7/inplace/video/presentation/dto/VideoSearchParams.java b/src/main/java/team7/inplace/video/presentation/dto/VideoSearchParams.java
index fb272b1b..be49ffce 100644
--- a/src/main/java/team7/inplace/video/presentation/dto/VideoSearchParams.java
+++ b/src/main/java/team7/inplace/video/presentation/dto/VideoSearchParams.java
@@ -19,7 +19,7 @@ private VideoSearchParams(String longitude, String latitude) {
);
}
- public static VideoSearchParams from(String longitude, String latitude){
+ public static VideoSearchParams from(String longitude, String latitude) {
return new VideoSearchParams(longitude, latitude);
}
diff --git a/src/main/resources/sql/schema.sql b/src/main/resources/sql/schema.sql
index 333db63e..7beb77b0 100644
--- a/src/main/resources/sql/schema.sql
+++ b/src/main/resources/sql/schema.sql
@@ -4,7 +4,9 @@ create table influencer
primary key,
job varchar(20) not null,
name varchar(30) not null,
- img_url text not null
+ img_url text not null,
+
+ FULLTEXT INDEX ft_name_ngram (name) WITH PARSER ngram
);
create table places
@@ -21,7 +23,9 @@ create table places
longitude text not null,
menu_img_url text null,
category enum ('CAFE', 'JAPANESE', 'KOREAN', 'NONE', 'RESTAURANT', 'WESTERN') not null,
- index idx_long_lat (longitude(15), latitude(15))
+
+ FULLTEXT INDEX ft_name_ngram (name) WITH PARSER ngram,
+ INDEX idx_long_lat (longitude(15), latitude(15))
);
create table places_menuboardphotourl_list
diff --git a/src/test/java/team7/inplace/config/annotation/CustomRepositoryTest.java b/src/test/java/team7/inplace/config/annotation/CustomRepositoryTest.java
index 0232a2d0..02cdc70c 100644
--- a/src/test/java/team7/inplace/config/annotation/CustomRepositoryTest.java
+++ b/src/test/java/team7/inplace/config/annotation/CustomRepositoryTest.java
@@ -1,22 +1,23 @@
package team7.inplace.config.annotation;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.TestPropertySource;
@Target(ElementType.TYPE) // 클래스에 붙일 수 있도록 설정
@Retention(RetentionPolicy.RUNTIME) // 런타임에 유지
@SpringBootTest // SpringBootTest를 포함
@TestPropertySource(properties = {
- "spring.datasource.url=jdbc:h2:mem:testdb",
- "spring.datasource.driver-class-name=org.h2.Driver",
- "spring.datasource.username=sa",
- "spring.datasource.password=",
- "spring.jpa.hibernate.ddl-auto=create-drop",
- "spring.sql.init.mode=never"
+ "spring.datasource.url=jdbc:h2:mem:testdb",
+ "spring.datasource.driver-class-name=org.h2.Driver",
+ "spring.datasource.username=sa",
+ "spring.datasource.password=",
+ "spring.jpa.hibernate.ddl-auto=create-drop",
+ "spring.sql.init.mode=never"
})
public @interface CustomRepositoryTest {
diff --git a/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java b/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java
index 4f94f611..4d0d0652 100644
--- a/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java
+++ b/src/test/java/team7/inplace/crawling/application/AddressUtilTest.java
@@ -1,11 +1,11 @@
package team7.inplace.crawling.application;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import team7.inplace.admin.crawling.application.AddressUtil;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
class AddressUtilTest {
@DisplayName("주소 추출 테스트 1")
diff --git a/src/test/java/team7/inplace/crawling/client/KakaoMapClientTest.java b/src/test/java/team7/inplace/crawling/client/KakaoMapClientTest.java
index b553b875..4afc626f 100644
--- a/src/test/java/team7/inplace/crawling/client/KakaoMapClientTest.java
+++ b/src/test/java/team7/inplace/crawling/client/KakaoMapClientTest.java
@@ -1,13 +1,13 @@
package team7.inplace.crawling.client;
-import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
+import static org.assertj.core.api.Assertions.assertThat;
+
@SpringBootTest
@ActiveProfiles("test")
class KakaoMapClientTest {
diff --git a/src/test/java/team7/inplace/crawling/client/YoutubeClientTest.java b/src/test/java/team7/inplace/crawling/client/YoutubeClientTest.java
index ef8c0675..4f8f16bd 100644
--- a/src/test/java/team7/inplace/crawling/client/YoutubeClientTest.java
+++ b/src/test/java/team7/inplace/crawling/client/YoutubeClientTest.java
@@ -1,7 +1,5 @@
package team7.inplace.crawling.client;
-import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -9,6 +7,8 @@
import org.springframework.test.context.ActiveProfiles;
import team7.inplace.admin.crawling.client.YoutubeClient;
+import static org.assertj.core.api.Assertions.assertThat;
+
@SpringBootTest
@ActiveProfiles("test")
class YoutubeClientTest {
diff --git a/src/test/java/team7/inplace/influencer/InfluencerControllerTest.java b/src/test/java/team7/inplace/influencer/InfluencerControllerTest.java
index 3b067cef..8d2d1bfb 100644
--- a/src/test/java/team7/inplace/influencer/InfluencerControllerTest.java
+++ b/src/test/java/team7/inplace/influencer/InfluencerControllerTest.java
@@ -1,15 +1,6 @@
package team7.inplace.influencer;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
import com.fasterxml.jackson.databind.ObjectMapper;
-import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -29,6 +20,16 @@
import team7.inplace.influencer.presentation.InfluencerController;
import team7.inplace.influencer.presentation.dto.InfluencerResponse;
+import java.util.List;
+
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
@ExtendWith(MockitoExtension.class)
public class InfluencerControllerTest {
@@ -46,24 +47,24 @@ public class InfluencerControllerTest {
public void setUp() {
PageableHandlerMethodArgumentResolver pageableArgumentResolver = new PageableHandlerMethodArgumentResolver();
mockMvc = MockMvcBuilders.standaloneSetup(influencerController)
- .setCustomArgumentResolvers(pageableArgumentResolver)
- .build();
+ .setCustomArgumentResolvers(pageableArgumentResolver)
+ .build();
objectMapper = new ObjectMapper();
}
@Test
public void getAllInfluencersTest() throws Exception {
InfluencerInfo influencerInfo1 = new InfluencerInfo(1L, "influencer1",
- "imgUrl1", "job1", false);
+ "imgUrl1", "job1", false);
InfluencerInfo influencerInfo2 = new InfluencerInfo(2L, "influencer2",
- "imgUrl2", "job2", false);
+ "imgUrl2", "job2", false);
// Pageable 객체 생성
Pageable pageable = PageRequest.of(0, 10);
// Page 객체 생성 (서비스에서 반환될 객체)
Page influencerInfoPage = new PageImpl<>(
- List.of(influencerInfo1, influencerInfo2), pageable, 2);
+ List.of(influencerInfo1, influencerInfo2), pageable, 2);
// influencerService.getAllInfluencers(pageable)의 반환값을 모킹
given(influencerService.getAllInfluencers(pageable)).willReturn(influencerInfoPage);
@@ -74,12 +75,12 @@ public void getAllInfluencersTest() throws Exception {
// API 호출 및 검증
mockMvc.perform(get("/influencers")
- .contentType(MediaType.APPLICATION_JSON)
- .param("page", "0") // 페이지 번호
- .param("size", "10")) // 페이지 크기
- .andDo(print())
- .andExpect(status().isOk()) // HTTP 200 OK 응답 확인
- .andExpect(content().json(expectedJson)); // JSON 응답이 예상값과 일치하는지 확인
+ .contentType(MediaType.APPLICATION_JSON)
+ .param("page", "0") // 페이지 번호
+ .param("size", "10")) // 페이지 크기
+ .andDo(print())
+ .andExpect(status().isOk()) // HTTP 200 OK 응답 확인
+ .andExpect(content().json(expectedJson)); // JSON 응답이 예상값과 일치하는지 확인
// influencerService.getAllInfluencers(pageable) 메서드가 한 번 호출됐는지 검증
verify(influencerService, times(1)).getAllInfluencers(pageable);
diff --git a/src/test/java/team7/inplace/influencer/InfluencerRepositoryTest.java b/src/test/java/team7/inplace/influencer/InfluencerRepositoryTest.java
index 26f38f8e..397b08eb 100644
--- a/src/test/java/team7/inplace/influencer/InfluencerRepositoryTest.java
+++ b/src/test/java/team7/inplace/influencer/InfluencerRepositoryTest.java
@@ -1,14 +1,15 @@
package team7.inplace.influencer;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import team7.inplace.config.annotation.CustomRepositoryTest;
import team7.inplace.influencer.domain.Influencer;
import team7.inplace.influencer.persistence.InfluencerRepository;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
@CustomRepositoryTest
public class InfluencerRepositoryTest {
diff --git a/src/test/java/team7/inplace/influencer/InfluencerServiceTest.java b/src/test/java/team7/inplace/influencer/InfluencerServiceTest.java
index fdedeafc..f1db88a2 100644
--- a/src/test/java/team7/inplace/influencer/InfluencerServiceTest.java
+++ b/src/test/java/team7/inplace/influencer/InfluencerServiceTest.java
@@ -1,16 +1,6 @@
package team7.inplace.influencer;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mockStatic;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
@@ -33,6 +23,15 @@
import team7.inplace.user.domain.User;
import team7.inplace.user.domain.UserType;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.*;
+
@ExtendWith(MockitoExtension.class)
public class InfluencerServiceTest {
@@ -61,11 +60,11 @@ public void getAllInfluencersTest_NotLoggedIn() {
assertThat(influencerInfoPage).hasSize(2);
assertThat(influencerInfoPage.getContent().get(0))
- .extracting("influencerName", "likes")
- .containsExactly(influencer1.getName(), false);
+ .extracting("influencerName", "likes")
+ .containsExactly(influencer1.getName(), false);
assertThat(influencerInfoPage.getContent().get(1))
- .extracting("influencerName", "likes")
- .containsExactly(influencer2.getName(), false);
+ .extracting("influencerName", "likes")
+ .containsExactly(influencer2.getName(), false);
authorizationUtil.close();
}
@@ -79,7 +78,7 @@ public void getAllInfluencersTest_LoggedIn() {
Influencer influencer2 = new Influencer(2L, "influencer2", "imgUrl2", "job2");
Influencer influencer3 = new Influencer(3L, "influencer3", "imgUrl3", "job3");
Page influencersPage = new PageImpl<>(
- List.of(influencer1, influencer2, influencer3));
+ List.of(influencer1, influencer2, influencer3));
Long userId = 1L;
User user = new User("name", "password", "nickname", UserType.KAKAO, Role.USER);
@@ -93,20 +92,20 @@ public void getAllInfluencersTest_LoggedIn() {
FavoriteInfluencer favoriteInfluencer2 = new FavoriteInfluencer(user, influencer3);
favoriteInfluencer2.updateLike(true);
given(favoriteInfluencerRepository.findLikedInfluencerIdsByUserId(userId)).willReturn(
- Set.of(2L, 3L));
+ Set.of(2L, 3L));
Page influencerInfoPage = influencerService.getAllInfluencers(pageable);
assertThat(influencerInfoPage).hasSize(3);
assertThat(influencerInfoPage.getContent().get(0))
- .extracting("influencerName", "likes")
- .containsExactly(influencer2.getName(), true);
+ .extracting("influencerName", "likes")
+ .containsExactly(influencer2.getName(), true);
assertThat(influencerInfoPage.getContent().get(1))
- .extracting("influencerName", "likes")
- .containsExactly(influencer3.getName(), true);
+ .extracting("influencerName", "likes")
+ .containsExactly(influencer3.getName(), true);
assertThat(influencerInfoPage.getContent().get(2))
- .extracting("influencerName", "likes")
- .containsExactly(influencer1.getName(), false);
+ .extracting("influencerName", "likes")
+ .containsExactly(influencer1.getName(), false);
authorizationUtil.close();
}
@@ -126,7 +125,7 @@ public void createInfluencerTest() {
@Test
public void updateInfluencerTest() {
InfluencerCommand command = new InfluencerCommand("updatedName", "updatedImgUrl",
- "updatedJob");
+ "updatedJob");
Influencer influencer = new Influencer(1L, "name", "imgUrl", "job");
given(influencerRepository.findById(any(Long.class))).willReturn(Optional.of(influencer));
diff --git a/src/test/java/team7/inplace/likedPlace/persistence/LikedPlaceRepositoryTest.java b/src/test/java/team7/inplace/likedPlace/persistence/LikedPlaceRepositoryTest.java
index bcf8bb8e..d68ba7ff 100644
--- a/src/test/java/team7/inplace/likedPlace/persistence/LikedPlaceRepositoryTest.java
+++ b/src/test/java/team7/inplace/likedPlace/persistence/LikedPlaceRepositoryTest.java
@@ -1,12 +1,7 @@
package team7.inplace.likedPlace.persistence;
-import static org.assertj.core.api.Assertions.assertThat;
-
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
-import java.time.LocalDateTime;
-import java.util.Arrays;
-import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -21,6 +16,12 @@
import team7.inplace.user.domain.User;
import team7.inplace.user.domain.UserType;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Optional;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
@CustomRepositoryTest
@Transactional
class LikedPlaceRepositoryTest {
@@ -42,19 +43,19 @@ public void init() {
// 장소 생성 및 persist
place1 = new Place("Place 1",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "카페",
- "Address 1|Address 2|Address 3",
- "10.0", "10.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "카페",
+ "Address 1|Address 2|Address 3",
+ "10.0", "10.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
entityManager.persist(place1);
@@ -72,7 +73,7 @@ public void test1() {
// when
Optional actual = likedPlaceRepository.findByUserIdAndPlaceId(
- user1.getId(), place1.getId()
+ user1.getId(), place1.getId()
);
// then
@@ -101,7 +102,7 @@ public void test2() {
// then
LikedPlace updatedLikedPlace = likedPlaceRepository.findByUserIdAndPlaceId(
- user1.getId(), place1.getId()
+ user1.getId(), place1.getId()
).orElseThrow(() -> InplaceException.of(LikedPlaceErrorCode.NOT_FOUND));
assertThat(updatedLikedPlace.isLiked()).isTrue();
diff --git a/src/test/java/team7/inplace/place/application/PlaceServiceTest.java b/src/test/java/team7/inplace/place/application/PlaceServiceTest.java
index f414e503..fce4c233 100644
--- a/src/test/java/team7/inplace/place/application/PlaceServiceTest.java
+++ b/src/test/java/team7/inplace/place/application/PlaceServiceTest.java
@@ -38,6 +38,8 @@
import team7.inplace.place.domain.Category;
import team7.inplace.place.domain.Place;
import team7.inplace.place.persistence.PlaceRepository;
+import team7.inplace.review.domain.Review;
+import team7.inplace.review.persistence.ReviewRepository;
import team7.inplace.security.util.AuthorizationUtil;
import team7.inplace.user.domain.Role;
import team7.inplace.user.domain.User;
@@ -57,13 +59,16 @@ class PlaceServiceTest {
private UserRepository userRepository;
@Mock
private LikedPlaceRepository likedPlaceRepository;
+ @Mock
+ private ReviewRepository reviewRepository;
@InjectMocks
private PlaceService placeService;
private Place place1, place2, place3, place4;
private Video video1, video2, video3;
private Influencer influencer1, influencer2;
- private User user1, user2;
+ private User user1, user2, user3;
+ private Review review1, review2, review3;
// * 테스트 Place 좌표 (longitude, latitude)
// * (10.0, 10.0) -> video1 -> 성시경
@@ -191,6 +196,17 @@ public void init() throws NoSuchFieldException, IllegalAccessException {
userIdField.set(user1, 1L);
user2 = new User("user2", "pass2", "nick2", UserType.KAKAO, Role.USER);
userIdField.set(user2, 2L);
+ user3 = new User("user3", "pass3", "nick3", UserType.KAKAO, Role.USER);
+ userIdField.set(user3, 3L);
+
+ Field reviewIdField = Review.class.getDeclaredField("id");
+ reviewIdField.setAccessible(true);
+ review1 = new Review(user1, place4, true, "comment1");
+ reviewIdField.set(review1, 1L);
+ review2 = new Review(user2, place4, false, "comment1");
+ reviewIdField.set(review2, 2L);
+ review3 = new Review(user3, place4, true, "comment1");
+ reviewIdField.set(review3, 3L);
authorizationUtil = mockStatic(AuthorizationUtil.class);
}
@@ -389,13 +405,16 @@ public void test7() {
given(AuthorizationUtil.getUsername()).willReturn(null);
PlaceDetailInfo expected = PlaceDetailInfo.from(place4,
- influencer2, video2, false);
+ influencer2, video2, false, 2, 1);
when(placeRepository.findById(place4.getId()))
.thenReturn(Optional.of(place4));
when(videoRepository.findByPlaceId(place4.getId()))
.thenReturn(Arrays.asList(video2, video3));
-
+ when(reviewRepository.countByPlaceIdAndIsLikedTrue(place4.getId()))
+ .thenReturn(2);
+ when(reviewRepository.countByPlaceIdAndIsLikedFalse(place4.getId()))
+ .thenReturn(1);
// when
PlaceDetailInfo result = placeService.getPlaceDetailInfo(4L);
@@ -408,6 +427,11 @@ public void test7() {
expected.placeInfo().influencerName());
assertThat(result.placeInfo().likes()).isEqualTo(
expected.placeInfo().likes());
+ assertThat(result.placeLikes().like())
+ .isEqualTo(expected.placeLikes().like());
+ assertThat(result.placeLikes().dislike())
+ .isEqualTo(expected.placeLikes().dislike());
+
assertThat(result.facilityInfo()).isEqualTo(
objectMapper.createObjectNode().put("message", "NO DATA"));
}
@@ -499,12 +523,16 @@ public void test10() {
given(AuthorizationUtil.getUserId()).willReturn(1L);
PlaceDetailInfo expected = PlaceDetailInfo.from(place4,
- influencer2, video2, false);
+ influencer2, video2, false, 2, 1);
when(placeRepository.findById(place4.getId()))
.thenReturn(Optional.of(place4));
when(videoRepository.findByPlaceId(place4.getId()))
.thenReturn(Arrays.asList(video2, video3));
+ when(reviewRepository.countByPlaceIdAndIsLikedTrue(place4.getId()))
+ .thenReturn(2);
+ when(reviewRepository.countByPlaceIdAndIsLikedFalse(place4.getId()))
+ .thenReturn(1);
// when
PlaceDetailInfo result = placeService.getPlaceDetailInfo(4L);
@@ -527,7 +555,7 @@ public void test11() {
given(AuthorizationUtil.getUserId()).willReturn(user1.getId());
PlaceDetailInfo expected = PlaceDetailInfo.from(place4,
- influencer2, video2, true);
+ influencer2, video2, true, 2, 1);
when(placeRepository.findById(place4.getId()))
.thenReturn(Optional.of(place4));
@@ -543,6 +571,10 @@ public void test11() {
.thenReturn(Optional.of(saved));
return saved;
}).when(likedPlaceRepository).save(any(LikedPlace.class));
+ when(reviewRepository.countByPlaceIdAndIsLikedTrue(place4.getId()))
+ .thenReturn(2);
+ when(reviewRepository.countByPlaceIdAndIsLikedFalse(place4.getId()))
+ .thenReturn(1);
// when
PlaceLikeCommand placeLikeCommand = new PlaceLikeCommand(place4.getId(), true);
@@ -560,6 +592,10 @@ public void test11() {
expected.placeInfo().influencerName());
assertThat(result.placeInfo().likes()).isEqualTo(
expected.placeInfo().likes());
+ assertThat(result.placeLikes().like())
+ .isEqualTo(expected.placeLikes().like());
+ assertThat(result.placeLikes().dislike())
+ .isEqualTo(expected.placeLikes().dislike());
}
// LikedPlace 테스트
diff --git a/src/test/java/team7/inplace/place/persistence/PlaceRepositoryTest.java b/src/test/java/team7/inplace/place/persistence/PlaceRepositoryTest.java
index a9fb846c..1b3acff4 100644
--- a/src/test/java/team7/inplace/place/persistence/PlaceRepositoryTest.java
+++ b/src/test/java/team7/inplace/place/persistence/PlaceRepositoryTest.java
@@ -1,12 +1,7 @@
package team7.inplace.place.persistence;
-import static org.assertj.core.api.Assertions.assertThat;
-
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
-import java.time.LocalDateTime;
-import java.util.Arrays;
-import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -21,6 +16,12 @@
import team7.inplace.place.domain.Place;
import team7.inplace.video.domain.Video;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
@CustomRepositoryTest
@Transactional
@@ -56,67 +57,67 @@ class PlaceRepositoryTest {
@BeforeEach
public void init() {
Place place1 = new Place("Place 1",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "카페",
- "Address 1|Address 2|Address 3",
- "10.0", "10.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "카페",
+ "Address 1|Address 2|Address 3",
+ "10.0", "10.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
Place place2 = new Place("Place 2",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "일식",
- "Address 1|Address 2|Address 3",
- "10.0", "50.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "일식",
+ "Address 1|Address 2|Address 3",
+ "10.0", "50.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
Place place3 = new Place("Place 3",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "카페",
- "Address 1|Address 2|Address 3",
- "10.0", "100.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "카페",
+ "Address 1|Address 2|Address 3",
+ "10.0", "100.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
Place place4 = new Place("Place 4",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "일식",
- "Address 1|Address 2|Address 3",
- "50.0", "50.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "일식",
+ "Address 1|Address 2|Address 3",
+ "50.0", "50.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
entityManager.persist(place1);
@@ -145,9 +146,9 @@ public void test1() {
// when
Page foundPlaces = placeRepository.findPlacesByDistance(
- longitude,
- latitude,
- pageable
+ longitude,
+ latitude,
+ pageable
);
System.out.println(foundPlaces);
@@ -170,15 +171,15 @@ public void test2() {
// when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
assertThat(foundPlaces.getTotalElements()).isEqualTo(3);
// Then
@@ -194,20 +195,20 @@ public void test2() {
public void test3() {
// given
List categories = Arrays.asList(Category.CAFE.getName(),
- Category.JAPANESE.getName());
+ Category.JAPANESE.getName());
List influencers = null;
// when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
// Then
assertThat(foundPlaces).hasSize(3);
@@ -227,15 +228,15 @@ public void test4() {
List influencers = null;
// when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
// Then
assertThat(foundPlaces).hasSize(2);
@@ -254,15 +255,15 @@ public void test5() {
//when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
//then
@@ -280,15 +281,15 @@ public void test6() {
//when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
//then
@@ -305,15 +306,15 @@ public void test7() {
//when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
//then
@@ -335,15 +336,15 @@ public void test8() {
// when
Page foundPlaces = placeRepository.findPlacesByDistanceAndFilters(
- topLeftLongitude,
- topLeftLatitude,
- bottomRightLongitude,
- bottomRightLatitude,
- longitude,
- latitude,
- categories,
- influencers,
- pageable
+ topLeftLongitude,
+ topLeftLatitude,
+ bottomRightLongitude,
+ bottomRightLatitude,
+ longitude,
+ latitude,
+ categories,
+ influencers,
+ pageable
);
// Then
// pagenation
diff --git a/src/test/java/team7/inplace/review/ReviewServiceTest.java b/src/test/java/team7/inplace/review/ReviewServiceTest.java
index b3bc2644..b662624b 100644
--- a/src/test/java/team7/inplace/review/ReviewServiceTest.java
+++ b/src/test/java/team7/inplace/review/ReviewServiceTest.java
@@ -1,18 +1,5 @@
package team7.inplace.review;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.mockStatic;
-import static org.mockito.Mockito.verify;
-
-import java.time.LocalDateTime;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@@ -41,6 +28,18 @@
import team7.inplace.user.domain.UserType;
import team7.inplace.user.persistence.UserRepository;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.BDDMockito.given;
+import static org.mockito.Mockito.*;
+
@ExtendWith(MockitoExtension.class)
public class ReviewServiceTest {
@@ -76,13 +75,13 @@ void setUp() {
user = new User("name", "password", "nickname", UserType.KAKAO, Role.USER);
place = new Place("name", "facility", "menuImgUrl", "category",
- "Address 1|Address 2|Address 3", "x", "y",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList("menuBoard1.url", "menuBoard2.url")
+ "Address 1|Address 2|Address 3", "x", "y",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList("menuBoard1.url", "menuBoard2.url")
);
command = new ReviewCommand(isLiked, comment);
@@ -119,8 +118,8 @@ void createReviewTest_ReviewAlreadyExists() {
given(reviewRepository.existsByUserIdAndPlaceId(userId, placeId)).willReturn(true);
assertThatThrownBy(() -> reviewService.createReview(placeId, command))
- .isInstanceOf(InplaceException.class)
- .hasMessage(ReviewErrorCode.REVIEW_ALREADY_EXISTS.getMessage());
+ .isInstanceOf(InplaceException.class)
+ .hasMessage(ReviewErrorCode.REVIEW_ALREADY_EXISTS.getMessage());
authorizationUtil.close();
}
@@ -141,8 +140,8 @@ void getReviews_LoggedIn() {
Page result = reviewService.getReviews(placeId, pageable);
assertThat(result.getContent().get(0))
- .extracting("comment", "mine")
- .containsExactly(comment, true);
+ .extracting("comment", "mine")
+ .containsExactly(comment, true);
authorizationUtil.close();
}
@@ -161,8 +160,8 @@ void getReviews_NotLoggedIn() {
Page result = reviewService.getReviews(placeId, pageable);
assertThat(result.getContent().get(0))
- .extracting("comment", "mine")
- .containsExactly(comment, false);
+ .extracting("comment", "mine")
+ .containsExactly(comment, false);
authorizationUtil.close();
}
@@ -182,8 +181,8 @@ void deleteReview_NotOwner() {
given(userMock.getId()).willReturn(1L); // 리뷰의 userId가 1L
assertThatThrownBy(() -> reviewService.deleteReview(reviewId))
- .isInstanceOf(InplaceException.class)
- .hasMessage(ReviewErrorCode.NOT_OWNER.getMessage());
+ .isInstanceOf(InplaceException.class)
+ .hasMessage(ReviewErrorCode.NOT_OWNER.getMessage());
authorizationUtil.close();
}
diff --git a/src/test/java/team7/inplace/review/persistence/ReviewRepositoryTest.java b/src/test/java/team7/inplace/review/persistence/ReviewRepositoryTest.java
new file mode 100644
index 00000000..09f0972a
--- /dev/null
+++ b/src/test/java/team7/inplace/review/persistence/ReviewRepositoryTest.java
@@ -0,0 +1,91 @@
+package team7.inplace.review.persistence;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.PersistenceContext;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+import team7.inplace.config.annotation.CustomRepositoryTest;
+import team7.inplace.place.domain.Place;
+import team7.inplace.review.domain.Review;
+import team7.inplace.user.domain.Role;
+import team7.inplace.user.domain.User;
+import team7.inplace.user.domain.UserType;
+
+@CustomRepositoryTest
+@Transactional
+class ReviewRepositoryTest {
+
+ @PersistenceContext
+ EntityManager entityManager;
+
+ @Autowired
+ private ReviewRepository reviewRepository;
+
+ @BeforeEach
+ void init() {
+ Place place1 = new Place("Place 1",
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "카페",
+ "Address 1|Address 2|Address 3",
+ "10.0", "10.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
+ );
+
+ entityManager.persist(place1);
+
+ User user1 = new User("user1", "pass1", "nick1", UserType.KAKAO, Role.USER);
+ User user2 = new User("user2", "pass1", "nick1", UserType.KAKAO, Role.USER);
+ User user3 = new User("user3", "pass1", "nick1", UserType.KAKAO, Role.USER);
+ User user4 = new User("user4", "pass1", "nick1", UserType.KAKAO, Role.USER);
+
+ entityManager.persist(user1);
+ entityManager.persist(user2);
+ entityManager.persist(user3);
+ entityManager.persist(user4);
+
+ Review review1 = new Review(user1, place1, true, "comment1");
+ Review review2 = new Review(user2, place1, true, "comment2");
+ Review review3 = new Review(user3, place1, false, "comment3");
+ Review review4 = new Review(user4, place1, true, "comment4");
+
+ entityManager.persist(review1);
+ entityManager.persist(review2);
+ entityManager.persist(review3);
+ entityManager.persist(review4);
+
+ entityManager.flush();
+ entityManager.clear();
+ }
+
+ @Test
+ @DisplayName("like true false test")
+ public void checkLikedDisliked() {
+ //given
+ //when
+ int likes = reviewRepository.countByPlaceIdAndIsLikedTrue(
+ 1L);
+
+ int dislikes = reviewRepository.countByPlaceIdAndIsLikedFalse(
+ 1L);
+
+ //then
+ assertThat(likes).isEqualTo(3);
+ assertThat(dislikes).isEqualTo(1);
+ }
+}
diff --git a/src/test/java/team7/inplace/security/config/CorsTest.java b/src/test/java/team7/inplace/security/config/CorsTest.java
index 0103763a..36b6fcac 100644
--- a/src/test/java/team7/inplace/security/config/CorsTest.java
+++ b/src/test/java/team7/inplace/security/config/CorsTest.java
@@ -1,9 +1,5 @@
package team7.inplace.security.config;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -11,6 +7,10 @@
import org.springframework.http.HttpHeaders;
import org.springframework.test.web.servlet.MockMvc;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
@SpringBootTest
@AutoConfigureMockMvc
class CorsTest {
@@ -21,12 +21,12 @@ class CorsTest {
@Test
void cors() throws Exception {
mockMvc.perform(
- get("/places/categories")
- .header(HttpHeaders.ORIGIN, "https://www.inplace.my")
- .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
- .header(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")
- )
- .andExpect(status().isOk())
- .andDo(print());
+ get("/places/categories")
+ .header(HttpHeaders.ORIGIN, "https://www.inplace.my")
+ .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
+ .header(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true")
+ )
+ .andExpect(status().isOk())
+ .andDo(print());
}
}
diff --git a/src/test/java/team7/inplace/security/config/SecurityConfigTest.java b/src/test/java/team7/inplace/security/config/SecurityConfigTest.java
index 4bdd5a06..28e59d7b 100644
--- a/src/test/java/team7/inplace/security/config/SecurityConfigTest.java
+++ b/src/test/java/team7/inplace/security/config/SecurityConfigTest.java
@@ -1,10 +1,5 @@
package team7.inplace.security.config;
-import static org.hamcrest.Matchers.containsString;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
-
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
@@ -13,6 +8,11 @@
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
+import static org.hamcrest.Matchers.containsString;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
+
@SpringBootTest
@AutoConfigureMockMvc
class SecurityConfigTest {
@@ -24,29 +24,29 @@ class SecurityConfigTest {
@WithMockUser(roles = "USER")
void testAdminEndpoints() throws Exception {
mockMvc.perform(get("/admin/video"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(get("/admin/error-logs"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(post("/api/error-logs/1/video"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(get("/cicd"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(post("/crawling/video/1/place/1"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
}
@Test
@WithAnonymousUser
void testAnonymousEndpoints() throws Exception {
mockMvc.perform(get("/admin/video"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(get("/admin/error-logs"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(post("/api/error-logs/1/video"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(get("/cicd"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
mockMvc.perform(post("/influencers/likes"))
- .andExpect(header().string("Location", containsString("inplace.my")));
+ .andExpect(header().string("Location", containsString("inplace.my")));
}
}
diff --git a/src/test/java/team7/inplace/security/util/AuthorizationUtilTest.java b/src/test/java/team7/inplace/security/util/AuthorizationUtilTest.java
index 0f691c0e..c9dac322 100644
--- a/src/test/java/team7/inplace/security/util/AuthorizationUtilTest.java
+++ b/src/test/java/team7/inplace/security/util/AuthorizationUtilTest.java
@@ -1,7 +1,5 @@
package team7.inplace.security.util;
-import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
@@ -12,6 +10,8 @@
import team7.inplace.security.application.dto.CustomOAuth2User;
import team7.inplace.user.domain.Role;
+import static org.assertj.core.api.Assertions.assertThat;
+
class AuthorizationUtilTest {
@AfterEach
@@ -45,14 +45,14 @@ void tearDown() {
private void setAnonymousUser() {
Authentication authentication = new AnonymousAuthenticationToken("key", "anonymous",
- AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
+ AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
SecurityContextHolder.getContext().setAuthentication(authentication);
}
private void setUser() {
CustomOAuth2User customOAuth2User = new CustomOAuth2User("test", 1L, Role.USER.getRoles());
Authentication authentication = new UsernamePasswordAuthenticationToken(customOAuth2User,
- null);
+ null);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
}
diff --git a/src/test/java/team7/inplace/security/util/JwtUtilTest.java b/src/test/java/team7/inplace/security/util/JwtUtilTest.java
index 16019835..1e5a6391 100644
--- a/src/test/java/team7/inplace/security/util/JwtUtilTest.java
+++ b/src/test/java/team7/inplace/security/util/JwtUtilTest.java
@@ -1,19 +1,20 @@
package team7.inplace.security.util;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertAll;
-
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.Jwts.SIG;
-import java.nio.charset.StandardCharsets;
-import java.util.Date;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import team7.inplace.security.config.JwtProperties;
import team7.inplace.user.domain.Role;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
class JwtUtilTest {
String testSecretKey = "testKeyTestKeyTestKeyTestKeyTestKeyTestKey";
@@ -23,7 +24,7 @@ class JwtUtilTest {
@BeforeEach
void setUp() {
jwtProperties = new JwtProperties(testSecretKey, 60000L,
- 180000L);
+ 180000L);
jwtUtil = new JwtUtil(jwtProperties);
}
@@ -51,12 +52,12 @@ void getInfoTests() {
String refreshToken = jwtUtil.createRefreshToken(username, userId, Role.USER.getRoles());
assertAll(
- () -> assertThat(jwtUtil.getUsername(accessToken)).isEqualTo(username),
- () -> assertThat(jwtUtil.getId(accessToken)).isEqualTo(userId),
- () -> assertThat(jwtUtil.getRoles(accessToken)).isEqualTo(Role.USER.getRoles()),
- () -> assertThat(jwtUtil.getUsername(refreshToken)).isEqualTo(username),
- () -> assertThat(jwtUtil.getId(refreshToken)).isEqualTo(userId),
- () -> assertThat(jwtUtil.getRoles(refreshToken)).isEqualTo(Role.USER.getRoles())
+ () -> assertThat(jwtUtil.getUsername(accessToken)).isEqualTo(username),
+ () -> assertThat(jwtUtil.getId(accessToken)).isEqualTo(userId),
+ () -> assertThat(jwtUtil.getRoles(accessToken)).isEqualTo(Role.USER.getRoles()),
+ () -> assertThat(jwtUtil.getUsername(refreshToken)).isEqualTo(username),
+ () -> assertThat(jwtUtil.getId(refreshToken)).isEqualTo(userId),
+ () -> assertThat(jwtUtil.getRoles(refreshToken)).isEqualTo(Role.USER.getRoles())
);
}
@@ -64,12 +65,12 @@ void getInfoTests() {
void 토큰이_만료된_경우() {
Date expiredDate = new Date(System.currentTimeMillis() - 3600 * 1000);
SecretKey secretKey = new SecretKeySpec(
- jwtProperties.secret().getBytes(StandardCharsets.UTF_8),
- SIG.HS256.key().build().getAlgorithm());
+ jwtProperties.secret().getBytes(StandardCharsets.UTF_8),
+ SIG.HS256.key().build().getAlgorithm());
String expiredToken = Jwts.builder()
- .expiration(expiredDate)
- .signWith(secretKey)
- .compact();
+ .expiration(expiredDate)
+ .signWith(secretKey)
+ .compact();
assertThat(jwtUtil.isNotExpired(expiredToken)).isFalse();
}
diff --git a/src/test/java/team7/inplace/video/application/VideoServiceTest.java b/src/test/java/team7/inplace/video/application/VideoServiceTest.java
index cb25bcea..9d844d2c 100644
--- a/src/test/java/team7/inplace/video/application/VideoServiceTest.java
+++ b/src/test/java/team7/inplace/video/application/VideoServiceTest.java
@@ -1,15 +1,6 @@
package team7.inplace.video.application;
-import static org.mockito.BDDMockito.given;
-
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-
import org.assertj.core.api.Assertions;
-import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -21,20 +12,23 @@
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
import team7.inplace.influencer.domain.Influencer;
-import team7.inplace.place.domain.*;
+import team7.inplace.place.domain.Place;
import team7.inplace.place.persistence.PlaceRepository;
-import team7.inplace.security.application.dto.CustomOAuth2User;
-import team7.inplace.user.domain.Role;
import team7.inplace.util.TestUtil;
import team7.inplace.video.application.dto.VideoInfo;
import team7.inplace.video.domain.Video;
import team7.inplace.video.persistence.VideoRepository;
import team7.inplace.video.presentation.dto.VideoSearchParams;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+
+import static org.mockito.BDDMockito.given;
+
@ExtendWith(MockitoExtension.class)
public class VideoServiceTest {
@Mock
@@ -46,7 +40,7 @@ public class VideoServiceTest {
@Test
@DisplayName("getVideosBySurround Test")
- void test1(){
+ void test1() {
// given
// 매개변수
VideoSearchParams videoSearchParams = new VideoSearchParams(
@@ -113,7 +107,7 @@ void test1(){
ArgumentCaptor captor_pla = ArgumentCaptor.forClass(Place.class);
given(videoRepository.findTopByPlaceOrderByIdDesc(captor_pla.capture())).willAnswer(
invocation -> {
- if(captor_pla.getValue() == place1)
+ if (captor_pla.getValue() == place1)
return Optional.of(video1);
return Optional.of(video2);
}
@@ -127,7 +121,7 @@ void test1(){
@Test
@DisplayName("getAllVideosDesc Test")
- void test2(){
+ void test2() {
// Place 객체
Place place1 = new Place("Place 1",
"\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
@@ -217,7 +211,7 @@ void test3() {
@Test
@DisplayName("getPlaceNullVideo Test")
- void test4(){
+ void test4() {
// Place 객체
Place place1 = new Place("Place 1",
"\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
@@ -262,7 +256,7 @@ void test4(){
@Test
@DisplayName("getPlaceNullVideo Test")
- void test5(){
+ void test5() {
// Place 객체
Place place1 = new Place("Place 1",
"\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
diff --git a/src/test/java/team7/inplace/video/domain/VideoTest.java b/src/test/java/team7/inplace/video/domain/VideoTest.java
index d35777de..fc23a95a 100644
--- a/src/test/java/team7/inplace/video/domain/VideoTest.java
+++ b/src/test/java/team7/inplace/video/domain/VideoTest.java
@@ -1,10 +1,10 @@
package team7.inplace.video.domain;
-import static org.assertj.core.api.Assertions.assertThat;
-
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import static org.assertj.core.api.Assertions.assertThat;
+
public class VideoTest {
@Test
diff --git a/src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java b/src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java
index 0816ec4c..e3c9e507 100644
--- a/src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java
+++ b/src/test/java/team7/inplace/video/persistence/VideoRepositoryTest.java
@@ -2,10 +2,6 @@
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
@@ -27,6 +23,11 @@
import team7.inplace.place.persistence.PlaceRepository;
import team7.inplace.video.domain.Video;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
@CustomRepositoryTest
@Transactional
@Import(QueryDslConfig.class)
@@ -44,34 +45,34 @@ public class VideoRepositoryTest {
@BeforeEach
void init() {
Place place1 = new Place("Place 1",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "카페",
- "Address 1|Address 2|Address 3",
- "10.0", "10.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "카페",
+ "Address 1|Address 2|Address 3",
+ "10.0", "10.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
Place place2 = new Place("Place 2",
- "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
- "menuImg.url", "일식",
- "Address 1|Address 2|Address 3",
- "10.0", "50.0",
- Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
- Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
- Arrays.asList("삼겹살|5000|false|menu.url|description",
- "돼지찌개|7000|true|menu.url|description"),
- LocalDateTime.of(2024, 3, 28, 5, 30),
- Arrays.asList(
- "menuBoard1.url",
- "menuBoard2.url"
- )
+ "\"wifi\": true, \"pet\": false, \"parking\": false, \"forDisabled\": true, \"nursery\": false, \"smokingRoom\": false}",
+ "menuImg.url", "일식",
+ "Address 1|Address 2|Address 3",
+ "10.0", "50.0",
+ Arrays.asList("한글날|수|N", "크리스마스|수|Y"),
+ Arrays.asList("오픈 시간|9:00 AM|월", "닫는 시간|6:00 PM|월"),
+ Arrays.asList("삼겹살|5000|false|menu.url|description",
+ "돼지찌개|7000|true|menu.url|description"),
+ LocalDateTime.of(2024, 3, 28, 5, 30),
+ Arrays.asList(
+ "menuBoard1.url",
+ "menuBoard2.url"
+ )
);
entityManager.persist(place1);
entityManager.persist(place2);
@@ -120,8 +121,8 @@ void test1() {
influencerIds.add(1L);
List savedVideos = videoRepository.findTop10ByInfluencerIdIn(
- influencerIds,
- pageable
+ influencerIds,
+ pageable
);
// then
Assertions.assertThat(savedVideos.size()).isEqualTo(5);
@@ -210,9 +211,9 @@ void test4() {
// when
Place place = placeRepository.findById(1L)
- .orElseThrow(() -> InplaceException.of(PlaceErrorCode.NOT_FOUND));
+ .orElseThrow(() -> InplaceException.of(PlaceErrorCode.NOT_FOUND));
Video video = videoRepository.findTopByPlaceOrderByIdDesc(place)
- .orElseThrow(() -> InplaceException.of(VideoErrorCode.NOT_FOUND));
+ .orElseThrow(() -> InplaceException.of(VideoErrorCode.NOT_FOUND));
// then
Assertions.assertThat(video).isNotNull();
@@ -282,10 +283,10 @@ void test7() {
// given
// when
- for(int i = 1; i <= 11; i++){
- Video video = videoRepository.findById((long)i)
+ for (int i = 1; i <= 11; i++) {
+ Video video = videoRepository.findById((long) i)
.orElseThrow(() -> InplaceException.of(VideoErrorCode.NOT_FOUND));
- video.updateViewCount((long)i);
+ video.updateViewCount((long) i);
}
List videos = videoRepository.findTop10ByOrderByViewCountIncreaseDesc(pageable);