mengstack-api/internal/kernel/model/base.go
MengStack Dev fbf9af32f0 Initial commit: MengStack Go API framework
Clean public release with:
- Go/Gin/PostgreSQL/Redis architecture
- Multi-tenant support
- JWT authentication
- Docker Compose deployment
- Environment-based configuration
2026-10-03 00:14:40 +08:00

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()
}