Skip to content
Merged
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
8 changes: 6 additions & 2 deletions src/main/java/com/back/domain/user/enums/AbvLevel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.back.domain.user.enums;

public enum AbvLevel {
L1(1, 0, 10, "/img/grade/1.png"),
L1(1, 5, 10, "/img/grade/1.png"),
L2(2, 11, 25, "/img/grade/2.png"),
L3(3, 26, 45, "/img/grade/3.png"),
L4(4, 46, 65, "/img/grade/4.png"),
Expand All @@ -19,10 +19,14 @@ public enum AbvLevel {
this.imagePath = imagePath;
}

/**
* percent 값에 따라 등급 반환
* 5% 미만은 L1보다 낮으므로 기본값 L1 반환
*/
public static AbvLevel of(int percent) {
for (var lv : values()) {
if (percent >= lv.min && percent <= lv.max) return lv;
}
return L1; // 기본값
return L1; // 5% 미만도 기본적으로 L1 처리
}
}