case-api/api/model/Platform.go
2025-03-07 16:57:28 +08:00

36 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"case-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
}