From d9a91b64bb705b2e734a00adf535566c35d87003 Mon Sep 17 00:00:00 2001 From: clz Date: Sat, 10 Jun 2023 16:53:19 +0800 Subject: [PATCH] refactor: refactor api --- internal/bill/handler.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/bill/handler.go b/internal/bill/handler.go index d93d28c..a994d13 100644 --- a/internal/bill/handler.go +++ b/internal/bill/handler.go @@ -14,7 +14,7 @@ func NewBillHandler(billRoute fiber.Router, bs BillService) { billService: bs, } - billRoute.Get("/", handler.getBills) + billRoute.Get("/:year?/:month?/:day?", handler.checkGetBillsParams, handler.getBills) billRoute.Post("/", handler.createBill) billRoute.Put("/", handler.updateBill) billRoute.Delete("/", handler.deleteBill) @@ -23,8 +23,10 @@ func NewBillHandler(billRoute fiber.Router, bs BillService) { func (h *BillHandler) getBills(c *fiber.Ctx) error { customContext, cancel := context.WithCancel(context.Background()) defer cancel() - // TODO() - bills, err := h.billService.GetBills(customContext, BDate{}) + + bDate := c.Locals("bDate").(BDate) + + bills, err := h.billService.GetBills(customContext, bDate) if err != nil { return c.Status(fiber.StatusInternalServerError).JSON(&fiber.Map{ "status": "fail",