feat: 添加预算管理功能,包括预算的创建、查询、更新、删除及进度计算。
This commit is contained in:
@@ -278,6 +278,7 @@ type Account struct {
|
||||
PiggyBanks []PiggyBank `gorm:"foreignKey:LinkedAccountID" json:"-"`
|
||||
ParentAccount *Account `gorm:"foreignKey:ParentAccountID" json:"parent_account,omitempty"`
|
||||
SubAccounts []Account `gorm:"foreignKey:ParentAccountID" json:"sub_accounts,omitempty"`
|
||||
Tags []Tag `gorm:"many2many:account_tags;" json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// TableName specifies the table name for Account
|
||||
@@ -417,6 +418,17 @@ func (TransactionTag) TableName() string {
|
||||
return "transaction_tags"
|
||||
}
|
||||
|
||||
// AccountTag represents the many-to-many relationship between accounts and tags
|
||||
type AccountTag struct {
|
||||
AccountID uint `gorm:"primaryKey" json:"account_id"`
|
||||
TagID uint `gorm:"primaryKey" json:"tag_id"`
|
||||
}
|
||||
|
||||
// TableName specifies the table name for AccountTag
|
||||
func (AccountTag) TableName() string {
|
||||
return "account_tags"
|
||||
}
|
||||
|
||||
// Budget represents a spending budget for a category or account
|
||||
type Budget struct {
|
||||
BaseModel
|
||||
@@ -843,6 +855,7 @@ func AllModels() []interface{} {
|
||||
&Tag{},
|
||||
&Transaction{},
|
||||
&TransactionTag{}, // Explicit join table for many-to-many relationship
|
||||
&AccountTag{}, // Explicit join table for account-tag many-to-many relationship
|
||||
&Budget{},
|
||||
&PiggyBank{},
|
||||
&RecurringTransaction{},
|
||||
|
||||
Reference in New Issue
Block a user