Demontrates the usecases for microservices, Java Records as DTO, Stream APIs, JPA Specification, Rest Apis, Swagger.
Tech stack | Version |
---|---|
Java | 17 |
Spring Boot | 3.1.1 |
Spring Framework | 6.0.10 |
MySql | 8 |
Api Doc | OpenAPI 3.0 |
NOTE: Spring boot 3 has issues with Springfox' Swagger, we had to use OpenAPI
- Exception library
- Fabric service
- Clone project
- Build microservice
skn_lm_exception
- Go to project location
SKN-LMS/skn_lm_exception
- Execute
mvn clean install
- Go to project location
- Build Catalog Fabric Service
- Go to
SKN-LMS/skn_lms_fabrics
- Execute
mvn clean install
- Go to
- Start the service as:
- Go to
SKN-LMS/skn_lms_fabrics/target/
- Execute
java -jar skn_lms_fabrics-1.0-SNAPSHOT-exec.jar
- Go to
{
"_links": {
"self": {
"href": "http://localhost:3000/skn-lms-fabrics/actuator",
"templated": false
},
"health": {
"href": "http://localhost:3000/skn-lms-fabrics/actuator/health",
"templated": false
},
"health-path": {
"href": "http://localhost:3000/skn-lms-fabrics/actuator/health/{*path}",
"templated": true
},
"info": {
"href": "http://localhost:3000/skn-lms-fabrics/actuator/info",
"templated": false
}
}
}
Create few colors as:
curl --location 'http://localhost:3000/skn-lms-fabrics/v1/fabric-color' \
--header 'Content-Type: application/json' \
--data '{
"code":"BLACK",
"description":"Black color",
"status":"AVAILABLE"
}'
> 201 Created
Create few materials as:
curl --location 'http://localhost:3000/skn-lms-fabrics/v1/fabric-material' \
--header 'Content-Type: application/json' \
--data '{
"code":"LEATHER",
"description":"Leather type material",
"status":"AVAILABLE"
}'
> 201 Created
Create a Fabric as:
curl --location 'http://localhost:3000/skn-lms-fabrics/v1/fabric' \
--header 'Content-Type: application/json' \
--data '{
"code":"FABRIC-7",
"description":"Fabric 7",
"status":"AVAILABLE",
"price": 750.00,
"color-code":"ORANGE",
"materials": [
{
"material-code":"VELVET",
"percent": 20.00
},
{
"material-code":"KHADI",
"percent": 30.00
},
{
"material-code":"LINEN",
"percent": 50.00
}
]
}'
> 201 Created
Search a Fabric as :
curl -X 'GET' \
'http://localhost:3000/skn-lms-fabrics/v1/fabric?color-code=RED&fabric-status%5B%5D=AVAILABLE&sort-by=FABRIC_PRICE&page-number=0&per-page=10&sort-order=ASC' \
-H 'accept: */*'
Response:
{
"paginator": {
"pageNo": 0,
"itemPerPages": 1,
"totalItems": 1,
"hasNext": false,
"hasPrevious": false,
"isFirst": true,
"isLast": true,
"first": true,
"last": true
},
"data": [
{
"fabricId": 1,
"fabricCode": "RED",
"description": "Red color",
"price": 1000,
"fabricStatus": "AVAILABLE",
"fabricColorDto": {
"fabricColorId": 1,
"fabricColorCode": "RED",
"description": "Red color",
"status": "AVAILABLE"
},
"fabricMaterialDtos": [
{
"fabricMaterialId": 1,
"percentage": 50,
"material": {
"materialId": 5,
"materialCode": "LINEN",
"description": "Linen type material",
"status": "AVAILABLE"
}
},
{
"fabricMaterialId": 2,
"percentage": 50,
"material": {
"materialId": 3,
"materialCode": "SILK",
"description": "SILK type material",
"status": "AVAILABLE"
}
}
]
}
]
}