refactor: refactor Bill struct
This commit is contained in:
parent
91f212ba62
commit
c3231ea141
|
@ -8,11 +8,37 @@ import (
|
|||
// Bill represents 'bills' object.
|
||||
type Bill struct {
|
||||
gorm.Model
|
||||
Type string
|
||||
Date string
|
||||
Year int
|
||||
Month int
|
||||
Day int
|
||||
Money float64
|
||||
Class string
|
||||
Label string
|
||||
Options string
|
||||
Type string
|
||||
}
|
||||
|
||||
type BillDTO struct {
|
||||
ID int `json:"id"`
|
||||
Year int `json:"year"`
|
||||
Month int `json:"month"`
|
||||
Day int `json:"day"`
|
||||
Money float64 `json:"money"`
|
||||
Label string `json:"label"`
|
||||
Options string `json:"options"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
func (b *Bill) Dto() BillDTO {
|
||||
return BillDTO{
|
||||
ID: int(b.ID),
|
||||
Year: b.Year,
|
||||
Month: b.Month,
|
||||
Day: b.Day,
|
||||
Money: b.Money,
|
||||
Label: b.Label,
|
||||
Options: b.Options,
|
||||
Type: b.Type,
|
||||
}
|
||||
}
|
||||
|
||||
// BDate 用于判断获取bill的时间范围
|
||||
|
@ -34,8 +60,8 @@ type BillRepository interface {
|
|||
}
|
||||
|
||||
type BillService interface {
|
||||
GetBills(ctx context.Context, date BDate) ([]Bill, error)
|
||||
GetBillByID(ctx context.Context, id int) (*Bill, error)
|
||||
GetBills(ctx context.Context, date BDate) ([]interface{}, error)
|
||||
GetBillByID(ctx context.Context, id int) (interface{}, error)
|
||||
CreateBill(ctx context.Context, bill *Bill) error
|
||||
UpdateBill(ctx context.Context, bill *Bill) error
|
||||
DeleteBill(ctx context.Context, id int) error
|
||||
|
|
Loading…
Reference in New Issue
Block a user