-
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.
fix: 잘못된 카테고리 생성 요청에 대한 예외 처리 (#159)
- Loading branch information
1 parent
4412fbe
commit 2fd131a
Showing
15 changed files
with
232 additions
and
101 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
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
Oops, something went wrong.