diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 73db6f8..3da794b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -58,4 +58,4 @@ jobs: version_label: github-action-${{ steps.current-time.outputs.formattedTime }} region: ap-northeast-2 deployment_package: deploy/deploy.zip - wait_for_environment_recovery: 60 + wait_for_environment_recovery: 300 diff --git a/src/main/java/zipdabang/server/apiPayload/code/CommonStatus.java b/src/main/java/zipdabang/server/apiPayload/code/CommonStatus.java index 1ce29b8..f122a8e 100644 --- a/src/main/java/zipdabang/server/apiPayload/code/CommonStatus.java +++ b/src/main/java/zipdabang/server/apiPayload/code/CommonStatus.java @@ -92,6 +92,9 @@ public enum CommonStatus implements BaseCode { //FORBIDDEN SELF_FOLLOW_FORBIDDEN(HttpStatus.OK, 4065, "스스로 팔로우는 안됩니다."), + BLOCKED_MEMBER(HttpStatus.OK, 4066, "내가 차단한 사용자입니다."), + + // market error //recipe error diff --git a/src/main/java/zipdabang/server/converter/MemberConverter.java b/src/main/java/zipdabang/server/converter/MemberConverter.java index 538f793..da3d686 100644 --- a/src/main/java/zipdabang/server/converter/MemberConverter.java +++ b/src/main/java/zipdabang/server/converter/MemberConverter.java @@ -17,7 +17,9 @@ import zipdabang.server.domain.member.Terms; import zipdabang.server.domain.member.Member; import zipdabang.server.domain.member.MemberPreferCategory; +import zipdabang.server.repository.memberRepositories.FollowRepository; import zipdabang.server.repository.memberRepositories.MemberRepository; +import zipdabang.server.service.MemberService; import zipdabang.server.utils.converter.TimeConverter; import zipdabang.server.utils.dto.OAuthJoin; import zipdabang.server.web.dto.requestDto.MemberRequestDto; @@ -46,6 +48,8 @@ public class MemberConverter { private static String defaultProfileImage; private static AmazonS3Manager staticAmazonS3Manager; + private final MemberService memberService; + private static MemberService staticMemberService; @Value("${cloud.aws.s3.user-default-image}") public void setDefaultImage(String value) { @@ -116,6 +120,7 @@ public static MemberResponseDto.SocialJoinDto toSocialJoinDto(OAuthJoin.OAuthJoi public void init() { this.staticMemberRepository = this.memberRepository; this.staticAmazonS3Manager = amazonS3Manager; + this.staticMemberService = memberService; } @@ -399,4 +404,19 @@ public static MemberResponseDto.FollowerListDto toFollowerListDto(Page f .currentPageElements(followList.getNumberOfElements()) .build(); } + + public static MemberResponseDto.MyZipdabangDto toMyZipdabangDto(Member member, boolean checkSelf, boolean isFollowing,MemberResponseDto.MemberPreferCategoryDto memberPreferCategoryDto) { + + return MemberResponseDto.MyZipdabangDto.builder() + .memberId(member.getMemberId()) + .imageUrl(member.getProfileUrl()) + .checkSelf(checkSelf) + .checkFollowing(isFollowing) + .nickname(member.getNickname()) + .caption(member.getCaption()) + .memberPreferCategoryDto(memberPreferCategoryDto) + .followerCount(staticMemberService.getFollowerCount(member)) + .followingCount(staticMemberService.getFollowingCount(member)) + .build(); + } } diff --git a/src/main/java/zipdabang/server/domain/member/Member.java b/src/main/java/zipdabang/server/domain/member/Member.java index 73d92d9..a68d125 100644 --- a/src/main/java/zipdabang/server/domain/member/Member.java +++ b/src/main/java/zipdabang/server/domain/member/Member.java @@ -136,6 +136,10 @@ public void setNickname(String nickname) { this.nickname = nickname; } + public void setCaption(String caption) { + this.caption = caption; + } + public void inactivateStatus(){ this.status = StatusType.INACTIVE;} } diff --git a/src/main/java/zipdabang/server/repository/memberRepositories/FollowRepository.java b/src/main/java/zipdabang/server/repository/memberRepositories/FollowRepository.java index 861ccbe..4399d2a 100644 --- a/src/main/java/zipdabang/server/repository/memberRepositories/FollowRepository.java +++ b/src/main/java/zipdabang/server/repository/memberRepositories/FollowRepository.java @@ -12,7 +12,13 @@ public interface FollowRepository extends JpaRepository { Page findAllByFollowee(Member member, PageRequest pageRequest); + Long countByFollowee(Member followee); + Page findAllByFollower(Member member, PageRequest pageRequest); + Long countByFollower(Member follower); Optional findByFollowerAndFollowee(Member follower, Member followee); + + boolean existsByFollowerAndFollowee(Member follower, Member followee); + } diff --git a/src/main/java/zipdabang/server/service/MemberService.java b/src/main/java/zipdabang/server/service/MemberService.java index a94ce07..6c9d794 100644 --- a/src/main/java/zipdabang/server/service/MemberService.java +++ b/src/main/java/zipdabang/server/service/MemberService.java @@ -63,8 +63,13 @@ public interface MemberService { public Follow toggleFollow(Long targetId, Member member); Page findFollowing(Member member, Integer page); + public Long getFollowingCount(Member member); Page findFollower(Member member, Integer page); + public Long getFollowerCount(Member member); + public void updateCaption(Member member, MemberRequestDto.changeCaptionDto captionDto); + public void updateProfileDefault(Member member); Boolean checkFollowing(Member loginMember, Member targetMember); -} + public MemberResponseDto.MyZipdabangDto getMyZipdabang(Member member, Long targetId); + } diff --git a/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java b/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java index bd8612f..9e38e72 100644 --- a/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java +++ b/src/main/java/zipdabang/server/service/serviceImpl/MemberServiceImpl.java @@ -40,12 +40,15 @@ import zipdabang.server.web.dto.requestDto.MemberRequestDto; import zipdabang.server.web.dto.responseDto.MemberResponseDto; +import javax.annotation.PostConstruct; import java.io.IOException; import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; @Service @@ -71,15 +74,24 @@ public class MemberServiceImpl implements MemberService { private final InqueryRepository inqueryRepository; private final AmazonS3Manager s3Manager; + private static AmazonS3Manager staticAmazonS3Manager; private final DeregisterRepository deregisterRepository; private final DeregisterReasonRepository deregisterReasonRepository; private final BlockedMemberRepository blockedMemberRepository; - private final FollowRepository followRepository; + private static String defaultProfileImage; @Value("${paging.size}") private Integer pageSize; + @Value("${cloud.aws.s3.user-default-image}") + public void setDefaultImage(String value) { + defaultProfileImage = value; + } + @PostConstruct + public void init(){ + this.staticAmazonS3Manager = this.s3Manager;} + @Override @Transactional public OAuthResult.OAuthResultDto SocialLogin(MemberRequestDto.OAuthRequestDto request,String type) { @@ -399,6 +411,12 @@ public Page findFollowing(Member member, Integer page) { return followingMember; } + @Override + public Long getFollowingCount(Member member) { + return followRepository.countByFollower(member); + } + + @Override public Page findFollower(Member member, Integer page) { page -= 1; @@ -410,10 +428,66 @@ public Page findFollower(Member member, Integer page) { return followerMember; } + @Override + public Long getFollowerCount(Member member) { + return followRepository.countByFollowee(member); + } + + + @Override + @Transactional + public void updateCaption(Member member, MemberRequestDto.changeCaptionDto captionDto) { + member.setCaption(captionDto.getCaption()); + + } + + public static String toKeyName(String imageUrl) { + String input = imageUrl; + + Pattern regex = Pattern.compile(staticAmazonS3Manager.getPattern()); + Matcher matcher = regex.matcher(input); + String extractedString = null; + if (matcher.find()) + extractedString = matcher.group(1); + + return extractedString; + + } + + @Override + @Transactional + public void updateProfileDefault(Member member) { + s3Manager.deleteFile(toKeyName(member.getProfileUrl()).substring(1)); + member.setProfileUrl(defaultProfileImage); + } + @Override public Boolean checkFollowing(Member loginMember, Member targetMember) { return followRepository.findByFollowerAndFollowee(loginMember,targetMember).isPresent(); } + + @Override + public MemberResponseDto.MyZipdabangDto getMyZipdabang(Member member, Long targetId) { + Member target = memberRepository.findById(targetId).orElseThrow(() -> new MemberException(CommonStatus.MEMBER_NOT_FOUND)); + boolean checkSelf = false; + boolean isFollowing = false; + if (member.getMemberId() == target.getMemberId()) { + checkSelf=true; + } + else if(blockedMemberRepository.existsByOwnerAndBlocked(member,target)){ + throw new MemberException(CommonStatus.BLOCKED_MEMBER); + } + + if (followRepository.existsByFollowerAndFollowee(member, target)) { + isFollowing=true; + } + + List categories = findMemberPreferCategories(member); + MemberResponseDto.MemberPreferCategoryDto memberPreferCategoryDto = MemberConverter.toMemberPreferCategoryDto(categories); + + return MemberConverter.toMyZipdabangDto(target, checkSelf, isFollowing, memberPreferCategoryDto); + + } } diff --git a/src/main/java/zipdabang/server/web/controller/MemberRestController.java b/src/main/java/zipdabang/server/web/controller/MemberRestController.java index 436e34d..900850d 100644 --- a/src/main/java/zipdabang/server/web/controller/MemberRestController.java +++ b/src/main/java/zipdabang/server/web/controller/MemberRestController.java @@ -390,7 +390,7 @@ public ResponseDto unblock(@AuthMember Member return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(), "Unblock")); } - @Operation(summary = "차단 유저 목록 조회 API 🔑", description = "차단 유저 목록 조회 API 입니다.") + @Operation(summary = "차단 유저 목록 조회 API ✔️🔑", description = "차단 유저 목록 조회 API 입니다.") @Parameters({ @Parameter(name = "member", hidden = true), @Parameter(name = "page", description = "페이지 번호, 1부터 시작") @@ -459,5 +459,56 @@ public ResponseDto getFollowerMember(@CheckPa Page follower = memberService.findFollower(member, page); return ResponseDto.of(MemberConverter.toFollowerListDto(follower, member)); } + + + @Operation(summary = "🎪figma[내집다방 - 회원 정보 수정4] 한줄소개 변경 API ✔️🔑", description = "한줄 소개 변경 API 입니다.") + @PatchMapping("/members/caption") + @Parameters({ + @Parameter(name = "member", hidden = true) + }) + @ApiResponses({ + @ApiResponse(responseCode = "2000", description = "OK 성공"), + }) + public ResponseDto updateCaption(@AuthMember Member member, MemberRequestDto.changeCaptionDto captionDto) { + memberService.updateCaption(member, captionDto); + return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(), "UpdateCaption")); + } + + + @Operation(summary = "🎪figma[내집다방 - 프로필 사진 변경2] 기본 프로필로 변경 API ✔️🔑", description = "유저 기본 프로필로 변경 API 입니다.") + @PatchMapping("/members/defaultProfile") + @Parameters({ + @Parameter(name = "member", hidden = true) + }) + @ApiResponses({ + @ApiResponse(responseCode = "2000", description = "OK 성공"), + }) + public ResponseDto updateProfileDefault(@AuthMember Member member) { + memberService.updateProfileDefault(member); + + return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(), "UpdateProfileDefault")); + } + + + @Operation(summary = "🎪figma[내집다방 - 원본] 내집다방 화면 조회 API ✔️🔑", description = "내집다방 화면 조회 API 입니다.
" + + "\"checkSelf\" : 자신의 내집다방을 조회하는 경우 true, 남이면 false
" + +"\"checkFollowing\" : 자신이 follow하는 사람이면 true, 아니면 false") + @GetMapping("/members/myZipdabang") + @Parameters({ + @Parameter(name = "member", hidden = true) + }) + @ApiResponses({ + @ApiResponse(responseCode = "2000", description = "OK 성공"), + @ApiResponse(responseCode = "4052", description = "해당 사용자가 존재하지 않습니다."), + @ApiResponse(responseCode = "4059", description = "로그인 후 조회 가능합니다."), + @ApiResponse(responseCode = "4066", description = "내가 차단한 사용자입니다."), + }) + public ResponseDto getMyZipdabang(@CheckTempMember @AuthMember Member member, Long targetMemberId) { + + return ResponseDto.of(memberService.getMyZipdabang(member, targetMemberId)); + + + } + } 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 caedff5..968905f 100644 --- a/src/main/java/zipdabang/server/web/dto/requestDto/MemberRequestDto.java +++ b/src/main/java/zipdabang/server/web/dto/requestDto/MemberRequestDto.java @@ -148,6 +148,12 @@ public static class changeNicknameDto { String nickname; } + @Getter + @Setter + public static class changeCaptionDto { + String caption; + } + @Getter @Setter public static class changeProfileDto { 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 3fd95e0..8727450 100644 --- a/src/main/java/zipdabang/server/web/dto/responseDto/MemberResponseDto.java +++ b/src/main/java/zipdabang/server/web/dto/responseDto/MemberResponseDto.java @@ -268,4 +268,21 @@ public static class FollowerListDto{ Boolean isFirst; Boolean isLast; } + + @Builder + @Getter + @AllArgsConstructor(access = AccessLevel.PROTECTED) + @NoArgsConstructor(access = AccessLevel.PROTECTED) + public static class MyZipdabangDto{ + Long memberId; + String imageUrl; + boolean checkSelf; + boolean checkFollowing; + String nickname; + String caption; + MemberPreferCategoryDto memberPreferCategoryDto; + Long followerCount; + Long followingCount; + + } }