36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package model
|
||
|
||
import (
|
||
"case-admin-api/global"
|
||
"gorm.io/gorm"
|
||
"time"
|
||
)
|
||
|
||
// Platform 项目表-关联平台
|
||
type Platform struct {
|
||
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);primary_key;comment:主键id" json:"platform_id"`
|
||
PlatformName string `gorm:"column:platform_name;type:varchar(100);comment:平台名称;NOT NULL" json:"platform_name"`
|
||
PlatformStatus int `gorm:"column:platform_status;type:tinyint(1);default:1;comment:平台状态(1:正常 2:禁用);NOT NULL" json:"platform_status"`
|
||
PlatformKey string `gorm:"column:platform_key;type:varchar(100);comment:平台标识(用于鉴权);NOT NULL" json:"platform_key"`
|
||
PlatformSecret string `gorm:"column:platform_secret;type:varchar(100);comment:平台密钥(用于鉴权)" json:"platform_secret"`
|
||
Model
|
||
}
|
||
|
||
func (m *Platform) TableName() string {
|
||
return "platform"
|
||
}
|
||
|
||
func (m *Platform) BeforeCreate(tx *gorm.DB) error {
|
||
if m.PlatformId == 0 {
|
||
m.PlatformId = global.Snowflake.Generate().Int64()
|
||
}
|
||
|
||
m.CreatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||
|
||
m.UpdatedAt = LocalTime(time.Now())
|
||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||
|
||
return nil
|
||
}
|