첫 커밋: 로컬 프로젝트 업로드
This commit is contained in:
27
baron-sso/backend/internal/domain/tenant_domain.go
Normal file
27
baron-sso/backend/internal/domain/tenant_domain.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// TenantDomain represents a domain associated with a tenant for auto-assignment.
|
||||
type TenantDomain struct {
|
||||
ID string `gorm:"primaryKey;type:uuid;default:gen_random_uuid()" json:"id"`
|
||||
TenantID string `gorm:"type:uuid;not null;uniqueIndex:idx_tenant_domains_tenant_domain" json:"tenantId"`
|
||||
Domain string `gorm:"not null;uniqueIndex:idx_tenant_domains_tenant_domain" json:"domain"` // e.g. "example.com"
|
||||
Verified bool `gorm:"default:false" json:"verified"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
}
|
||||
|
||||
// BeforeCreate hook to generate UUID if not present.
|
||||
func (td *TenantDomain) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if td.ID == "" {
|
||||
td.ID = uuid.NewString()
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user