mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
[FIX/BE-US] feat adjustment location and area
This commit is contained in:
@@ -112,6 +112,10 @@ func (c *RepportController) GetMarketing(ctx *fiber.Ctx) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
areaScope, err := m.ResolveAreaScope(ctx, c.RepportService.DB())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if locationScope.Restrict {
|
||||
allowed := toInt64Slice(locationScope.IDs)
|
||||
if len(allowed) == 0 {
|
||||
@@ -119,6 +123,13 @@ func (c *RepportController) GetMarketing(ctx *fiber.Ctx) error {
|
||||
}
|
||||
query.AllowedLocationIDs = allowed
|
||||
}
|
||||
if areaScope.Restrict {
|
||||
allowed := toInt64Slice(areaScope.IDs)
|
||||
if len(allowed) == 0 {
|
||||
allowed = []int64{-1}
|
||||
}
|
||||
query.AllowedAreaIDs = allowed
|
||||
}
|
||||
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0")
|
||||
@@ -220,6 +231,21 @@ func (c *RepportController) GetDebtSupplier(ctx *fiber.Ctx) error {
|
||||
SortOrder: ctx.Query("sort_order", ""),
|
||||
}
|
||||
|
||||
locationScope, err := m.ResolveLocationScope(ctx, c.RepportService.DB())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
areaScope, err := m.ResolveAreaScope(ctx, c.RepportService.DB())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if locationScope.Restrict {
|
||||
query.AllowedLocationIDs = toInt64Slice(locationScope.IDs)
|
||||
}
|
||||
if areaScope.Restrict {
|
||||
query.AllowedAreaIDs = toInt64Slice(areaScope.IDs)
|
||||
}
|
||||
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
return fiber.NewError(fiber.StatusBadRequest, "page and limit must be greater than 0")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user