Skip to content

Commit

Permalink
fix : if-else문 object mapping으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboysj committed Nov 21, 2024
1 parent ad39cc2 commit 90db2a3
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main/java/gigedi/dev/domain/shoot/application/ShootService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gigedi.dev.domain.shoot.application;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -80,17 +82,21 @@ public List<GetOurShootResponse> getOurShoot(String tab) {
if (tab == null || tab.isBlank()) {
tab = YET;
}
if (tab.equals(YET)) {
return getShootByStatus(figma, Status.YET);
} else if (tab.equals(DOING)) {
return getShootByStatus(figma, Status.DOING);
} else if (tab.equals(DONE)) {
return getShootByStatus(figma, Status.DONE);
} else if (tab.equals(MENTIONED)) {
return getMentionedShoot(figma);
} else {
throw new CustomException(ErrorCode.INVALID_TAB);
}

Map<String, Function<Figma, List<GetOurShootResponse>>> tabMapping =
Map.of(
YET, f -> getShootByStatus(f, Status.YET),
DOING, f -> getShootByStatus(f, Status.DOING),
DONE, f -> getShootByStatus(f, Status.DONE),
MENTIONED, this::getMentionedShoot);

return tabMapping
.getOrDefault(
tab,
f -> {
throw new CustomException(ErrorCode.INVALID_TAB);
})
.apply(figma);
}

private List<GetOurShootResponse> getShootByStatus(Figma figma, Status status) {
Expand Down

0 comments on commit 90db2a3

Please sign in to comment.