Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#75 MyPage 사용자 정보 전달 #76

Merged
merged 4 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;


Expand All @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading