news.go 1.3 KB

1234567891011121314151617181920212223242526272829
  1. package model
  2. import (
  3. "time"
  4. "gorm.io/gorm"
  5. )
  6. // News 对应 cy_news 表
  7. type News struct {
  8. ID uint `gorm:"primaryKey" json:"id"`
  9. CategoryID uint `gorm:"column:category_id;not null" json:"category_id"`
  10. Title string `gorm:"column:title;size:255;not null" json:"title"`
  11. Author string `gorm:"column:author;size:50" json:"author,omitempty"`
  12. CoverImage string `gorm:"column:cover_image;size:255" json:"cover_image,omitempty"`
  13. Summary string `gorm:"column:summary;size:255" json:"summary,omitempty"`
  14. Content string `gorm:"column:content;type:longtext;not null" json:"content"`
  15. Status int8 `gorm:"column:status;default:1;not null" json:"status"`
  16. IsRecommend int8 `gorm:"column:is_recommend;default:0;not null" json:"is_recommend"`
  17. IsTop int8 `gorm:"column:is_top;default:0;not null" json:"is_top"`
  18. Views int `gorm:"column:views;default:0;not null" json:"views"`
  19. CreateTime time.Time `gorm:"column:create_time" json:"create_time"`
  20. UpdateTime time.Time `gorm:"column:update_time" json:"update_time"`
  21. DeleteTime gorm.DeletedAt `gorm:"column:delete_time;index" json:"delete_time,omitempty"`
  22. }
  23. func (News) TableName() string {
  24. return "cy_news"
  25. }