-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathClientController.java
More file actions
33 lines (25 loc) · 1011 Bytes
/
ClientController.java
File metadata and controls
33 lines (25 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.lohika.jclub.client;
import com.lohika.jclub.storage.client.Apartment;
import com.lohika.jclub.storage.client.StorageServiceClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.PagedResources;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.PostConstruct;
@Slf4j
@RestController
public class ClientController {
@Autowired
private StorageServiceClient storageServiceClient;
@PostConstruct
public void warmUp() {
storageServiceClient.list();
}
@GetMapping(value = "/apartments", produces = MediaType.APPLICATION_JSON_VALUE)
public PagedResources<Apartment> getApartments() {
PagedResources<Apartment> list = storageServiceClient.list();
return new PagedResources<>(list.getContent(), list.getMetadata());
}
}