File tree Expand file tree Collapse file tree
src/main/java/com/lohika/jclub
storage-service/src/main/java/com/lohika/jclub Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1717 <module >rating-service</module >
1818 <module >hackster-service</module >
1919 <module >realtor-service</module >
20+ <module >storage-service</module >>
2021 </modules >
2122</project >
Original file line number Diff line number Diff line change 4545 <artifactId >lombok</artifactId >
4646 <version >1.16.12</version >
4747 </dependency >
48+ <dependency >
49+ <groupId >io.github.openfeign</groupId >
50+ <artifactId >feign-okhttp</artifactId >
51+ <version >9.3.1</version >
52+ </dependency >
53+ <dependency >
54+ <groupId >io.github.openfeign</groupId >
55+ <artifactId >feign-gson</artifactId >
56+ <version >9.3.1</version >
57+ </dependency >
58+ <dependency >
59+ <groupId >io.github.openfeign</groupId >
60+ <artifactId >feign-slf4j</artifactId >
61+ <version >9.3.1</version >
62+ </dependency >
4863 </dependencies >
4964
5065 <dependencyManagement >
Original file line number Diff line number Diff line change @@ -17,4 +17,6 @@ public class ApartmentRecord {
1717 private String phone ;
1818 @ NonNull
1919 private String realtorName ;
20+ @ NonNull
21+ private String mail ;
2022}
Original file line number Diff line number Diff line change 1+ package com .lohika .jclub ;
2+
3+ import feign .Headers ;
4+ import feign .RequestLine ;
5+
6+ /**
7+ * Created by omuliarevych on 6/8/17.
8+ */
9+ public interface ApartmentRecordClient {
10+
11+ @ RequestLine ("POST /apartmentRecords" )
12+ @ Headers ("Content-Type: application/json" )
13+ void storeApartment (ApartmentRecord apartmentRecord );
14+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ public class RealtorController {
2121 @ Autowired
2222 private RestTemplate restTemplate ;
2323
24+ @ Autowired
25+ private RealtorService realtorService ;
26+
2427 @ PostMapping ("/apartments" )
2528 public void addApartment (@ RequestBody ApartmentRecord apartmentRecord ) {
2629 ResponseEntity <Boolean > isHackster =
@@ -29,6 +32,15 @@ public void addApartment(@RequestBody ApartmentRecord apartmentRecord) {
2932 log .info ("Is hackster " + isHackster );
3033 }
3134
35+ @ PostMapping ("/storeApartments" )
36+ public void storeApartment (@ RequestBody ApartmentRecord apartmentRecord ) {
37+ realtorService .storeApartment (apartmentRecord );
38+ /*ApartmentRecordClient apartmentRecordClient = Feign.builder().encoder(new JacksonEncoder())
39+ .decoder(new JacksonDecoder()).target(ApartmentRecordClient.class, "http://storage-service");
40+ apartmentRecordClient.storeApartment(apartmentRecord);*/
41+ log .info ("Stored" );
42+ }
43+
3244 @ RequestMapping ("/service-instances/{applicationName}" )
3345 public List <ServiceInstance > serviceInstancesByApplicationName (@ PathVariable String applicationName ) {
3446 return this .discoveryClient .getInstances (applicationName );
Original file line number Diff line number Diff line change 44import org .springframework .boot .autoconfigure .SpringBootApplication ;
55import org .springframework .cloud .client .discovery .EnableDiscoveryClient ;
66import org .springframework .cloud .client .loadbalancer .LoadBalanced ;
7+ import org .springframework .cloud .netflix .feign .EnableFeignClients ;
8+ import org .springframework .cloud .netflix .feign .FeignClient ;
79import org .springframework .context .annotation .Bean ;
10+ import org .springframework .web .bind .annotation .PostMapping ;
811import org .springframework .web .client .RestTemplate ;
912
13+ @ EnableFeignClients
1014@ EnableDiscoveryClient
1115@ SpringBootApplication
1216public class RealtorServiceApplication {
@@ -21,3 +25,9 @@ public RestTemplate restTemplate() {
2125 return new RestTemplate ();
2226 }
2327}
28+
29+ @ FeignClient ("storage-service" )
30+ interface RealtorService {
31+ @ PostMapping ("/apartmentRecords" )
32+ void storeApartment (ApartmentRecord apartmentRecord );
33+ }
Original file line number Diff line number Diff line change 1+ package com .lohika .jclub ;
2+
3+ import lombok .*;
4+
5+ import javax .persistence .Entity ;
6+ import javax .persistence .Id ;
7+
8+ @ NoArgsConstructor
9+ @ AllArgsConstructor
10+ @ Data
11+ @ Entity
12+ public class ApartmentRecord {
13+ @ NonNull
14+ private String location ;
15+ @ NonNull
16+ private double price ;
17+ @ NonNull
18+ private double sqft ;
19+ @ NonNull
20+ private String phone ;
21+ @ NonNull
22+ private String realtorName ;
23+ @ Id
24+ private String mail ;
25+ }
Original file line number Diff line number Diff line change 1+ package com .lohika .jclub ;
2+
3+ import org .springframework .data .repository .CrudRepository ;
4+ import org .springframework .data .rest .core .annotation .RepositoryRestResource ;
5+
6+ /**
7+ * Created by omuliarevych on 6/8/17.
8+ */
9+ @ RepositoryRestResource
10+ public interface ApartmentRepository extends CrudRepository <ApartmentRecord , String > {
11+ }
You can’t perform that action at this time.
0 commit comments