diff --git a/src/main/generated/com/gamegoo/domain/QMatchingRecord.java b/src/main/generated/com/gamegoo/domain/matching/QMatchingRecord.java similarity index 82% rename from src/main/generated/com/gamegoo/domain/QMatchingRecord.java rename to src/main/generated/com/gamegoo/domain/matching/QMatchingRecord.java index 50ee2dff..8d7fdd9e 100644 --- a/src/main/generated/com/gamegoo/domain/QMatchingRecord.java +++ b/src/main/generated/com/gamegoo/domain/matching/QMatchingRecord.java @@ -1,4 +1,4 @@ -package com.gamegoo.domain; +package com.gamegoo.domain.matching; import static com.querydsl.core.types.PathMetadataFactory.*; @@ -16,7 +16,7 @@ @Generated("com.querydsl.codegen.DefaultEntitySerializer") public class QMatchingRecord extends EntityPathBase { - private static final long serialVersionUID = 75682738L; + private static final long serialVersionUID = 1978268795L; private static final PathInits INITS = PathInits.DIRECT2; @@ -35,19 +35,19 @@ public class QMatchingRecord extends EntityPathBase { public final NumberPath mannerLevel = createNumber("mannerLevel", Integer.class); - public final StringPath matchingType = createString("matchingType"); + public final EnumPath matchingType = createEnum("matchingType", MatchingType.class); - public final com.gamegoo.domain.Member.QMember member; + public final com.gamegoo.domain.member.QMember member; public final BooleanPath mike = createBoolean("mike"); public final StringPath rank = createString("rank"); - public final StringPath status = createString("status"); + public final EnumPath status = createEnum("status", MatchingStatus.class); public final NumberPath subPosition = createNumber("subPosition", Integer.class); - public final EnumPath tier = createEnum("tier", com.gamegoo.domain.Member.Tier.class); + public final EnumPath tier = createEnum("tier", com.gamegoo.domain.member.Tier.class); //inherited public final DateTimePath updatedAt = _super.updatedAt; @@ -74,7 +74,7 @@ public QMatchingRecord(PathMetadata metadata, PathInits inits) { public QMatchingRecord(Class type, PathMetadata metadata, PathInits inits) { super(type, metadata, inits); - this.member = inits.isInitialized("member") ? new com.gamegoo.domain.Member.QMember(forProperty("member")) : null; + this.member = inits.isInitialized("member") ? new com.gamegoo.domain.member.QMember(forProperty("member")) : null; } } diff --git a/src/main/java/com/gamegoo/apiPayload/code/status/ErrorStatus.java b/src/main/java/com/gamegoo/apiPayload/code/status/ErrorStatus.java index 6f6946a7..50977dca 100644 --- a/src/main/java/com/gamegoo/apiPayload/code/status/ErrorStatus.java +++ b/src/main/java/com/gamegoo/apiPayload/code/status/ErrorStatus.java @@ -93,12 +93,14 @@ public enum ErrorStatus implements BaseErrorCode { // 매너평가 관련 에러 MANNER_TARGET_MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MANNER401", "매너 평가 대상 회원을 찾을 수 없습니다."), + BAD_MANNER_TARGET_MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MANNER401", "비매너 평가 대상 회원을 찾을 수 없습니다."), MANNER_UNAUTHORIZED(HttpStatus.UNAUTHORIZED, "MANNER401", "매너평가 작성자만 수정 가능합니다."), MANNER_KEYWORD_TYPE_INVALID(HttpStatus.BAD_REQUEST, "MANNER401", "매너 키워드 유형은 1~6만 가능합니다."), BAD_MANNER_KEYWORD_TYPE_INVALID(HttpStatus.BAD_REQUEST, "MANNER401", "비매너 키워드 유형은 7~12만 가능합니다."), MANNER_KEYWORD_NOT_FOUND(HttpStatus.NOT_FOUND, "MANNER404", "해당 매너 키워드를 찾을 수 없습니다."), MANNER_NOT_FOUND(HttpStatus.NOT_FOUND, "MANNER404", "해당 매너평가를 찾을 수 없습니다."), + BAD_MANNER_NOT_FOUND(HttpStatus.NOT_FOUND, "MANNER404", "해당 비매너평가를 찾을 수 없습니다."), MANNER_CONFLICT(HttpStatus.CONFLICT, "MANNER409", "매너 평가는 최초 1회만 가능합니다."), BAD_MANNER_CONFLICT(HttpStatus.CONFLICT, "MANNER409", "비매너 평가는 최초 1회만 가능합니다."), diff --git a/src/main/java/com/gamegoo/controller/mannner/MannerController.java b/src/main/java/com/gamegoo/controller/mannner/MannerController.java index 03f7df14..565804de 100644 --- a/src/main/java/com/gamegoo/controller/mannner/MannerController.java +++ b/src/main/java/com/gamegoo/controller/mannner/MannerController.java @@ -93,4 +93,28 @@ public ApiResponse mannerUpdate( return ApiResponse.onSuccess(result); } + + @GetMapping("good/{memberId}") + @Operation(summary = "매너 평가 조회 API", description = "회원이 실시한 매너 평가를 조회하는 API 입니다.") + @Parameter(name = "memberId", description = "회원이 실시한 매너평가 대상의 id 입니다.") + public ApiResponse getMannerKeyword(@PathVariable(name = "memberId") Long targetMemberId){ + + Long memberId = JWTUtil.getCurrentUserId(); + + MannerResponse.mannerKeywordResponseDTO result = mannerService.getMannerKeyword(memberId, targetMemberId); + + return ApiResponse.onSuccess(result); + } + + @GetMapping("bad/{memberId}") + @Operation(summary = "비매너 평가 조회 API", description = "회원이 실시한 비매너 평가를 조회하는 API 입니다.") + @Parameter(name = "memberId", description = "회원이 실시한 비매너평가 대상의 id 입니다.") + public ApiResponse getBadMannerKeyword(@PathVariable(name = "memberId") Long targetMemberId){ + + Long memberId = JWTUtil.getCurrentUserId(); + + MannerResponse.badMannerKeywordResponseDTO result = mannerService.getBadMannerKeyword(memberId, targetMemberId); + + return ApiResponse.onSuccess(result); + } } diff --git a/src/main/java/com/gamegoo/dto/manner/MannerResponse.java b/src/main/java/com/gamegoo/dto/manner/MannerResponse.java index 1a935917..4723804b 100644 --- a/src/main/java/com/gamegoo/dto/manner/MannerResponse.java +++ b/src/main/java/com/gamegoo/dto/manner/MannerResponse.java @@ -24,4 +24,22 @@ public static class mannerUpdateResponseDTO{ Long mannerId; List mannerRatingKeywordList; } + + @Getter + @Builder + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class mannerKeywordResponseDTO{ + List mannerRatingKeywordList; + } + + @Getter + @Builder + @Setter + @NoArgsConstructor + @AllArgsConstructor + public static class badMannerKeywordResponseDTO{ + List mannerRatingKeywordList; + } } diff --git a/src/main/java/com/gamegoo/service/manner/MannerService.java b/src/main/java/com/gamegoo/service/manner/MannerService.java index 15b4bc3f..52f85d2a 100644 --- a/src/main/java/com/gamegoo/service/manner/MannerService.java +++ b/src/main/java/com/gamegoo/service/manner/MannerService.java @@ -8,6 +8,7 @@ import com.gamegoo.domain.manner.MannerRating; import com.gamegoo.domain.manner.MannerRatingKeyword; import com.gamegoo.dto.manner.MannerRequest; +import com.gamegoo.dto.manner.MannerResponse; import com.gamegoo.repository.manner.MannerKeywordRepository; import com.gamegoo.repository.manner.MannerRatingKeywordRepository; import com.gamegoo.repository.manner.MannerRatingRepository; @@ -255,4 +256,69 @@ public MannerRating update(MannerRequest.mannerUpdateDTO request, Long memberId, } } + + // 매너평가 조회 + @Transactional(readOnly = true) + public MannerResponse.mannerKeywordResponseDTO getMannerKeyword(Long memberId, Long targetMemberId){ + + Member member = memberRepository.findById(memberId).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); + + // 매너평가를 받은 회원 존재 여부 검증. + Member targetMember = memberRepository.findById(targetMemberId).orElseThrow(() -> new MemberHandler(ErrorStatus.MANNER_TARGET_MEMBER_NOT_FOUND)); + + // 매너평가를 받은 회원 탈퇴 여부 검증. + if (targetMember.getBlind()) { + throw new MemberHandler(ErrorStatus.USER_DEACTIVATED); + } + + // 매너평가 ID 조회 + List mannerRatings = mannerRatingRepository.findByFromMemberIdAndToMemberId(member.getId(), targetMember.getId()); + List positiveMannerRatings = mannerRatings.stream() + .filter(MannerRating::getIsPositive) + .collect(Collectors.toList()); + + if (positiveMannerRatings.isEmpty()) { + throw new MannerHandler(ErrorStatus.MANNER_NOT_FOUND); + } + + MannerRating positiveMannerRating = positiveMannerRatings.get(0); + + List mannerKeywordIds = positiveMannerRating.getMannerRatingKeywordList().stream() + .map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId()) + .collect(Collectors.toList()); + + return MannerResponse.mannerKeywordResponseDTO.builder() + .mannerRatingKeywordList(mannerKeywordIds) + .build(); + } + + // 비매너평가 조회 + @Transactional(readOnly = true) + public MannerResponse.badMannerKeywordResponseDTO getBadMannerKeyword(Long memberId, Long targetMemberId){ + + Member member = memberRepository.findById(memberId).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND)); + + // 비매너평가를 받은 회원 존재 여부 검증. + Member targetMember = memberRepository.findById(targetMemberId).orElseThrow(() -> new MemberHandler(ErrorStatus.BAD_MANNER_TARGET_MEMBER_NOT_FOUND)); + + // 비매너평가 ID 조회 + List mannerRatings = mannerRatingRepository.findByFromMemberIdAndToMemberId(member.getId(), targetMember.getId()); + List negativeMannerRatings = mannerRatings.stream() + .filter(mannerRating -> !mannerRating.getIsPositive()) + .collect(Collectors.toList()); + + if (negativeMannerRatings.isEmpty()) { + throw new MannerHandler(ErrorStatus.BAD_MANNER_NOT_FOUND); + } + + MannerRating negativeMannerRating = negativeMannerRatings.get(0); + + List badMannerKeywordIds = negativeMannerRating.getMannerRatingKeywordList().stream() + .map(mannerRatingKeyword -> mannerRatingKeyword.getMannerKeyword().getId()) + .collect(Collectors.toList()); + + return MannerResponse.badMannerKeywordResponseDTO.builder() + .mannerRatingKeywordList(badMannerKeywordIds) + .build(); + } }