diff --git a/src/main/java/com/example/asterbackend/domain/user/user/service/BothMatchService.java b/src/main/java/com/example/asterbackend/domain/user/user/service/BothMatchService.java index 26f020c..09785d5 100644 --- a/src/main/java/com/example/asterbackend/domain/user/user/service/BothMatchService.java +++ b/src/main/java/com/example/asterbackend/domain/user/user/service/BothMatchService.java @@ -29,8 +29,7 @@ public MatchScoreResponse bothMatch(String username1, String username2) { User user2 = userRepository.findByUsername(username2) .orElseThrow(()->UserNotFoundException.EXCEPTION); - if(me.getStudentId().substring(0, 1).equals(user1.getStudentId().substring(0,1))) return 0; - else { + if(!me.getStudentId().substring(0, 1).equals(user1.getStudentId().substring(0,1))) { Long grade = Long.parseLong(user1.getStudentId().substring(0, 1)); Long classNumber = Long.parseLong(user1.getStudentId().substring(1, 2)); @@ -39,8 +38,7 @@ public MatchScoreResponse bothMatch(String username1, String username2) { schoolClass.addCandy(100); } - if(me.getStudentId().substring(0, 1).equals(user2.getStudentId().substring(0,1))) return 0; - else { + if(!me.getStudentId().substring(0, 1).equals(user2.getStudentId().substring(0,1))) { Long grade = Long.parseLong(user2.getStudentId().substring(0, 1)); Long classNumber = Long.parseLong(user2.getStudentId().substring(1, 2)); @@ -49,12 +47,12 @@ public MatchScoreResponse bothMatch(String username1, String username2) { schoolClass.addCandy(100); } - int socialScore, knowledgeScore, emotionScore, decisionScore; + int socialScore = 100 - Math.abs(user1.getSocialTypeScore() - user2.getSocialTypeScore()); + int knowledgeScore = 100 - Math.abs(user1.getKnowledgeTypeScore() - user2.getKnowledgeTypeScore()); + int emotionScore = 100 - Math.abs(user1.getEmotionTypeScore() - user2.getEmotionTypeScore()); + int decisionScore = 100 - Math.abs(user1.getDecisionTypeScore() - user2.getDecisionTypeScore()); - socialScore = 100 - Math.abs(user1.getSocialTypeScore() - user2.getSocialTypeScore()); - knowledgeScore = 100 - Math.abs(user1.getKnowledgeTypeScore() - user2.getKnowledgeTypeScore()); - emotionScore = 100 - Math.abs(user1.getEmotionTypeScore() - user2.getEmotionTypeScore()); - decisionScore = 100 - Math.abs(user1.getDecisionTypeScore() - user2.getDecisionTypeScore()); + int matchScore = (socialScore + knowledgeScore + emotionScore + decisionScore)/4; return new MatchScoreResponse(matchScore); } diff --git a/src/main/java/com/example/asterbackend/domain/user/user/service/WhoMatchService.java b/src/main/java/com/example/asterbackend/domain/user/user/service/WhoMatchService.java index 5967f25..6ad80c0 100644 --- a/src/main/java/com/example/asterbackend/domain/user/user/service/WhoMatchService.java +++ b/src/main/java/com/example/asterbackend/domain/user/user/service/WhoMatchService.java @@ -4,6 +4,7 @@ import com.example.asterbackend.domain.user.schoolClass.facade.SchoolClassFacade; import com.example.asterbackend.domain.user.user.entity.User; import com.example.asterbackend.domain.user.user.facade.UserFacade; +import com.example.asterbackend.domain.user.user.presentation.dto.response.MatchScoreResponse; import com.example.asterbackend.domain.user.user.repository.UserRepository; import com.example.asterbackend.global.exception.user.UserNotFoundException; import lombok.RequiredArgsConstructor; @@ -25,8 +26,8 @@ public MatchScoreResponse whoMatch(String username) { User user = userRepository.findByUsername(username) .orElseThrow(()-> UserNotFoundException.EXCEPTION); - if(me.getStudentId().substring(0, 1).equals(user.getStudentId().substring(0,1))) return 0; - else { + if(!me.getStudentId().substring(0, 1).equals(user.getStudentId().substring(0,1))){ + Long grade = Long.parseLong(user.getStudentId().substring(0, 1)); Long classNumber = Long.parseLong(user.getStudentId().substring(1, 2)); @@ -35,12 +36,12 @@ public MatchScoreResponse whoMatch(String username) { schoolClass.addCandy(100); } - int socialScore, knowledgeScore, emotionScore, decisionScore; + int socialScore = 100 - Math.abs(me.getSocialTypeScore() - user.getSocialTypeScore()); + int knowledgeScore = 100 - Math.abs(me.getKnowledgeTypeScore() - user.getKnowledgeTypeScore()); + int emotionScore = 100 - Math.abs(me.getEmotionTypeScore() - user.getEmotionTypeScore()); + int decisionScore = 100 - Math.abs(me.getDecisionTypeScore() - user.getDecisionTypeScore()); - socialScore = 100 - Math.abs(me.getSocialTypeScore() - user.getSocialTypeScore()); - knowledgeScore = 100 - Math.abs(me.getKnowledgeTypeScore() - user.getKnowledgeTypeScore()); - emotionScore = 100 - Math.abs(me.getEmotionTypeScore() - user.getEmotionTypeScore()); - decisionScore = 100 - Math.abs(me.getDecisionTypeScore() - user.getDecisionTypeScore()); + int matchScore = (socialScore + knowledgeScore + emotionScore + decisionScore)/4; return new MatchScoreResponse(matchScore); }