Files
neo-blog/internal/model/label.go
Snowykami abe1099711 ️ feat: update global styles and color variables for improved theming
refactor: change import paths for DeviceContext and GravatarAvatar components

fix: adjust login form API call and update UI text for clarity

feat: add post API for listing posts with pagination and filtering options

feat: implement BlogCard component for displaying blog posts with enhanced UI

feat: create Badge component for consistent styling of labels and indicators

refactor: reintroduce DeviceContext with improved functionality for theme and language management

feat: define Label and Post models for better type safety and structure
2025-07-24 13:12:59 +08:00

25 lines
999 B
Go

package model
import (
"github.com/snowykami/neo-blog/internal/dto"
"gorm.io/gorm"
)
type Label struct {
gorm.Model
Key string `gorm:"index"` // 标签键,唯一标识
Value string `gorm:"type:text"` // 标签值,描述标签的内容
Color string `gorm:"type:text"` // 前端可用颜色代码
TailwindClassName string `gorm:"type:text"` // Tailwind CSS 的类名,用于前端样式
Posts []Post `gorm:"many2many:post_labels;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` // 关联的帖子
}
func (l *Label) ToDto() dto.LabelDto {
return dto.LabelDto{
Key: l.Key,
Value: l.Value,
Color: l.Color,
TailwindClassName: l.TailwindClassName,
}
}