refac: debt on role backend
This commit is contained in:
1 parent
de142f6c5f
commit
a043f7f41a
130 files changed
+3591
-512
No files matched your search
@@ -3,6 +3,8 @@ package useCases
|
||||
import (
|
||||
"RenewCMS/internal/domain/article"
|
||||
"RenewCMS/internal/domain/audit"
|
||||
"RenewCMS/internal/domain/builtintype"
|
||||
"RenewCMS/internal/domain/role"
|
||||
"context"
|
||||
)
|
||||
|
||||
@@ -15,11 +17,17 @@ func NewDeleteArticleUseCase(articleRepository article.Repository, recorder audi
|
||||
return &DeleteArticleUseCase{articleRepository, recorder}
|
||||
}
|
||||
|
||||
func (g *DeleteArticleUseCase) DeleteArticle(ctx context.Context, id uint32) error {
|
||||
func (g *DeleteArticleUseCase) DeleteArticle(ctx context.Context, id uint32, caller ContentCaller) error {
|
||||
if err := caller.requireHolding(role.KeyContentDelete, builtintype.KeyArticle); err != nil {
|
||||
return err
|
||||
}
|
||||
target, err := g.articleRepository.Get(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := caller.authorize(role.KeyContentDelete, builtintype.KeyArticle, target.CreatedBy); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
event := audit.NewEvent(audit.ActionArticleDelete, audit.CategoryArticles)
|
||||
event.Target = articleTarget(target)
|
||||
|
||||
Reference in new issue
Block a user