engine/types/db.go

66 lines
1.6 KiB
Go
Raw Normal View History

2024-02-11 01:31:01 +08:00
package types
import (
"time"
"gorm.io/gorm"
)
type (
// sql options
SqlOptions struct {
MaxIdleConns int
MaxOpenConns int
ConnMaxLifetime time.Duration
LogStdout bool
Debug bool
}
// standard ID,Created,Updated,Deleted definition.
Std_IICUDS struct {
ID uint `gorm:"primarykey;"`
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;"` // 唯一标识24位NanoID,36位为UUID
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index";`
Status int8 `gorm:"default:0;index;"` // 状态默认为0-1禁止1为正常
}
// standard ID,Identity,Created,Updated,Deleted,Status definition.
Std_ICUD struct {
ID uint `gorm:"primarykey;"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}
// standard ID,Created definition.
Std_IdCreated struct {
ID uint `gorm:"primarykey;"`
CreatedAt time.Time
}
// standard PassportID,PassportIdentity definition.
Std_Passport struct {
PassportID uint `gorm:"column:passport_id;Index;"`
PassportIdentity string `gorm:"column:passport_identity;type:varchar(36);Index;"` // 用户唯一标识24位NanoID,36位为UUID
}
// standard ID definition.
Std_ID struct {
ID uint `gorm:"primarykey;"`
}
// standard Identity definition.
Std_Identity struct {
Identity string `gorm:"column:identity;type:varchar(36);uniqueIndex;"` // 唯一标识24位NanoID,36位为UUID
}
// standard Status definition.
Std_Status struct {
Status int8 `gorm:"default:0;index;"` // 状态默认为0-1禁止1为正常
}
)