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:
@@ -3,11 +3,13 @@ package controller
|
||||
import (
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/modules/master/warehouses/dto"
|
||||
service "gitlab.com/mbugroup/lti-api.git/internal/modules/master/warehouses/services"
|
||||
validation "gitlab.com/mbugroup/lti-api.git/internal/modules/master/warehouses/validations"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/response"
|
||||
"gitlab.com/mbugroup/lti-api.git/internal/utils"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -23,6 +25,11 @@ func NewWarehouseController(warehouseService service.WarehouseService) *Warehous
|
||||
}
|
||||
|
||||
func (u *WarehouseController) GetAll(c *fiber.Ctx) error {
|
||||
excludeIDs, err := parseCommaSeparatedUint(c.Query("exclude_id", ""))
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
query := &validation.Query{
|
||||
Page: c.QueryInt("page", 1),
|
||||
Limit: c.QueryInt("limit", 10),
|
||||
@@ -30,6 +37,8 @@ func (u *WarehouseController) GetAll(c *fiber.Ctx) error {
|
||||
AreaId: c.QueryInt("area_id", 0),
|
||||
LocationId: c.QueryInt("location_id", 0),
|
||||
ActiveProjectFlockOnly: c.QueryBool("active_project_flock", false),
|
||||
TransferContext: c.Query(utils.TransferContextKey, ""),
|
||||
ExcludeIDs: excludeIDs,
|
||||
}
|
||||
|
||||
if query.Page < 1 || query.Limit < 1 {
|
||||
@@ -56,6 +65,28 @@ func (u *WarehouseController) GetAll(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func parseCommaSeparatedUint(raw string) ([]uint, error) {
|
||||
raw = strings.TrimSpace(raw)
|
||||
if raw == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
parts := strings.Split(raw, ",")
|
||||
out := make([]uint, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
part = strings.TrimSpace(part)
|
||||
if part == "" {
|
||||
continue
|
||||
}
|
||||
value, err := strconv.ParseUint(part, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fiber.NewError(fiber.StatusBadRequest, "invalid exclude_id")
|
||||
}
|
||||
out = append(out, uint(value))
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (u *WarehouseController) GetOne(c *fiber.Ctx) error {
|
||||
param := c.Params("id")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user