From 729167529a8b520a46ff02f1a82652f2ed74ef0c Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 21 Apr 2024 03:38:34 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=08style:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20import=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/news/controller/NewsController.java | 1 - .../backend/domain/news/dto/response/NewsResponse.java | 4 ---- .../com/rollthedice/backend/global/config/SecurityConfig.java | 4 ---- 3 files changed, 9 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java index f62ac8bb..7f138c81 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/controller/NewsController.java @@ -1,6 +1,5 @@ package com.rollthedice.backend.domain.news.controller; -import com.rollthedice.backend.domain.crawling.NewsCrawlingService; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; import com.rollthedice.backend.domain.news.service.NewsService; import lombok.RequiredArgsConstructor; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/dto/response/NewsResponse.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/dto/response/NewsResponse.java index 538aec9a..c90433e5 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/dto/response/NewsResponse.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/dto/response/NewsResponse.java @@ -1,9 +1,5 @@ package com.rollthedice.backend.domain.news.dto.response; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.Lob; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/config/SecurityConfig.java b/backend/core/src/main/java/com/rollthedice/backend/global/config/SecurityConfig.java index 770cf1bb..8ab6b4ac 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/config/SecurityConfig.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/config/SecurityConfig.java @@ -1,13 +1,9 @@ package com.rollthedice.backend.global.config; -import com.fasterxml.jackson.databind.ObjectMapper; import com.rollthedice.backend.domain.member.repository.MemberRepository; import com.rollthedice.backend.global.jwt.filter.JwtAuthenticationProcessingFilter; import com.rollthedice.backend.global.jwt.refresh.service.RefreshTokenService; import com.rollthedice.backend.global.jwt.service.JwtService; -//import com.rollthedice.backend.global.login.handler.LoginFailureHandler; -//import com.rollthedice.backend.global.login.handler.LoginSuccessHandler; -//import com.rollthedice.backend.global.login.service.LoginService; import com.rollthedice.backend.global.oauth2.handler.OAuth2LoginFailureHandler; import com.rollthedice.backend.global.oauth2.handler.OAuth2LoginSuccessHandler; import com.rollthedice.backend.global.oauth2.service.CustomOAuth2UserService; From bf9e2f24fa57e7474cb8dfcdbf56a90f4293f1ee Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 21 Apr 2024 03:39:16 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20newsService=20&=20BookmarkService=20?= =?UTF-8?q?=EC=88=9C=ED=99=98=EC=B0=B8=EC=A1=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/bookmark/service/BookmarkService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/service/BookmarkService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/service/BookmarkService.java index 667bcf1e..df91954e 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/service/BookmarkService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/service/BookmarkService.java @@ -7,7 +7,9 @@ import com.rollthedice.backend.domain.news.dto.response.NewsResponse; import com.rollthedice.backend.domain.news.entity.News; import com.rollthedice.backend.domain.news.mapper.NewsMapper; +import com.rollthedice.backend.domain.news.repository.NewsRepository; import com.rollthedice.backend.domain.news.service.NewsService; +import jakarta.persistence.EntityNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; @@ -20,8 +22,8 @@ @Service public class BookmarkService { private final AuthService authService; - private final NewsService newsService; private final BookmarkRepository bookmarkRepository; + private final NewsRepository newsRepository; private final NewsMapper newsMapper; @@ -43,7 +45,8 @@ public void saveBookmark(Long newsId) { Member member = authService.getMember(); bookmarkRepository.save(Bookmark.builder() .member(member) - .news(newsService.getOneNews(newsId)) + .news(newsRepository.findById(newsId) + .orElseThrow(EntityNotFoundException::new)) .build()); } From e1646fc53a25e1db41aeca17caf100f2c79e9bc0 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 21 Apr 2024 03:39:28 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20MemberResponse=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/dto/response/MemberResponse.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 backend/core/src/main/java/com/rollthedice/backend/domain/member/dto/response/MemberResponse.java diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/dto/response/MemberResponse.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/dto/response/MemberResponse.java new file mode 100644 index 00000000..81d4353b --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/dto/response/MemberResponse.java @@ -0,0 +1,15 @@ +package com.rollthedice.backend.domain.member.dto.response; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MemberResponse { + private String nickname; + private String email; +} From 3fff89d19a9c119a01a61d9152e108b9e25a35ea Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 21 Apr 2024 03:40:10 +0900 Subject: [PATCH 4/4] =?UTF-8?q?feat:=20Member=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=A0=84=EB=8B=AC=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 23 +++++++++++++++++++ .../domain/member/service/MemberService.java | 9 ++++++++ 2 files changed, 32 insertions(+) create mode 100644 backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java new file mode 100644 index 00000000..be1f8857 --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/controller/MemberController.java @@ -0,0 +1,23 @@ +package com.rollthedice.backend.domain.member.controller; + +import com.rollthedice.backend.domain.member.dto.response.MemberResponse; +import com.rollthedice.backend.domain.member.service.MemberService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("members") +public class MemberController { + private final MemberService memberService; + + @ResponseStatus(HttpStatus.OK) + @GetMapping("") + public MemberResponse getMemberInfo() { + return memberService.getMemberInfo(); + } +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java index ef8a80fc..3150a4f8 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/service/MemberService.java @@ -1,6 +1,7 @@ package com.rollthedice.backend.domain.member.service; import com.rollthedice.backend.domain.member.dto.SignUpDto; +import com.rollthedice.backend.domain.member.dto.response.MemberResponse; import com.rollthedice.backend.domain.member.entity.Member; import com.rollthedice.backend.domain.member.query.AuthService; import com.rollthedice.backend.global.jwt.refresh.service.RefreshTokenService; @@ -29,4 +30,12 @@ public void signUp(SignUpDto dto) { jwtService.setRefreshTokenHeader(response, refreshToken); refreshTokenService.updateToken(member.getEmail(), refreshToken); } + + public MemberResponse getMemberInfo() { + Member member = authService.getMember(); + return MemberResponse.builder() + .email(member.getEmail()) + .nickname(member.getNickname()) + .build(); + } }