新增科普分类管理
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ArticleScience 文章-科普
|
||||
type ArticleScience struct {
|
||||
ArticleId int64 `gorm:"column:article_id;type:bigint(19);primary_key;comment:主键id" json:"article_id"`
|
||||
ArticleTitle string `gorm:"column:article_title;type:varchar(255);comment:文章标题" json:"article_title"`
|
||||
ArticleStatus int `gorm:"column:article_status;type:tinyint(1);default:1;comment:文章状态(1:正常 2:禁用)" json:"article_status"`
|
||||
IsTop int `gorm:"column:is_top;type:tinyint(1);default:0;comment:是否置顶(0:否 1:是)" json:"is_top"`
|
||||
ArticleImage string `gorm:"column:article_image;type:varchar(255);comment:文章图片(1张)" json:"article_image"`
|
||||
SourceId int64 `gorm:"column:source_id;type:bigint(19);comment:文章来源id;NOT NULL" json:"source_id"`
|
||||
ArticleUrl string `gorm:"column:article_url;type:varchar(255);comment:文章地址;NOT NULL" json:"article_url"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *ArticleScience) TableName() string {
|
||||
return "gdxz_article_science"
|
||||
}
|
||||
|
||||
func (m *ArticleScience) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ArticleId == 0 {
|
||||
m.ArticleId = 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
|
||||
}
|
||||
Reference in New Issue
Block a user