-
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.
feat: 권한 검증이 필요한 곳에서 권한 검증을 수행한다 (#112)
* [#111] feat: About 권한 검증 추가 * [#111] feat: Category 권한 검증 추가 * [#111] feat: Blog, Post 권한 검증 추가 * [#111] feat: Comment 권한 검증 추가 * [#111] refactor: polishing
- Loading branch information
1 parent
bb6a1d5
commit 5d7d7b5
Showing
53 changed files
with
536 additions
and
386 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
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
public record DeleteAboutCommand( | ||
Long aboutId, | ||
Long memberId, | ||
String blogName | ||
Long memberId | ||
) { | ||
} |
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
public record UpdateAboutCommand( | ||
Long aboutId, | ||
Long memberId, | ||
String blogName, | ||
String content | ||
) { | ||
} |
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
17 changes: 3 additions & 14 deletions
17
src/main/java/com/mallang/blog/domain/AboutRepository.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 |
---|---|---|
@@ -1,24 +1,13 @@ | ||
package com.mallang.blog.domain; | ||
|
||
import com.mallang.blog.exception.NotFoundAboutException; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface AboutRepository extends JpaRepository<About, Long> { | ||
|
||
boolean existsByBlog(Blog blog); | ||
|
||
default About getByIdAndWriterAndBlog(Long aboutId, Long memberId, String blogName) { | ||
return findByIdAndWriterAndBlog(aboutId, memberId, blogName) | ||
.orElseThrow(NotFoundAboutException::new); | ||
default About getById(Long id) { | ||
return findById(id).orElseThrow(NotFoundAboutException::new); | ||
} | ||
|
||
@Query("SELECT a FROM About a WHERE a.id = :aboutId AND a.writer.id = :writerId AND a.blog.name.value = :blogName") | ||
Optional<About> findByIdAndWriterAndBlog( | ||
@Param("aboutId") Long aboutId, | ||
@Param("writerId") Long writerId, | ||
@Param("blogName") String blogName | ||
); | ||
boolean existsByBlog(Blog blog); | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/mallang/blog/exception/NoAuthorityBlogException.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,13 @@ | ||
package com.mallang.blog.exception; | ||
|
||
import static org.springframework.http.HttpStatus.FORBIDDEN; | ||
|
||
import com.mallang.common.execption.ErrorCode; | ||
import com.mallang.common.execption.MallangLogException; | ||
|
||
public class NoAuthorityBlogException extends MallangLogException { | ||
|
||
public NoAuthorityBlogException() { | ||
super(new ErrorCode(FORBIDDEN, "블로그에 대한 권한이 없습니다.")); | ||
} | ||
} |
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
11 changes: 0 additions & 11 deletions
11
src/main/java/com/mallang/blog/presentation/request/DeleteAboutRequest.java
This file was deleted.
Oops, something went wrong.
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
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/mallang/category/exception/NoAuthorityCategoryException.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,13 @@ | ||
package com.mallang.category.exception; | ||
|
||
import static org.springframework.http.HttpStatus.FORBIDDEN; | ||
|
||
import com.mallang.common.execption.ErrorCode; | ||
import com.mallang.common.execption.MallangLogException; | ||
|
||
public class NoAuthorityCategoryException extends MallangLogException { | ||
|
||
public NoAuthorityCategoryException() { | ||
super(new ErrorCode(FORBIDDEN, "카테고리에 대한 권한이 없습니다.")); | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
src/main/java/com/mallang/category/exception/NoAuthorityDeleteCategoryException.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/java/com/mallang/category/exception/NoAuthorityUpdateCategoryException.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/main/java/com/mallang/category/exception/NoAuthorityUseCategoryException.java
This file was deleted.
Oops, something went wrong.
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.