35 lines
1.0 KiB
Go
35 lines
1.0 KiB
Go
package model
|
||
|
||
import (
|
||
"case-api/global"
|
||
"gorm.io/gorm"
|
||
"time"
|
||
)
|
||
|
||
// ProjectPlatformArea 关联平台-白名单-省份
|
||
type ProjectPlatformArea struct {
|
||
WhiteAreaId int64 `gorm:"column:white_area_id;type:bigint(19);primary_key;comment:主键id" json:"white_area_id"`
|
||
PlatformId int64 `gorm:"column:platform_id;type:bigint(19);comment:关联平台id;NOT NULL" json:"platform_id"`
|
||
AreaName string `gorm:"column:area_name;type:varchar(100);comment:地址名称;NOT NULL" json:"area_name"`
|
||
Status int `gorm:"column:status;type:tinyint(1);default:1;comment:状态(1:正常 2:禁用)" json:"status"`
|
||
Model
|
||
}
|
||
|
||
func (m *ProjectPlatformArea) TableName() string {
|
||
return "project_platform_area"
|
||
}
|
||
|
||
func (m *ProjectPlatformArea) BeforeCreate(tx *gorm.DB) error {
|
||
if m.WhiteAreaId == 0 {
|
||
m.WhiteAreaId = 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
|
||
}
|