-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 사용자 정보 조회 서비스 추가 * refactor: 사용자 정보를 찾지 못했을 때 예외 통합 * feat: 사용자 정보 조회 api 추가 * refactor: 머지로 인한 수정 사항 반영 * refactor: resolver argument 수정 및 서비스 메서드 파라미터 수정 * test: 사용자 정보 조회 api 추가 * refactor: 파라미터에 final 추가 * test: 파일 끝 개행 추가 * test: 개행 수정 * test: 개행 수정
- Loading branch information
Showing
27 changed files
with
417 additions
and
124 deletions.
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
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 final 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.