FEAT[BE]: create marketing report API

This commit is contained in:
aguhh18
2025-12-15 16:17:37 +07:00
parent efaeb89ca1
commit d5bc6838c8
9 changed files with 412 additions and 46 deletions
@@ -22,7 +22,7 @@ func NewRepportController(repportService service.RepportService) *RepportControl
}
func (c *RepportController) GetExpense(ctx *fiber.Ctx) error {
query := &validation.Query{
query := &validation.ExpenseQuery{
Page: ctx.QueryInt("page", 1),
Limit: ctx.QueryInt("limit", 10),
Search: ctx.Query("search", ""),
@@ -59,3 +59,41 @@ func (c *RepportController) GetExpense(ctx *fiber.Ctx) error {
Data: result,
})
}
func (c *RepportController) GetMarketing(ctx *fiber.Ctx) error {
query := &validation.MarketingQuery{
Page: ctx.QueryInt("page", 1),
Limit: ctx.QueryInt("limit", 10),
Search: ctx.Query("search", ""),
CustomerId: int64(ctx.QueryInt("customer_id", 0)),
ProjectFlockKandangId: int64(ctx.QueryInt("project_flock_kandang_id", 0)),
DeliveryDate: ctx.Query("delivery_date", ""),
ProductId: int64(ctx.QueryInt("product_id", 0)),
WarehouseId: int64(ctx.QueryInt("warehouse_id", 0)),
SalesPersonId: int64(ctx.QueryInt("sales_person_id", 0)),
MarketingId: int64(ctx.QueryInt("marketing_id", 0)),
}
if query.Page < 1 || query.Limit < 1 {
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0")
}
result, totalResults, err := c.RepportService.GetMarketing(ctx, query)
if err != nil {
return err
}
return ctx.Status(fiber.StatusOK).
JSON(response.SuccessWithPaginate[dto.RepportMarketingListDTO]{
Code: fiber.StatusOK,
Status: "success",
Message: "Get marketing report successfully",
Meta: response.Meta{
Page: query.Page,
Limit: query.Limit,
TotalPages: int64(math.Ceil(float64(totalResults) / float64(query.Limit))),
TotalResults: totalResults,
},
Data: result,
})
}