backend/pkg/permission/domain/repository/role.go

44 lines
1.4 KiB
Go
Raw Permalink Normal View History

2025-10-07 09:29:47 +00:00
package repository
import (
"backend/pkg/permission/domain/entity"
"backend/pkg/permission/domain/permission"
"context"
2025-10-10 15:25:36 +00:00
mongodriver "go.mongodb.org/mongo-driver/v2/mongo"
2025-10-07 09:29:47 +00:00
)
// RoleRepository 角色 Repository 介面
type RoleRepository interface {
// Create 建立角色
Create(ctx context.Context, role *entity.Role) error
// Update 更新角色
Update(ctx context.Context, role *entity.Role) error
// Delete 刪除角色 (軟刪除)
Delete(ctx context.Context, uid string) error
// Get 取得單一角色 (by ID)
Get(ctx context.Context, id int64) (*entity.Role, error)
// GetByUID 取得單一角色 (by UID)
GetByUID(ctx context.Context, uid string) (*entity.Role, error)
// GetByUIDs 批量取得角色 (by UIDs)
GetByUIDs(ctx context.Context, uids []string) ([]*entity.Role, error)
// List 列出所有角色
List(ctx context.Context, filter RoleFilter) ([]*entity.Role, error)
// Page 分頁查詢角色
Page(ctx context.Context, filter RoleFilter, page, size int) ([]*entity.Role, int64, error)
// Exists 檢查角色是否存在
Exists(ctx context.Context, uid string) (bool, error)
2025-10-10 15:25:36 +00:00
// NextID 取得下一個角色 ID用於生成 UID
2025-10-07 09:29:47 +00:00
NextID(ctx context.Context) (int64, error)
2025-10-10 15:25:36 +00:00
Index20251009002UP(ctx context.Context) (*mongodriver.Cursor, error)
2025-10-07 09:29:47 +00:00
}
// RoleFilter 角色查詢過濾條件
type RoleFilter struct {
ClientID int
UID string
Name string
Status *permission.RecordState
Permissions []string
}