-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ad0475
commit 44e5c5e
Showing
8 changed files
with
85 additions
and
40 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
src/main/java/org/example/gather_back_end/bucket/service/BucketService.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
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
19 changes: 15 additions & 4 deletions
19
src/main/java/org/example/gather_back_end/user/controller/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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
package org.example.gather_back_end.user.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.example.gather_back_end.bucket.service.BucketService; | ||
import org.example.gather_back_end.user.dto.UploadProfileImgRes; | ||
import org.example.gather_back_end.user.dto.GetUserRes; | ||
import org.example.gather_back_end.user.service.UserService; | ||
import org.example.gather_back_end.util.response.SuccessResponse; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/users") | ||
@RequestMapping("/api/user") | ||
public class UserController implements UserControllerApi { | ||
|
||
private final UserService userService; | ||
|
||
// 유저 프로필 이미지 & 이름 GetMapping | ||
@GetMapping("/header-info") | ||
public SuccessResponse<?> getUser(Authentication authentication){ | ||
|
||
GetUserRes res = userService.getUser(authentication); | ||
|
||
return SuccessResponse.of(res); | ||
|
||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/org/example/gather_back_end/user/dto/GetUserRes.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,17 @@ | ||
package org.example.gather_back_end.user.dto; | ||
|
||
import lombok.Builder; | ||
import org.example.gather_back_end.domain.User; | ||
|
||
@Builder | ||
public record GetUserRes( | ||
String profileImgUrl, | ||
String name | ||
) { | ||
public static GetUserRes from(User user) { | ||
return GetUserRes.builder() | ||
.profileImgUrl(user.getProfileImgUrl()) | ||
.name(user.getName()) | ||
.build(); | ||
} | ||
} |
17 changes: 0 additions & 17 deletions
17
src/main/java/org/example/gather_back_end/user/dto/UploadProfileImgRes.java
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
src/main/java/org/example/gather_back_end/user/service/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,11 @@ | ||
package org.example.gather_back_end.user.service; | ||
|
||
import org.example.gather_back_end.user.dto.GetUserRes; | ||
import org.springframework.security.core.Authentication; | ||
|
||
public interface UserService { | ||
|
||
// 사용자 프로필과 이름을 가져오는 서비스 | ||
GetUserRes getUser(Authentication authentication); | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/example/gather_back_end/user/service/UserServiceImpl.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 org.example.gather_back_end.user.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.example.gather_back_end.domain.User; | ||
import org.example.gather_back_end.repository.UserRepository; | ||
import org.example.gather_back_end.user.dto.GetUserRes; | ||
import org.example.gather_back_end.util.jwt.dto.CustomOAuth2User; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class UserServiceImpl implements UserService { | ||
|
||
private final UserRepository userRepository; | ||
|
||
// 사용자 프로필과 이름 가져오는 서비스 | ||
@Override | ||
public GetUserRes getUser(Authentication authentication) { | ||
CustomOAuth2User customOAuth2User = (CustomOAuth2User) authentication.getPrincipal(); | ||
User user = userRepository.getByUsername(customOAuth2User.getUsername()); | ||
return GetUserRes.from(user); | ||
} | ||
} |