-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vr79x
committed
Dec 6, 2017
1 parent
bc2220e
commit 524fc5e
Showing
12 changed files
with
360 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
CREATE SCHEMA microservices_prod; | ||
|
||
USE microservices_prod; | ||
|
||
DROP TABLE IF EXISTS unit_type; | ||
CREATE TABLE IF NOT EXISTS unit_type(ID BIGINT AUTO_INCREMENT PRIMARY KEY, UNIT_NAME VARCHAR(200) NOT NULL); | ||
|
||
DROP TABLE IF EXISTS categories; | ||
CREATE TABLE IF NOT EXISTS categories ( | ||
ID BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
CATEGORY_NAME VARCHAR(200) NOT NULL, | ||
unit_type_ID BIGINT NOT NULL, | ||
CONTROLLED BOOLEAN, | ||
FOREIGN KEY (unit_type_ID) | ||
REFERENCES unit_type (ID) | ||
); | ||
|
||
SELECT * FROM categories; | ||
|
||
DROP TABLE IF EXISTS inventory; | ||
CREATE TABLE IF NOT EXISTS inventory ( | ||
ID BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
PRODUCT_NAME VARCHAR(200) NOT NULL, | ||
QUANTITY BIGINT NOT NULL, | ||
UNIT_PRICE DOUBLE(10,4), | ||
PURCHASE_PRICE DOUBLE(10,4), | ||
TAX_RATE INTEGER(99), | ||
CATEGORY_ID BIGINT NOT NULL, | ||
BRAND_NAME VARCHAR(200), | ||
FOREIGN KEY (CATEGORY_ID) | ||
REFERENCES categories (ID) | ||
); | ||
CREATE SCHEMA microservices_invoice; | ||
|
||
USE microservices_invoice; | ||
|
||
DROP TABLE IF EXISTS mode_of_pay; | ||
CREATE TABLE IF NOT EXISTS mode_of_pay ( | ||
ID BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
MODE_NAME VARCHAR(100) NOT NULL, | ||
MODE_DESC VARCHAR(500) | ||
); | ||
|
||
DROP TABLE IF EXISTS invoice; | ||
CREATE TABLE IF NOT EXISTS invoice ( | ||
ID BIGINT AUTO_INCREMENT PRIMARY KEY, | ||
CUST_ID BIGINT NOT NULL, | ||
ITEM_ID BIGINT NOT NULL, | ||
QUANTITY INTEGER(5), | ||
DATE_OF_PURCHASE DATETIME, | ||
MODE_PAY_ID BIGINT NOT NULL, | ||
TAX_AMT INTEGER, | ||
CASHIER_NAME VARCHAR(500), | ||
FOREIGN KEY (MODE_PAY_ID) | ||
REFERENCES invoice (ID) | ||
); | ||
|
||
|
||
create schema microservices_cust; | ||
|
||
USE microservices_cust; | ||
|
||
DROP TABLE IF EXISTS customer; | ||
CREATE TABLE IF NOT EXISTS customer(ID BIGINT AUTO_INCREMENT PRIMARY KEY, CUST_NAME VARCHAR(400) NOT NULL, | ||
CUST_AGE INTEGER(3),MEMBERSHIP_ID BIGINT, CUST_PHONE_NUM BIGINT(10) NOT NULL, ALT_NUM BIGINT(10), PRIMARY_ADDR_ID BIGINT); | ||
|
||
|
||
DROP TABLE IF EXISTS address; | ||
CREATE TABLE IF NOT EXISTS address(ADDRESS_ID BIGINT AUTO_INCREMENT PRIMARY KEY, CUST_ID BIGINT NOT NULL,APARTMENT_NAME VARCHAR(500), | ||
STREET_NAME VARCHAR(800),CITY VARCHAR(200),STATE VARCHAR(20),PIN INTEGER(10), FOREIGN KEY(CUST_ID) REFERENCES customer(ID)); | ||
|
||
/*DML---------------- */ | ||
|
||
|
||
USE microservices_prod; | ||
|
||
INSERT INTO unit_type(UNIT_NAME) VALUES ('Per Unit'); | ||
|
||
INSERT INTO unit_type(UNIT_NAME) VALUES ('Per Kg'); | ||
|
||
SELECT * FROM unit_type; | ||
|
||
|
||
INSERT INTO categories(unit_type_ID,CATEGORY_NAME,CONTROLLED) | ||
VALUES (1,'CLOTHES',false); | ||
|
||
INSERT INTO categories(unit_type_ID,CATEGORY_NAME,CONTROLLED) | ||
VALUES (2,'VEGETABLES',false); | ||
|
||
INSERT INTO categories(unit_type_ID,CATEGORY_NAME,CONTROLLED) | ||
VALUES (1,'MEDICINES',true); | ||
|
||
INSERT INTO categories(unit_type_ID,CATEGORY_NAME,CONTROLLED) | ||
VALUES (1,'MEDICINES',true); | ||
|
||
SELECT * FROM categories; | ||
|
||
/*run inventory inserts in a seprate command*/ | ||
INSERT INTO inventory( | ||
PRODUCT_NAME, | ||
QUANTITY, | ||
UNIT_PRICE, | ||
PURCHASE_PRICE, | ||
TAX_RATE, | ||
CATEGORY_ID,BRAND_NAME) VALUES('Shirts', | ||
50, | ||
100, | ||
91, | ||
15, | ||
2,'Louis Phillipe'); | ||
|
||
INSERT INTO inventory( | ||
PRODUCT_NAME, | ||
QUANTITY, | ||
UNIT_PRICE, | ||
PURCHASE_PRICE, | ||
TAX_RATE, | ||
CATEGORY_ID,BRAND_NAME) VALUES('Pants', | ||
100, | ||
100, | ||
91, | ||
15, | ||
2,'Louis Phillipe'); | ||
|
||
INSERT INTO inventory( | ||
PRODUCT_NAME, | ||
QUANTITY, | ||
UNIT_PRICE, | ||
PURCHASE_PRICE, | ||
TAX_RATE, | ||
CATEGORY_ID) VALUES('Shimla Apples', | ||
1000, | ||
10, | ||
9, | ||
4, | ||
3); | ||
|
||
USE microservices_cust; | ||
INSERT INTO customer(CUST_NAME, CUST_AGE, CUST_PHONE_NUM) VALUES('Hitesh Joshi',31,951911009); | ||
|
||
INSERT INTO address(CUST_ID,APARTMENT_NAME,STREET_NAME,CITY,STATE,PIN) | ||
VALUES (1,'Hubris Residency','HSR layout','Bangalore','Karanataka',560037); | ||
|
||
|
||
/*run customer inserts in a separate command*/ | ||
INSERT INTO customer(CUST_NAME, CUST_AGE, CUST_PHONE_NUM) VALUES('Deepika Joshi',30,989220110); | ||
|
||
INSERT INTO address(CUST_ID,APARTMENT_NAME,STREET_NAME,CITY,STATE,PIN) | ||
VALUES (1,'Vijaya Residency','Allahpur','Bangalore','Karanataka',560037); | ||
|
||
INSERT INTO address(CUST_ID,APARTMENT_NAME,STREET_NAME,CITY,STATE,PIN) | ||
VALUES (2,'Vijaya Residency','KareemNagar','Allahbad','UP',560037); | ||
|
||
INSERT INTO address(CUST_ID,APARTMENT_NAME,STREET_NAME,CITY,STATE,PIN) | ||
VALUES (1,'Muir Road','Near Bus stand','Almora','Uttarakhand',262501); | ||
|
||
|
||
|
||
UPDATE customer | ||
SET | ||
PRIMARY_ADDR_ID = 1 | ||
WHERE | ||
ID = 1; | ||
|
||
USE microservices_invoice; | ||
insert into mode_of_pay(MODE_NAME,MODE_DESC) values('Cash','OTC cash settlement'); | ||
insert into mode_of_pay(MODE_NAME,MODE_DESC) values('Card','OTC card settlement'); | ||
insert into mode_of_pay(MODE_NAME,MODE_DESC) values('Online','Online through payment gateway'); | ||
insert into mode_of_pay(MODE_NAME,MODE_DESC) values('Wallet','OTC through wallet'); | ||
|
||
select * from mode_of_pay; | ||
|
||
/*run invoice inserts in a seprate command*/ | ||
|
||
insert into invoice(CUST_ID,ITEM_ID,QUANTITY,DATE_OF_PURCHASE,MODE_PAY_ID,TAX_AMT,CASHIER_NAME) values(1,4,10,NOW(),2,5,'Venu Babu'); | ||
insert into invoice(CUST_ID,ITEM_ID,QUANTITY,DATE_OF_PURCHASE,MODE_PAY_ID,TAX_AMT,CASHIER_NAME) values(1,3,10,'2017-10-01 00:00:00',2,5,'Venu Babu'); | ||
|
||
select * from invoice; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
eureka: | ||
image: springcloud/eureka | ||
container_name: eureka | ||
ports: | ||
- "1111:1111" | ||
net: "microservicesnet" | ||
customer1: | ||
image: hiteshjoshi1/microservice-docker-cart-example | ||
container_name: customer1 | ||
hostname: customer1 | ||
net: "microservicesnet" | ||
ports: | ||
- "2222:8080" | ||
volumes: | ||
- C:\\Users\\hitjoshi\\Desktop\\Microservices\\ci_output:/data | ||
command: -jar -Dspring.datasource.url=jdbc:mysql://docker-mysql/microservices_cust -Dspring.datasource.password=test /data/customer-0.0.1-SNAPSHOT.jar | ||
inventory1: | ||
image: hiteshjoshi1/microservice-docker-cart-example | ||
container_name: inventory1 | ||
hostname: inventory1 | ||
net: "microservicesnet" | ||
ports: | ||
- "3333:8080" | ||
volumes: | ||
- C:\\Users\\hitjoshi\\Desktop\\Microservices\\ci_output:/data | ||
command: -jar -Dspring.datasource.url=jdbc:mysql://docker-mysql/microservices_prod -Dspring.datasource.password=test /data/inventory-0.0.1-SNAPSHOT.jar | ||
invoice1: | ||
image: hiteshjoshi1/microservice-docker-cart-example | ||
container_name: invoice1 | ||
hostname: invoice1 | ||
net: "microservicesnet" | ||
ports: | ||
- "4444:8080" | ||
volumes: | ||
- C:\\Users\\hitjoshi\\Desktop\\Microservices\\ci_output:/data | ||
command: -jar -Dspring.datasource.url=jdbc:mysql://docker-mysql/microservices_invoice -Dspring.datasource.password=test /data/invoice-0.0.1-SNAPSHOT.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
FROM java:8 | ||
VOLUME /tmp | ||
ADD /target/inventory-0.0.1-SNAPSHOT.jar app.jar | ||
ADD /target/invoice-0.0.1-SNAPSHOT.jar app.jar | ||
EXPOSE 8080 | ||
RUN bash -c 'touch /app.jar' | ||
ENTRYPOINT ["java","-Dspring.datasource.url=jdbc:mysql://docker-mysql/microservices_prod","-Dspring.datasource.username=root","-Dspring.datasource.password=test","-jar","/app.jar"] | ||
ENTRYPOINT ["java","-Dspring.datasource.url=jdbc:mysql://docker-mysql/microservices_invoice","-Dspring.datasource.username=root","-Dspring.datasource.password=test","-jar","/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
nbproject/private/ | ||
build/ | ||
nbbuild/ | ||
dist/ | ||
nbdist/ | ||
.nb-gradle/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM java:8 | ||
VOLUME /tmp | ||
ADD /target/servicediscovery-0.0.1-SNAPSHOT.jar app.jar | ||
EXPOSE 1111 | ||
RUN bash -c 'touch /app.jar' | ||
ENTRYPOINT ["java","-jar","/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.hitesh.microservices</groupId> | ||
<artifactId>servicediscovery</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>servicediscovery</name> | ||
<description>Eureka Service</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.5.9.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<spring-cloud.version>Edgware.RELEASE</spring-cloud.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-eureka-server</artifactId> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
14 changes: 14 additions & 0 deletions
14
.../src/main/java/com/hitesh/microservices/servicediscovery/ServiceDiscoveryApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.hitesh.microservices.servicediscovery; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; | ||
|
||
@SpringBootApplication | ||
@EnableEurekaServer | ||
public class ServiceDiscoveryApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ServiceDiscoveryApplication.class, args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Configure this Discovery Server | ||
eureka: | ||
instance: | ||
hostname: localhost | ||
client: # Not a client, don't register with yourself | ||
registerWithEureka: false | ||
fetchRegistry: false | ||
|
||
server: | ||
port: 1111 # HTTP (Tomcat) port | ||
|
||
# Discovery Server Dashboard uses FreeMarker. Don't want Thymeleaf templates | ||
spring: | ||
thymeleaf: | ||
enabled: false # Disable Thymeleaf |
Oops, something went wrong.