diff --git a/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java b/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java index dfff7d0..a335062 100644 --- a/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java +++ b/src/main/java/zipdabang/server/aws/s3/AmazonS3Manager.java @@ -49,8 +49,8 @@ public void deleteFile(String keyname) { log.info("해당 uuid 삭제: "+ !uuidRepository.existsByUuid(getUuid)); } - public String generateMemberKeyName(Uuid uuid, String originalFilename) { - return amazonConfig.getUserProfile() + '/' + uuid.getUuid() + originalFilename; + public String generateMemberKeyName(Uuid uuid) { + return amazonConfig.getUserProfile() + '/' + uuid.getUuid(); } public String generateRecipeKeyName(Uuid uuid) { diff --git a/src/main/java/zipdabang/server/converter/MemberConverter.java b/src/main/java/zipdabang/server/converter/MemberConverter.java index 085858a..15b5681 100644 --- a/src/main/java/zipdabang/server/converter/MemberConverter.java +++ b/src/main/java/zipdabang/server/converter/MemberConverter.java @@ -69,35 +69,12 @@ public static int calculateAge(String birth) { public static Member toSocialMember(MemberRequestDto.MemberInfoDto request, String type) { int age = calculateAge(request.getBirth()); - // 생년월일 문자열을 LocalDate로 변환 -// String birth = request.getBirth().substring(0,2); -// -// // 현재 날짜를 가져옴 -// LocalDate currentDate = LocalDate.now(); -// -// // 생년월일과 현재 날짜를 기준으로 만 나이 계산 -// int age = currentDate.getYear() % 100 - Integer.valueOf(birth)- 1; -// -// if (age < 0) -// age += 100; -// -// // 현재 연도를 가져옴 -// int currentYear = LocalDate.now().getYear(); -// -// // 날짜 문자열을 LocalDate로 변환 -// LocalDate date = LocalDate.parse(request.getBirth(), DateTimeFormatter.ofPattern("yyMMdd")); -// -// // 생년월일에 현재 연도를 설정하여 완전한 날짜로 만듦 -// LocalDate completeDate = date.withYear(currentYear); -// -// age = ChronoUnit.DAYS.between(completeDate, currentDate) >= 0 ? age + 1 : age; GenderType gender = Integer.valueOf(request.getGender()) % 2 == 0 ? GenderType.WOMAN : GenderType.MAN; Member member = Member.builder() .age(age) .socialType(type.equals("kakao") ? SocialType.KAKAO : SocialType.GOOGLE) .email(request.getEmail()) - .profileUrl(request.getProfileUrl()) .nickname(request.getNickname()) .birth(request.getBirth()) .gender(gender) @@ -190,6 +167,23 @@ public static MemberPreferCategory toMemberPreferCategory(Member member, Categor .build(); } + public static MemberResponseDto.CategoryDto toMemberPreferCategoryDto(Category category) { + return MemberResponseDto.CategoryDto.builder() + .name(category.getName()) + .imageUrl(category.getImageUrl()) + .build(); + } + + public static MemberResponseDto.MemberPreferCategoryDto toMemberPreferCategoryDto(List categories) { + List categoryDtoList = categories.stream() + .map(category -> toMemberPreferCategoryDto(category)).collect(Collectors.toList()); + + return MemberResponseDto.MemberPreferCategoryDto.builder() + .categories(categoryDtoList) + .size(categories.size()) + .build(); + } + public static MemberResponseDto.MemberStatusDto toMemberStatusDto(Long memberId, String status){ return MemberResponseDto.MemberStatusDto.builder() .memberId(memberId) diff --git a/src/main/java/zipdabang/server/repository/memberRepositories/PreferCategoryRepository.java b/src/main/java/zipdabang/server/repository/memberRepositories/PreferCategoryRepository.java index 441fe2c..62428d3 100644 --- a/src/main/java/zipdabang/server/repository/memberRepositories/PreferCategoryRepository.java +++ b/src/main/java/zipdabang/server/repository/memberRepositories/PreferCategoryRepository.java @@ -1,7 +1,11 @@ package zipdabang.server.repository.memberRepositories; import org.springframework.data.jpa.repository.JpaRepository; +import zipdabang.server.domain.member.Member; import zipdabang.server.domain.member.MemberPreferCategory; +import java.util.List; + public interface PreferCategoryRepository extends JpaRepository { + List findByMember(Member member); } diff --git a/src/main/java/zipdabang/server/service/MemberService.java b/src/main/java/zipdabang/server/service/MemberService.java index 17f00ac..4c988c0 100644 --- a/src/main/java/zipdabang/server/service/MemberService.java +++ b/src/main/java/zipdabang/server/service/MemberService.java @@ -21,8 +21,8 @@ public interface MemberService { public void existByPhoneNumber(String phoneNum); OAuthJoin.OAuthJoinDto joinInfoComplete(MemberRequestDto.MemberInfoDto request, String type); + public List findMemberPreferCategories(Member member); - List getCategoryList(); public String updateMemberProfileImage(Member member, MemberRequestDto.changeProfileDto profileDto) throws IOException; public void updateMemberBasicInfo(Member member, MemberResponseDto.MemberBasicInfoDto memberBasicInfoDto); diff --git a/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java b/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java index b315db3..c2d1a77 100644 --- a/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java +++ b/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.time.LocalDate; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -110,16 +111,12 @@ public void existByPhoneNumber(String phoneNum) { } } - @Override - public List getCategoryList(){ - return categoryRepository.findAll(); - } @Override @Transactional public String updateMemberProfileImage(Member member, MemberRequestDto.changeProfileDto profileDto) throws IOException { Uuid uuid = s3Manager.createUUID(); - String KeyName = s3Manager.generateMemberKeyName(uuid, profileDto.getNewProfile().getOriginalFilename()); + String KeyName = s3Manager.generateMemberKeyName(uuid); String fileUrl = s3Manager.uploadFile(KeyName, profileDto.getNewProfile()); member.setProfileUrl(fileUrl); return fileUrl; @@ -201,4 +198,15 @@ public OAuthJoin.OAuthJoinDto joinInfoComplete(MemberRequestDto.MemberInfoDto re .accessToken(redisService.saveLoginStatus(joinUser.getMemberId(), tokenProvider.createAccessToken(joinUser.getMemberId(), type.equals("kakao") ? SocialType.KAKAO.toString() : SocialType.GOOGLE.toString(),request.getEmail(),Arrays.asList(new SimpleGrantedAuthority("USER"))))) .build(); } + + @Override + @Transactional + public List findMemberPreferCategories(Member member) { + List categories = preferCategoryRepository.findByMember(member); + List categoryList = new ArrayList<>(); + for (MemberPreferCategory memberPreferCategory : categories) { + categoryList.add(memberPreferCategory.getCategory()); + } + return categoryList; + } } diff --git a/src/main/java/zipdabang/server/web/controller/MemberRestController.java b/src/main/java/zipdabang/server/web/controller/MemberRestController.java index 3a8e982..4711c6c 100644 --- a/src/main/java/zipdabang/server/web/controller/MemberRestController.java +++ b/src/main/java/zipdabang/server/web/controller/MemberRestController.java @@ -23,6 +23,7 @@ import zipdabang.server.base.Code; import zipdabang.server.base.ResponseDto; import zipdabang.server.converter.MemberConverter; +import zipdabang.server.converter.RootConverter; import zipdabang.server.domain.Category; import zipdabang.server.domain.member.Member; import zipdabang.server.redis.domain.RefreshToken; @@ -36,6 +37,7 @@ import org.springframework.web.bind.annotation.*; import zipdabang.server.sms.dto.SmsResponseDto; import zipdabang.server.utils.dto.OAuthResult; +import zipdabang.server.web.dto.responseDto.RootResponseDto; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -109,13 +111,6 @@ public ResponseDto oauthKakao( return oAuthResultDto.getIsLogin() ? ResponseDto.of(Code.OAUTH_LOGIN, socialLoginDto) : ResponseDto.of(Code.OAUTH_JOIN, null); } - @GetMapping("/members/category") - public ResponseDto> getCategoryList() { - List categoryList = memberService.getCategoryList(); - - log.info("음료 카테고리 리스트: {}", categoryList); - return ResponseDto.of(categoryList); - } //회원 정보 추가입력 = 회원가입 완료 + 로그인 @Operation(summary = "🎪figma[회원가입 까지 페이지 - 회원가입 완료 시] 소셜 회원가입 최종 완료 API ✔️", description = "소셜로그인을 통한 회원가입 최종완료 API입니다. agreeTermsIdList는 동의 한(선택 약관 중) 약관의 Id를 주세요 약관의 Id는 약관 조회 API에서 준 데이터에서 가져오세요") @@ -124,7 +119,7 @@ public ResponseDto> getCategoryList() { }) @ApiResponses({ @ApiResponse(responseCode = "2000", description = "OK 성공, access Token과 refresh 토큰을 반환함"), - @ApiResponse(responseCode = "4053", description = "BAD_REQEUST, 선호하는 음료 카테고리 id가 이상할 경우", content = @Content(schema = @Schema(implementation = ResponseDto.class))), + @ApiResponse(responseCode = "4053", description = "BAD_REQUEST, 선호하는 음료 카테고리 id가 이상할 경우", content = @Content(schema = @Schema(implementation = ResponseDto.class))), }) @PostMapping("/members/oauth/info") public ResponseDto memberInfoForSignUp(@RequestBody MemberRequestDto.MemberInfoDto request, @RequestParam(name = "type", required = true) String type) { @@ -179,7 +174,16 @@ public ResponseDto showMyProfile(@AuthMember return null; } + // 내 선호 음료 조회 + @Parameters({ + @Parameter(name = "member", hidden = true), + }) + @GetMapping("/members/category") + public ResponseDto memberPreferCategories(@AuthMember Member member) { + List categories = memberService.findMemberPreferCategories(member); + return ResponseDto.of(MemberConverter.toMemberPreferCategoryDto(categories)); + } // 회원정보 조회 및 수정 APIs @@ -197,7 +201,7 @@ public ResponseDto showMyInfo(@AuthMemb return ResponseDto.of(MemberConverter.toMemberInfoDto(member)); } - @Operation(summary = "[figma 더보기 - 회원 정보 1] 프로필사진 수정 API ", description = "프로필사진 수정 API입니다.") + @Operation(summary = "[figma 더보기 - 회원 정보 1] 프로필사진 수정 API ✔️", description = "프로필사진 수정 API입니다.") @Parameters({ @Parameter(name = "member", hidden = true), }) @@ -210,7 +214,7 @@ public ResponseDto updateProfileImage(@AuthMe return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(),"updateProfileImage")); } - @Operation(summary = "[figma 더보기 - 회원 정보 수정 1] 기본정보 수정 API ", description = "기본정보 수정 API입니다.") + @Operation(summary = "[figma 더보기 - 회원 정보 수정 1] 기본정보 수정 API ✔️", description = "기본정보 수정 API입니다.") @Parameters({ @Parameter(name = "member", hidden = true), }) @@ -224,7 +228,7 @@ public ResponseDto updateBasicInfo(@AuthMembe return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(),"updateBasicInfo")); } - @Operation(summary = "[figma 더보기 - 회원 정보 수정 2] 상세정보 수정 API ", description = "상세정보 수정 API입니다.") + @Operation(summary = "[figma 더보기 - 회원 정보 수정 2] 상세정보 수정 API ✔️", description = "상세정보 수정 API입니다.") @Parameters({ @Parameter(name = "member", hidden = true), }) @@ -237,7 +241,7 @@ public ResponseDto updateDetailInfo(@AuthMemb return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(),"updateDetailInfo")); } - @Operation(summary = "[figma 더보기 - 회원 정보 수정 3] 닉네임 수정 API ", description = "닉네임 수정 API입니다.") + @Operation(summary = "[figma 더보기 - 회원 정보 수정 3] 닉네임 수정 API ✔️", description = "닉네임 수정 API입니다.") @Parameters({ @Parameter(name = "member", hidden = true), }) diff --git a/src/main/java/zipdabang/server/web/dto/requestDto/MemberRequestDto.java b/src/main/java/zipdabang/server/web/dto/requestDto/MemberRequestDto.java index 4d9a6fe..c2398b4 100644 --- a/src/main/java/zipdabang/server/web/dto/requestDto/MemberRequestDto.java +++ b/src/main/java/zipdabang/server/web/dto/requestDto/MemberRequestDto.java @@ -58,7 +58,6 @@ public static class OAuthRequestDto { @Setter public static class MemberInfoDto{ - @NotBlank private String name; @NotBlank @@ -66,8 +65,6 @@ public static class MemberInfoDto{ @NotBlank private String email; @NotBlank - private String profileUrl; - @NotBlank private String gender; @NotBlank private String nickname; diff --git a/src/main/java/zipdabang/server/web/dto/responseDto/MemberResponseDto.java b/src/main/java/zipdabang/server/web/dto/responseDto/MemberResponseDto.java index 9458f01..94dac19 100644 --- a/src/main/java/zipdabang/server/web/dto/responseDto/MemberResponseDto.java +++ b/src/main/java/zipdabang/server/web/dto/responseDto/MemberResponseDto.java @@ -1,6 +1,7 @@ package zipdabang.server.web.dto.responseDto; import lombok.*; +import zipdabang.server.domain.Category; import zipdabang.server.domain.enums.GenderType; @@ -88,7 +89,7 @@ public static class MemberInfoResponseDto { @Getter @AllArgsConstructor(access = AccessLevel.PROTECTED) @NoArgsConstructor(access = AccessLevel.PROTECTED) - public static class MemberStatusDto{ + public static class MemberStatusDto{ private Long memberId; private String status; private LocalDateTime calledAt; @@ -130,4 +131,26 @@ public static class TermsListDto{ public static class TempLoginDto{ String accessToken; } + + + @Builder + @Getter + @AllArgsConstructor(access = AccessLevel.PROTECTED) + @NoArgsConstructor(access = AccessLevel.PROTECTED) + public static class CategoryDto{ + private String name; + + private String imageUrl; + } + + @Builder + @Getter + @AllArgsConstructor(access = AccessLevel.PROTECTED) + @NoArgsConstructor(access = AccessLevel.PROTECTED) + public static class MemberPreferCategoryDto{ + List categories; + Integer size; + } + + }