Service for handling all product related operations
- MongoDB instance
Functionality | REST Endpoint | Parameter | Body | Response |
---|---|---|---|---|
Get Information of all Products | GET /product/all |
JSON String | ||
Get Information of all Similar Products | GET /product/similar |
query - String | JSON String | |
Get Information of Products by Pincode | GET /product/allByPin |
pincode - String | JSON String | |
Get Information of Products by Id | GET /product/id |
prodId - String | JSON String | |
Get Information of Products by Category | GET /product/allByCategory |
category - String | JSON String | |
Add New Product | POST /product/add |
JSON String | JSON String | |
Update Product | Not Implemented | |||
Enable Product | Not Implemented | |||
Disable Product | Not Implemented | |||
Add New Category | POST /category/add |
category - String | JSON String |
Edit the properties of application.yml file
# Eureka properties
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: address of the eureka server (Eg: http://localhost:8761/eureka)
instance:
hostname: specify the hostname of service here (Eg: localhost)
# Server properties
server:
port: port in which the product service is to be run (Eg: 8094)
# Application properties
spring:
application:
name: name of the application (Eg: PRODUCT-SERVICE)
# MongoDB properties
data:
mongodb:
database: mongoDB database name (Eg: testWorkingDB)
host: name of mongoDB host (Eg: localhost)
port: port in which mongoDB is being run (Eg: 27017)
Service Registry should be started for successful execution of all queries.
In application.yml file, change the properties
Property | Value | Example |
---|---|---|
eureka_hostname | hostname of eureka server | service-registry |
service_hostname | hostname of service (try to use the same as in docker-compose) | product-service |
mongodb_hostname | hostname of mongodb | product-db |
mongodb_database_name | database name | productDB |
Create docker bridge network: docker network create -d bridge pigihi-network
docker-compose can be used to run the application and the corresponding mongodb instance
- Go to project folder
- Open terminal and run
docker-compose up
- The application can be accessed at localhost:8094 (port 8094 is set in docker-compose)
- MongoDB port is set to 27021
To run only the application
- Go to project folder
- Open terminal and run
docker build .
- Run
docker run -p 8094:8094 docker_image_name
- The application can be accessed at localhost:8094
MongoDB should be run seperately and the configurations should be updated in application.yml
- Go to project folder
- Open terminal and run
./gradlew build
- Run
./gradlew bootRun