From 1e96c35919b0cc33720ca9467e5985660bc64634 Mon Sep 17 00:00:00 2001 From: clz Date: Sun, 7 May 2023 22:49:59 +0800 Subject: [PATCH] to: bill domain --- internal/bill/domain.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 internal/bill/domain.go diff --git a/internal/bill/domain.go b/internal/bill/domain.go new file mode 100644 index 0000000..bb830c6 --- /dev/null +++ b/internal/bill/domain.go @@ -0,0 +1,39 @@ +package bill + +import "context" + +// Bill represents 'bills' object. +type Bill struct { + 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"` +} + +type BDate struct { + Year int `json:"year"` + Month int `json:"month"` + Day int `json:"day"` +} + +type BillRepository interface { + GetBills(ctx context.Context) (*[]Bill, error) + GetBillByDate(ctx context.Context, year int, month int, day int) (*[]Bill, error) + 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 { + FetchBills(ctx context.Context, date BDate) (*[]Bill, error) + FetchBillByID(ctx context.Context, id int) (*Bill, error) + BuildBill(ctx context.Context, bill *Bill) error + ModifyBill(ctx context.Context, id int) error + DestroyBill(ctx context.Context, id int) error +}