de.frachtwerk.essencium.backend.controller.AbstractDefaultRestController Maven / Gradle / Ivy
/*
* Copyright (C) 2024 Frachtwerk GmbH, Leopoldstraße 7C, 76133 Karlsruhe.
*
* This file is part of essencium-backend.
*
* essencium-backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* essencium-backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with essencium-backend. If not, see .
*/
package de.frachtwerk.essencium.backend.controller;
import de.frachtwerk.essencium.backend.model.AbstractBaseModel;
import de.frachtwerk.essencium.backend.service.AbstractEntityService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
public abstract class AbstractDefaultRestController<
I, ID extends Serializable, O extends AbstractBaseModel>
extends AbstractRestController {
protected AbstractDefaultRestController(AbstractEntityService service) {
super(service);
}
@GetMapping
@Parameter(
in = ParameterIn.QUERY,
description = "Page you want to retrieve (0..N)",
name = "page",
content = @Content(schema = @Schema(type = "integer", defaultValue = "0")))
@Parameter(
in = ParameterIn.QUERY,
description = "Number of records per page.",
name = "size",
content = @Content(schema = @Schema(type = "integer", defaultValue = "20")))
@Parameter(
in = ParameterIn.QUERY,
description =
"Sorting criteria in the format: property(,)(asc|desc). "
+ "Default sort order is ascending. "
+ "Multiple sort criteria are supported.",
name = "sort",
content = @Content(array = @ArraySchema(schema = @Schema(type = "string"))))
@NotNull
public Page findAll(@NotNull @ParameterObject final Pageable pageable) {
return service.getAll(pageable);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy