Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] 추천 사용자4명, 상대방 프로필 이미지 전달 #248 #254

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.palbang.unsemawang.chemistry.batch.TotalCalculationService;
import com.palbang.unsemawang.chemistry.dto.response.ChemistryRecommendResponse;
import com.palbang.unsemawang.chemistry.service.RecommendService;
import com.palbang.unsemawang.common.constants.ResponseCode;
Expand All @@ -23,7 +22,6 @@
public class RecommendControllerImpl implements RecommendController {

private final RecommendService recommendService;
private final TotalCalculationService totalCalculationService;

@GetMapping("/recommendations")
@Override
Expand All @@ -34,7 +32,7 @@ public ResponseEntity<List<ChemistryRecommendResponse>> recommendChemistryMember
throw new GeneralException(ResponseCode.EMPTY_TOKEN);
}

List<ChemistryRecommendResponse> recommendedMemberList = recommendService.getTop5Matches(auth.getId());
List<ChemistryRecommendResponse> recommendedMemberList = recommendService.getTopMatches(auth.getId());

return ResponseEntity.ok(recommendedMemberList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Repository
public interface MemberMatchingScoreRepository extends JpaRepository<MemberMatchingScore, Long> {

List<MemberMatchingScore> findTop5ByMemberIdOrderByScoreDesc(String memberId);
List<MemberMatchingScore> findTop4ByMemberIdOrderByScoreDesc(String memberId);

MemberMatchingScore findByMemberAndMatchMember(Member member, Member matchMember);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ public class RecommendService {
private final FileService fileService;

@Transactional(readOnly = true)
public List<ChemistryRecommendResponse> getTop5Matches(String memberId) {
public List<ChemistryRecommendResponse> getTopMatches(String memberId) {
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new GeneralException(ResponseCode.NOT_EXIST_MEMBER_ID));

List<MemberMatchingScore> matchingScores = memberMatchingScoreRepository.findTop5ByMemberIdOrderByScoreDesc(
List<MemberMatchingScore> matchingScores = memberMatchingScoreRepository.findTop4ByMemberIdOrderByScoreDesc(
member.getId());

if (matchingScores.isEmpty()) {
throw new GeneralException(ResponseCode.ERROR_SEARCH);
throw new GeneralException(ResponseCode.NOT_MATCHING_PEOPLE);
}

// 최대 점수 찾기
int maxScore = matchingScores.get(0).getScore(); // 가장 높은 점수 기준으로 스케일링
String imgUrl = fileService.getProfileImgUrl(memberId);


return matchingScores.stream()
.map(score -> {
String matchMemberId = score.getMatchMember().getId();
String imgUrl = fileService.getProfileImgUrl(matchMemberId);
FortuneUserInfo fortuneUserInfo = fortuneUserInfoRepository.findByMemberIdRelationIdIsOne(matchMemberId)
.orElseThrow(() -> new GeneralException(ResponseCode.ERROR_SEARCH));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public enum ResponseCode implements Codable {
NOT_EXIST_FORTUNE_USER_INFO("6133", HttpStatus.BAD_REQUEST, "해당 사주 정보를 찾을 수 없습니다."),
NOT_EXIST_USER_RELATION("6134", HttpStatus.BAD_REQUEST, "해당 사주 관계를 찾을 수 없습니다."),
NOT_CHANGED_RELATION("6135", HttpStatus.BAD_REQUEST, "본인 관계는 수정할 수 없습니다."),
NOT_MATCHING_PEOPLE("6135", HttpStatus.BAD_REQUEST, "추천된 사용자 리스트가 없습니다."),
NOT_UPDATED_SHARE_FORTUNE_CATEGORY("6136", HttpStatus.BAD_REQUEST, "운세공유 게시판은 수정이 불가합니다."),

// 유효성 검사 오류 (형식: 62xx)
Expand Down