d495a2b798
- 待办事项(支持优先级、截止日期) - 每日记录(上午/下午/晚上分条目) - Go后端 + Gin + GORM + MySQL - React前端 + TailwindCSS
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type Todo struct {
|
|
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
Title string `gorm:"type:varchar(255);not null" json:"title"`
|
|
Done bool `gorm:"type:tinyint(1);not null;default:0" json:"done"`
|
|
Priority int `gorm:"type:tinyint(1);not null;default:2" json:"priority"` // 1高 2中 3低
|
|
DueDate *time.Time `gorm:"type:date" json:"due_date"` // 可选截止日期
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
}
|
|
|
|
func (Todo) TableName() string {
|
|
return "todos"
|
|
}
|
|
|
|
type DailyLog struct {
|
|
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
Date string `gorm:"type:date;not null;uniqueIndex" json:"date"` // 格式:2024-07-24
|
|
Morning string `gorm:"type:text" json:"morning"`
|
|
Afternoon string `gorm:"type:text" json:"afternoon"`
|
|
Evening string `gorm:"type:text" json:"evening"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
}
|
|
|
|
func (DailyLog) TableName() string {
|
|
return "daily_logs"
|
|
}
|