diff --git a/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java b/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java index b9959c0c..4dbf64b2 100644 --- a/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java +++ b/src/main/java/com/umc/naoman/domain/member/controller/MemberController.java @@ -2,6 +2,8 @@ import com.umc.naoman.domain.member.converter.MemberConverter; import com.umc.naoman.domain.member.dto.MemberResponse; +import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.service.MemberService; @@ -21,7 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import static com.umc.naoman.global.result.code.MemberResultCode.CHECK_MEMBER_REGISTRATION; +import static com.umc.naoman.global.result.code.MemberResultCode.*; @RestController @RequestMapping("/members") @@ -51,6 +53,12 @@ public ResultResponse getMyInfo(@LoginMember Member member) { return ResultResponse.of(CHECK_MEMBER_REGISTRATION, memberService.getMyInfo(member)); } + @GetMapping("/my-memberId") + @Operation(summary = "내 memberId 조회 API", description = "자신의 memberId를 조회하는 API입니다.") + public ResultResponse getMyMemberId(@LoginMember Member member) { + return ResultResponse.of(GET_MY_MEMBERID, memberService.getMyMemberId(member)); + } + @GetMapping("/terms/{memberId}") @Operation(summary = "마케팅 약관 동의 여부 조회 API", description = "[PathVariable]\n memberId\n[request]\n" + "[response]\n 마케팅 동의 여부 -> 동의 => true, 비동의 => false") @@ -63,4 +71,10 @@ public ResultResponse getMarketingAgreed(@PathVa Member member = memberService.findMember(memberId); return ResultResponse.of(MemberResultCode.CHECK_MARKETING_AGREED, memberConverter.toMarketingAgreed(member)); } + + @GetMapping("/samplePhoto") + @Operation(summary = "샘플 사진 업로드 여부 조회", description = "자신이 샘플 사진을 업로드했는지 여부를 확인하는 API입니다.") + public ResultResponse hasSamplePhoto(@LoginMember Member member) { + return ResultResponse.of(CHECK_HAS_SAMPLE_PHOTO, memberService.hasSamplePhoto(member)); + } } diff --git a/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java b/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java index ac5472b8..e1fece0f 100644 --- a/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java +++ b/src/main/java/com/umc/naoman/domain/member/converter/MemberConverter.java @@ -1,8 +1,12 @@ package com.umc.naoman.domain.member.converter; import com.umc.naoman.domain.member.dto.MemberRequest.SignupRequest; -import com.umc.naoman.domain.member.dto.MemberResponse; +import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; +import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; +import com.umc.naoman.domain.member.dto.MemberResponse.MarketingAgreed; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.entity.SocialType; import io.jsonwebtoken.Claims; @@ -40,16 +44,29 @@ public SignupRequest toSignupRequest(Claims payload, boolean marketingAgreed) { .build(); } - public MemberResponse.MemberInfo toMemberInfo(Member member) { - return MemberResponse.MemberInfo.builder() + public MemberInfo toMemberInfo(Member member) { + return MemberInfo.builder() + .memberId(member.getId()) .name(member.getName()) .email(member.getEmail()) .image(member.getImage()) .build(); } - public MemberResponse.MarketingAgreed toMarketingAgreed(Member member) { - return MemberResponse.MarketingAgreed.builder() + public MemberId toMemberId(Long memberId) { + return new MemberId(memberId); + } + + public CheckMemberRegistration toCheckMemberRegistration(boolean isRegistered) { + return new CheckMemberRegistration(isRegistered); + } + + public HasSamplePhoto toHasSamplePhoto(boolean hasSamplePhoto) { + return new HasSamplePhoto(hasSamplePhoto); + } + + public MarketingAgreed toMarketingAgreed(Member member) { + return MarketingAgreed.builder() .marketingAgreed(member.getMarketingAgreed()) .build(); } diff --git a/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java b/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java index ba0f4260..1bd72b8e 100644 --- a/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java +++ b/src/main/java/com/umc/naoman/domain/member/dto/MemberResponse.java @@ -30,6 +30,7 @@ public static class LoginInfo { @Getter @AllArgsConstructor public static class MemberInfo { //특정 회원 조회 + private Long memberId; private String name; private String email; private String image; @@ -41,4 +42,10 @@ public static class MemberInfo { //특정 회원 조회 public static class MarketingAgreed { private Boolean marketingAgreed; } + + @Getter + @AllArgsConstructor + public static class HasSamplePhoto { + private Boolean hasSamplePhoto; + } } diff --git a/src/main/java/com/umc/naoman/domain/member/service/MemberService.java b/src/main/java/com/umc/naoman/domain/member/service/MemberService.java index da9cca45..6526b893 100644 --- a/src/main/java/com/umc/naoman/domain/member/service/MemberService.java +++ b/src/main/java/com/umc/naoman/domain/member/service/MemberService.java @@ -4,7 +4,9 @@ import com.umc.naoman.domain.member.dto.MemberRequest.MarketingAgreedRequest; import com.umc.naoman.domain.member.dto.MemberRequest.SignupRequest; import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; +import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.entity.SocialType; @@ -14,7 +16,10 @@ public interface MemberService { LoginInfo signup(SignupRequest request); LoginInfo login(LoginRequest request); CheckMemberRegistration checkRegistration(LoginRequest request); + HasSamplePhoto hasSamplePhoto(Member member); MemberInfo getMyInfo(Member member); + MemberId getMyMemberId(Member member); Member findMember(Long memberId); Member findMember(SocialType socialType, String authId); + } diff --git a/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java b/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java index b46befbc..5af55be7 100644 --- a/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/member/service/MemberServiceImpl.java @@ -5,12 +5,15 @@ import com.umc.naoman.domain.member.dto.MemberRequest.MarketingAgreedRequest; import com.umc.naoman.domain.member.dto.MemberRequest.SignupRequest; import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; +import com.umc.naoman.domain.member.dto.MemberResponse.HasSamplePhoto; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; +import com.umc.naoman.domain.member.dto.MemberResponse.MemberId; import com.umc.naoman.domain.member.dto.MemberResponse.MemberInfo; import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.member.entity.SocialType; import com.umc.naoman.domain.member.repository.MemberRepository; import com.umc.naoman.domain.member.service.redis.RefreshTokenService; +import com.umc.naoman.domain.photo.service.PhotoService; import com.umc.naoman.global.error.BusinessException; import com.umc.naoman.global.security.util.JwtUtils; import io.jsonwebtoken.Claims; @@ -26,6 +29,7 @@ @RequiredArgsConstructor public class MemberServiceImpl implements MemberService { private final RefreshTokenService refreshTokenService; + private final PhotoService photoService; private final MemberRepository memberRepository; private final MemberConverter memberConverter; private final JwtUtils jwtUtils; @@ -82,7 +86,13 @@ public LoginInfo login(LoginRequest request) { @Override public CheckMemberRegistration checkRegistration(LoginRequest request) { boolean isRegistered = memberRepository.existsBySocialTypeAndAuthId(request.getSocialType(), request.getAuthId()); - return new CheckMemberRegistration(isRegistered); + return memberConverter.toCheckMemberRegistration(isRegistered); + } + + @Override + public HasSamplePhoto hasSamplePhoto(Member member) { + boolean hasSamplePhoto = photoService.hasSamplePhoto(member); + return memberConverter.toHasSamplePhoto(hasSamplePhoto); } @Override @@ -90,6 +100,11 @@ public MemberInfo getMyInfo(Member member) { return memberConverter.toMemberInfo(member); } + @Override + public MemberId getMyMemberId(Member member) { + return memberConverter.toMemberId(member.getId()); + } + @Override public Member findMember(Long memberId) { return memberRepository.findById(memberId) diff --git a/src/main/java/com/umc/naoman/domain/photo/dto/PhotoRequest.java b/src/main/java/com/umc/naoman/domain/photo/dto/PhotoRequest.java index 3fa2f630..971b065b 100644 --- a/src/main/java/com/umc/naoman/domain/photo/dto/PhotoRequest.java +++ b/src/main/java/com/umc/naoman/domain/photo/dto/PhotoRequest.java @@ -17,9 +17,6 @@ public abstract class PhotoRequest { @NoArgsConstructor @AllArgsConstructor public static class PreSignedUrlRequest { - - @NotNull(message = "공유 그룹의 아이디 값을 입력해야 합니다.") - private Long shareGroupId; @NotEmpty(message = "사진의 이름은 하나 이상이어야 합니다.") private List photoNameList; diff --git a/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java b/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java index c335c51f..e5107af5 100644 --- a/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java +++ b/src/main/java/com/umc/naoman/domain/photo/repository/SamplePhotoRepository.java @@ -6,4 +6,5 @@ @Repository public interface SamplePhotoRepository extends JpaRepository { + boolean existsByMemberId(Long memberId); } diff --git a/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java b/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java index dc7d6291..f1ae0c53 100644 --- a/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java +++ b/src/main/java/com/umc/naoman/domain/photo/service/PhotoService.java @@ -27,4 +27,5 @@ public interface PhotoService { List deletePhotoList(PhotoRequest.PhotoDeletedRequest request, Member member); Photo findPhoto(Long photoId); + boolean hasSamplePhoto(Member member); } diff --git a/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java b/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java index 0d9c7aac..00b73ed5 100644 --- a/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java +++ b/src/main/java/com/umc/naoman/domain/photo/service/PhotoServiceImpl.java @@ -8,8 +8,9 @@ import com.umc.naoman.domain.member.entity.Member; import com.umc.naoman.domain.photo.converter.PhotoConverter; import com.umc.naoman.domain.photo.converter.SamplePhotoConverter; -import com.umc.naoman.domain.photo.dto.PhotoRequest; +import com.umc.naoman.domain.photo.dto.PhotoRequest.PhotoDeletedRequest; import com.umc.naoman.domain.photo.dto.PhotoRequest.PhotoUploadRequest; +import com.umc.naoman.domain.photo.dto.PhotoRequest.PreSignedUrlRequest; import com.umc.naoman.domain.photo.dto.PhotoRequest.UploadSamplePhotoRequest; import com.umc.naoman.domain.photo.dto.PhotoResponse.PhotoDownloadUrlListInfo; import com.umc.naoman.domain.photo.dto.PhotoResponse.PhotoUploadInfo; @@ -67,9 +68,7 @@ public class PhotoServiceImpl implements PhotoService { @Override @Transactional - public List getPreSignedUrlList(PhotoRequest.PreSignedUrlRequest request, Member member) { - validateShareGroupAndProfile(request.getShareGroupId(), member); - + public List getPreSignedUrlList(PreSignedUrlRequest request, Member member) { return request.getPhotoNameList().stream() .map(this::getPreSignedUrl) .collect(Collectors.toList()); @@ -260,7 +259,7 @@ public PhotoDownloadUrlListInfo getEtcPhotoDownloadUrlList(Long shareGroupId, Me @Override @Transactional - public List deletePhotoList(PhotoRequest.PhotoDeletedRequest request, Member member) { + public List deletePhotoList(PhotoDeletedRequest request, Member member) { validateShareGroupAndProfile(request.getShareGroupId(), member); // 요청된 사진 ID 목록과 공유 그룹 ID를 기반으로 사진 목록 조회 List photoList = photoRepository.findByIdInAndShareGroupId(request.getPhotoIdList(), request.getShareGroupId()); @@ -305,4 +304,9 @@ public Photo findPhoto(Long photoId) { return photoRepository.findById(photoId) .orElseThrow(() -> new BusinessException(PHOTO_NOT_FOUND)); } + + @Override + public boolean hasSamplePhoto(Member member) { + return samplePhotoRepository.existsByMemberId(member.getId()); + } } diff --git a/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java b/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java index 4d31ec57..3ab97ab3 100644 --- a/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java +++ b/src/main/java/com/umc/naoman/global/result/code/MemberResultCode.java @@ -13,7 +13,9 @@ public enum MemberResultCode implements ResultCode { EDIT_MYPAGE_INFO(200, "SM002", "내 정보를 성공적으로 수정하였습니다."), CHECK_MEMBER_REGISTRATION(200, "SM000", "해당 정보에 대응하는 회원의 가입 여부를 성공적으로 조회하였습니다."), MEMBER_INFO (200,"SM005","회원 정보를 성공적으로 조회하였습니다."), - CHECK_MARKETING_AGREED(200,"SM006","마케팅동의여부를 성공적으로 조회하였습니다."), + CHECK_MARKETING_AGREED(200,"SM006","마케팅 동의 여부를 성공적으로 조회하였습니다."), + GET_MY_MEMBERID(200,"SM000","자신의 memberId를 성공적으로 조회하였습니다."), + CHECK_HAS_SAMPLE_PHOTO(200,"SM000","자신의 샘플 사진 업로드 여부를 성공적으로 조회하였습니다."), ; private final int status; private final String code;