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 - - - - - - + + + + + + + +

이상희

💻

김동윤

💻

정수현

💻

우현서

💻

배준호

💻
+ Frontend
+
+ Frontend
+
+
이정민
+
+
이효은
+
+ + + + + + + + + + + + + +
+ Backend
+
+ Backend
+
+ Backend
+
+ Backend
+
+ Backend
+
+
이상희
+
+
김동윤
+
+
정수현
+
+
우현서
+
+
배준호
+
-## 주요 종속성 버전 -- Spring Boots 3.3.3 -- Java 17 LTS +## Program Architecture +- **ERD** + + 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