-
Notifications
You must be signed in to change notification settings - Fork 0
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 : 마이페이지 기능 구현 #42
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
981b314
feat : 마이페이지 기능 구현
lljh1992 188b2da
Merge remote-tracking branch 'origin' into feat/39-mypage
donsonioc2010 a59abc0
Merge branch 'dev' into feat/39-mypage
donsonioc2010 903a9cc
Merge branch 'dev' into feat/39-mypage
donsonioc2010 e2f83b8
feat : PasswordEncoder Static 변수로 변경
donsonioc2010 6ca080d
feat : MyPage 기능 구현 완료
donsonioc2010 f945749
feat : MappingPath 변경
donsonioc2010 0b2def6
fix : Builder문제로 인해 Build안되던 Issue수정
donsonioc2010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/HookKiller/server/user/controller/MypageController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package HookKiller.server.user.controller; | ||
|
||
import HookKiller.server.board.dto.ArticleRequestDto; | ||
import HookKiller.server.board.entity.Article; | ||
import HookKiller.server.board.entity.ArticleContent; | ||
import HookKiller.server.board.service.ArticleContentService; | ||
import HookKiller.server.user.dto.MyPageRequestDto; | ||
import HookKiller.server.user.service.MyPageService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/mypage") | ||
@RequiredArgsConstructor | ||
public class MypageController { | ||
|
||
private final MyPageService myPageService; | ||
private final ArticleContentService articleContentService; | ||
|
||
/** | ||
* 마이페이지 조회 | ||
* @param userId | ||
* @return | ||
*/ | ||
@GetMapping("/{userId}") | ||
public MyPageRequestDto getMyPage(Long userId) { | ||
return myPageService.getMyPage(userId); | ||
} | ||
|
||
/** | ||
* 정보 수정 | ||
* @param requestDto | ||
*/ | ||
@PutMapping | ||
public void updatePasswordAndNickname(@RequestBody MyPageRequestDto requestDto) { | ||
myPageService.updatePasswordAndNickname(requestDto); | ||
} | ||
|
||
/** | ||
* 마이페이지 내가쓴 글 | ||
* | ||
*/ | ||
@GetMapping("/{myList}") | ||
public List<ArticleRequestDto> getMyList(Long userId) { | ||
return myPageService.getMyList(userId); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/HookKiller/server/user/dto/MyPageRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package HookKiller.server.user.dto; | ||
|
||
import HookKiller.server.user.entity.User; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
public class MyPageRequestDto { | ||
|
||
private Long userId; | ||
private String email; | ||
private String password; | ||
private String thumbnail; | ||
private String nickName; | ||
|
||
public static MyPageRequestDto from(User user) { | ||
return MyPageRequestDto.builder() | ||
.userId(user.getId()) | ||
.email(user.getEmail()) | ||
.password(user.getPassword()) | ||
.thumbnail(user.getThumbnail()) | ||
.nickName(user.getNickName()) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/HookKiller/server/user/service/MyPageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package HookKiller.server.user.service; | ||
|
||
import HookKiller.server.auth.exception.UserNotFoundException; | ||
import HookKiller.server.board.dto.ArticleRequestDto; | ||
import HookKiller.server.common.util.UserUtils; | ||
import HookKiller.server.user.dto.MyPageRequestDto; | ||
import HookKiller.server.user.entity.User; | ||
import HookKiller.server.user.repository.UserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class MyPageService { | ||
|
||
private final UserUtils userUtils; | ||
private final UserRepository userRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public MyPageRequestDto getMyPage(Long userId) { | ||
// 로그인한 사용자 정보를 가져옴 | ||
User user = userUtils.getUser(); | ||
|
||
User requestUser = userRepository.findById(userId).orElseThrow(() -> UserNotFoundException.EXCEPTION); | ||
|
||
if (user.getId().equals(requestUser.getId())) { | ||
return MyPageRequestDto.from(requestUser); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Transactional | ||
public void updatePasswordAndNickname(MyPageRequestDto myPageRequestDto) { | ||
User user = userUtils.getUser(); | ||
|
||
User requestUser = userRepository.findById(myPageRequestDto.getUserId()) | ||
.orElseThrow(()-> UserNotFoundException.EXCEPTION); | ||
|
||
if (myPageRequestDto.getPassword() != null) { | ||
requestUser.setPassword(myPageRequestDto.getPassword()); | ||
} | ||
if (myPageRequestDto.getNickName() != null) { | ||
requestUser.setNickName(myPageRequestDto.getNickName()); | ||
} | ||
|
||
userRepository.save(requestUser); | ||
|
||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<ArticleRequestDto> getMyList(Long userId) { | ||
return null; | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArticleContent에 User가 있나...?
혹시 Article이랑 매핑 되어있어서 되는건가요? (진짜모름)