generated from 2martens/template-service
63 lines
2.3 KiB
Java
63 lines
2.3 KiB
Java
package de.twomartens.oparlservice.control;
|
|
|
|
import de.twomartens.oparlservice.configs.OParlServiceProperties;
|
|
import de.twomartens.oparlservice.entity.Body;
|
|
import de.twomartens.oparlservice.entity.Organization;
|
|
import de.twomartens.oparlservice.entity.System;
|
|
import de.twomartens.oparlservice.service.OParlService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import java.util.Collections;
|
|
import java.util.List;
|
|
|
|
@Slf4j
|
|
@RestController
|
|
@RequestMapping(path = "/v1.1")
|
|
public class OParlController {
|
|
private final OParlService service;
|
|
|
|
OParlController(OParlService service) {
|
|
this.service = service;
|
|
}
|
|
|
|
@GetMapping("/")
|
|
@Operation(summary = "System information", description = "returns information about the OParl system")
|
|
public System system() {
|
|
log.info("method invoked /v1.1");
|
|
return service.getSystem();
|
|
}
|
|
|
|
@GetMapping("/bodies")
|
|
@Operation(summary = "List of available bodies", description = "returns a list of available bodies in this OParl system")
|
|
public List<Body> bodies() {
|
|
log.info("method invoked /v1.1/bodies");
|
|
return this.service.getBodies();
|
|
}
|
|
|
|
@GetMapping("/body/{id}")
|
|
@Operation(summary = "information about body", description = "returns information about the requested body")
|
|
public Body body(
|
|
@PathVariable
|
|
@Parameter(description = "body ID", example = "0")
|
|
String id) {
|
|
log.info("method invoked /v1.1/body/{}", id);
|
|
return service.getBody(id);
|
|
}
|
|
|
|
@GetMapping("/body/{id}/organizations")
|
|
@Operation(summary = "List of all organizations in body", description = "returns a list of all organizations in requested body")
|
|
public List<Organization> organizations(
|
|
@PathVariable
|
|
@Parameter(description = "body ID", example = "0")
|
|
String id) {
|
|
log.info("invoked method /v1.1/body/{}/organizations", id);
|
|
return Collections.emptyList();
|
|
}
|
|
}
|