oparl-service/oparl-server/src/main/java/de/twomartens/oparlservice/control/OParlController.java

63 lines
2.3 KiB
Java
Raw Normal View History

2020-07-08 00:06:57 +02:00
package de.twomartens.oparlservice.control;
import de.twomartens.oparlservice.configs.OParlServiceProperties;
import de.twomartens.oparlservice.entity.Body;
2020-07-08 23:48:45 +02:00
import de.twomartens.oparlservice.entity.Organization;
2020-07-08 00:06:57 +02:00
import de.twomartens.oparlservice.entity.System;
2020-07-08 23:48:45 +02:00
import de.twomartens.oparlservice.service.OParlService;
2020-07-08 00:06:57 +02:00
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
2020-07-08 00:06:57 +02:00
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
2020-07-08 00:06:57 +02:00
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
2020-07-08 23:48:45 +02:00
import java.util.Collections;
import java.util.List;
2020-07-08 00:06:57 +02:00
@Slf4j
@RestController
@RequestMapping(path = "/v1.1")
2020-07-08 00:06:57 +02:00
public class OParlController {
2020-07-08 23:48:45 +02:00
private final OParlService service;
2020-07-08 00:06:57 +02:00
2020-07-08 23:48:45 +02:00
OParlController(OParlService service) {
this.service = service;
2020-07-08 00:06:57 +02:00
}
@GetMapping("/")
2020-07-08 00:06:57 +02:00
@Operation(summary = "System information", description = "returns information about the OParl system")
public System system() {
log.info("method invoked /v1.1");
2020-07-08 23:48:45 +02:00
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");
2020-07-08 23:48:45 +02:00
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")
2020-07-08 23:48:45 +02:00
String id) {
log.info("method invoked /v1.1/body/{}", id);
2020-07-08 23:48:45 +02:00
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();
2020-07-08 00:06:57 +02:00
}
}