-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#158] fix: 이미 카테고리 존재 시, 부모, 형제가 주어지지 않은 카테고리를 또 생성하는 경우 예외처리
- Loading branch information
1 parent
4412fbe
commit 34fb101
Showing
12 changed files
with
194 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/java/com/mallang/category/TieredCategoryValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mallang.category; | ||
|
||
import com.mallang.auth.domain.Member; | ||
|
||
public interface TieredCategoryValidator { | ||
|
||
void validateNoCategories(Member member); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mallang/post/domain/PostCategoryValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mallang.post.domain; | ||
|
||
import com.mallang.auth.domain.Member; | ||
import com.mallang.category.CategoryHierarchyViolationException; | ||
import com.mallang.category.TieredCategoryValidator; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class PostCategoryValidator implements TieredCategoryValidator { | ||
|
||
private final PostCategoryRepository postCategoryRepository; | ||
|
||
@Override | ||
public void validateNoCategories(Member member) { | ||
if (postCategoryRepository.existsByOwner(member)) { | ||
throw new CategoryHierarchyViolationException("이미 존재하는 카테고리가 있습니다."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mallang/post/domain/star/StarGroupValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mallang.post.domain.star; | ||
|
||
import com.mallang.auth.domain.Member; | ||
import com.mallang.category.CategoryHierarchyViolationException; | ||
import com.mallang.category.TieredCategoryValidator; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class StarGroupValidator implements TieredCategoryValidator { | ||
|
||
private final StarGroupRepository starGroupRepository; | ||
|
||
@Override | ||
public void validateNoCategories(Member member) { | ||
if (starGroupRepository.existsByOwner(member)) { | ||
throw new CategoryHierarchyViolationException("이미 존재하는 즐겨찾기 그룹이 있습니다."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.