package adminkindboxhandler import ( "net/http" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" queryparam "git.gocasts.ir/ebhomengo/niki/pkg/query_param" "github.com/labstack/echo/v4" ) // GetAll godoc // @Summary Get all KindBoxes by admin // @Description Retrieves a list of all KindBoxes with filtering, sorting, and pagination options // @Tags KindBox // @Accept json // @Produce json // @Param filter_id query int false "Filter by ID" // @Param filter_kind_box_req_id query int false "Filter by KindBox request ID" // @Param filter_benefactor_id query int false "Filter by benefactor ID" // @Param filter_kind_box_type query string false "Filter by KindBox type" Enums(on-table,cylindrical,stand-up) // @Param filter_amount query int false "Filter by amount" // @Param filter_serial_number query string false "Filter by serial number" // @Param filter_status query string false "Filter by status" Enums(delivered,ready-to-return,assigned-receiver-agent,returned,enumerated) // @Param filter_delivered_at query string false "Filter by delivered at" Format(date-time) // @Param filter_return_refer_time_id query int false "Filter by return refer time ID" // @Param filter_return_refer_date query string false "Filter by return refer date" Format(date) // @Param filter_return_address_id query int false "Filter by return address ID" // @Param filter_receiver_agent_id query int false "Filter by receiver agent ID" // @Param filter_returned_at query string false "Filter by returned at" Format(date-time) // @Param filter_sender_agent_id query int false "Filter by sender agent ID" // @Param filter_deliver_refer_date query string false "Filter by deliver refer date" Format(date) // @Param filter_deliver_address_id query int false "Filter by deliver address ID" // @Param page_number query int false "Page number" // @Param page_size query int false "Page size" // @Param sort_field query string false "Sort by field" Enums(id,kind_box_req_id,benefactor_id,kind_box_type,amount,serial_number,status,delivered_at,return_refer_time_id,return_refer_date,return_address_id,receiver_agent_id,returned_at,sender_agent_id,deliver_refer_date,deliver_address_id) // @Param sort_direction query string false "Sort order" Enums(asc,desc) // @Success 200 {object} param.KindBoxGetAllResponse // @Failure 400 {string} "Bad request" // @Security AuthBearerAdmin // @Router /admin/kindboxes [get]. func (h Handler) GetAll(c echo.Context) error { var req param.KindBoxGetAllRequest if bErr := c.Bind(&req); bErr != nil { return echo.NewHTTPError(http.StatusBadRequest) } req.Filter = queryparam.GetFilterParams(c) if fieldErrors, err := h.adminKindBoxVld.ValidateGetAll(req); err != nil { msg, code := httpmsg.Error(err) return c.JSON(code, echo.Map{ "message": msg, "errors": fieldErrors, }) } resp, sErr := h.adminKindBoxSvc.GetAll(c.Request().Context(), req) if sErr != nil { msg, code := httpmsg.Error(sErr) return echo.NewHTTPError(code, msg) } return c.JSON(http.StatusOK, resp) }