1
0
forked from baron/baron-sso

3단계 권한 모델 확장, keto 권한 정책

This commit is contained in:
2026-02-03 14:21:37 +09:00
parent 6dbdd5d483
commit d09abab5a2
24 changed files with 1071 additions and 141 deletions

View File

@@ -9,6 +9,8 @@ import (
type TenantRepository interface {
Create(ctx context.Context, tenant *domain.Tenant) error
Update(ctx context.Context, tenant *domain.Tenant) error
FindByID(ctx context.Context, id string) (*domain.Tenant, error)
FindBySlug(ctx context.Context, slug string) (*domain.Tenant, error)
FindByName(ctx context.Context, name string) (*domain.Tenant, error)
FindByDomain(ctx context.Context, domainName string) (*domain.Tenant, error)
@@ -27,6 +29,18 @@ func (r *tenantRepository) Create(ctx context.Context, tenant *domain.Tenant) er
return r.db.WithContext(ctx).Create(tenant).Error
}
func (r *tenantRepository) Update(ctx context.Context, tenant *domain.Tenant) error {
return r.db.WithContext(ctx).Save(tenant).Error
}
func (r *tenantRepository) FindByID(ctx context.Context, id string) (*domain.Tenant, error) {
var tenant domain.Tenant
if err := r.db.WithContext(ctx).Preload("Domains").First(&tenant, "id = ?", id).Error; err != nil {
return nil, err
}
return &tenant, nil
}
func (r *tenantRepository) FindBySlug(ctx context.Context, slug string) (*domain.Tenant, error) {
var tenant domain.Tenant
if err := r.db.WithContext(ctx).Preload("Domains").Where("slug = ?", slug).First(&tenant).Error; err != nil {