36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package usecase
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gateway/internal/model/permission/domain/entity"
|
|
"gateway/internal/model/permission/domain/enum"
|
|
)
|
|
|
|
// CreateRoleParam carries the fields a tenant submits when creating a role.
|
|
type CreateRoleParam struct {
|
|
TenantID string
|
|
Key string
|
|
DisplayName string
|
|
CreatorUID string
|
|
Status enum.Status // optional; defaults to open
|
|
}
|
|
|
|
// UpdateRoleParam patches an existing role. CRITICAL: Key is intentionally
|
|
// omitted — keys are immutable so external mappings stay valid.
|
|
type UpdateRoleParam struct {
|
|
DisplayName *string
|
|
Status *enum.Status
|
|
}
|
|
|
|
// RoleUseCase manages tenant-scoped role definitions. System roles
|
|
// (is_system=true) are immutable except for DisplayName and refuse delete.
|
|
type RoleUseCase interface {
|
|
Create(ctx context.Context, param *CreateRoleParam) (*entity.Role, error)
|
|
Get(ctx context.Context, tenantID, id string) (*entity.Role, error)
|
|
GetByKey(ctx context.Context, tenantID, key string) (*entity.Role, error)
|
|
List(ctx context.Context, tenantID string) ([]*entity.Role, error)
|
|
Update(ctx context.Context, tenantID, id string, param *UpdateRoleParam) (*entity.Role, error)
|
|
Delete(ctx context.Context, tenantID, id string) error
|
|
}
|