Use Case

 1. we would need couple of microservice in place so that we can take spring component and plug them in whenever and however required 

2. Here we would have 2 microservices

        1. Product Service: 

        2. Coupon Service:

These two services will expose out the restful api, which will allow a end user to create a product.

and in the process, the product service will use the coupon service to apply a coupon code that the client passes in and gets the discount.

so all the coupon information is maintained by the coupon service.

the product service is only responsible for creating the product in the database along with its price and description details which the client passes.

so the process here is take the clients request, the product service will call the coupon service, get the discount for the coupon code, which the client would have passed , apply the discount on the price which the client passes and then save the product to the database.

All the coupon details will be savedn in the coupon service database.

The coupon service will expose out a couple of restful api's

One is to create the coupons and the second one is to get the coupon details through the coupon code.




show databases;
create database mydb;
use mydb;
show tables;
create table product(id int auto_increment, name varchar(20), description varchar(100), price decimal(10,2), primary key(id));
create table coupon(id int auto_increment, code varchar(20), discount decimal(10,2), exp_date varchar(100), primary key(id));

select * from product;
select * from coupon;



Comments