From 9f531bb4c6c440e977eb304dfb0c93c00372a87f Mon Sep 17 00:00:00 2001 From: suhyeon7497 Date: Wed, 30 Oct 2024 15:43:38 +0900 Subject: [PATCH 01/97] =?UTF-8?q?[feat]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20=EC=8B=9C,=20frontend=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=EB=A1=9C=20redirect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 회원가입 시에는 inplace.my/choice로 redirect되고, 로그인 시에는 inplace.my/auth로 redirect 되도록 하였습니다. 관련 이슈: #50 --- .../inplace/security/handler/CustomSuccessHandler.java | 8 ++++++-- src/main/resources/application-security.yaml | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java b/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java index 1c2c7b75..8d317366 100644 --- a/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java +++ b/src/main/java/team7/inplace/security/handler/CustomSuccessHandler.java @@ -4,6 +4,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.io.IOException; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import team7.inplace.security.application.dto.CustomOAuth2User; @@ -17,6 +18,9 @@ public class CustomSuccessHandler implements AuthenticationSuccessHandler { private final RefreshTokenService refreshTokenService; private final CookieUtil cookieUtil; + @Value("${spring.redirect.front-end-url}") + private String frontEndUrl; + public CustomSuccessHandler( JwtUtil jwtUtil, RefreshTokenService refreshTokenService, @@ -60,9 +64,9 @@ private void setRedirectUrlToResponse( CustomOAuth2User customOAuth2User ) throws IOException { if (customOAuth2User.isFirstUser()) { - response.sendRedirect("/choice"); + response.sendRedirect(frontEndUrl + "/choice"); return; } - response.sendRedirect("/auth"); + response.sendRedirect(frontEndUrl + "/auth"); } } diff --git a/src/main/resources/application-security.yaml b/src/main/resources/application-security.yaml index 68fa588f..f2dc19a4 100644 --- a/src/main/resources/application-security.yaml +++ b/src/main/resources/application-security.yaml @@ -20,4 +20,6 @@ spring: jwt: secret: ${JWT_SECRET} access-token-expired-time: ${JWT_ACCESS_TOKEN_EXPIRED_TIME} - refresh-token-expired-time: ${JWT_REFRESH_TOKEN_EXPIRED_TIME} \ No newline at end of file + refresh-token-expired-time: ${JWT_REFRESH_TOKEN_EXPIRED_TIME} + redirect: + front-end-url: ${FRONT_END_URL} From 51c3f4be7fc0e91ceb5166297f371f7c000068d0 Mon Sep 17 00:00:00 2001 From: suhyeon7497 Date: Wed, 30 Oct 2024 15:45:57 +0900 Subject: [PATCH 02/97] =?UTF-8?q?[refactor]=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20query=EB=AC=B8=202=EA=B0=9C=20->=201=EA=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 로그인할 때, User 조회를 해보고 있으면, User를 가져오던 부분을 Optional을 사용하여 query한번으로 가져올 수 있도록 하였습니다. --- .../domain/QFavoriteInfluencer.java | 2 +- .../team7/inplace/place/domain/QPlace.java | 2 ++ .../application/CustomOAuth2UserService.java | 13 +++++++------ .../team7/inplace/user/application/UserService.java | 9 ++++++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java b/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java index a0ddba4b..ae4ab9f7 100644 --- a/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java +++ b/src/main/generated/team7/inplace/favoriteInfluencer/domain/QFavoriteInfluencer.java @@ -26,7 +26,7 @@ public class QFavoriteInfluencer extends EntityPathBase { public final team7.inplace.influencer.domain.QInfluencer influencer; - public final BooleanPath like = createBoolean("like"); + public final BooleanPath isLiked = createBoolean("isLiked"); public final team7.inplace.user.domain.QUser user; diff --git a/src/main/generated/team7/inplace/place/domain/QPlace.java b/src/main/generated/team7/inplace/place/domain/QPlace.java index 707b39b6..26dba19b 100644 --- a/src/main/generated/team7/inplace/place/domain/QPlace.java +++ b/src/main/generated/team7/inplace/place/domain/QPlace.java @@ -32,6 +32,8 @@ public class QPlace extends EntityPathBase { public final NumberPath id = createNumber("id", Long.class); + public final ListPath menuboardphotourlList = this.createList("menuboardphotourlList", String.class, StringPath.class, PathInits.DIRECT2); + public final StringPath menuImgUrl = createString("menuImgUrl"); public final ListPath menus = this.createList("menus", Menu.class, QMenu.class, PathInits.DIRECT2); diff --git a/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java b/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java index 3d061d44..0d6293bd 100644 --- a/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java +++ b/src/main/java/team7/inplace/security/application/CustomOAuth2UserService.java @@ -1,5 +1,6 @@ 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; @@ -22,13 +23,13 @@ public OAuth2User loadUser(OAuth2UserRequest oAuth2UserRequest) throws OAuth2AuthenticationException { OAuth2User oAuth2User = defaultOAuth2UserService.loadUser(oAuth2UserRequest); KakaoOAuthResponse kakaoOAuthResponse = new KakaoOAuthResponse(oAuth2User.getAttributes()); - if (userService.isExistUser(kakaoOAuthResponse.getEmail())) { - UserCommand.Info userInfo = userService.getUserByUsername( - kakaoOAuthResponse.getEmail()); - return CustomOAuth2User.makeExistUser(userInfo); + Optional userInfo = userService.findUserByUsername( + kakaoOAuthResponse.getEmail()); + if (userInfo.isPresent()) { + return CustomOAuth2User.makeExistUser(userInfo.get()); } - UserCommand.Info userInfo = userService.registerUser( + UserCommand.Info newUser = userService.registerUser( UserCommand.Create.of(kakaoOAuthResponse)); - return CustomOAuth2User.makeNewUser(userInfo); + return CustomOAuth2User.makeNewUser(newUser); } } diff --git a/src/main/java/team7/inplace/user/application/UserService.java b/src/main/java/team7/inplace/user/application/UserService.java index a32dc9d8..850e7fc3 100644 --- a/src/main/java/team7/inplace/user/application/UserService.java +++ b/src/main/java/team7/inplace/user/application/UserService.java @@ -1,6 +1,7 @@ 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; @@ -10,6 +11,7 @@ import team7.inplace.global.exception.code.UserErroCode; import team7.inplace.influencer.domain.Influencer; import team7.inplace.user.application.dto.UserCommand; +import team7.inplace.user.application.dto.UserCommand.Info; import team7.inplace.user.domain.User; import team7.inplace.user.persistence.UserRepository; @@ -24,7 +26,6 @@ public class UserService { public UserCommand.Info registerUser(UserCommand.Create userCreate) { User user = userCreate.toEntity(); userRepository.save(user); - System.out.println("user id = " + user.getId()); return UserCommand.Info.of(user); } @@ -39,6 +40,12 @@ public UserCommand.Info getUserByUsername(String username) { .orElseThrow(() -> InplaceException.of(UserErroCode.NOT_FOUND))); } + @Transactional + public Optional findUserByUsername(String username) { + Optional userOptional = userRepository.findByUsername(username); + return userOptional.map(Info::of); + } + @Transactional(readOnly = true) public List getInfluencerIdsByUsername(Long userId) { List likes = favoriteInfluencerRepository.findByUserId(userId); From 099b6ed6ef332f3a07427bf3012fb2f15c7f2dc6 Mon Sep 17 00:00:00 2001 From: suhyeon7497 Date: Thu, 31 Oct 2024 20:02:47 +0900 Subject: [PATCH 03/97] =?UTF-8?q?[feat]=20Kakao=20Location=20Message?= =?UTF-8?q?=EB=A7=8C=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 장소 정보를 kakaoMessage로 보내기위해 Messsage를 만드는 기능을 작성하였습니다. 관련 이슈: #50 --- .../inplace/global/rest/WebClientConfig.java | 0 .../inplace/placeMessage/util/Button.java | 8 +++++ .../inplace/placeMessage/util/Content.java | 16 ++++++++++ .../placeMessage/util/KakaoMessageClient.java | 17 ++++++++++ .../placeMessage/util/KakaoMessageMaker.java | 31 +++++++++++++++++++ .../team7/inplace/placeMessage/util/Link.java | 17 ++++++++++ .../placeMessage/util/LocationTemplate.java | 17 ++++++++++ src/main/resources/application-kakao.yaml | 3 +- 8 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/main/java/team7/inplace/global/rest/WebClientConfig.java create mode 100644 src/main/java/team7/inplace/placeMessage/util/Button.java create mode 100644 src/main/java/team7/inplace/placeMessage/util/Content.java create mode 100644 src/main/java/team7/inplace/placeMessage/util/KakaoMessageClient.java create mode 100644 src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java create mode 100644 src/main/java/team7/inplace/placeMessage/util/Link.java create mode 100644 src/main/java/team7/inplace/placeMessage/util/LocationTemplate.java diff --git a/src/main/java/team7/inplace/global/rest/WebClientConfig.java b/src/main/java/team7/inplace/global/rest/WebClientConfig.java new file mode 100644 index 00000000..e69de29b diff --git a/src/main/java/team7/inplace/placeMessage/util/Button.java b/src/main/java/team7/inplace/placeMessage/util/Button.java new file mode 100644 index 00000000..5b31afc4 --- /dev/null +++ b/src/main/java/team7/inplace/placeMessage/util/Button.java @@ -0,0 +1,8 @@ +package team7.inplace.placeMessage.util; + +public record Button( + String title, + Link link +) { + +} diff --git a/src/main/java/team7/inplace/placeMessage/util/Content.java b/src/main/java/team7/inplace/placeMessage/util/Content.java new file mode 100644 index 00000000..fc47f3c3 --- /dev/null +++ b/src/main/java/team7/inplace/placeMessage/util/Content.java @@ -0,0 +1,16 @@ +package team7.inplace.placeMessage.util; + +import com.fasterxml.jackson.annotation.JsonProperty; +import org.springframework.lang.NonNull; + +public record Content( + @NonNull String title, + @NonNull @JsonProperty("image_url") String imageUrl, + @NonNull String description, + @NonNull Link link +) { + + public static Content of(String title, String imageUrl, String description, Link link) { + return new Content(title, imageUrl, description, link); + } +} diff --git a/src/main/java/team7/inplace/placeMessage/util/KakaoMessageClient.java b/src/main/java/team7/inplace/placeMessage/util/KakaoMessageClient.java new file mode 100644 index 00000000..7834ca76 --- /dev/null +++ b/src/main/java/team7/inplace/placeMessage/util/KakaoMessageClient.java @@ -0,0 +1,17 @@ +package team7.inplace.placeMessage.util; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import team7.inplace.global.kakao.config.KakaoApiProperties; + +@Component +@RequiredArgsConstructor +public class KakaoMessageClient { + + private final KakaoApiProperties kakaoApiProperties; + private final KakaoMessageMaker kakaoMessageMaker; + + public void sendLocationMessageToMe() { + + } +} diff --git a/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java b/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java new file mode 100644 index 00000000..16d59d2e --- /dev/null +++ b/src/main/java/team7/inplace/placeMessage/util/KakaoMessageMaker.java @@ -0,0 +1,31 @@ +package team7.inplace.placeMessage.util; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.util.LinkedMultiValueMap; + +@Component +@RequiredArgsConstructor +public class KakaoMessageMaker { + + private final ObjectMapper objectMapper; + + public Map> createLocationTemplate() { + try { + LinkedMultiValueMap body = new LinkedMultiValueMap<>(); + Link link = Link.of("webUrl", "mobileWebUrl", "android", "ios"); + Content content = Content.of("title", "imageUrl", "description", link); + LocationTemplate locationTemplate = new LocationTemplate("location", "address", + "addressTitle", content, "buttonTitle", new ArrayList + + + `; + tbody.append(row); + + currentPage = data.number; + + $('#prevPage').prop('disabled', data.first); + $('#nextPage').prop('disabled', data.last); + }); + }, + error: function (err) { + if (err.responseJSON) { + var s = JSON.stringify(err.responseJSON); + alert(s); + } else { + alert("문제가 발생했습니다! 상태 코드 : " + err.status) + } + } + }); +} + +$(document).ready(function () { + getNullVideos(currentPage); + + $('#prevPage').click(function () { + if (currentPage > 0) { + getNullVideos(currentPage - 1); + } + }); + + $('#nextPage').click(function () { + getNullVideos(currentPage + 1); + }); +}); + +function getYouTubeVideoId(url) { + const urlObj = new URL(url); // Create a URL object from the input URL + return urlObj.searchParams.get('v'); // Extract the 'v' parameter from the query string +} + +// 장소 검색 객체 생성 +var ps = new kakao.maps.services.Places(); + +// 키워드 검색을 요청하는 함수 +function searchPlaces() { + var keyword = document.getElementById('keyword').value; + + if (!keyword.trim()) { + alert('키워드를 입력해주세요!'); + return; + } + + // 키워드로 장소 검색 + ps.keywordSearch(keyword, function (data, status) { + if (status === kakao.maps.services.Status.OK) { + var tbody = $('#search-tbody'); + tbody.empty() + for (let i = 0; i < data.length; i++) { + var row = ` + + ${data[i].place_name} + ${data[i].address_name} + ${data[i].id} + + + `; + tbody.append(row); + const placeId = data[i].id; // 각 장소의 고유 id + console.log(`장소명: ${data[i].place_name}, 주소: ${data[i].address_name} ID: ${placeId}`); + } + } else if (status === kakao.maps.services.Status.ZERO_RESULT) { + alert('검색 결과가 존재하지 않습니다.'); + } else if (status === kakao.maps.services.Status.ERROR) { + alert('검색 결과 중 오류가 발생했습니다.'); + } + }); +} + +function placeSetting(id) { + console.log(id); +} \ No newline at end of file diff --git a/src/main/resources/templates/admin/video.html b/src/main/resources/templates/admin/video.html index ba777c2c..41dd27fd 100644 --- a/src/main/resources/templates/admin/video.html +++ b/src/main/resources/templates/admin/video.html @@ -5,19 +5,21 @@ 인플레이스 어드민 페이지 + -