Skip to content

Commit cf6987f

Browse files
author
ardizioa
committed
Change entity nam
1 parent 9e8e4b3 commit cf6987f

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

src/main/java/com/aardizio/client/RestClientExample.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.aardizio.client;
22

3-
import com.aardizio.model.Hotels;
3+
import com.aardizio.model.Hotel;
44

55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.beans.factory.annotation.Qualifier;
@@ -25,16 +25,16 @@ public class RestClientExample {
2525
@Qualifier("hotelWebClient")
2626
private WebClient hotelWebClient;
2727

28-
public Flux<Hotels> send() {
28+
public Flux<Hotel> getAllHotels(){
2929

30-
Flux<Hotels> hotels = hotelWebClient.get()
30+
Flux<Hotel> hotels = hotelWebClient.get()
3131
.uri("/hotels")
3232
.accept(MediaType.APPLICATION_JSON)
3333
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString())
3434
.retrieve()
3535
.onStatus(HttpStatus::is4xxClientError, RestClientErrorHandler::handle)
3636
.onStatus(HttpStatus::is5xxServerError, RestClientErrorHandler::handle)
37-
.bodyToFlux(Hotels.class);
37+
.bodyToFlux(Hotel.class);
3838
return hotels;
3939
}
4040

src/main/java/com/aardizio/model/Hotels.java renamed to src/main/java/com/aardizio/model/Hotel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import com.datastax.driver.mapping.annotations.PartitionKey;
77
import com.datastax.driver.mapping.annotations.Table;
88

9-
@Table(keyspace = "hotel", name = "hotels")
10-
public class Hotels {
9+
@Table(keyspace = "hotel", name = "hotel")
10+
public class Hotel {
1111

1212
@PartitionKey
1313
private String uuid;

src/main/java/com/aardizio/repository/ReactiveHotelRepository.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@
1212
*
1313
* @author Alessandro Pio Ardizio
1414
*/
15-
public interface ReactiveHotelRepository extends ReactiveCrudRepository<Hotels, String> {
15+
public interface ReactiveHotelRepository extends ReactiveCrudRepository<Hotel, String> {
1616

1717
/**
1818
* Derived query selecting by {@code lastname}.
1919
*
2020
* @param lastname
2121
* @return
2222
*/
23-
Mono<Hotels> findByUuid(String id);
23+
Mono<Hotel> findByUuid(String id);
2424

2525
/**
2626
* Delete by uuid.
2727
*/
28-
@Query("DELETE FROM HOTELS WHERE UUID=?0")
29-
Mono<Hotels> deleteByUuid(String id);
28+
@Query("DELETE FROM HOTEL WHERE UUID=?0")
29+
Mono<Hotel> deleteByUuid(String id);
3030

3131
}

src/main/java/com/aardizio/resource/HotelController.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.aardizio.resource;
22

33
import java.io.IOException;
4-
import java.util.Collection;
54
import java.util.List;
65

7-
import com.aardizio.client.RestClientErrorHandler;
86
import com.aardizio.client.RestClientExample;
9-
import com.aardizio.model.Hotels;
7+
import com.aardizio.model.Hotel;
108
import com.aardizio.repository.ReactiveHotelRepository;
119
import com.datastax.driver.core.ConsistencyLevel;
1210
import com.datastax.driver.core.Statement;
@@ -64,14 +62,14 @@ public class HotelController {
6462

6563
@GetMapping(value = "/clientExample", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
6664
MediaType.APPLICATION_JSON_VALUE })
67-
public @ResponseBody Flux<Hotels> clientExample() {
65+
public @ResponseBody Flux<Hotel> clientExample() {
6866
log.info("Client example start");
69-
return hotelRestClient.send();
67+
return hotelRestClient.getAllHotels();
7068
}
7169

7270
@DeleteMapping(value = "/hotels/{id}", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
7371
MediaType.APPLICATION_JSON_VALUE })
74-
public Mono<Hotels> delete(@PathVariable String id) {
72+
public Mono<Hotel> delete(@PathVariable String id) {
7573

7674
tracer.currentSpan().tag("hotelid", id);
7775
log.info("deleting a journal");
@@ -80,7 +78,7 @@ public Mono<Hotels> delete(@PathVariable String id) {
8078

8179
@PostMapping(value = "/hotels", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
8280
MediaType.APPLICATION_JSON_VALUE })
83-
public @ResponseBody Mono<Hotels> create(@RequestBody Hotels hotel) {
81+
public @ResponseBody Mono<Hotel> create(@RequestBody Hotel hotel) {
8482
tracer.currentSpan().tag("hotelid", hotel.getId());
8583
log.info("creating a journal 1");
8684

@@ -98,7 +96,7 @@ public Mono<Hotels> delete(@PathVariable String id) {
9896

9997
@GetMapping(value = "/hotels/{uuid}", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
10098
MediaType.APPLICATION_JSON_VALUE })
101-
public Mono<Hotels> search(@PathVariable String uuid) {
99+
public Mono<Hotel> search(@PathVariable String uuid) {
102100
tracer.currentSpan().tag("hotelid", uuid);
103101
log.info("Search gas");
104102
return hotelRepo.findByUuid(uuid);
@@ -109,12 +107,12 @@ public Mono<Hotels> search(@PathVariable String uuid) {
109107
*/
110108
@GetMapping(value = "/hotels", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = {
111109
MediaType.APPLICATION_JSON_VALUE })
112-
public Mono<List<Hotels>> getAllRetryProof() {
110+
public Mono<List<Hotel>> getAllRetryProof() {
113111
Statement search = QueryBuilder.select()
114-
.from("hotels")
112+
.from("hotel")
115113
.setConsistencyLevel(ConsistencyLevel.THREE)
116114
.setRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE);
117-
return reactiveCassandraTemplate.select(search, Hotels.class).collectList();
115+
return reactiveCassandraTemplate.select(search, Hotel.class).collectList();
118116
}
119117

120118
@ExceptionHandler

src/main/resources/schema.cql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE TABLE hotel.hotels (
1+
CREATE TABLE hotel.hotel (
22
uuid text PRIMARY KEY,
33
name text,
44
phone text,

0 commit comments

Comments
 (0)