Skip to content

Commit

Permalink
conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
CYY1007 committed Oct 5, 2023
2 parents 8ed21ce + fa1201d commit 87d4434
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/zipdabang/server/converter/MemberConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -116,6 +120,7 @@ public static MemberResponseDto.SocialJoinDto toSocialJoinDto(OAuthJoin.OAuthJoi
public void init() {
this.staticMemberRepository = this.memberRepository;
this.staticAmazonS3Manager = amazonS3Manager;
this.staticMemberService = memberService;
}


Expand Down Expand Up @@ -399,4 +404,19 @@ public static MemberResponseDto.FollowerListDto toFollowerListDto(Page<Follow> 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();
}
}
4 changes: 4 additions & 0 deletions src/main/java/zipdabang/server/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
public interface FollowRepository extends JpaRepository<Follow, Long> {

Page<Follow> findAllByFollowee(Member member, PageRequest pageRequest);
Long countByFollowee(Member followee);

Page<Follow> findAllByFollower(Member member, PageRequest pageRequest);

Long countByFollower(Member follower);
Optional<Follow> findByFollowerAndFollowee(Member follower, Member followee);

boolean existsByFollowerAndFollowee(Member follower, Member followee);

}
7 changes: 6 additions & 1 deletion src/main/java/zipdabang/server/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ public interface MemberService {
public Follow toggleFollow(Long targetId, Member member);

Page<Follow> findFollowing(Member member, Integer page);
public Long getFollowingCount(Member member);

Page<Follow> 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -399,6 +411,12 @@ public Page<Follow> findFollowing(Member member, Integer page) {
return followingMember;
}

@Override
public Long getFollowingCount(Member member) {
return followRepository.countByFollower(member);
}


@Override
public Page<Follow> findFollower(Member member, Integer page) {
page -= 1;
Expand All @@ -410,10 +428,66 @@ public Page<Follow> 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<Category> categories = findMemberPreferCategories(member);
MemberResponseDto.MemberPreferCategoryDto memberPreferCategoryDto = MemberConverter.toMemberPreferCategoryDto(categories);

return MemberConverter.toMyZipdabangDto(target, checkSelf, isFollowing, memberPreferCategoryDto);

}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ public ResponseDto<MemberResponseDto.MemberStatusDto> 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부터 시작")
Expand Down Expand Up @@ -459,5 +459,56 @@ public ResponseDto<MemberResponseDto.FollowerListDto> getFollowerMember(@CheckPa
Page<Follow> 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<MemberResponseDto.MemberStatusDto> 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<MemberResponseDto.MemberStatusDto> updateProfileDefault(@AuthMember Member member) {
memberService.updateProfileDefault(member);

return ResponseDto.of(MemberConverter.toMemberStatusDto(member.getMemberId(), "UpdateProfileDefault"));
}


@Operation(summary = "🎪figma[내집다방 - 원본] 내집다방 화면 조회 API ✔️🔑", description = "내집다방 화면 조회 API 입니다.<br>"
+ "\"checkSelf\" : 자신의 내집다방을 조회하는 경우 true, 남이면 false <br>"
+"\"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<MemberResponseDto.MyZipdabangDto> getMyZipdabang(@CheckTempMember @AuthMember Member member, Long targetMemberId) {

return ResponseDto.of(memberService.getMyZipdabang(member, targetMemberId));


}

}

Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ public static class changeNicknameDto {
String nickname;
}

@Getter
@Setter
public static class changeCaptionDto {
String caption;
}

@Getter
@Setter
public static class changeProfileDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
}

0 comments on commit 87d4434

Please sign in to comment.