├── mailService
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── don
│ │ │ │ └── mailservice
│ │ │ │ ├── service
│ │ │ │ ├── MailService.java
│ │ │ │ └── MailServiceImpl.java
│ │ │ │ ├── MailServiceApplication.java
│ │ │ │ ├── model
│ │ │ │ └── Mail.java
│ │ │ │ └── controller
│ │ │ │ └── MailController.java
│ │ └── resources
│ │ │ └── application.yml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── don
│ │ └── mailservice
│ │ └── MailServiceApplicationTests.java
├── .gitignore
├── build.gradle
└── gradlew.bat
├── orderService
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── don
│ │ │ │ └── orderservice
│ │ │ │ ├── enums
│ │ │ │ └── OrderStatus.java
│ │ │ │ ├── repository
│ │ │ │ ├── CartItemRepository.java
│ │ │ │ ├── CartRepository.java
│ │ │ │ └── OrderRepository.java
│ │ │ │ ├── service
│ │ │ │ ├── CartService.java
│ │ │ │ ├── OrderService.java
│ │ │ │ ├── CartServiceImpl.java
│ │ │ │ └── OrderServiceImpl.java
│ │ │ │ ├── dto
│ │ │ │ ├── order
│ │ │ │ │ ├── PaymentRequestDto.java
│ │ │ │ │ ├── PaymentResponseDto.java
│ │ │ │ │ ├── OrderRequestDto.java
│ │ │ │ │ └── OrderResponseDto.java
│ │ │ │ ├── user
│ │ │ │ │ └── UserResponse.java
│ │ │ │ ├── CartResponse.java
│ │ │ │ ├── ProductResponse.java
│ │ │ │ └── CartItemResponse.java
│ │ │ │ ├── model
│ │ │ │ ├── mail
│ │ │ │ │ └── Mail.java
│ │ │ │ ├── Cart.java
│ │ │ │ ├── CartItem.java
│ │ │ │ └── order
│ │ │ │ │ ├── Address.java
│ │ │ │ │ └── Order.java
│ │ │ │ ├── OrderServiceApplication.java
│ │ │ │ ├── feignClient
│ │ │ │ ├── MailService.java
│ │ │ │ ├── UserService.java
│ │ │ │ ├── PaymentService.java
│ │ │ │ └── ProductService.java
│ │ │ │ ├── util
│ │ │ │ ├── AuthUtil.java
│ │ │ │ ├── OrderTotalUtil.java
│ │ │ │ └── JwtUtil.java
│ │ │ │ └── controller
│ │ │ │ ├── CartController.java
│ │ │ │ └── OrderController.java
│ │ └── resources
│ │ │ └── application.yml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── don
│ │ └── orderservice
│ │ └── OrderServiceApplicationTests.java
├── .gitignore
├── build.gradle
└── gradlew.bat
├── productService
├── path
│ └── to
│ │ └── images
│ │ └── images
│ │ └── Test Product
│ │ └── image1.jpg
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── don
│ │ │ │ └── productservice
│ │ │ │ ├── eunm
│ │ │ │ ├── GlobalOperator.java
│ │ │ │ ├── ProductStatus.java
│ │ │ │ └── Operation.java
│ │ │ │ ├── exception
│ │ │ │ ├── ProductDoNotExistException.java
│ │ │ │ ├── ProductAlreadyExistException.java
│ │ │ │ ├── ProductCategoryDoNotExistException.java
│ │ │ │ └── GlobalExceptionHandler.java
│ │ │ │ ├── repository
│ │ │ │ ├── ImageRepository.java
│ │ │ │ ├── ProductCategoryRepository.java
│ │ │ │ └── ProductRepository.java
│ │ │ │ ├── dto
│ │ │ │ ├── ApiResponse.java
│ │ │ │ ├── specification
│ │ │ │ │ ├── SearchRequestDto.java
│ │ │ │ │ └── RequestDto.java
│ │ │ │ ├── ProductCategoryResponse.java
│ │ │ │ └── ProductResponse.java
│ │ │ │ ├── ProductServiceApplication.java
│ │ │ │ ├── model
│ │ │ │ ├── Image.java
│ │ │ │ ├── ProductCategory.java
│ │ │ │ └── Product.java
│ │ │ │ ├── service
│ │ │ │ ├── ProductService.java
│ │ │ │ ├── FilterSpecification.java
│ │ │ │ └── ProductServiceImpl.java
│ │ │ │ ├── mapper
│ │ │ │ ├── ProductCategoryResponseMapper.java
│ │ │ │ └── ProductResponseMapper.java
│ │ │ │ └── controller
│ │ │ │ └── ProductController.java
│ │ └── resources
│ │ │ ├── static
│ │ │ └── images
│ │ │ │ ├── banana
│ │ │ │ └── Untitled.jpeg
│ │ │ │ ├── butter
│ │ │ │ ├── mugewaras.jpg
│ │ │ │ └── nicoRobin.jpg
│ │ │ │ ├── cheese
│ │ │ │ └── Untitled.jpeg
│ │ │ │ ├── mango
│ │ │ │ └── Untitled.jpeg
│ │ │ │ └── chocolate
│ │ │ │ └── Untitled.jpeg
│ │ │ └── application.yml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── don
│ │ └── productservice
│ │ ├── ProductServiceApplicationTests.java
│ │ └── service
│ │ └── ProductServiceImplTest.java
├── .gitignore
├── build.gradle
└── gradlew.bat
├── userService
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── don
│ │ │ │ └── userservice
│ │ │ │ ├── enums
│ │ │ │ └── UserStatus.java
│ │ │ │ ├── exception
│ │ │ │ ├── UserDoNotExistException.java
│ │ │ │ ├── UserAlreadyExistException.java
│ │ │ │ └── GlobalExceptionHandler.java
│ │ │ │ ├── dto
│ │ │ │ ├── JwtResponse.java
│ │ │ │ ├── JwtRequest.java
│ │ │ │ ├── ApiResponse.java
│ │ │ │ ├── UserLogin.java
│ │ │ │ └── UserResponse.java
│ │ │ │ ├── UserServiceApplication.java
│ │ │ │ ├── repository
│ │ │ │ ├── RefreshTokenRepository.java
│ │ │ │ └── UserCredentialRepository.java
│ │ │ │ ├── service
│ │ │ │ ├── RefreshTokenService.java
│ │ │ │ ├── UserCredentialService.java
│ │ │ │ ├── JwtService.java
│ │ │ │ ├── RefreshTokenServiceImpl.java
│ │ │ │ └── UserCredentialServiceImpl.java
│ │ │ │ ├── model
│ │ │ │ ├── RefreshToken.java
│ │ │ │ └── UserCredential.java
│ │ │ │ ├── mapper
│ │ │ │ └── UserToResponseMapper.java
│ │ │ │ ├── config
│ │ │ │ ├── CustomUserDetailsService.java
│ │ │ │ ├── CustomUserDetails.java
│ │ │ │ └── SecurityConfig.java
│ │ │ │ └── controller
│ │ │ │ └── UserCredentialController.java
│ │ └── resources
│ │ │ └── application.yml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── don
│ │ └── userservice
│ │ └── UserServiceApplicationTests.java
├── .gitignore
├── build.gradle
└── gradlew.bat
├── .idea
├── sonarlint
│ ├── issuestore
│ │ ├── 0
│ │ │ ├── 2
│ │ │ │ └── 027f18fe0812b03eddf2b7fb246197986115693f
│ │ │ └── 8
│ │ │ │ └── 0872e1905568f8ff256c302eefc44c016badacd4
│ │ ├── 1
│ │ │ └── 5
│ │ │ │ └── 15d81d3a53e825fd7907a4e5ef48694672b04d2c
│ │ ├── 2
│ │ │ └── 6
│ │ │ │ └── 26e5882c59dc2f30d6fee473b4ea90b8bebef4e4
│ │ ├── 3
│ │ │ ├── 4
│ │ │ │ └── 34d030c67abf66c202ced2383b5b3218dd37fab5
│ │ │ ├── 6
│ │ │ │ └── 3678f1c223d0d659b3d4edf7317640e71ba9d02f
│ │ │ ├── c
│ │ │ │ └── 3c8fadeb196f0d0f2cdd5a21ecdbcfa88645210d
│ │ │ ├── d
│ │ │ │ └── 3d7a93375fd1f85d1de3a30a8e3d241f7c8ec609
│ │ │ └── e
│ │ │ │ └── 3ecc72dbb7620293e40e46f1423e167fe32a90d9
│ │ ├── 5
│ │ │ └── c
│ │ │ │ └── 5c9486b7830631facb0eb4878b21992f7e8fcc57
│ │ ├── 6
│ │ │ ├── 0
│ │ │ │ ├── 603b081b2ed577d921b68f3f22e9b1468df9d318
│ │ │ │ └── 6070a8e325a2c8699177d1b96b99b741698285de
│ │ │ ├── 3
│ │ │ │ └── 63ad145cb156f35157ca65445f7aec2386e11375
│ │ │ └── 7
│ │ │ │ └── 6745e35bf2914ac4f5af9b78c28b613b0d7ab303
│ │ ├── 8
│ │ │ └── 3
│ │ │ │ └── 839bc4767d4e48996386e1a6ed76385eea1bbb1e
│ │ ├── 9
│ │ │ ├── 3
│ │ │ │ └── 9360951fa8cabed9f4d45b36e1afbfa4a8769af9
│ │ │ ├── c
│ │ │ │ └── 9c6e57b5e689b530b20e95c80959d7463cd6da41
│ │ │ └── f
│ │ │ │ └── 9fe0ab1308346b365bd272983500cd6c0d9a34d2
│ │ ├── a
│ │ │ └── 6
│ │ │ │ └── a66a99af370cb802aa88a1bc1c4957648bb83fa1
│ │ ├── b
│ │ │ ├── 3
│ │ │ │ ├── b30656358f3d98d07386356656666bc517618dbb
│ │ │ │ └── b3293f33f4551b8a86db221a59e8b306dd7d0877
│ │ │ ├── 4
│ │ │ │ └── b4e41457bc534e4d6672999455d9fd0537d91827
│ │ │ ├── a
│ │ │ │ └── ba9d6c4093745ac131e57117fad27f243291f774
│ │ │ └── e
│ │ │ │ └── bebcb3142a643f9d61adc73e3875342534b280b7
│ │ ├── d
│ │ │ ├── 0
│ │ │ │ ├── d040bb53131cc4132dbfa783fa39d2e22d1e81c2
│ │ │ │ └── d0bf9ac4f191f6c3fb7811dbd59e5a68f370b962
│ │ │ ├── 6
│ │ │ │ └── d61cf4179ba667588fcbbccc17b18ef3c722ddb5
│ │ │ ├── 7
│ │ │ │ └── d7dd5214fe969b47a937b2996d4471a1105b7642
│ │ │ └── f
│ │ │ │ ├── df16ad3a406a90e9cd23da63fbac2c234e6d73ed
│ │ │ │ └── dfbf2c32deedf74c1f0fa4bd9cba37a539aa59e9
│ │ ├── f
│ │ │ ├── 2
│ │ │ │ └── f29aef5d8e0a4f6e473af943f6f2f60db1e75838
│ │ │ └── e
│ │ │ │ └── fef604e1863a3ff5167e1a08f4b33d1fcf280273
│ │ └── index.pb
│ └── securityhotspotstore
│ │ ├── 0
│ │ ├── 2
│ │ │ └── 027f18fe0812b03eddf2b7fb246197986115693f
│ │ └── 8
│ │ │ └── 0872e1905568f8ff256c302eefc44c016badacd4
│ │ ├── 1
│ │ └── 5
│ │ │ └── 15d81d3a53e825fd7907a4e5ef48694672b04d2c
│ │ ├── 2
│ │ └── 6
│ │ │ └── 26e5882c59dc2f30d6fee473b4ea90b8bebef4e4
│ │ ├── 3
│ │ ├── 4
│ │ │ └── 34d030c67abf66c202ced2383b5b3218dd37fab5
│ │ ├── 6
│ │ │ └── 3678f1c223d0d659b3d4edf7317640e71ba9d02f
│ │ ├── c
│ │ │ └── 3c8fadeb196f0d0f2cdd5a21ecdbcfa88645210d
│ │ ├── d
│ │ │ └── 3d7a93375fd1f85d1de3a30a8e3d241f7c8ec609
│ │ └── e
│ │ │ └── 3ecc72dbb7620293e40e46f1423e167fe32a90d9
│ │ ├── 5
│ │ └── c
│ │ │ └── 5c9486b7830631facb0eb4878b21992f7e8fcc57
│ │ ├── 6
│ │ ├── 0
│ │ │ ├── 603b081b2ed577d921b68f3f22e9b1468df9d318
│ │ │ └── 6070a8e325a2c8699177d1b96b99b741698285de
│ │ ├── 3
│ │ │ └── 63ad145cb156f35157ca65445f7aec2386e11375
│ │ └── 7
│ │ │ └── 6745e35bf2914ac4f5af9b78c28b613b0d7ab303
│ │ ├── 8
│ │ └── 3
│ │ │ └── 839bc4767d4e48996386e1a6ed76385eea1bbb1e
│ │ ├── 9
│ │ ├── 3
│ │ │ └── 9360951fa8cabed9f4d45b36e1afbfa4a8769af9
│ │ ├── c
│ │ │ └── 9c6e57b5e689b530b20e95c80959d7463cd6da41
│ │ └── f
│ │ │ └── 9fe0ab1308346b365bd272983500cd6c0d9a34d2
│ │ ├── a
│ │ └── 6
│ │ │ └── a66a99af370cb802aa88a1bc1c4957648bb83fa1
│ │ ├── b
│ │ ├── 3
│ │ │ ├── b30656358f3d98d07386356656666bc517618dbb
│ │ │ └── b3293f33f4551b8a86db221a59e8b306dd7d0877
│ │ ├── 4
│ │ │ └── b4e41457bc534e4d6672999455d9fd0537d91827
│ │ ├── a
│ │ │ └── ba9d6c4093745ac131e57117fad27f243291f774
│ │ └── e
│ │ │ └── bebcb3142a643f9d61adc73e3875342534b280b7
│ │ ├── d
│ │ ├── 0
│ │ │ ├── d040bb53131cc4132dbfa783fa39d2e22d1e81c2
│ │ │ └── d0bf9ac4f191f6c3fb7811dbd59e5a68f370b962
│ │ ├── 6
│ │ │ └── d61cf4179ba667588fcbbccc17b18ef3c722ddb5
│ │ ├── 7
│ │ │ └── d7dd5214fe969b47a937b2996d4471a1105b7642
│ │ └── f
│ │ │ ├── df16ad3a406a90e9cd23da63fbac2c234e6d73ed
│ │ │ └── dfbf2c32deedf74c1f0fa4bd9cba37a539aa59e9
│ │ ├── f
│ │ ├── 2
│ │ │ └── f29aef5d8e0a4f6e473af943f6f2f60db1e75838
│ │ └── e
│ │ │ └── fef604e1863a3ff5167e1a08f4b33d1fcf280273
│ │ └── index.pb
├── vcs.xml
├── .gitignore
├── modules
│ ├── cartService.main.iml
│ ├── mailService.main.iml
│ ├── userService.main.iml
│ ├── apiGatewayService.main.iml
│ ├── ecommerceMicroService.orderService.main.iml
│ └── productService.main.iml
├── compiler.xml
├── misc.xml
├── modules.xml
├── jarRepositories.xml
├── gradle.xml
└── uiDesigner.xml
├── apiGatewayService
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── don
│ │ │ └── apigatewayservice
│ │ │ └── ApiGatewayServiceApplicationTests.java
│ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── don
│ │ │ └── apigatewayservice
│ │ │ ├── dto
│ │ │ └── ApiResponse.java
│ │ │ ├── exception
│ │ │ ├── MustLoginException.java
│ │ │ ├── RoleNotMatchedException.java
│ │ │ └── GlobalExceptionHandler.java
│ │ │ ├── ApiGatewayServiceApplication.java
│ │ │ ├── util
│ │ │ └── JwtUtil.java
│ │ │ └── filter
│ │ │ ├── RouteValidator.java
│ │ │ └── AuthenticationFilter.java
│ │ └── resources
│ │ └── application.yml
├── .gitignore
├── build.gradle
└── gradlew.bat
├── discoveryService
├── settings.gradle
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── application.yml
│ │ └── java
│ │ │ └── com
│ │ │ └── don
│ │ │ └── discoveryservice
│ │ │ └── DiscoveryServiceApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── don
│ │ └── discoveryservice
│ │ └── DiscoveryServiceApplicationTests.java
├── .gitignore
├── build.gradle
└── gradlew.bat
├── ecommerceMicroService.iml
├── README.md
└── postman_apis
├── ecommerce_payment_mock.postman_collection.json
└── sql_database_file
└── ecommerce_sql
├── ecommerce_order_service_cart.sql
├── ecommerce_product_service_product_category.sql
├── ecommerce_order_service_cart_item.sql
├── ecommerce_order_service_order_detail.sql
├── ecommerce_user_service_user_credential.sql
├── ecommerce_product_service_product.sql
└── ecommerce_order_service_address.sql
/mailService/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'mailService'
2 |
--------------------------------------------------------------------------------
/orderService/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'orderService'
2 |
--------------------------------------------------------------------------------
/productService/path/to/images/images/Test Product/image1.jpg:
--------------------------------------------------------------------------------
1 | data
--------------------------------------------------------------------------------
/userService/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'userService'
2 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/0/2/027f18fe0812b03eddf2b7fb246197986115693f:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/0/8/0872e1905568f8ff256c302eefc44c016badacd4:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/1/5/15d81d3a53e825fd7907a4e5ef48694672b04d2c:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/2/6/26e5882c59dc2f30d6fee473b4ea90b8bebef4e4:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/3/6/3678f1c223d0d659b3d4edf7317640e71ba9d02f:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/3/c/3c8fadeb196f0d0f2cdd5a21ecdbcfa88645210d:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/3/d/3d7a93375fd1f85d1de3a30a8e3d241f7c8ec609:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/5/c/5c9486b7830631facb0eb4878b21992f7e8fcc57:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/6/0/603b081b2ed577d921b68f3f22e9b1468df9d318:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/6/0/6070a8e325a2c8699177d1b96b99b741698285de:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/8/3/839bc4767d4e48996386e1a6ed76385eea1bbb1e:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/9/3/9360951fa8cabed9f4d45b36e1afbfa4a8769af9:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/9/c/9c6e57b5e689b530b20e95c80959d7463cd6da41:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/9/f/9fe0ab1308346b365bd272983500cd6c0d9a34d2:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/a/6/a66a99af370cb802aa88a1bc1c4957648bb83fa1:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/b/3/b30656358f3d98d07386356656666bc517618dbb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/b/3/b3293f33f4551b8a86db221a59e8b306dd7d0877:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/b/a/ba9d6c4093745ac131e57117fad27f243291f774:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/b/e/bebcb3142a643f9d61adc73e3875342534b280b7:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/d/0/d040bb53131cc4132dbfa783fa39d2e22d1e81c2:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/d/6/d61cf4179ba667588fcbbccc17b18ef3c722ddb5:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/d/7/d7dd5214fe969b47a937b2996d4471a1105b7642:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/d/f/df16ad3a406a90e9cd23da63fbac2c234e6d73ed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/d/f/dfbf2c32deedf74c1f0fa4bd9cba37a539aa59e9:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/f/e/fef604e1863a3ff5167e1a08f4b33d1fcf280273:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/productService/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'productService'
2 |
--------------------------------------------------------------------------------
/apiGatewayService/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'apiGatewayService'
2 |
--------------------------------------------------------------------------------
/discoveryService/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'discoveryService'
2 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/0/2/027f18fe0812b03eddf2b7fb246197986115693f:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/0/8/0872e1905568f8ff256c302eefc44c016badacd4:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/1/5/15d81d3a53e825fd7907a4e5ef48694672b04d2c:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/2/6/26e5882c59dc2f30d6fee473b4ea90b8bebef4e4:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/3/4/34d030c67abf66c202ced2383b5b3218dd37fab5:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/3/6/3678f1c223d0d659b3d4edf7317640e71ba9d02f:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/3/c/3c8fadeb196f0d0f2cdd5a21ecdbcfa88645210d:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/3/d/3d7a93375fd1f85d1de3a30a8e3d241f7c8ec609:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/3/e/3ecc72dbb7620293e40e46f1423e167fe32a90d9:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/5/c/5c9486b7830631facb0eb4878b21992f7e8fcc57:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/6/0/603b081b2ed577d921b68f3f22e9b1468df9d318:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/6/0/6070a8e325a2c8699177d1b96b99b741698285de:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/6/3/63ad145cb156f35157ca65445f7aec2386e11375:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/6/7/6745e35bf2914ac4f5af9b78c28b613b0d7ab303:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/8/3/839bc4767d4e48996386e1a6ed76385eea1bbb1e:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/9/3/9360951fa8cabed9f4d45b36e1afbfa4a8769af9:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/9/c/9c6e57b5e689b530b20e95c80959d7463cd6da41:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/9/f/9fe0ab1308346b365bd272983500cd6c0d9a34d2:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/a/6/a66a99af370cb802aa88a1bc1c4957648bb83fa1:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/b/3/b30656358f3d98d07386356656666bc517618dbb:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/b/3/b3293f33f4551b8a86db221a59e8b306dd7d0877:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/b/4/b4e41457bc534e4d6672999455d9fd0537d91827:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/b/a/ba9d6c4093745ac131e57117fad27f243291f774:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/b/e/bebcb3142a643f9d61adc73e3875342534b280b7:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/d/0/d040bb53131cc4132dbfa783fa39d2e22d1e81c2:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/d/0/d0bf9ac4f191f6c3fb7811dbd59e5a68f370b962:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/d/6/d61cf4179ba667588fcbbccc17b18ef3c722ddb5:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/d/7/d7dd5214fe969b47a937b2996d4471a1105b7642:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/d/f/df16ad3a406a90e9cd23da63fbac2c234e6d73ed:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/d/f/dfbf2c32deedf74c1f0fa4bd9cba37a539aa59e9:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/f/2/f29aef5d8e0a4f6e473af943f6f2f60db1e75838:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/f/e/fef604e1863a3ff5167e1a08f4b33d1fcf280273:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/index.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/index.pb
--------------------------------------------------------------------------------
/.idea/sonarlint/securityhotspotstore/index.pb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/securityhotspotstore/index.pb
--------------------------------------------------------------------------------
/mailService/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/mailService/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/orderService/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/orderService/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/userService/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/userService/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/productService/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/apiGatewayService/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/apiGatewayService/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/discoveryService/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/discoveryService/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/enums/UserStatus.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.enums;
2 |
3 | public enum UserStatus {
4 | ACTIVE,
5 | DELETED
6 | }
7 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/eunm/GlobalOperator.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.eunm;
2 |
3 | public enum GlobalOperator {
4 | AND,
5 | OR
6 | }
7 |
--------------------------------------------------------------------------------
/productService/src/main/resources/static/images/banana/Untitled.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/src/main/resources/static/images/banana/Untitled.jpeg
--------------------------------------------------------------------------------
/productService/src/main/resources/static/images/butter/mugewaras.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/src/main/resources/static/images/butter/mugewaras.jpg
--------------------------------------------------------------------------------
/productService/src/main/resources/static/images/butter/nicoRobin.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/src/main/resources/static/images/butter/nicoRobin.jpg
--------------------------------------------------------------------------------
/productService/src/main/resources/static/images/cheese/Untitled.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/src/main/resources/static/images/cheese/Untitled.jpeg
--------------------------------------------------------------------------------
/productService/src/main/resources/static/images/mango/Untitled.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/src/main/resources/static/images/mango/Untitled.jpeg
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/3/4/34d030c67abf66c202ced2383b5b3218dd37fab5:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/3/4/34d030c67abf66c202ced2383b5b3218dd37fab5
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/3/e/3ecc72dbb7620293e40e46f1423e167fe32a90d9:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/3/e/3ecc72dbb7620293e40e46f1423e167fe32a90d9
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/6/3/63ad145cb156f35157ca65445f7aec2386e11375:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/6/3/63ad145cb156f35157ca65445f7aec2386e11375
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/6/7/6745e35bf2914ac4f5af9b78c28b613b0d7ab303:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/6/7/6745e35bf2914ac4f5af9b78c28b613b0d7ab303
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/b/4/b4e41457bc534e4d6672999455d9fd0537d91827:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/b/4/b4e41457bc534e4d6672999455d9fd0537d91827
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/d/0/d0bf9ac4f191f6c3fb7811dbd59e5a68f370b962:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/d/0/d0bf9ac4f191f6c3fb7811dbd59e5a68f370b962
--------------------------------------------------------------------------------
/.idea/sonarlint/issuestore/f/2/f29aef5d8e0a4f6e473af943f6f2f60db1e75838:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/.idea/sonarlint/issuestore/f/2/f29aef5d8e0a4f6e473af943f6f2f60db1e75838
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/productService/src/main/resources/static/images/chocolate/Untitled.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GyalbuSherpa5/ecommerceMicroService/HEAD/productService/src/main/resources/static/images/chocolate/Untitled.jpeg
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/eunm/ProductStatus.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.eunm;
2 |
3 | public enum ProductStatus {
4 | AVAILABLE,
5 | NOT_AVAILABLE,
6 | DELETED
7 | }
8 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/mailService/src/main/java/com/don/mailservice/service/MailService.java:
--------------------------------------------------------------------------------
1 | package com.don.mailservice.service;
2 |
3 | import com.don.mailservice.model.Mail;
4 |
5 | public interface MailService {
6 | String sendMail(Mail mail);
7 | }
8 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/enums/OrderStatus.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.enums;
2 |
3 | public enum OrderStatus {
4 | PROCESSING,
5 | FAILED,
6 | AMBIGUOUS,
7 | CANCELLED,
8 | SHIPPED,
9 | DELIVERED
10 | }
11 |
--------------------------------------------------------------------------------
/mailService/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/orderService/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/productService/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/eunm/Operation.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.eunm;
2 |
3 | public enum Operation {
4 | EQUAL,
5 | LIKE,
6 | IN,
7 | GREATER_THAN,
8 | LESS_THAN,
9 | BETWEEN,
10 | JOIN
11 | }
12 |
--------------------------------------------------------------------------------
/userService/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/apiGatewayService/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/discoveryService/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/discoveryService/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | eureka:
2 | instance:
3 | hostname: localhost
4 |
5 | client:
6 | fetch-registry: false
7 | register-with-eureka: false
8 |
9 | spring:
10 | application:
11 | name: discovery-server
12 |
13 | server:
14 | port: 8761
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/exception/UserDoNotExistException.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.exception;
2 |
3 | public class UserDoNotExistException extends RuntimeException{
4 | public UserDoNotExistException(String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/exception/UserAlreadyExistException.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.exception;
2 |
3 | public class UserAlreadyExistException extends RuntimeException{
4 | public UserAlreadyExistException(String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/exception/ProductDoNotExistException.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.exception;
2 |
3 | public class ProductDoNotExistException extends RuntimeException {
4 | public ProductDoNotExistException(String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/exception/ProductAlreadyExistException.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.exception;
2 |
3 | public class ProductAlreadyExistException extends RuntimeException {
4 | public ProductAlreadyExistException(String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/repository/ImageRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.repository;
2 |
3 | import com.don.productservice.model.Image;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | public interface ImageRepository extends JpaRepository {
7 | }
8 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/repository/CartItemRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.repository;
2 |
3 | import com.don.orderservice.model.CartItem;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | public interface CartItemRepository extends JpaRepository {
7 | }
8 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/dto/JwtResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.dto;
2 |
3 | import lombok.*;
4 |
5 | @Getter
6 | @Setter
7 | @Builder
8 | @AllArgsConstructor
9 | @NoArgsConstructor
10 | public class JwtResponse {
11 | private String accessToken;
12 | private String token;
13 | }
14 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/exception/ProductCategoryDoNotExistException.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.exception;
2 |
3 | public class ProductCategoryDoNotExistException extends RuntimeException{
4 | public ProductCategoryDoNotExistException(String message) {
5 | super(message);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/ecommerceMicroService.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/mailService/src/test/java/com/don/mailservice/MailServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.don.mailservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class MailServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/userService/src/test/java/com/don/userservice/UserServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class UserServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/orderService/src/test/java/com/don/orderservice/OrderServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class OrderServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/productService/src/test/java/com/don/productservice/ProductServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class ProductServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/service/CartService.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.service;
2 |
3 | import com.don.orderservice.dto.CartResponse;
4 | import com.don.orderservice.model.CartItem;
5 |
6 | public interface CartService {
7 | void saveToCart(CartItem cartItem, String username);
8 | CartResponse getMyCart(String username);
9 | }
10 |
--------------------------------------------------------------------------------
/discoveryService/src/test/java/com/don/discoveryservice/DiscoveryServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.don.discoveryservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class DiscoveryServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/apiGatewayService/src/test/java/com/don/apigatewayservice/ApiGatewayServiceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice;
2 |
3 | import org.junit.jupiter.api.Test;
4 | import org.springframework.boot.test.context.SpringBootTest;
5 |
6 | @SpringBootTest
7 | class ApiGatewayServiceApplicationTests {
8 |
9 | @Test
10 | void contextLoads() {
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/dto/JwtRequest.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class JwtRequest {
13 | private String token;
14 | }
15 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/repository/CartRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.repository;
2 |
3 | import com.don.orderservice.model.Cart;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.Optional;
7 |
8 | public interface CartRepository extends JpaRepository {
9 | Optional findByName(String name);
10 | }
11 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/order/PaymentRequestDto.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto.order;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class PaymentRequestDto {
13 | private double amount;
14 | }
15 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/dto/ApiResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class ApiResponse {
13 | String error;
14 | String message;
15 | }
16 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/dto/ApiResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class ApiResponse {
13 | private String error;
14 | private String message;
15 | }
16 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/dto/UserLogin.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class UserLogin {
13 | private String userName;
14 | private String password;
15 | }
16 |
--------------------------------------------------------------------------------
/mailService/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8090
3 |
4 | spring:
5 | application:
6 | name: mail-service
7 |
8 | mail:
9 | host: smtp.gmail.com
10 | username: gelbuhherpa456@gmail.com
11 | password: myhlafudrncsbogo
12 | port: 587
13 | properties:
14 | mail:
15 | smtp:
16 | starttls:
17 | enable: true
18 | auth: true
19 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/dto/UserResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class UserResponse {
13 | private String userName;
14 | private String email;
15 | }
16 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/dto/specification/SearchRequestDto.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.dto.specification;
2 |
3 | import com.don.productservice.eunm.Operation;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | @Getter
8 | @Setter
9 | public class SearchRequestDto {
10 | private String column;
11 | private String value;
12 | private Operation operation;
13 | }
14 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/user/UserResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto.user;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class UserResponse {
13 | private String userName;
14 | private String email;
15 | }
16 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/java/com/don/apigatewayservice/dto/ApiResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class ApiResponse {
13 | private String error;
14 | private String message;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/repository/OrderRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.repository;
2 |
3 | import com.don.orderservice.model.order.Order;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.List;
7 | import java.util.Optional;
8 |
9 | public interface OrderRepository extends JpaRepository {
10 | List findByUserId(Long id);
11 | }
12 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/service/OrderService.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.service;
2 |
3 | import com.don.orderservice.dto.order.OrderRequestDto;
4 | import com.don.orderservice.dto.order.OrderResponseDto;
5 |
6 | import java.util.List;
7 |
8 | public interface OrderService {
9 | void placeOrder(OrderRequestDto order, String userName);
10 | List getMyOrder(String userName);
11 | }
12 |
--------------------------------------------------------------------------------
/userService/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8081
3 |
4 | spring:
5 | datasource:
6 | url: jdbc:mysql://localhost:3306/ecommerce_user_service
7 | username: root
8 | password: Basketball
9 |
10 | jpa:
11 | hibernate:
12 | ddl-auto: update
13 | properties:
14 | hibernate:
15 | show_sql: true
16 | show-sql: true
17 |
18 | application:
19 | name: user-service
20 |
21 |
--------------------------------------------------------------------------------
/mailService/src/main/java/com/don/mailservice/MailServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.don.mailservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class MailServiceApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(MailServiceApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/orderService/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8085
3 |
4 | spring:
5 | datasource:
6 | url: jdbc:mysql://localhost:3306/ecommerce_order_service
7 | username: root
8 | password: Basketball
9 |
10 | jpa:
11 | hibernate:
12 | ddl-auto: update
13 | properties:
14 | hibernate:
15 | show_sql: true
16 | show-sql: true
17 |
18 | application:
19 | name: order-service
20 |
21 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/UserServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class UserServiceApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(UserServiceApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/repository/RefreshTokenRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.repository;
2 |
3 | import com.don.userservice.model.RefreshToken;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.Optional;
7 |
8 | public interface RefreshTokenRepository extends JpaRepository {
9 | Optional findByToken(String token);
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/service/RefreshTokenService.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.service;
2 |
3 | import com.don.userservice.model.RefreshToken;
4 |
5 | import java.util.Optional;
6 |
7 | public interface RefreshTokenService {
8 | RefreshToken createRefreshToken(String userName);
9 | Optional findByToken(String token);
10 | RefreshToken verifyExpiration(RefreshToken refreshToken);
11 | }
12 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/dto/specification/RequestDto.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.dto.specification;
2 |
3 | import com.don.productservice.eunm.GlobalOperator;
4 | import lombok.Getter;
5 | import lombok.Setter;
6 |
7 | import java.util.List;
8 |
9 | @Getter
10 | @Setter
11 | public class RequestDto {
12 | private List searchRequestDto;
13 | private GlobalOperator globalOperator;
14 | }
15 |
--------------------------------------------------------------------------------
/mailService/src/main/java/com/don/mailservice/model/Mail.java:
--------------------------------------------------------------------------------
1 | package com.don.mailservice.model;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class Mail {
13 | private String to;
14 | private String cc;
15 | private String body;
16 | private String subject;
17 | }
18 |
--------------------------------------------------------------------------------
/.idea/modules/cartService.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/modules/mailService.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/modules/userService.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/java/com/don/apigatewayservice/exception/MustLoginException.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice.exception;
2 |
3 | import org.springframework.http.HttpStatusCode;
4 | import org.springframework.web.server.ResponseStatusException;
5 |
6 | public class MustLoginException extends ResponseStatusException {
7 | public MustLoginException(HttpStatusCode status, String reason) {
8 | super(status, reason);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/ProductServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class ProductServiceApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(ProductServiceApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/model/mail/Mail.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.model.mail;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class Mail {
13 | private String to;
14 | private String cc;
15 | private String body;
16 | private String subject;
17 | }
18 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/java/com/don/apigatewayservice/exception/RoleNotMatchedException.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice.exception;
2 |
3 | import org.springframework.http.HttpStatusCode;
4 | import org.springframework.web.server.ResponseStatusException;
5 |
6 | public class RoleNotMatchedException extends ResponseStatusException {
7 | public RoleNotMatchedException(HttpStatusCode status, String reason) {
8 | super(status, reason);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/CartResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | import java.util.List;
9 |
10 | @Getter
11 | @Setter
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | public class CartResponse {
15 | private String name;
16 | private List cartItemResponses;
17 | }
18 |
--------------------------------------------------------------------------------
/.idea/modules/apiGatewayService.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/java/com/don/apigatewayservice/ApiGatewayServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class ApiGatewayServiceApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(ApiGatewayServiceApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/.idea/modules/ecommerceMicroService.orderService.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/repository/ProductCategoryRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.repository;
2 |
3 | import com.don.productservice.model.ProductCategory;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 |
6 | import java.util.Optional;
7 |
8 | public interface ProductCategoryRepository extends JpaRepository {
9 | Optional findByCategoryName(String name);
10 |
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/ProductResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class ProductResponse {
13 | private String productName;
14 | private String description;
15 | private double price;
16 | private double stockQuantity;
17 | }
18 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/CartItemResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class CartItemResponse {
13 | private String productName;
14 | private String productDescription;
15 | private double orderedQuantity;
16 | private double price;
17 | }
18 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/order/PaymentResponseDto.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto.order;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | public class PaymentResponseDto {
13 | private double amount;
14 | private String transaction_code;
15 | private String unique_id;
16 | private String status;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/model/Image.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.model;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Getter;
6 | import lombok.NoArgsConstructor;
7 | import lombok.Setter;
8 |
9 | @Getter
10 | @Setter
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Entity
14 | public class Image{
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
17 | private Long imageId;
18 | private String url;
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/order/OrderRequestDto.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto.order;
2 |
3 | import com.don.orderservice.model.order.Address;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Getter;
6 | import lombok.NoArgsConstructor;
7 | import lombok.Setter;
8 |
9 | import java.util.List;
10 |
11 | @Getter
12 | @Setter
13 | @AllArgsConstructor
14 | @NoArgsConstructor
15 | public class OrderRequestDto {
16 |
17 | private List address;
18 | private String paymentMethod;
19 | }
20 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/OrderServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.openfeign.EnableFeignClients;
6 |
7 | @SpringBootApplication
8 | @EnableFeignClients
9 | public class OrderServiceApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(OrderServiceApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/dto/ProductCategoryResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.dto;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Getter;
5 | import lombok.NoArgsConstructor;
6 | import lombok.Setter;
7 |
8 | import java.util.List;
9 |
10 | @Getter
11 | @Setter
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | public class ProductCategoryResponse {
15 | private String categoryName;
16 | private String description;
17 | private List productResponses;
18 | }
19 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/repository/ProductRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.repository;
2 |
3 | import com.don.productservice.model.Product;
4 | import org.springframework.data.jpa.repository.JpaRepository;
5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 |
7 | import java.util.Optional;
8 |
9 | public interface ProductRepository extends JpaRepository, JpaSpecificationExecutor {
10 | Optional findByProductName(String name);
11 | }
12 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/feignClient/MailService.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.feignClient;
2 |
3 | import com.don.orderservice.model.mail.Mail;
4 | import org.springframework.cloud.openfeign.FeignClient;
5 | import org.springframework.web.bind.annotation.PostMapping;
6 | import org.springframework.web.bind.annotation.RequestBody;
7 |
8 | @FeignClient(name = "mail-service", path = "/mails")
9 | public interface MailService {
10 | @PostMapping("/sendMail")
11 | String sendEmail(@RequestBody Mail mail);
12 | }
13 |
--------------------------------------------------------------------------------
/discoveryService/src/main/java/com/don/discoveryservice/DiscoveryServiceApplication.java:
--------------------------------------------------------------------------------
1 | package com.don.discoveryservice;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @SpringBootApplication
8 | @EnableEurekaServer
9 | public class DiscoveryServiceApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(DiscoveryServiceApplication.class, args);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/service/UserCredentialService.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.service;
2 |
3 | import com.don.userservice.dto.UserResponse;
4 | import com.don.userservice.model.UserCredential;
5 |
6 | import java.util.List;
7 |
8 | public interface UserCredentialService {
9 | void saveUser(UserCredential userCredential);
10 | Long getUserId(String userName);
11 | void updateUser(UserCredential userCredential, Long userId);
12 | void deleteUser(Long userId);
13 | UserResponse getUserByName(String name);
14 | List getAllUser();
15 | }
16 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/dto/ProductResponse.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.dto;
2 |
3 | import com.don.productservice.eunm.ProductStatus;
4 | import com.don.productservice.model.Image;
5 | import lombok.*;
6 |
7 | import java.util.List;
8 |
9 | @Getter
10 | @Setter
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | public class ProductResponse {
14 | private String productName;
15 | private String description;
16 | private double price;
17 | private double stockQuantity;
18 | private ProductStatus availability;
19 | private List images;
20 | }
21 |
--------------------------------------------------------------------------------
/mailService/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/orderService/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/userService/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/apiGatewayService/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/discoveryService/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/productService/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | .gradle
3 | build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 | !**/src/main/**/build/
6 | !**/src/test/**/build/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 | bin/
17 | !**/src/main/**/bin/
18 | !**/src/test/**/bin/
19 |
20 | ### IntelliJ IDEA ###
21 | .idea
22 | *.iws
23 | *.iml
24 | *.ipr
25 | out/
26 | !**/src/main/**/out/
27 | !**/src/test/**/out/
28 |
29 | ### NetBeans ###
30 | /nbproject/private/
31 | /nbbuild/
32 | /dist/
33 | /nbdist/
34 | /.nb-gradle/
35 |
36 | ### VS Code ###
37 | .vscode/
38 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/model/ProductCategory.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.model;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.*;
5 |
6 | import java.util.List;
7 |
8 | @Getter
9 | @Setter
10 | @AllArgsConstructor
11 | @NoArgsConstructor
12 | @Builder
13 | @Entity
14 | public class ProductCategory {
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
17 | private Long categoryId;
18 | private String categoryName;
19 | private String description;
20 |
21 | @OneToMany(fetch = FetchType.EAGER, mappedBy = "category")
22 | private List products;
23 | }
24 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/model/RefreshToken.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.model;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.*;
5 |
6 | import java.time.Instant;
7 |
8 | @Entity
9 | @Getter
10 | @Setter
11 | @Builder
12 | @AllArgsConstructor
13 | @NoArgsConstructor
14 | public class RefreshToken {
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
17 | private Long id;
18 | private String token;
19 | private Instant expiryDate;
20 | @OneToOne
21 | @JoinColumn(name = "users_id",referencedColumnName = "userId")
22 | private UserCredential userCredential;
23 | }
24 |
--------------------------------------------------------------------------------
/productService/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8080
3 |
4 | spring:
5 | datasource:
6 | url: jdbc:mysql://localhost:3306/ecommerce_product_service
7 | username: root
8 | password: Basketball
9 |
10 | jpa:
11 | hibernate:
12 | ddl-auto: update
13 | properties:
14 | hibernate:
15 | show_sql: true
16 | format_sql: true
17 | show-sql: true
18 |
19 | application:
20 | name: product-service
21 |
22 | servlet:
23 | multipart:
24 | max-file-size: 10MB
25 | max-request-size: 10MB
26 |
27 | project:
28 | image: productService/src/main/resources/static/
29 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/mapper/UserToResponseMapper.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.mapper;
2 |
3 | import com.don.userservice.dto.UserResponse;
4 | import com.don.userservice.model.UserCredential;
5 | import org.springframework.stereotype.Component;
6 |
7 | import java.util.function.Function;
8 |
9 | @Component
10 | public class UserToResponseMapper implements Function {
11 | @Override
12 | public UserResponse apply(UserCredential userCredential) {
13 | return new UserResponse(
14 | userCredential.getUserName(),
15 | userCredential.getEmail()
16 | );
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/feignClient/UserService.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.feignClient;
2 |
3 | import com.don.orderservice.dto.user.UserResponse;
4 | import org.springframework.cloud.openfeign.FeignClient;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 | import org.springframework.web.bind.annotation.PathVariable;
7 |
8 | @FeignClient(name = "user-service", path = "/users")
9 | public interface UserService {
10 | @GetMapping("/getUserId/{userName}")
11 | Long getUserId(@PathVariable String userName);
12 |
13 | @GetMapping("/getUserByName/{name}")
14 | UserResponse getUserByName(@PathVariable String name);
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/model/Cart.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.model;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Getter;
6 | import lombok.NoArgsConstructor;
7 | import lombok.Setter;
8 |
9 | import java.util.List;
10 |
11 | @Getter
12 | @Setter
13 | @AllArgsConstructor
14 | @NoArgsConstructor
15 | @Entity
16 | public class Cart {
17 | @Id
18 | @GeneratedValue(strategy = GenerationType.IDENTITY)
19 | private Long cartId;
20 | private Long userId;
21 | private String name;
22 |
23 | @OneToMany(fetch = FetchType.EAGER, mappedBy = "cart")
24 | private List cartItems;
25 | }
26 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/model/CartItem.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.model;
2 |
3 | import jakarta.persistence.*;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Getter;
6 | import lombok.NoArgsConstructor;
7 | import lombok.Setter;
8 |
9 | @Getter
10 | @Setter
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Entity
14 | public class CartItem {
15 | @Id
16 | @GeneratedValue(strategy = GenerationType.IDENTITY)
17 | private Long cartItemId;
18 | private String productName;
19 | private double orderedQuantity;
20 |
21 | @ManyToOne(cascade = CascadeType.PERSIST)
22 | @JoinColumn(name = "cart_id")
23 | private Cart cart;
24 | }
25 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/feignClient/PaymentService.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.feignClient;
2 |
3 | import com.don.orderservice.dto.order.PaymentRequestDto;
4 | import com.don.orderservice.dto.order.PaymentResponseDto;
5 | import org.springframework.cloud.openfeign.FeignClient;
6 | import org.springframework.web.bind.annotation.PostMapping;
7 | import org.springframework.web.bind.annotation.RequestBody;
8 |
9 | @FeignClient(value = "external", url = "https://acca33c3-19e4-40b1-8e64-a2b3050d451e.mock.pstmn.io")
10 | public interface PaymentService {
11 |
12 | @PostMapping("/makePayment")
13 | PaymentResponseDto makePayment(@RequestBody PaymentRequestDto paymentRequestDto);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/model/order/Address.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.model.order;
2 |
3 | import jakarta.persistence.Entity;
4 | import jakarta.persistence.GeneratedValue;
5 | import jakarta.persistence.GenerationType;
6 | import jakarta.persistence.Id;
7 | import lombok.AllArgsConstructor;
8 | import lombok.Getter;
9 | import lombok.NoArgsConstructor;
10 | import lombok.Setter;
11 |
12 | @Getter
13 | @Setter
14 | @AllArgsConstructor
15 | @NoArgsConstructor
16 | @Entity
17 | public class Address {
18 | @Id
19 | @GeneratedValue(strategy = GenerationType.IDENTITY)
20 | private Long addressId;
21 | private String customerName;
22 | private String provinces;
23 | private String city;
24 | private String area;
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/util/AuthUtil.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.util;
2 |
3 | import lombok.RequiredArgsConstructor;
4 | import org.springframework.stereotype.Component;
5 |
6 | @Component
7 | @RequiredArgsConstructor
8 | public class AuthUtil {
9 |
10 | private final JwtUtil jwtUtil;
11 |
12 | public String getUserName(String authorizationHeader) {
13 | if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) {
14 | // Exclude "Bearer " prefix
15 | String authorizationKey = authorizationHeader.substring(7);
16 | return jwtUtil.extractUserName(authorizationKey); // Extract the username
17 |
18 | } else {
19 | return null;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/feignClient/ProductService.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.feignClient;
2 |
3 | import com.don.orderservice.dto.ProductResponse;
4 | import org.springframework.cloud.openfeign.FeignClient;
5 | import org.springframework.web.bind.annotation.GetMapping;
6 | import org.springframework.web.bind.annotation.PathVariable;
7 | import org.springframework.web.bind.annotation.PutMapping;
8 |
9 | @FeignClient(name = "product-service")
10 | public interface ProductService {
11 | @GetMapping("/products/getProductByName/{name}")
12 | ProductResponse getProductByName(@PathVariable String name);
13 |
14 | @PutMapping("/updateProductStock/{productName}/{quantity}")
15 | public String updateProductStock(@PathVariable String productName, @PathVariable double quantity);
16 |
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/mailService/src/main/java/com/don/mailservice/controller/MailController.java:
--------------------------------------------------------------------------------
1 | package com.don.mailservice.controller;
2 |
3 | import com.don.mailservice.model.Mail;
4 | import com.don.mailservice.service.MailService;
5 | import lombok.RequiredArgsConstructor;
6 | import org.springframework.web.bind.annotation.PostMapping;
7 | import org.springframework.web.bind.annotation.RequestBody;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | @RestController
12 | @RequiredArgsConstructor
13 | @RequestMapping("/mails")
14 | public class MailController {
15 |
16 | private final MailService emailService;
17 |
18 | @PostMapping("/sendMail")
19 | public String sendEmail(@RequestBody Mail mail){
20 | return emailService.sendMail(mail);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/util/OrderTotalUtil.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.util;
2 |
3 | import com.don.orderservice.dto.CartItemResponse;
4 | import com.don.orderservice.dto.CartResponse;
5 | import org.springframework.stereotype.Component;
6 |
7 | import java.util.List;
8 |
9 | @Component
10 | public class OrderTotalUtil {
11 | public double calculateTotal(CartResponse cartResponse) {
12 | List cartItemResponses = cartResponse.getCartItemResponses();
13 |
14 | double total = 0;
15 |
16 | for (CartItemResponse cartItems : cartItemResponses) {
17 | double orderedQuantity = cartItems.getOrderedQuantity();
18 | double price = cartItems.getPrice();
19 | total += orderedQuantity * price;
20 | }
21 | return total;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/discoveryService/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.springframework.boot' version '3.0.7'
4 | id 'io.spring.dependency-management' version '1.1.0'
5 | }
6 |
7 | group = 'com.don'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '17'
10 |
11 | repositories {
12 | mavenCentral()
13 | maven { url 'https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates' }
14 | }
15 |
16 | ext {
17 | set('springCloudVersion', "2022.0.3")
18 | }
19 |
20 | dependencies {
21 | implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
22 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
23 | }
24 |
25 | dependencyManagement {
26 | imports {
27 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
28 | }
29 | }
30 |
31 | tasks.named('test') {
32 | useJUnitPlatform()
33 | }
34 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/dto/order/OrderResponseDto.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.dto.order;
2 |
3 | import com.don.orderservice.dto.CartResponse;
4 | import com.don.orderservice.enums.OrderStatus;
5 | import com.don.orderservice.model.order.Address;
6 | import lombok.AllArgsConstructor;
7 | import lombok.Getter;
8 | import lombok.NoArgsConstructor;
9 | import lombok.Setter;
10 |
11 | import java.time.LocalDate;
12 | import java.util.List;
13 |
14 | @Getter
15 | @Setter
16 | @AllArgsConstructor
17 | @NoArgsConstructor
18 | public class OrderResponseDto {
19 | private List address;
20 |
21 | private LocalDate orderedDate;
22 |
23 | private OrderStatus orderStatus;
24 |
25 | private Long userId;
26 |
27 | private CartResponse cartResponse;
28 |
29 | private double totalPayment;
30 |
31 | private String paymentMethod;
32 | }
33 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/util/JwtUtil.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.util;
2 |
3 | import io.jsonwebtoken.Claims;
4 | import io.jsonwebtoken.Jwts;
5 | import io.jsonwebtoken.io.Decoders;
6 | import io.jsonwebtoken.security.Keys;
7 | import org.springframework.stereotype.Component;
8 |
9 | import java.security.Key;
10 |
11 | @Component
12 | public class JwtUtil {
13 | public static final String SECRET = "5367566B59703373367639792F423F4528482B4D6251655468576D5A71347437";
14 |
15 | public String extractUserName(final String token) {
16 | Claims claims = Jwts.parserBuilder().setSigningKey(getSignKey()).build().parseClaimsJws(token).getBody();
17 | return claims.getSubject();
18 | }
19 |
20 | private Key getSignKey() {
21 | byte[] keyBytes = Decoders.BASE64.decode(SECRET);
22 | return Keys.hmacShaKeyFor(keyBytes);
23 | }
24 | }
25 |
26 |
--------------------------------------------------------------------------------
/.idea/modules/productService.main.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Ecommerce microservice
2 |
3 | Ecommerce microservice using spring boot, spring cloud and spring security with JWT
4 | 
5 |
6 | 1. Project Application Description
7 |
8 | The microservice architecture includes several components such as user management, product management, order processing,
9 | integration with a third-party payment system, and an API gateway. The goal is to create a scalable and modular system for
10 | handling various ecommerce functionalities efficiently.
11 |
12 | 2. Technology Used
13 |
14 | - spring boot
15 | - Spring web
16 | - Spring cloud
17 | - eureka
18 | - gateway
19 | - open feign
20 | - JPA
21 | - Security
22 | - lombok
23 | - mysql (for database)
24 | - postman (for api testing)
25 |
26 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/repository/UserCredentialRepository.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.repository;
2 |
3 | import com.don.userservice.enums.UserStatus;
4 | import com.don.userservice.model.UserCredential;
5 | import org.springframework.data.jpa.repository.JpaRepository;
6 | import org.springframework.data.jpa.repository.Query;
7 |
8 | import java.util.List;
9 | import java.util.Optional;
10 |
11 | public interface UserCredentialRepository extends JpaRepository {
12 | Optional findByUserName(String userName);
13 |
14 | @Query(value = "select role from user_credential where user_name=?1", nativeQuery = true)
15 | Optional getUserRole(String userName);
16 |
17 | @Query(value = "select user_id from user_credential where user_name=?1", nativeQuery = true)
18 | Optional getUserId(String userName);
19 |
20 | List findByStatus(UserStatus userStatus);
21 | }
22 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/model/Product.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.model;
2 |
3 | import com.don.productservice.eunm.ProductStatus;
4 | import jakarta.persistence.*;
5 | import lombok.*;
6 |
7 | import java.util.List;
8 |
9 | @Getter
10 | @Setter
11 | @AllArgsConstructor
12 | @NoArgsConstructor
13 | @Builder
14 | @Entity
15 | public class Product {
16 | @Id
17 | @GeneratedValue(strategy = GenerationType.IDENTITY)
18 | private Long productId;
19 |
20 | private String productName;
21 | private double price;
22 | private double stockQuantity;
23 | private String description;
24 |
25 | @Enumerated(EnumType.STRING)
26 | private ProductStatus availability;
27 |
28 | @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
29 | @JoinColumn(name = "category_id")
30 | private ProductCategory category;
31 |
32 | @OneToMany(cascade = CascadeType.ALL)
33 | @JoinColumn(name = "products_id")
34 | private List images;
35 | }
36 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/config/CustomUserDetailsService.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.config;
2 |
3 | import com.don.userservice.repository.UserCredentialRepository;
4 | import lombok.RequiredArgsConstructor;
5 | import org.springframework.security.core.userdetails.UserDetails;
6 | import org.springframework.security.core.userdetails.UserDetailsService;
7 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
8 | import org.springframework.stereotype.Service;
9 |
10 | @RequiredArgsConstructor
11 | @Service
12 | public class CustomUserDetailsService implements UserDetailsService {
13 |
14 | private final UserCredentialRepository repository;
15 |
16 | @Override
17 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
18 | return repository.findByUserName(username)
19 | .map(CustomUserDetails::new)
20 | .orElseThrow(() -> new UsernameNotFoundException("User does not exist"));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8069
3 |
4 | spring:
5 | application:
6 | name: api-gateway
7 |
8 | cloud:
9 | gateway:
10 |
11 | default-filters:
12 | - name: AuthenticationFilter
13 |
14 | routes:
15 | - id: product-service
16 | uri: lb://product-service
17 | predicates:
18 | - Path=/products/**
19 | # filters:
20 | # - AuthenticationFilter
21 |
22 | - id: user-service
23 | uri: lb://user-service
24 | predicates:
25 | - Path=/users/**
26 |
27 | - id: order-service
28 | uri: lb://order-service
29 | predicates:
30 | - Path=/carts/**, /orders/**
31 |
32 | - id: payment-service
33 | uri: lb://payment-service
34 | predicates:
35 | - Path=/payments/**
36 |
37 | - id: mail-service
38 | uri: lb://mail-service
39 | predicates:
40 | - Path=/mails/**
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/java/com/don/apigatewayservice/util/JwtUtil.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice.util;
2 |
3 | import io.jsonwebtoken.Claims;
4 | import io.jsonwebtoken.Jwts;
5 | import io.jsonwebtoken.io.Decoders;
6 | import io.jsonwebtoken.security.Keys;
7 | import org.springframework.stereotype.Component;
8 |
9 | import java.security.Key;
10 |
11 | @Component
12 | public class JwtUtil {
13 | public static final String SECRET = "5367566B59703373367639792F423F4528482B4D6251655468576D5A71347437";
14 |
15 | public void validateToken(final String token) {
16 | Jwts.parserBuilder().setSigningKey(getSignKey()).build().parseClaimsJws(token);
17 | }
18 |
19 | public String extractUserRole(final String token) {
20 | Claims claims = Jwts.parserBuilder().setSigningKey(getSignKey()).build().parseClaimsJws(token).getBody();
21 | return claims.getAudience();
22 | }
23 |
24 | private Key getSignKey() {
25 | byte[] keyBytes = Decoders.BASE64.decode(SECRET);
26 | return Keys.hmacShaKeyFor(keyBytes);
27 | }
28 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/service/ProductService.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.service;
2 |
3 | import com.don.productservice.dto.ProductCategoryResponse;
4 | import com.don.productservice.dto.ProductResponse;
5 | import com.don.productservice.dto.specification.RequestDto;
6 | import com.don.productservice.model.Product;
7 | import org.springframework.web.multipart.MultipartFile;
8 |
9 | import java.io.IOException;
10 | import java.util.List;
11 |
12 | public interface ProductService {
13 | void saveProducts(Product product, String path, List images) throws IOException;
14 | List getAllProductByName(int offSet, int pageSize, String productAttribute);
15 | ProductResponse getProductById(Long id);
16 | void deleteProduct(Long id);
17 | ProductCategoryResponse getProductByCategory(String name);
18 | List getAll();
19 | ProductResponse getProductByName(String name);
20 | List getBySpecification(RequestDto requestDto);
21 | void updateStock(String productName, double quantity);
22 | }
23 |
--------------------------------------------------------------------------------
/mailService/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.springframework.boot' version '3.1.0'
4 | id 'io.spring.dependency-management' version '1.1.0'
5 | }
6 |
7 | group = 'com.don'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '17'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | }
20 |
21 | ext {
22 | set('springCloudVersion', "2022.0.3")
23 | }
24 |
25 | dependencies {
26 | implementation 'org.springframework.boot:spring-boot-starter-mail'
27 | implementation 'org.springframework.boot:spring-boot-starter-web'
28 | implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
29 | compileOnly 'org.projectlombok:lombok'
30 | annotationProcessor 'org.projectlombok:lombok'
31 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
32 | }
33 |
34 | dependencyManagement {
35 | imports {
36 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
37 | }
38 | }
39 |
40 | tasks.named('test') {
41 | useJUnitPlatform()
42 | }
43 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/mapper/ProductCategoryResponseMapper.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.mapper;
2 |
3 | import com.don.productservice.dto.ProductCategoryResponse;
4 | import com.don.productservice.model.ProductCategory;
5 | import lombok.RequiredArgsConstructor;
6 | import org.springframework.stereotype.Service;
7 |
8 | import java.util.function.Function;
9 | import java.util.stream.Collectors;
10 |
11 | @Service
12 | @RequiredArgsConstructor
13 | public class ProductCategoryResponseMapper implements Function {
14 |
15 | private final ProductResponseMapper mapper;
16 |
17 | @Override
18 | public ProductCategoryResponse apply(ProductCategory productCategory) {
19 | return new ProductCategoryResponse(
20 | productCategory.getCategoryName(),
21 | productCategory.getDescription(),
22 | productCategory.getProducts()
23 | .stream()
24 | .map(mapper)
25 | .collect(Collectors.toList())
26 | );
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/model/UserCredential.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.model;
2 |
3 | import com.don.userservice.enums.UserStatus;
4 | import jakarta.persistence.*;
5 | import jakarta.validation.constraints.Email;
6 | import jakarta.validation.constraints.Min;
7 | import jakarta.validation.constraints.NotBlank;
8 | import jakarta.validation.constraints.NotNull;
9 | import lombok.AllArgsConstructor;
10 | import lombok.Getter;
11 | import lombok.NoArgsConstructor;
12 | import lombok.Setter;
13 | import org.hibernate.validator.constraints.Length;
14 |
15 | @Entity
16 | @Getter
17 | @Setter
18 | @AllArgsConstructor
19 | @NoArgsConstructor
20 | public class UserCredential {
21 | @Id
22 | @GeneratedValue(strategy = GenerationType.IDENTITY)
23 | private Long userId;
24 |
25 | @NotBlank(message = "User name cannot be null or empty")
26 | @NotNull(message = "i am don")
27 | private String userName;
28 |
29 | @Email(message = "please enter valid email")
30 | private String email;
31 |
32 | // @Min(value = 5,message = "minimum password length should be 5")
33 | private String password;
34 | private String role;
35 |
36 | @Enumerated(EnumType.STRING)
37 | private UserStatus status;
38 | }
39 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/model/order/Order.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.model.order;
2 |
3 | import com.don.orderservice.dto.CartResponse;
4 | import com.don.orderservice.enums.OrderStatus;
5 | import jakarta.persistence.*;
6 | import lombok.AllArgsConstructor;
7 | import lombok.Getter;
8 | import lombok.NoArgsConstructor;
9 | import lombok.Setter;
10 | import org.hibernate.annotations.CreationTimestamp;
11 |
12 | import java.time.LocalDate;
13 | import java.util.List;
14 |
15 | @Getter
16 | @Setter
17 | @AllArgsConstructor
18 | @NoArgsConstructor
19 | @Entity
20 | @Table(name = "order_detail")
21 | public class Order {
22 | @Id
23 | @GeneratedValue(strategy = GenerationType.IDENTITY)
24 | private Long orderId;
25 |
26 | @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
27 | @JoinColumn(name = "order_id")
28 | private List address;
29 |
30 | @CreationTimestamp
31 | private LocalDate orderedDate;
32 |
33 | @Enumerated(EnumType.STRING)
34 | private OrderStatus orderStatus;
35 |
36 | private Long userId;
37 |
38 | @Transient
39 | private CartResponse cartResponse;
40 |
41 | private double totalPayment;
42 |
43 | private String paymentMethod;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/productService/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.springframework.boot' version '3.0.7'
4 | id 'io.spring.dependency-management' version '1.1.0'
5 | }
6 |
7 | group = 'com.don'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '17'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | maven { url 'https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates' }
20 | }
21 |
22 | ext {
23 | set('springCloudVersion', "2022.0.3")
24 | }
25 |
26 | dependencies {
27 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
28 | implementation 'org.springframework.boot:spring-boot-starter-web'
29 | implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
30 | compileOnly 'org.projectlombok:lombok'
31 | runtimeOnly 'com.mysql:mysql-connector-j'
32 | annotationProcessor 'org.projectlombok:lombok'
33 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
34 | }
35 |
36 | dependencyManagement {
37 | imports {
38 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
39 | }
40 | }
41 |
42 | tasks.named('test') {
43 | useJUnitPlatform()
44 | }
45 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/mapper/ProductResponseMapper.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.mapper;
2 |
3 | import com.don.productservice.dto.ProductResponse;
4 | import com.don.productservice.model.Image;
5 | import com.don.productservice.model.Product;
6 | import org.springframework.stereotype.Service;
7 |
8 | import java.util.ArrayList;
9 | import java.util.List;
10 | import java.util.function.Function;
11 |
12 | @Service
13 | public class ProductResponseMapper implements Function {
14 | @Override
15 | public ProductResponse apply(Product product) {
16 |
17 | List images = product.getImages();
18 | List newImages = new ArrayList<>();
19 |
20 | for (Image image : images) {
21 |
22 | String saveImagePath = image.getUrl().replace("productService/src/main/resources/static/","");
23 |
24 | Image image1 = new Image();
25 | image1.setUrl("http://localhost:8080/" + saveImagePath);
26 | image1.setImageId(image.getImageId());
27 |
28 | newImages.add(image1);
29 | }
30 |
31 | return new ProductResponse(
32 | product.getProductName(),
33 | product.getDescription(),
34 | product.getPrice(),
35 | product.getStockQuantity(),
36 | product.getAvailability(),
37 | newImages
38 | );
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/controller/CartController.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.controller;
2 |
3 | import com.don.orderservice.dto.CartResponse;
4 | import com.don.orderservice.model.CartItem;
5 | import com.don.orderservice.service.CartService;
6 | import com.don.orderservice.util.AuthUtil;
7 | import lombok.RequiredArgsConstructor;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | @RestController
11 | @RequiredArgsConstructor
12 | @RequestMapping("/carts")
13 | public class CartController {
14 |
15 | private final CartService cartService;
16 | private final AuthUtil authUtil;
17 |
18 | @PostMapping("/addToCart")
19 | public String addProductToCart(
20 | @RequestHeader("Authorization") String authorizationHeader,
21 | @RequestBody CartItem cartItem) {
22 |
23 | String userName = authUtil.getUserName(authorizationHeader);
24 | if (userName == null) {
25 | return "error";
26 | }
27 | cartService.saveToCart(cartItem, userName);
28 | return "saved success";
29 | }
30 |
31 | @GetMapping("/viewMyCart")
32 | public CartResponse viewMyCart(
33 | @RequestHeader("Authorization") String authorizationHeader) {
34 |
35 | String userName = authUtil.getUserName(authorizationHeader);
36 | if(userName!=null){
37 | return cartService.getMyCart(userName);
38 | }
39 | return new CartResponse();
40 | }
41 |
42 | }
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/apiGatewayService/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.springframework.boot' version '3.0.7'
4 | id 'io.spring.dependency-management' version '1.1.0'
5 | }
6 |
7 | group = 'com.don'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '17'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | maven { url 'https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates' }
20 | }
21 |
22 | ext {
23 | set('springCloudVersion', "2022.0.3")
24 | }
25 |
26 | dependencies {
27 | implementation 'org.springframework.boot:spring-boot-starter-webflux'
28 | implementation 'org.springframework.cloud:spring-cloud-starter'
29 | implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
30 | implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
31 | compileOnly 'org.projectlombok:lombok'
32 | annotationProcessor 'org.projectlombok:lombok'
33 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
34 | testImplementation 'io.projectreactor:reactor-test'
35 |
36 | implementation "io.jsonwebtoken:jjwt-api:0.11.5"
37 | implementation "io.jsonwebtoken:jjwt-impl:0.11.5"
38 | implementation "io.jsonwebtoken:jjwt-jackson:0.11.5"
39 | }
40 |
41 | dependencyManagement {
42 | imports {
43 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
44 | }
45 | }
46 |
47 | tasks.named('test') {
48 | useJUnitPlatform()
49 | }
50 |
--------------------------------------------------------------------------------
/apiGatewayService/src/main/java/com/don/apigatewayservice/filter/RouteValidator.java:
--------------------------------------------------------------------------------
1 | package com.don.apigatewayservice.filter;
2 |
3 | import org.springframework.http.server.reactive.ServerHttpRequest;
4 | import org.springframework.stereotype.Component;
5 | import org.springframework.util.AntPathMatcher;
6 |
7 | import java.util.*;
8 | import java.util.function.Predicate;
9 |
10 | @Component
11 | public class RouteValidator {
12 |
13 | public static final List openApiEndpoints = List.of(
14 | "/users/register",
15 | "/users/login",
16 | "/users/getUserId/**",
17 | "/users/refreshToken",
18 | "/products/getAllProducts/**",
19 | "/products/getById/**",
20 | "/products/specification",
21 | "/products/getByAttribute/**",
22 | "/getProductByName/**",
23 | "/eureka"
24 | );
25 | public Predicate isSecured =
26 | request -> openApiEndpoints
27 | .stream()
28 | .noneMatch(uri -> new AntPathMatcher().match(uri, request.getURI().getPath()));
29 |
30 | public static final List adminEndpoints = List.of(
31 | "/products/addProduct",
32 | "/users/deleteUser/**"
33 | );
34 | public Predicate isAdminAccess =
35 | request -> adminEndpoints
36 | .stream()
37 | .anyMatch(uri -> new AntPathMatcher().match(uri, request.getURI().getPath()));
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/mailService/src/main/java/com/don/mailservice/service/MailServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.don.mailservice.service;
2 |
3 | import com.don.mailservice.model.Mail;
4 | import jakarta.mail.MessagingException;
5 | import jakarta.mail.internet.MimeMessage;
6 | import lombok.RequiredArgsConstructor;
7 | import org.springframework.beans.factory.annotation.Value;
8 | import org.springframework.mail.javamail.JavaMailSender;
9 | import org.springframework.mail.javamail.MimeMessageHelper;
10 | import org.springframework.stereotype.Service;
11 |
12 | @Service
13 | @RequiredArgsConstructor
14 | public class MailServiceImpl implements MailService{
15 |
16 | @Value("${spring.mail.username}")
17 | private String fromEmail;
18 |
19 | private final JavaMailSender mailSender;
20 | @Override
21 | public String sendMail(Mail mail) {
22 | try {
23 | MimeMessage mimeMailMessage = mailSender.createMimeMessage();
24 | MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMailMessage, true);
25 |
26 | mimeMessageHelper.setFrom(fromEmail);
27 | mimeMessageHelper.setCc(mail.getCc());
28 | mimeMessageHelper.setTo(mail.getTo());
29 | mimeMessageHelper.setSubject(mail.getSubject());
30 | mimeMessageHelper.setText(mail.getBody());
31 |
32 | mailSender.send(mimeMailMessage);
33 |
34 | return "mail send successfully";
35 |
36 | } catch (MessagingException e) {
37 | throw new RuntimeException(e);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/orderService/src/main/java/com/don/orderservice/controller/OrderController.java:
--------------------------------------------------------------------------------
1 | package com.don.orderservice.controller;
2 |
3 | import com.don.orderservice.dto.order.OrderRequestDto;
4 | import com.don.orderservice.dto.order.OrderResponseDto;
5 | import com.don.orderservice.service.OrderService;
6 | import com.don.orderservice.util.AuthUtil;
7 | import lombok.RequiredArgsConstructor;
8 | import org.springframework.web.bind.annotation.*;
9 |
10 | import java.util.List;
11 |
12 | @RestController
13 | @RequiredArgsConstructor
14 | @RequestMapping("/orders")
15 | public class OrderController {
16 | private final OrderService orderService;
17 | private final AuthUtil authUtil;
18 |
19 | @PostMapping("/placeOrder")
20 | public String placeOrder(
21 | @RequestHeader("Authorization") String authorizationHeader,
22 | @RequestBody OrderRequestDto order) {
23 |
24 | String userName = authUtil.getUserName(authorizationHeader);
25 | if (userName == null) {
26 | return "error";
27 | }
28 | orderService.placeOrder(order, userName);
29 | return "Order placed successfully";
30 | }
31 | @GetMapping("/getOrder")
32 | public List getOrder(
33 | @RequestHeader("Authorization") String authorizationHeader
34 | ) {
35 |
36 | String userName = authUtil.getUserName(authorizationHeader);
37 | if (userName == null) {
38 | return null;
39 | }
40 | return orderService.getMyOrder(userName);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/orderService/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.springframework.boot' version '3.0.7'
4 | id 'io.spring.dependency-management' version '1.1.0'
5 | }
6 |
7 | group = 'com.don'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '17'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | maven { url 'https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates' }
20 | }
21 |
22 | ext {
23 | set('springCloudVersion', "2022.0.3")
24 | }
25 |
26 | dependencies {
27 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
28 | implementation 'org.springframework.boot:spring-boot-starter-web'
29 | implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
30 | compileOnly 'org.projectlombok:lombok'
31 | runtimeOnly 'com.mysql:mysql-connector-j'
32 | annotationProcessor 'org.projectlombok:lombok'
33 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
34 |
35 | implementation "io.jsonwebtoken:jjwt-api:0.11.5"
36 | implementation "io.jsonwebtoken:jjwt-impl:0.11.5"
37 | implementation "io.jsonwebtoken:jjwt-jackson:0.11.5"
38 |
39 | implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
40 | implementation 'org.springframework.boot:spring-boot-starter-mail'
41 | }
42 |
43 | dependencyManagement {
44 | imports {
45 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
46 | }
47 | }
48 |
49 | tasks.named('test') {
50 | useJUnitPlatform()
51 | }
52 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/service/JwtService.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.service;
2 |
3 | import io.jsonwebtoken.Jwts;
4 | import io.jsonwebtoken.SignatureAlgorithm;
5 | import io.jsonwebtoken.io.Decoders;
6 | import io.jsonwebtoken.security.Keys;
7 | import org.springframework.stereotype.Component;
8 |
9 | import java.security.Key;
10 | import java.util.Date;
11 | import java.util.HashMap;
12 | import java.util.Map;
13 |
14 | @Component
15 | public class JwtService {
16 |
17 | public static final String SECRET = "5367566B59703373367639792F423F4528482B4D6251655468576D5A71347437";
18 |
19 | public void validateToken(final String token) {
20 | Jwts.parserBuilder().setSigningKey(getSignKey()).build().parseClaimsJws(token);
21 | }
22 |
23 | public String generateToken(String userName,String role) {
24 | Map claims = new HashMap<>();
25 | return createToken(claims, userName,role);
26 | }
27 |
28 | private String createToken(Map claims, String userName,String role) {
29 | return Jwts.builder()
30 | .setClaims(claims)
31 | .setSubject(userName)
32 | .setAudience(role)
33 | .setIssuedAt(new Date(System.currentTimeMillis()))
34 | .setExpiration(new Date(System.currentTimeMillis() + 1000 * 60 * 30))
35 | .signWith(getSignKey(), SignatureAlgorithm.HS256)
36 | .compact();
37 | }
38 |
39 | private Key getSignKey() {
40 | byte[] keyBytes = Decoders.BASE64.decode(SECRET);
41 | return Keys.hmacShaKeyFor(keyBytes);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/userService/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.springframework.boot' version '3.0.7'
4 | id 'io.spring.dependency-management' version '1.1.0'
5 | }
6 |
7 | group = 'com.don'
8 | version = '0.0.1-SNAPSHOT'
9 | sourceCompatibility = '17'
10 |
11 | configurations {
12 | compileOnly {
13 | extendsFrom annotationProcessor
14 | }
15 | }
16 |
17 | repositories {
18 | mavenCentral()
19 | maven { url 'https://artifactory-oss.prod.netflix.net/artifactory/maven-oss-candidates' }
20 | }
21 |
22 | ext {
23 | set('springCloudVersion', "2022.0.3")
24 | }
25 |
26 | dependencies {
27 | implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
28 | implementation 'org.springframework.boot:spring-boot-starter-security'
29 | implementation 'org.springframework.boot:spring-boot-starter-web'
30 | implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
31 | compileOnly 'org.projectlombok:lombok'
32 | runtimeOnly 'com.mysql:mysql-connector-j'
33 | annotationProcessor 'org.projectlombok:lombok'
34 | testImplementation 'org.springframework.boot:spring-boot-starter-test'
35 | testImplementation 'org.springframework.security:spring-security-test'
36 |
37 | implementation "io.jsonwebtoken:jjwt-api:0.11.5"
38 | implementation "io.jsonwebtoken:jjwt-impl:0.11.5"
39 | implementation "io.jsonwebtoken:jjwt-jackson:0.11.5"
40 |
41 | implementation 'org.springframework.boot:spring-boot-starter-validation'
42 | }
43 |
44 | dependencyManagement {
45 | imports {
46 | mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
47 | }
48 | }
49 |
50 | tasks.named('test') {
51 | useJUnitPlatform()
52 | }
53 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/config/CustomUserDetails.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.config;
2 |
3 | import com.don.userservice.model.UserCredential;
4 | import org.springframework.security.core.GrantedAuthority;
5 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
6 | import org.springframework.security.core.userdetails.UserDetails;
7 |
8 | import java.util.Arrays;
9 | import java.util.Collection;
10 | import java.util.stream.Collectors;
11 |
12 | public class CustomUserDetails implements UserDetails {
13 | private final UserCredential userCredential;
14 |
15 | public CustomUserDetails(UserCredential userCredential) {
16 | this.userCredential = userCredential;
17 | }
18 |
19 | @Override
20 | public Collection extends GrantedAuthority> getAuthorities() {
21 | return Arrays.stream(
22 | userCredential
23 | .getRole()
24 | .split(","))
25 | .map(SimpleGrantedAuthority::new)
26 | .collect(Collectors.toList());
27 | }
28 |
29 | @Override
30 | public String getPassword() {
31 | return userCredential.getPassword();
32 | }
33 |
34 | @Override
35 | public String getUsername() {
36 | return userCredential.getUserName();
37 | }
38 |
39 | @Override
40 | public boolean isAccountNonExpired() {
41 | return true;
42 | }
43 |
44 | @Override
45 | public boolean isAccountNonLocked() {
46 | return true;
47 | }
48 |
49 | @Override
50 | public boolean isCredentialsNonExpired() {
51 | return true;
52 | }
53 |
54 | @Override
55 | public boolean isEnabled() {
56 | return true;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/service/RefreshTokenServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.service;
2 |
3 | import com.don.userservice.model.RefreshToken;
4 | import com.don.userservice.repository.RefreshTokenRepository;
5 | import com.don.userservice.repository.UserCredentialRepository;
6 | import lombok.RequiredArgsConstructor;
7 | import org.springframework.stereotype.Service;
8 |
9 | import java.time.Instant;
10 | import java.util.Optional;
11 | import java.util.UUID;
12 |
13 | @Service
14 | @RequiredArgsConstructor
15 | public class RefreshTokenServiceImpl implements RefreshTokenService {
16 | private final RefreshTokenRepository refreshTokenRepository;
17 | private final UserCredentialRepository userCredentialRepository;
18 |
19 | @Override
20 | public RefreshToken createRefreshToken(String userName) {
21 | RefreshToken refreshToken = RefreshToken.builder()
22 | .userCredential(userCredentialRepository.findByUserName(userName).get())
23 | .token(UUID.randomUUID().toString())
24 | .expiryDate(Instant.now().plusMillis(600000))
25 | .build();
26 | return refreshTokenRepository.save(refreshToken);
27 | }
28 |
29 | @Override
30 | public Optional findByToken(String token) {
31 | return refreshTokenRepository.findByToken(token);
32 | }
33 |
34 | @Override
35 | public RefreshToken verifyExpiration(RefreshToken refreshToken) {
36 | if (refreshToken.getExpiryDate().compareTo(Instant.now()) < 0) {
37 | refreshTokenRepository.delete(refreshToken);
38 | throw new RuntimeException(refreshToken.getToken() +
39 | "refresh token was expired, please sign in again");
40 | }
41 | return refreshToken;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/productService/src/main/java/com/don/productservice/exception/GlobalExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.don.productservice.exception;
2 |
3 | import com.don.productservice.dto.ApiResponse;
4 | import org.springframework.http.HttpStatus;
5 | import org.springframework.http.ResponseEntity;
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
7 | import org.springframework.web.bind.annotation.RestControllerAdvice;
8 |
9 | @RestControllerAdvice
10 | public class GlobalExceptionHandler {
11 |
12 | @ExceptionHandler(ProductAlreadyExistException.class)
13 | public ResponseEntity alreadyExistException(ProductAlreadyExistException exception) {
14 |
15 | ApiResponse apiResponse = new ApiResponse();
16 | apiResponse.setError("PRODUCT_ALREADY_EXIST");
17 | apiResponse.setMessage(exception.getMessage());
18 |
19 | return new ResponseEntity<>(apiResponse, HttpStatus.BAD_REQUEST);
20 | }
21 |
22 | @ExceptionHandler(ProductDoNotExistException.class)
23 | public ResponseEntity alreadyExistException(ProductDoNotExistException exception) {
24 |
25 | ApiResponse apiResponse = new ApiResponse();
26 | apiResponse.setError("PRODUCT_DO_NOT_EXIST");
27 | apiResponse.setMessage(exception.getMessage());
28 |
29 | return new ResponseEntity<>(apiResponse, HttpStatus.NOT_FOUND);
30 | }
31 |
32 | @ExceptionHandler(ProductCategoryDoNotExistException.class)
33 | public ResponseEntity categoryDoNotExistException(ProductCategoryDoNotExistException exception) {
34 |
35 | ApiResponse apiResponse = new ApiResponse();
36 | apiResponse.setError("PRODUCT_CATEGORY_DO_NOT_EXIST");
37 | apiResponse.setMessage(exception.getMessage());
38 |
39 | return new ResponseEntity<>(apiResponse, HttpStatus.NOT_FOUND);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/userService/src/main/java/com/don/userservice/exception/GlobalExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.don.userservice.exception;
2 |
3 | import com.don.userservice.dto.ApiResponse;
4 | import org.springframework.http.HttpStatus;
5 | import org.springframework.http.ResponseEntity;
6 | import org.springframework.web.bind.MethodArgumentNotValidException;
7 | import org.springframework.web.bind.annotation.ExceptionHandler;
8 | import org.springframework.web.bind.annotation.RestControllerAdvice;
9 |
10 | import java.util.HashMap;
11 | import java.util.Map;
12 |
13 | @RestControllerAdvice
14 | public class GlobalExceptionHandler {
15 |
16 | @ExceptionHandler(UserAlreadyExistException.class)
17 | public ResponseEntity userAlreadyExist(UserAlreadyExistException exception) {
18 | ApiResponse apiResponse = new ApiResponse();
19 | apiResponse.setError("USER_ALREADY_EXIST");
20 | apiResponse.setMessage(exception.getMessage());
21 |
22 | return new ResponseEntity<>(apiResponse, HttpStatus.BAD_REQUEST);
23 | }
24 |
25 | @ExceptionHandler(UserDoNotExistException.class)
26 | public ResponseEntity userDoNotExist(UserDoNotExistException exception) {
27 | ApiResponse apiResponse = new ApiResponse();
28 | apiResponse.setError("USER_D0_NOT_EXIST");
29 | apiResponse.setMessage(exception.getMessage());
30 |
31 | return new ResponseEntity<>(apiResponse, HttpStatus.NOT_FOUND);
32 | }
33 |
34 | @ExceptionHandler(MethodArgumentNotValidException.class)
35 | public ResponseEntity