acd70d319f
- FinanceEntry model (income/expense x fixed/extra) - CRUD API endpoints for finance entries - FinancePage with summary cards and drill-down - Updated navigation with Finance tab - Updated todos default filter to active
53 lines
2.2 KiB
Go
53 lines
2.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"
|
|
}
|
|
|
|
// FinanceEntry 收支条目
|
|
// Type: income(收入) / expense(支出)
|
|
// Category: fixed(固定) / extra(额外)
|
|
type FinanceEntry struct {
|
|
ID uint64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
Year int `gorm:"type:int;not null;index" json:"year"` // 年份
|
|
Month int `gorm:"type:int;not null;default:0" json:"month"` // 月份(0表示全年)
|
|
Type string `gorm:"type:varchar(10);not null" json:"type"` // income / expense
|
|
Category string `gorm:"type:varchar(10);not null" json:"category"` // fixed / extra
|
|
Description string `gorm:"type:varchar(255)" json:"description"` // 条目描述
|
|
Amount float64 `gorm:"type:decimal(12,2);not null" json:"amount"` // 金额(正数)
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
}
|
|
|
|
func (FinanceEntry) TableName() string {
|
|
return "finance_entries"
|
|
}
|