新增科普分类管理
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
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ArticleScienceClass 文章-科普-分类
|
||||
type ArticleScienceClass struct {
|
||||
ClassId int64 `gorm:"column:class_id;type:bigint(19);primary_key;comment:主键id" json:"class_id"`
|
||||
ArticleId int64 `gorm:"column:article_id;type:bigint(19);comment:文章-科普id;NOT NULL" json:"article_id"`
|
||||
BasicClassId int64 `gorm:"column:basic_class_id;type:bigint(19);comment:基础数据-科普-分类id;NOT NULL" json:"basic_class_id"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *ArticleScienceClass) TableName() string {
|
||||
return "gdxz_article_science_class"
|
||||
}
|
||||
|
||||
func (m *ArticleScienceClass) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.ClassId == 0 {
|
||||
m.ClassId = 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
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ArticleScienceSource 文章-科普-来源
|
||||
type ArticleScienceSource struct {
|
||||
SourceId int64 `gorm:"column:source_id;type:bigint(19);primary_key;comment:主键id" json:"source_id"`
|
||||
SourceName string `gorm:"column:source_name;type:varchar(200);comment:来源名称" json:"source_name"`
|
||||
SourceImage string `gorm:"column:source_image;type:varchar(200);comment:来源图片" json:"source_image"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *ArticleScienceSource) TableName() string {
|
||||
return "gdxz_article_science_source"
|
||||
}
|
||||
|
||||
func (m *ArticleScienceSource) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.SourceId == 0 {
|
||||
m.SourceId = 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
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// BasicArticleClass 基础数据-科普-分类
|
||||
type BasicArticleClass struct {
|
||||
BasicClassId int64 `gorm:"column:basic_class_id;type:bigint(19);primary_key;comment:主键id" json:"basic_class_id"`
|
||||
BasicClassName string `gorm:"column:basic_class_name;type:varchar(255);comment:分类名称" json:"basic_class_name"`
|
||||
BasicClassSort uint `gorm:"column:basic_class_sort;type:int(5);default:1;comment:排序(越大排序越靠前)" json:"basic_class_sort"`
|
||||
Model
|
||||
}
|
||||
|
||||
func (m *BasicArticleClass) TableName() string {
|
||||
return "gdxz_basic_article_class"
|
||||
}
|
||||
|
||||
func (m *BasicArticleClass) BeforeCreate(tx *gorm.DB) error {
|
||||
if m.BasicClassId == 0 {
|
||||
m.BasicClassId = 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