case-admin-api/api/model/ProjectPlatformDynamic.go
2025-03-07 17:23:50 +08:00

36 lines
1.3 KiB
Go
Raw 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-admin-api/global"
"gorm.io/gorm"
"time"
)
// ProjectPlatformDynamic 关联平台-白名单-动态
type ProjectPlatformDynamic struct {
WhiteDynamicId int64 `gorm:"column:white_dynamic_id;type:bigint(19);primary_key;comment:主键id" json:"white_dynamic_id"`
ProjectPlatformId int64 `gorm:"column:project_platform_id;type:bigint(19);comment:关联id;NOT NULL" json:"project_platform_id"`
DynamicType string `gorm:"column:dynamic_type;type:varchar(50);comment:动态类型area:省份 level:医院等级 title:职称 department:科室 url:地址栏 类型间以-链接)" json:"dynamic_type"`
Status int `gorm:"column:status;type:tinyint(1);comment:状态1:正常 2:禁用)" json:"status"`
Model
ProjectPlatformDynamicItem []*ProjectPlatformDynamicItem `gorm:"foreignKey:WhiteDynamicId;references:white_dynamic_id" json:"project_platform_dynamic_item"`
}
func (m *ProjectPlatformDynamic) TableName() string {
return "project_platform_dynamic"
}
func (m *ProjectPlatformDynamic) BeforeCreate(tx *gorm.DB) error {
if m.WhiteDynamicId == 0 {
m.WhiteDynamicId = 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
}