2026-03-24 22:27:53 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Channel 频道配置(用于帖子分区)
|
|
|
|
|
type Channel struct {
|
|
|
|
|
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
|
|
|
|
Name string `json:"name" gorm:"type:varchar(100);not null"`
|
|
|
|
|
Slug string `json:"slug" gorm:"type:varchar(100);uniqueIndex;not null"`
|
|
|
|
|
Description string `json:"description" gorm:"type:varchar(255)"`
|
|
|
|
|
SortOrder int `json:"sort_order" gorm:"default:0;index"`
|
|
|
|
|
IsActive bool `json:"is_active" gorm:"default:true;index"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Channel) BeforeCreate(tx *gorm.DB) error {
|
2026-05-04 13:07:03 +08:00
|
|
|
SetUUIDIfEmpty(&c.ID)
|
2026-03-24 22:27:53 +08:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Channel) TableName() string {
|
|
|
|
|
return "channels"
|
|
|
|
|
}
|
|
|
|
|
|