Skip to content

Commit

Permalink
🐛 [fix] riot rank 자료형 string -> int
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi3226 committed Aug 9, 2024
1 parent 3796531 commit 5f5b229
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MatchingRecord extends BaseDateTimeEntity {
private Tier tier;

@Column(name = "rank", columnDefinition = "VARCHAR(10)")
private String rank;
private Integer rank;

@Column(name = "winrate")
private Double winRate;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gamegoo/domain/member/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Member extends BaseDateTimeEntity {
private Tier tier;

@Column(name = "rank")
private String rank;
private Integer rank;

@Column(name = "winrate")
private Double winRate;
Expand Down Expand Up @@ -126,7 +126,7 @@ public void initializeMemberChampionList() {
this.memberChampionList = new ArrayList<>();
}

public void updateRiotDetails(Tier tier, String rank, Double winRate) {
public void updateRiotDetails(Tier tier, Integer rank, Double winRate) {
this.tier = tier;
this.rank = rank;
this.winRate = winRate;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gamegoo/dto/member/MemberResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public static class myProfileMemberDTO {
String gameName;
String tag;
Tier tier;
String rank;
Integer rank;
String updatedAt;
List<GameStyleResponseDTO> gameStyleResponseDTOList;
List<ChampionResponseDTO> championResponseDTOList;
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/gamegoo/util/RiotUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import javax.transaction.Transactional;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand All @@ -28,6 +29,14 @@ public class RiotUtil {
private static final String RIOT_LEAGUE_API_URL_TEMPLATE = "https://kr.api.riotgames.com/lol/league/v4/entries/by-summoner/%s?api_key=%s";
private static final String RIOT_MATCH_API_URL_TEMPLATE = "https://asia.api.riotgames.com/lol/match/v5/matches/by-puuid/%s/ids?start=0&count=%s&api_key=%s";
private static final String RIOT_MATCH_INFO_API_URL_TEMPLATE = "https://asia.api.riotgames.com/lol/match/v5/matches/%s?api_key=%s";
private static final Map<String, Integer> romanToIntMap = new HashMap<>();

static {
romanToIntMap.put("I", 1);
romanToIntMap.put("II", 2);
romanToIntMap.put("III", 3);
romanToIntMap.put("IV", 4);
}

@Autowired
public RiotUtil(RestTemplate restTemplate) {
Expand Down Expand Up @@ -162,9 +171,10 @@ public void addTierRankWinRate(Member member, String gameName, String encryptedS
double winrate = (double) wins / (wins + losses);
winrate = Math.round(winrate * 1000) / 10.0;
Tier tier = Tier.valueOf(entry.getTier().toUpperCase());
Integer rank = romanToIntMap.get(entry.getRank());

// DB에 저장
member.updateRiotDetails(tier, entry.getRank(), winrate);
member.updateRiotDetails(tier, rank, winrate);
break;
}
}
Expand Down

0 comments on commit 5f5b229

Please sign in to comment.