Skip to content

Commit

Permalink
๐Ÿ”€ :: isTest filter ์ถ”๊ฐ€
Browse files Browse the repository at this point in the history
  • Loading branch information
์ •๋Œ€ํ˜„ committed Mar 14, 2023
1 parent 8f5a41d commit 34a6812
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ public FeedListResponse getAllFeed(UUID categoryId) {
.collect(Collectors.toMap(User::getId, user -> user, (userId, user) -> user, HashMap::new));
User defaultUser = User.builder().name("").profileFileName("").build();
UUID currentUserId = securitySpi.getCurrentUserId();
boolean isTest = isUserValidate();

List<FeedElement> feedList = queryFeedSpi.queryAllFeedByCategory(categoryId)
.stream()
.filter(feed -> !isTest || !feed.getType().equals(UserAuthority.UKN.name()))
.map(feed -> {
UserAuthority userAuthority = UserAuthority.valueOf(feed.getType());
User user = hashMap.getOrDefault(feed.getUserId(), defaultUser);
Expand All @@ -118,13 +120,16 @@ public FeedListResponse getAllFeed(UUID categoryId) {

@Override
public FeedCategoryListResponse getAllCategory() {
boolean isTest = isUserValidate();
List<FeedCategoryElement> categoryList = queryCategorySpi.queryAllCategory()
.stream()
.map(category -> FeedCategoryElement.builder()
.categoryId(category.getCategoryId())
.name(CategoryEnum.valueOf(category.getName()).getKoreaName())
.key(CategoryEnum.valueOf(category.getName()).getName())
.build())
.filter(category -> !isTest || !category.getName().equals(CategoryEnum.BAMBOO.getName()))
.map(category ->
FeedCategoryElement.builder()
.categoryId(category.getCategoryId())
.name(CategoryEnum.valueOf(category.getName()).getKoreaName())
.key(CategoryEnum.valueOf(category.getName()).getName())
.build())
.toList();

return new FeedCategoryListResponse(categoryList);
Expand Down Expand Up @@ -170,4 +175,9 @@ private FeedElement builderFeedElement(
.attachmentsUrl(attachmentsUrl)
.build();
}

private boolean isUserValidate() {
List<String> userAuthorities = securitySpi.getUserAuthority();
return userAuthorities.contains(UserAuthority.TEST.name());
}
}

0 comments on commit 34a6812

Please sign in to comment.