package @app.group.id@.@app.name@.resources;

import @app.group.id@.@app.name@.resources.support.HypermediaSupport;
import @app.group.id@.@app.name@.services.BuildingService;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/buildings")
public class BuildingResource {
    private BuildingService buildingService;
    private HypermediaSupport hateoasPageSupport;

    public BuildingResource(BuildingService buildingService, HypermediaSupport hateoasPageSupport) {
        this.buildingService = buildingService;
        this.hateoasPageSupport = hateoasPageSupport;
    }

    @GetMapping()
    public ResponseEntity getAllBuildings(Pageable pageable) {
        return hateoasPageSupport.wrap(buildingService.findAll(pageable), pageable);
    }
}
