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] 내 프로필 이미지 조회 기능 구현 #347

Merged
merged 2 commits into from
May 17, 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
5 changes: 5 additions & 0 deletions src/main/java/synk/meeteam/domain/user/user/api/UserApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import synk.meeteam.domain.portfolio.portfolio.dto.response.GetUserPortfolioResponseDto;
import synk.meeteam.domain.user.user.dto.request.UpdateProfileRequestDto;
import synk.meeteam.domain.user.user.dto.response.CheckDuplicateNicknameResponseDto;
import synk.meeteam.domain.user.user.dto.response.GetProfileImageResponseDto;
import synk.meeteam.domain.user.user.dto.response.GetProfileResponseDto;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.global.common.exception.ExceptionResponse;
Expand Down Expand Up @@ -66,4 +67,8 @@ public interface UserApi {
ResponseEntity<GetUserPortfolioResponseDto> getUserPortfolio(@AuthUser User user,
@RequestParam(name = "page", defaultValue = "1") int page,
@RequestParam(name = "size", defaultValue = "12") int size);

@Operation(summary = "내 프로필 사진 조회 API")
@SecurityRequirement(name = "Authorization")
ResponseEntity<GetProfileImageResponseDto> getProfileImage(@AuthUser User user);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package synk.meeteam.domain.user.user.api;

import static synk.meeteam.infra.s3.S3FileName.USER;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -14,11 +16,13 @@
import synk.meeteam.domain.portfolio.portfolio.service.PortfolioService;
import synk.meeteam.domain.user.user.dto.request.UpdateProfileRequestDto;
import synk.meeteam.domain.user.user.dto.response.CheckDuplicateNicknameResponseDto;
import synk.meeteam.domain.user.user.dto.response.GetProfileImageResponseDto;
import synk.meeteam.domain.user.user.dto.response.GetProfileResponseDto;
import synk.meeteam.domain.user.user.entity.User;
import synk.meeteam.domain.user.user.service.ProfileFacade;
import synk.meeteam.domain.user.user.service.UserService;
import synk.meeteam.global.util.Encryption;
import synk.meeteam.infra.s3.service.S3Service;
import synk.meeteam.security.AuthUser;

@RestController
Expand All @@ -28,6 +32,8 @@ public class UserController implements UserApi {

private final UserService userService;
private final PortfolioService portfolioService;
private final S3Service s3Service;

private final ProfileFacade profileFacade;

@Override
Expand Down Expand Up @@ -69,4 +75,11 @@ public ResponseEntity<GetUserPortfolioResponseDto> getUserPortfolio(
@RequestParam(name = "size", defaultValue = "12") int size) {
return ResponseEntity.ok(portfolioService.getSliceMyAllPortfolio(page, size, user));
}

@Override
@GetMapping("/profile/image")
public ResponseEntity<GetProfileImageResponseDto> getProfileImage(@AuthUser User user) {
String profileImgUrl = s3Service.createPreSignedGetUrl(USER, user.getProfileImgFileName());
return ResponseEntity.ok(GetProfileImageResponseDto.of(profileImgUrl));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package synk.meeteam.domain.user.user.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;

public record GetProfileImageResponseDto(
@Schema(description = "프로필 이미지 url", example = "https://image.png")
String imageUrl
) {
public static GetProfileImageResponseDto of(String imageUrl){
return new GetProfileImageResponseDto(imageUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class UserServiceImpl implements UserService {

private final UserRepository userRepository;
private final RoleRepository roleRepository;
private final ProfileMapper profileMapper;

@Transactional(readOnly = true)
public boolean checkAvailableNickname(String nickname) {
Expand Down
Loading