|
3 | 3 | import io.vertx.core.Promise; |
4 | 4 | import io.vertx.easyerp.microservice.common.RestAPIVerticle; |
5 | 5 | import io.vertx.easyerp.microservice.propertymanagement.PropertyManagementService; |
| 6 | +import io.vertx.easyerp.microservice.propertymanagement.jpojo.Accommodation; |
| 7 | +import io.vertx.easyerp.microservice.propertymanagement.jpojo.PropertyAmenity; |
| 8 | +import io.vertx.easyerp.microservice.propertymanagement.jpojo.PropertyProfile; |
6 | 9 | import io.vertx.ext.web.Router; |
| 10 | +import io.vertx.ext.web.RoutingContext; |
7 | 11 | import org.slf4j.Logger; |
8 | 12 | import org.slf4j.LoggerFactory; |
9 | 13 |
|
@@ -42,17 +46,83 @@ public void start(Promise<Void> startPromise) throws Exception { |
42 | 46 | final Router router = enableRouteLoggingSupport(Router.router(vertx)); |
43 | 47 |
|
44 | 48 | // api route handler |
45 | | - /*router.post(API_ADD).handler(this::apiAddUser); |
| 49 | + /* |
| 50 | + router.post(API_ADD).handler(this::apiAddUser); |
46 | 51 | router.get(API_RETRIEVE).handler(this::apiRetrieveUser); |
47 | 52 | router.get(API_RETRIEVE_ALL).handler(this::apiRetrieveAll); |
48 | 53 | router.patch(API_UPDATE).handler(this::apiUpdateUser); |
49 | 54 | router.delete(API_DELETE).handler(this::apiDeleteUser); |
50 | | -*/ |
| 55 | + */ |
| 56 | + |
| 57 | + router.post(API_PROFILE_ADD).handler(this::addPropProfile); |
| 58 | + |
51 | 59 | String host = config().getString("property.http.address", "0.0.0.0"); |
52 | 60 | int port = config().getInteger("property.http.port", 8085); |
53 | 61 |
|
54 | 62 | createHttpServer(router, host, port) |
55 | 63 | .compose(serverCreated -> publishHttpEndpoint(SERVICE_NAME, host, port)) |
56 | 64 | .onComplete(startPromise); |
57 | 65 | } |
| 66 | + |
| 67 | + private void addPropProfile(RoutingContext context){ |
| 68 | + PropertyProfile profile = new PropertyProfile(context.getBodyAsJson()); |
| 69 | + service.createProfile(profile, resultHandler(context, 201)); |
| 70 | + } |
| 71 | + |
| 72 | + private void editPropProfile(RoutingContext context){ |
| 73 | + notImplemented(context); |
| 74 | + } |
| 75 | + |
| 76 | + private void fetcPropProfile(RoutingContext context){ |
| 77 | + String id = context.request().getParam("id"); |
| 78 | + service.retrieveProfile(id, resultHandlerNonEmpty(context)); |
| 79 | + } |
| 80 | + |
| 81 | + private void deletePropProfile(RoutingContext context){ |
| 82 | + String serialNo = context.request().getParam("Id"); |
| 83 | + service.deleteProfile(serialNo, deleteResultHandler(context)); |
| 84 | + } |
| 85 | + |
| 86 | + private void addPropAmenity(RoutingContext context){ |
| 87 | + PropertyAmenity propertyAmenity = new PropertyAmenity((context.getBodyAsJson())); |
| 88 | + service.createAmenity(propertyAmenity, resultHandler(context, 201)); |
| 89 | + } |
| 90 | + |
| 91 | + private void editPropAmenity(RoutingContext context){ |
| 92 | + notImplemented(context); |
| 93 | + } |
| 94 | + |
| 95 | + private void fetchPropAmenities(RoutingContext context){ |
| 96 | + service.retrieveAmenities(resultHandlerNonEmpty(context)); |
| 97 | + } |
| 98 | + |
| 99 | + |
| 100 | + private void deletePropAmenity(RoutingContext context){ |
| 101 | + String serialNo = context.request().getParam("Id"); |
| 102 | + service.deleteAmenity(serialNo, deleteResultHandler(context)); |
| 103 | + } |
| 104 | + |
| 105 | + private void addAccommodation(RoutingContext context){ |
| 106 | + Accommodation accommodation = new Accommodation(context.getBodyAsJson()); |
| 107 | + service.createAccommodation(accommodation, resultHandler(context, 201)); |
| 108 | + } |
| 109 | + |
| 110 | + |
| 111 | + private void fetchAccommodations(RoutingContext context){ |
| 112 | + service.retrieveAllAccommodations(resultHandlerNonEmpty(context)); |
| 113 | + } |
| 114 | + |
| 115 | + private void fetchAccommodation(RoutingContext context){ |
| 116 | + String id = context.request().getParam("id"); |
| 117 | + service.retrieveAccommodation(id , resultHandlerNonEmpty(context)); |
| 118 | + } |
| 119 | + |
| 120 | + |
| 121 | + private void deleteAccommodation(RoutingContext context){ |
| 122 | + String serialNo = context.request().getParam("Id"); |
| 123 | + service.deleteAccommodation(serialNo, deleteResultHandler(context)); |
| 124 | + } |
| 125 | + |
58 | 126 | } |
| 127 | + |
| 128 | + |
0 commit comments