Clean public release with: - Go/Gin/PostgreSQL/Redis architecture - Multi-tenant support - JWT authentication - Docker Compose deployment - Environment-based configuration
36 lines
983 B
Go
36 lines
983 B
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type BaseModel struct {
|
|
ID uint `json:"id" gorm:"primaryKey"`
|
|
TenantID string `json:"tenant_id" gorm:"type:uuid;not null;index;primaryKey"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
|
CreatorID uint `json:"creator_id"`
|
|
}
|
|
|
|
type Tenant struct {
|
|
ID string `json:"id" gorm:"type:uuid;primaryKey"`
|
|
Name string `json:"name" gorm:"size:128;not null"`
|
|
Slug string `json:"slug" gorm:"uniqueIndex;size:64;not null"`
|
|
Status int `json:"status" gorm:"default:1"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
|
}
|
|
|
|
func (Tenant) TableName() string {
|
|
return "tenants"
|
|
}
|
|
|
|
func NewTenantID() string {
|
|
return uuid.New().String()
|
|
}
|