2023-05-07 22:49:59 +08:00
|
|
|
package bill
|
|
|
|
|
2023-06-01 17:55:41 +08:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
2023-05-07 22:49:59 +08:00
|
|
|
|
|
|
|
// Bill represents 'bills' object.
|
|
|
|
type Bill struct {
|
2023-06-01 17:55:41 +08:00
|
|
|
gorm.Model
|
2023-05-07 22:49:59 +08:00
|
|
|
ID int `json:"id"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
Date string `json:"date"`
|
|
|
|
Money float64 `json:"money"`
|
|
|
|
Class string `json:"class"`
|
|
|
|
Label string `json:"label"`
|
|
|
|
Options string `json:"options"`
|
|
|
|
}
|
|
|
|
|
2023-05-31 15:40:27 +08:00
|
|
|
// BDate 用于判断获取bill的时间范围
|
2023-05-07 22:49:59 +08:00
|
|
|
type BDate struct {
|
|
|
|
Year int `json:"year"`
|
|
|
|
Month int `json:"month"`
|
|
|
|
Day int `json:"day"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type BillRepository interface {
|
|
|
|
GetBills(ctx context.Context) (*[]Bill, error)
|
2023-05-08 21:48:34 +08:00
|
|
|
GetBillByDay(ctx context.Context, year int, month int, day int) (*[]Bill, error)
|
2023-05-07 22:49:59 +08:00
|
|
|
GetBillByMonth(ctx context.Context, year int, month int) (*[]Bill, error)
|
|
|
|
GetBillByYear(ctx context.Context, year int) (*[]Bill, error)
|
|
|
|
GetBillByID(ctx context.Context, id int) (*Bill, error)
|
|
|
|
CreateBill(ctx context.Context, bill *Bill) error
|
|
|
|
UpdateBill(ctx context.Context, bill *Bill) error
|
|
|
|
DeleteBill(ctx context.Context, id int) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type BillService interface {
|
2023-05-11 21:00:29 +08:00
|
|
|
GetBills(ctx context.Context, date BDate) (*[]Bill, error)
|
|
|
|
GetBillByID(ctx context.Context, id int) (*Bill, error)
|
|
|
|
CreateBill(ctx context.Context, bill *Bill) error
|
|
|
|
UpdateBill(ctx context.Context, bill *Bill) error
|
|
|
|
DeleteBill(ctx context.Context, id int) error
|
2023-05-07 22:49:59 +08:00
|
|
|
}
|