-
Notifications
You must be signed in to change notification settings - Fork 4
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
사용자 정보 조회 api 추가 #256
Merged
Merged
사용자 정보 조회 api 추가 #256
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
54efd51
feat: 사용자 정보 조회 서비스 추가
JJ503 c2db49b
refactor: 사용자 정보를 찾지 못했을 때 예외 통합
JJ503 c376e7b
feat: 사용자 정보 조회 api 추가
JJ503 b6a2af8
Merge remote-tracking branch 'origin/develop-be' into feature/247
JJ503 8ed7519
refactor: 머지로 인한 수정 사항 반영
JJ503 e8bc894
refactor: resolver argument 수정 및 서비스 메서드 파라미터 수정
JJ503 98d6322
test: 사용자 정보 죄회 api 추가
JJ503 837b7d0
refactor: 파라미터에 final 추가
JJ503 7cb34cc
test: 파일 끝 개행 추가
JJ503 a88573d
test: 개행 수정
JJ503 029f489
test: 개행 수정
JJ503 eb31921
Merge branch 'develop-be' into feature/247
JJ503 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
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
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 |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
import com.ddang.ddang.chat.application.dto.ReadParticipatingChatRoomDto; | ||
import com.ddang.ddang.chat.application.exception.ChatRoomNotFoundException; | ||
import com.ddang.ddang.chat.application.exception.UserNotAccessibleException; | ||
import com.ddang.ddang.chat.application.exception.UserNotFoundException; | ||
import com.ddang.ddang.chat.domain.ChatRoom; | ||
import com.ddang.ddang.chat.infrastructure.persistence.JpaChatRoomRepository; | ||
import com.ddang.ddang.user.application.exception.UserNotFoundException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 예외 통일 좋습니다 👍 |
||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
|
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
8 changes: 0 additions & 8 deletions
8
...ddang/src/main/java/com/ddang/ddang/chat/application/exception/UserNotFoundException.java
This file was deleted.
Oops, something went wrong.
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
24 changes: 24 additions & 0 deletions
24
backend/ddang/src/main/java/com/ddang/ddang/user/application/UserService.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,24 @@ | ||
package com.ddang.ddang.user.application; | ||
|
||
import com.ddang.ddang.user.application.dto.ReadUserDto; | ||
import com.ddang.ddang.user.application.exception.UserNotFoundException; | ||
import com.ddang.ddang.user.domain.User; | ||
import com.ddang.ddang.user.infrastructure.persistence.JpaUserRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
@RequiredArgsConstructor | ||
public class UserService { | ||
|
||
private final JpaUserRepository userRepository; | ||
|
||
public ReadUserDto readById(final Long userId) { | ||
final User user = userRepository.findById(userId) | ||
.orElseThrow(() -> new UserNotFoundException("사용자 정보를 사용할 수 없습니다.")); | ||
|
||
return ReadUserDto.from(user); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/ddang/src/main/java/com/ddang/ddang/user/application/dto/ReadUserDto.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,16 @@ | ||
package com.ddang.ddang.user.application.dto; | ||
|
||
import com.ddang.ddang.user.domain.User; | ||
|
||
public record ReadUserDto(Long id, String name, String profileImage, double reliability, String oauthId) { | ||
|
||
public static ReadUserDto from(final User user) { | ||
return new ReadUserDto( | ||
user.getId(), | ||
user.getName(), | ||
user.getProfileImage(), | ||
user.getReliability(), | ||
user.getOauthId() | ||
); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tion/exception/UserNotFoundException.java → ...tion/exception/UserNotFoundException.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
28 changes: 28 additions & 0 deletions
28
backend/ddang/src/main/java/com/ddang/ddang/user/presentation/UserController.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 com.ddang.ddang.user.presentation; | ||
|
||
import com.ddang.ddang.authentication.configuration.AuthenticateUser; | ||
import com.ddang.ddang.authentication.domain.dto.AuthenticationUserInfo; | ||
import com.ddang.ddang.user.application.UserService; | ||
import com.ddang.ddang.user.application.dto.ReadUserDto; | ||
import com.ddang.ddang.user.presentation.dto.ReadUserResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/users") | ||
@RequiredArgsConstructor | ||
public class UserController { | ||
|
||
private final UserService userService; | ||
|
||
@GetMapping | ||
public ResponseEntity<ReadUserResponse> readById(@AuthenticateUser AuthenticationUserInfo userInfo) { | ||
final ReadUserDto readUserDto = userService.readById(userInfo.userId()); | ||
final ReadUserResponse response = ReadUserResponse.from(readUserDto); | ||
|
||
return ResponseEntity.ok(response); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
backend/ddang/src/main/java/com/ddang/ddang/user/presentation/dto/ReadUserResponse.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,10 @@ | ||
package com.ddang.ddang.user.presentation.dto; | ||
|
||
import com.ddang.ddang.user.application.dto.ReadUserDto; | ||
|
||
public record ReadUserResponse(String name, String profileImage, double reliability) { | ||
|
||
public static ReadUserResponse from(final ReadUserDto readUserDto) { | ||
return new ReadUserResponse(readUserDto.name(), readUserDto.profileImage(), readUserDto.reliability()); | ||
} | ||
} |
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
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
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
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.
이거는 왜 정렬만 변경되었을까요..? 인텔리제이 설정은 참 어려운 것 같습니다
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.
import 관련 정렬이 안 된 곳이 있었나 봐요... 허허
혹은 각각 intellij 설정이 약간씩 다른 것일 수도..?!