mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-06-09 15:07:49 +00:00
4b9e86427d
Added start_date, end_date, and filter_by query parameters to the GET /api/marketing/ endpoint. Users can now filter marketing records by a date range using either so_date (Sales Order date, default) or created_at as the target column. Changes: - validation: added StartDate, EndDate (YYYY-MM-DD format), and FilterBy (oneof: so_date, created_at) to DeliveryOrderQuery struct - controller: parse the three new query params in GetAll handler - service: apply >=start / <end+1day date range filter in the query modifier using the existing utils.ParseDateRangeForQuery helper Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
2.7 KiB
Go
47 lines
2.7 KiB
Go
package validation
|
|
|
|
type DeliveryProduct struct {
|
|
MarketingProductId uint `json:"marketing_product_id" validate:"required,gt=0"`
|
|
Qty float64 `json:"qty" validate:"omitempty,gte=0"`
|
|
UnitPrice float64 `json:"unit_price" validate:"omitempty,gte=0"`
|
|
AvgWeight float64 `json:"avg_weight" validate:"omitempty,gte=0"`
|
|
WeightPerConvertion *float64 `json:"weight_per_convertion" validate:"omitempty,gte=0"`
|
|
TotalWeight *float64 `json:"total_weight" validate:"omitempty,gte=0"`
|
|
TotalPrice *float64 `json:"total_price" validate:"omitempty,gte=0"`
|
|
DeliveryDate string `json:"delivery_date" validate:"omitempty,datetime=2006-01-02"`
|
|
VehicleNumber string `json:"vehicle_number" validate:"omitempty,max=50"`
|
|
}
|
|
|
|
type DeliveryOrderCreate struct {
|
|
MarketingId uint `json:"marketing_id" validate:"required,gt=0"`
|
|
DeliveryProducts []DeliveryProduct `json:"delivery_products" validate:"required,min=1,dive"`
|
|
}
|
|
|
|
type DeliveryOrderUpdate struct {
|
|
DeliveryProducts []DeliveryProduct `json:"delivery_products" validate:"omitempty,min=1,dive"`
|
|
}
|
|
|
|
type DeliveryOrderQuery struct {
|
|
Page int `query:"page" validate:"omitempty,number,min=1,gt=0"`
|
|
Limit int `query:"limit" validate:"omitempty,number,min=1,gt=0"`
|
|
Search string `query:"search" validate:"omitempty,max=100"`
|
|
ProductIDs []uint `query:"product_ids" validate:"omitempty,dive,gt=0"`
|
|
Status string `query:"status" validate:"omitempty,max=50"`
|
|
CustomerId uint `query:"customer_id" validate:"omitempty,gt=0"`
|
|
MarketingId uint `query:"marketing_id" validate:"omitempty,gt=0"`
|
|
ProjectFlockID uint `query:"project_flock_id" validate:"omitempty,gt=0"`
|
|
ProjectFlockKandangID uint `query:"project_flock_kandang_id" validate:"omitempty,gt=0"`
|
|
WarehouseID uint `query:"warehouse_id" validate:"omitempty,gt=0"`
|
|
SortBy string `query:"sort_by" validate:"omitempty,oneof=so_number so_date status customer grand_total created_at"`
|
|
SortOrder string `query:"sort_order" validate:"omitempty,oneof=asc desc"`
|
|
StartDate string `query:"start_date" validate:"omitempty,datetime=2006-01-02"`
|
|
EndDate string `query:"end_date" validate:"omitempty,datetime=2006-01-02"`
|
|
FilterBy string `query:"filter_by" validate:"omitempty,oneof=so_date created_at"`
|
|
}
|
|
|
|
type DeliveryOrderApprove struct {
|
|
Action string `json:"action" validate:"required_strict"`
|
|
ApprovableIds []uint `json:"approvable_ids" validate:"required_strict,min=1,dive,gt=0"`
|
|
Notes *string `json:"notes,omitempty" validate:"omitempty,max=500"`
|
|
}
|