├── 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 | ![ecommerceFlowDiagram](https://github.com/GyalbuSherpa5/ecommerceMicroService/assets/80906287/3ab5df17-245c-4bb6-bc27-07fb9672571a) 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 | 9 | 10 | 14 | 15 | 19 | 20 | 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 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> handleInvalidArgument(MethodArgumentNotValidException ex) { 36 | Map errorMap = new HashMap<>(); 37 | ex.getBindingResult().getFieldErrors().forEach(error -> 38 | errorMap.put(error.getField(), error.getDefaultMessage())); 39 | return ResponseEntity.badRequest().body(errorMap); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /postman_apis/ecommerce_payment_mock.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "99aef8b8-1845-496e-a612-d8d03b56ae66", 4 | "name": "ecommerce_payment_mock", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", 6 | "_exporter_id": "27538277" 7 | }, 8 | "item": [ 9 | { 10 | "name": "makePayment", 11 | "request": { 12 | "method": "POST", 13 | "header": [], 14 | "body": { 15 | "mode": "raw", 16 | "raw": "" 17 | }, 18 | "url": { 19 | "raw": "{{url}}/makePayment", 20 | "host": [ 21 | "{{url}}" 22 | ], 23 | "path": [ 24 | "makePayment" 25 | ] 26 | } 27 | }, 28 | "response": [ 29 | { 30 | "name": "Default", 31 | "originalRequest": { 32 | "method": "POST", 33 | "header": [ 34 | { 35 | "key": "Content-Type", 36 | "name": "Content-Type", 37 | "value": "application/json", 38 | "type": "text" 39 | } 40 | ], 41 | "body": { 42 | "mode": "raw", 43 | "raw": "{\n \"amount\":1000\n}", 44 | "options": { 45 | "raw": { 46 | "language": "json" 47 | } 48 | } 49 | }, 50 | "url": { 51 | "raw": "{{url}}/makePayment", 52 | "host": [ 53 | "{{url}}" 54 | ], 55 | "path": [ 56 | "makePayment" 57 | ] 58 | } 59 | }, 60 | "code": 201, 61 | "_postman_previewlanguage": "json", 62 | "header": [ 63 | { 64 | "key": "Content-Type", 65 | "value": "application/json", 66 | "name": "Content-Type", 67 | "description": "", 68 | "type": "text" 69 | } 70 | ], 71 | "cookie": [], 72 | "body": "{\n \"amount\": 1000,\n \"transaction_code\": \"53d\",\n \"unique_id\": \"te\",\n \"status\": \"success\"\n}" 73 | } 74 | ] 75 | } 76 | ], 77 | "variable": [ 78 | { 79 | "key": "url", 80 | "value": "https://acca33c3-19e4-40b1-8e64-a2b3050d451e.mock.pstmn.io" 81 | } 82 | ] 83 | } -------------------------------------------------------------------------------- /apiGatewayService/src/main/java/com/don/apigatewayservice/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.don.apigatewayservice.exception; 2 | 3 | import com.don.apigatewayservice.dto.ApiResponse; 4 | import org.springframework.boot.web.reactive.error.ErrorAttributes; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.ControllerAdvice; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.reactive.function.BodyInserters; 10 | import org.springframework.web.reactive.function.server.ServerResponse; 11 | import org.springframework.web.server.ServerWebExchange; 12 | import reactor.core.publisher.Mono; 13 | 14 | @ControllerAdvice 15 | public class GlobalExceptionHandler { 16 | 17 | @ExceptionHandler(MustLoginException.class) 18 | public Mono handleMustLoginException(ServerWebExchange exchange, MustLoginException exception) { 19 | exchange.getAttributes().putIfAbsent(ErrorAttributes.ERROR_ATTRIBUTE, exception); 20 | 21 | ApiResponse apiResponse = new ApiResponse(); 22 | apiResponse.setError("PLEASE_LOG_IN"); 23 | apiResponse.setMessage(exception.getReason()); 24 | 25 | return ServerResponse.status(HttpStatus.UNAUTHORIZED) 26 | .contentType(MediaType.APPLICATION_JSON) 27 | .body(BodyInserters.fromValue(apiResponse)); 28 | } 29 | 30 | @ExceptionHandler(RoleNotMatchedException.class) 31 | public Mono roleNotMatch(ServerWebExchange exchange, RoleNotMatchedException exception) { 32 | exchange.getAttributes().putIfAbsent(ErrorAttributes.ERROR_ATTRIBUTE, exception); 33 | 34 | ApiResponse apiResponse = new ApiResponse(); 35 | apiResponse.setError("ROLE_MUST_BE_ADMIN"); 36 | apiResponse.setMessage(exception.getReason()); 37 | 38 | return ServerResponse.status(HttpStatus.FORBIDDEN) 39 | .contentType(MediaType.APPLICATION_JSON) 40 | .body(BodyInserters.fromValue(apiResponse)); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_order_service_cart.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_order_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `cart` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `cart`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `cart` ( 26 | `cart_id` bigint NOT NULL AUTO_INCREMENT, 27 | `name` varchar(255) DEFAULT NULL, 28 | `user_id` bigint DEFAULT NULL, 29 | PRIMARY KEY (`cart_id`) 30 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 31 | /*!40101 SET character_set_client = @saved_cs_client */; 32 | 33 | -- 34 | -- Dumping data for table `cart` 35 | -- 36 | 37 | LOCK TABLES `cart` WRITE; 38 | /*!40000 ALTER TABLE `cart` DISABLE KEYS */; 39 | INSERT INTO `cart` VALUES (1,'don',1),(2,'admin',3),(3,'hero',2); 40 | /*!40000 ALTER TABLE `cart` ENABLE KEYS */; 41 | UNLOCK TABLES; 42 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 43 | 44 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 45 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 46 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 47 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 48 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 49 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 50 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 51 | 52 | -- Dump completed on 2023-06-06 10:22:00 53 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_product_service_product_category.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_product_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `product_category` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `product_category`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `product_category` ( 26 | `category_id` bigint NOT NULL AUTO_INCREMENT, 27 | `category_name` varchar(255) DEFAULT NULL, 28 | `description` varchar(255) DEFAULT NULL, 29 | PRIMARY KEY (`category_id`) 30 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 31 | /*!40101 SET character_set_client = @saved_cs_client */; 32 | 33 | -- 34 | -- Dumping data for table `product_category` 35 | -- 36 | 37 | LOCK TABLES `product_category` WRITE; 38 | /*!40000 ALTER TABLE `product_category` DISABLE KEYS */; 39 | INSERT INTO `product_category` VALUES (1,'fruit','Fruit is healthy'),(3,'dairy','Dairy is gutuka drink'); 40 | /*!40000 ALTER TABLE `product_category` ENABLE KEYS */; 41 | UNLOCK TABLES; 42 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 43 | 44 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 45 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 46 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 47 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 48 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 49 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 50 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 51 | 52 | -- Dump completed on 2023-06-06 10:22:00 53 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 61 | 62 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_order_service_cart_item.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_order_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `cart_item` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `cart_item`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `cart_item` ( 26 | `cart_item_id` bigint NOT NULL AUTO_INCREMENT, 27 | `ordered_quantity` double NOT NULL, 28 | `product_name` varchar(255) DEFAULT NULL, 29 | `cart_id` bigint DEFAULT NULL, 30 | PRIMARY KEY (`cart_item_id`), 31 | KEY `FK1uobyhgl1wvgt1jpccia8xxs3` (`cart_id`), 32 | CONSTRAINT `FK1uobyhgl1wvgt1jpccia8xxs3` FOREIGN KEY (`cart_id`) REFERENCES `cart` (`cart_id`) 33 | ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 34 | /*!40101 SET character_set_client = @saved_cs_client */; 35 | 36 | -- 37 | -- Dumping data for table `cart_item` 38 | -- 39 | 40 | LOCK TABLES `cart_item` WRITE; 41 | /*!40000 ALTER TABLE `cart_item` DISABLE KEYS */; 42 | INSERT INTO `cart_item` VALUES (1,0,'mango',1),(2,0,'ghee',1),(3,3,'milk',1),(4,3,'milk',2),(5,3,'milk',2),(6,3,'cake',2),(7,3,'cake',3); 43 | /*!40000 ALTER TABLE `cart_item` ENABLE KEYS */; 44 | UNLOCK TABLES; 45 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 46 | 47 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 48 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 49 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 50 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 51 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 52 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 53 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 54 | 55 | -- Dump completed on 2023-06-06 10:22:00 56 | -------------------------------------------------------------------------------- /userService/src/main/java/com/don/userservice/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.don.userservice.config; 2 | 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.authentication.AuthenticationManager; 7 | import org.springframework.security.authentication.AuthenticationProvider; 8 | import org.springframework.security.authentication.dao.DaoAuthenticationProvider; 9 | import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; 10 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 11 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 12 | import org.springframework.security.crypto.password.PasswordEncoder; 13 | import org.springframework.security.web.SecurityFilterChain; 14 | 15 | @Configuration 16 | @RequiredArgsConstructor 17 | public class SecurityConfig { 18 | 19 | private final CustomUserDetailsService userDetailsService; 20 | 21 | @Bean 22 | public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { 23 | return http.csrf().disable() 24 | .authorizeHttpRequests() 25 | .requestMatchers( 26 | "/users/register", 27 | "/users/login", 28 | "/users/validate", 29 | "/users/getUserId/**", 30 | "/users/getUserByName/**", 31 | "/users/getAllUser", 32 | "/users/deleteUser/**", 33 | "/users/refreshToken") 34 | .permitAll() 35 | .anyRequest().authenticated() 36 | .and() 37 | .userDetailsService(userDetailsService) 38 | .httpBasic().and().formLogin() 39 | .and().build(); 40 | } 41 | 42 | @Bean 43 | public PasswordEncoder passwordEncoder() { 44 | return new BCryptPasswordEncoder(); 45 | } 46 | 47 | @Bean 48 | public AuthenticationManager authenticationManager(AuthenticationConfiguration config) throws Exception { 49 | return config.getAuthenticationManager(); 50 | } 51 | 52 | @Bean 53 | public AuthenticationProvider authenticationProvider(){ 54 | DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); 55 | authenticationProvider.setUserDetailsService(userDetailsService); 56 | authenticationProvider.setPasswordEncoder(passwordEncoder()); 57 | return authenticationProvider; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /apiGatewayService/src/main/java/com/don/apigatewayservice/filter/AuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package com.don.apigatewayservice.filter; 2 | 3 | import com.don.apigatewayservice.exception.MustLoginException; 4 | import com.don.apigatewayservice.exception.RoleNotMatchedException; 5 | import com.don.apigatewayservice.util.JwtUtil; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.cloud.gateway.filter.GatewayFilter; 8 | import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; 9 | import org.springframework.http.HttpHeaders; 10 | import org.springframework.http.HttpStatus; 11 | import org.springframework.stereotype.Component; 12 | 13 | @Component 14 | @Slf4j 15 | public class AuthenticationFilter extends AbstractGatewayFilterFactory { 16 | private final RouteValidator validator; 17 | private final JwtUtil jwtUtil; 18 | 19 | public AuthenticationFilter(RouteValidator validator, JwtUtil jwtUtil) { 20 | super(Config.class); 21 | this.validator = validator; 22 | this.jwtUtil = jwtUtil; 23 | } 24 | 25 | @Override 26 | public GatewayFilter apply(Config config) { 27 | return (exchange, chain) -> { 28 | if (validator.isSecured.test(exchange.getRequest())) { 29 | HttpHeaders headers = exchange.getRequest().getHeaders(); 30 | if (!headers.containsKey(HttpHeaders.AUTHORIZATION)) { 31 | log.error("Sign in required to access"); 32 | throw new MustLoginException(HttpStatus.UNAUTHORIZED, "Sign in required"); 33 | } 34 | 35 | String authHeader = headers.getFirst(HttpHeaders.AUTHORIZATION); 36 | if (authHeader != null && authHeader.startsWith("Bearer ")) { 37 | authHeader = authHeader.substring(7); 38 | } 39 | 40 | jwtUtil.validateToken(authHeader); 41 | String role = jwtUtil.extractUserRole(authHeader); 42 | 43 | if (validator.isAdminAccess.test(exchange.getRequest())) { 44 | if (role.equals("ROLE_admin")) { 45 | log.info("User with " + role + " accessing the endpoint"); 46 | } else { 47 | log.error("User does not have access to admin endpoint. Unauthorized access to the endpoint"); 48 | throw new RoleNotMatchedException(HttpStatus.FORBIDDEN, "Only admin can access"); 49 | } 50 | } else { 51 | log.info("User with " + role + " accessing the endpoint"); 52 | } 53 | } 54 | return chain.filter(exchange); 55 | }; 56 | } 57 | 58 | public static class Config { 59 | 60 | } 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_order_service_order_detail.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_order_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `order_detail` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `order_detail`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `order_detail` ( 26 | `order_id` bigint NOT NULL AUTO_INCREMENT, 27 | `order_status` varchar(255) DEFAULT NULL, 28 | `ordered_date` date DEFAULT NULL, 29 | `total_payment` double NOT NULL, 30 | `user_id` bigint DEFAULT NULL, 31 | `payment_method` varchar(255) DEFAULT NULL, 32 | PRIMARY KEY (`order_id`) 33 | ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 34 | /*!40101 SET character_set_client = @saved_cs_client */; 35 | 36 | -- 37 | -- Dumping data for table `order_detail` 38 | -- 39 | 40 | LOCK TABLES `order_detail` WRITE; 41 | /*!40000 ALTER TABLE `order_detail` DISABLE KEYS */; 42 | INSERT INTO `order_detail` VALUES (1,'PROCESSING','2023-06-05',450,2,NULL),(2,'PROCESSING','2023-06-05',300,1,NULL),(3,'PROCESSING','2023-06-06',450,2,NULL),(4,'PROCESSING','2023-06-06',450,2,NULL),(5,'PROCESSING','2023-06-06',450,2,'esewa'),(6,'PROCESSING','2023-06-06',450,2,'esewa'),(7,'PROCESSING','2023-06-06',450,2,'esewa'),(8,'PROCESSING','2023-06-06',450,2,'esewa'),(9,'PROCESSING','2023-06-06',450,2,'esewa'); 43 | /*!40000 ALTER TABLE `order_detail` ENABLE KEYS */; 44 | UNLOCK TABLES; 45 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 46 | 47 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 48 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 49 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 50 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 51 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 52 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 53 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 54 | 55 | -- Dump completed on 2023-06-06 10:22:00 56 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_user_service_user_credential.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_user_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `user_credential` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `user_credential`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `user_credential` ( 26 | `user_id` bigint NOT NULL AUTO_INCREMENT, 27 | `email` varchar(255) DEFAULT NULL, 28 | `password` varchar(255) DEFAULT NULL, 29 | `role` varchar(255) DEFAULT NULL, 30 | `user_name` varchar(255) DEFAULT NULL, 31 | PRIMARY KEY (`user_id`) 32 | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 33 | /*!40101 SET character_set_client = @saved_cs_client */; 34 | 35 | -- 36 | -- Dumping data for table `user_credential` 37 | -- 38 | 39 | LOCK TABLES `user_credential` WRITE; 40 | /*!40000 ALTER TABLE `user_credential` DISABLE KEYS */; 41 | INSERT INTO `user_credential` VALUES (1,'don@gmail.com','$2a$10$YHjm6gAsSwoSsrGmLctk7u7rKpkr2XMKGokMiFYnoNeeTzMEdkQpa','ROLE_user','don'),(2,'hero@gmail.com','$2a$10$xBHrUDmQHx2DBLGGXMlS8OaUreOM4oWF6yKguF.mUZPuYI09IYk1a','ROLE_user','hero'),(3,'admin@gmail.com','$2a$12$zMpGQvbGgjUIJATuG6Ju0.5TPsvglOvz5Dtr8GIaM9wkignNXIZcO','ROLE_admin','admin'),(4,'gunda@gmail.com','$2a$10$8YEZjZJoezHIImJegdCrdO5DR03GnP5TIKvvf/.fdQO8DKyiN31Ma','ROLE_USER','gunda'); 42 | /*!40000 ALTER TABLE `user_credential` ENABLE KEYS */; 43 | UNLOCK TABLES; 44 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 45 | 46 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 47 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 48 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 49 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 50 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 51 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 52 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 53 | 54 | -- Dump completed on 2023-06-06 10:22:00 55 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_product_service_product.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_product_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `product` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `product`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `product` ( 26 | `product_id` bigint NOT NULL AUTO_INCREMENT, 27 | `availability` varchar(255) DEFAULT NULL, 28 | `description` varchar(255) DEFAULT NULL, 29 | `price` double NOT NULL, 30 | `product_name` varchar(255) DEFAULT NULL, 31 | `stock_quantity` double NOT NULL, 32 | `category_id` bigint DEFAULT NULL, 33 | PRIMARY KEY (`product_id`), 34 | KEY `FK5cypb0k23bovo3rn1a5jqs6j4` (`category_id`), 35 | CONSTRAINT `FK5cypb0k23bovo3rn1a5jqs6j4` FOREIGN KEY (`category_id`) REFERENCES `product_category` (`category_id`) 36 | ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 37 | /*!40101 SET character_set_client = @saved_cs_client */; 38 | 39 | -- 40 | -- Dumping data for table `product` 41 | -- 42 | 43 | LOCK TABLES `product` WRITE; 44 | /*!40000 ALTER TABLE `product` DISABLE KEYS */; 45 | INSERT INTO `product` VALUES (1,'AVAILABLE','raseley aam',20,'mango',10,1),(5,'AVAILABLE','drink milk = good',100,'milk',10,3),(6,'AVAILABLE','butter = good',150,'butter',10,3),(7,'AVAILABLE','butter = good',150,'cheese',10,3),(8,'AVAILABLE','butter = good',150,'ghee',10,3),(9,'AVAILABLE','yogurt = good',150,'yogurt',5,3),(10,'AVAILABLE','yogurt = good',150,'cake',5,3); 46 | /*!40000 ALTER TABLE `product` ENABLE KEYS */; 47 | UNLOCK TABLES; 48 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 49 | 50 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 51 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 52 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 53 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 54 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 55 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 56 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 57 | 58 | -- Dump completed on 2023-06-06 10:22:00 59 | -------------------------------------------------------------------------------- /postman_apis/sql_database_file/ecommerce_sql/ecommerce_order_service_address.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 8.0.33, for Linux (x86_64) 2 | -- 3 | -- Host: localhost Database: ecommerce_order_service 4 | -- ------------------------------------------------------ 5 | -- Server version 8.0.33-0ubuntu0.22.04.2 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!50503 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `address` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `address`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!50503 SET character_set_client = utf8mb4 */; 25 | CREATE TABLE `address` ( 26 | `address_id` bigint NOT NULL AUTO_INCREMENT, 27 | `area` varchar(255) DEFAULT NULL, 28 | `city` varchar(255) DEFAULT NULL, 29 | `customer_name` varchar(255) DEFAULT NULL, 30 | `provinces` varchar(255) DEFAULT NULL, 31 | `order_id` bigint DEFAULT NULL, 32 | PRIMARY KEY (`address_id`), 33 | KEY `FK9i35q68ennwhbt1rplbixx4nu` (`order_id`), 34 | CONSTRAINT `FK9i35q68ennwhbt1rplbixx4nu` FOREIGN KEY (`order_id`) REFERENCES `order_detail` (`order_id`) 35 | ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 36 | /*!40101 SET character_set_client = @saved_cs_client */; 37 | 38 | -- 39 | -- Dumping data for table `address` 40 | -- 41 | 42 | LOCK TABLES `address` WRITE; 43 | /*!40000 ALTER TABLE `address` DISABLE KEYS */; 44 | INSERT INTO `address` VALUES (1,'sundarijal','kathmandu','don ho ma','bagmati',1),(2,'andrapur','dang','hero ho ma','gandaki',2),(3,'andrapur','pokhaara','hero ho ma','pokhara',3),(4,'andrapur','pokhaara','hero ho ma','pokhara',4),(5,'andrapur','pokhaara','hero ho ma','pokhara',5),(6,'andrapur','pokhaara','hero ho ma','pokhara',6),(7,'andrapur','pokhaara','hero ho ma','pokhara',7),(8,'andrapur','pokhaara','hero ho ma','pokhara',8),(9,'andrapur','pokhaara','hero ho ma','pokhara',9); 45 | /*!40000 ALTER TABLE `address` ENABLE KEYS */; 46 | UNLOCK TABLES; 47 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 48 | 49 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 50 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 51 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 52 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 53 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 54 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 55 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 56 | 57 | -- Dump completed on 2023-06-06 10:22:00 58 | -------------------------------------------------------------------------------- /mailService/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /orderService/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /userService/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /apiGatewayService/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /discoveryService/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /productService/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /productService/src/main/java/com/don/productservice/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.don.productservice.controller; 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 com.don.productservice.service.ProductService; 8 | import lombok.RequiredArgsConstructor; 9 | import org.springframework.beans.factory.annotation.Value; 10 | import org.springframework.web.bind.annotation.*; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import java.io.IOException; 14 | import java.util.List; 15 | 16 | @RestController 17 | @RequiredArgsConstructor 18 | @RequestMapping("/products") 19 | public class ProductController { 20 | 21 | private final ProductService productService; 22 | 23 | @Value(("${project.image}")) 24 | private String path; 25 | 26 | @GetMapping("/getAllProducts") 27 | public List getAll() { 28 | return productService.getAll(); 29 | } 30 | 31 | 32 | @PostMapping("/addProduct") 33 | public String addProduct( 34 | @RequestPart Product product, 35 | @RequestPart List images 36 | ) throws IOException { 37 | productService.saveProducts(product,path,images); 38 | return "product added successfully"; 39 | } 40 | 41 | @GetMapping("/getByAttribute/{offSet}/{pageSize}/{productAttribute}") 42 | public List getAllProductsByName( 43 | @PathVariable int offSet, // page number [starts from 0] 44 | @PathVariable int pageSize, // total element per page [starts from 1] 45 | @PathVariable String productAttribute) { 46 | 47 | return productService.getAllProductByName(offSet, pageSize, productAttribute); 48 | } 49 | 50 | @GetMapping("/getByCategoryName/{name}") 51 | public ProductCategoryResponse getAllProductByCategory(@PathVariable String name) { 52 | return productService.getProductByCategory(name); 53 | } 54 | 55 | @GetMapping("/getById/{id}") 56 | public ProductResponse getProductById(@PathVariable Long id) { 57 | return productService.getProductById(id); 58 | } 59 | 60 | @GetMapping("/getProductByName/{name}") 61 | public ProductResponse getProductByName(@PathVariable String name) { 62 | return productService.getProductByName(name); 63 | } 64 | 65 | @DeleteMapping("/deleteProduct/{id}") 66 | public String deleteProduct(@PathVariable Long id) { 67 | productService.deleteProduct(id); 68 | return "product with id " + id + " deleted successfully"; 69 | } 70 | @PostMapping("/specification") 71 | public List getProductBySpecification(@RequestBody RequestDto requestDto){ 72 | return productService.getBySpecification(requestDto); 73 | } 74 | 75 | @PutMapping("/updateProductStock/{productName}/{quantity}") 76 | public String updateProductStock(@PathVariable String productName, @PathVariable double quantity){ 77 | productService.updateStock(productName,quantity); 78 | return "updated successfully"; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /productService/src/main/java/com/don/productservice/service/FilterSpecification.java: -------------------------------------------------------------------------------- 1 | package com.don.productservice.service; 2 | 3 | import com.don.productservice.dto.specification.SearchRequestDto; 4 | import com.don.productservice.eunm.GlobalOperator; 5 | import jakarta.persistence.criteria.Predicate; 6 | import org.springframework.data.jpa.domain.Specification; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Arrays; 11 | import java.util.List; 12 | 13 | @Service 14 | public class FilterSpecification { 15 | public Specification getSearchSpecification(SearchRequestDto searchRequestDto) { 16 | return (root, query, criteriaBuilder) -> 17 | criteriaBuilder.equal(root.get(searchRequestDto.getColumn()), searchRequestDto.getValue()); 18 | } 19 | 20 | public Specification getSearchSpecification( 21 | List searchRequestDto, 22 | GlobalOperator globalOperator) { 23 | return (root, query, criteriaBuilder) -> 24 | { 25 | List predicates = new ArrayList<>(); 26 | 27 | for (SearchRequestDto requestDto : searchRequestDto) { 28 | 29 | switch (requestDto.getOperation()) { 30 | case EQUAL -> { 31 | Predicate equal = criteriaBuilder.equal(root.get(requestDto.getColumn()), requestDto.getValue()); 32 | predicates.add(equal); 33 | } 34 | case LIKE -> { 35 | Predicate like = criteriaBuilder.like(root.get(requestDto.getColumn()), "%" + requestDto.getValue() + "%"); 36 | predicates.add(like); 37 | } 38 | case IN -> { 39 | String[] spilt = requestDto.getValue().split(","); 40 | Predicate in = root.get(requestDto.getColumn()).in(Arrays.asList(spilt)); 41 | predicates.add(in); 42 | } 43 | case GREATER_THAN -> { 44 | Predicate greaterThan = criteriaBuilder.greaterThan(root.get(requestDto.getColumn()), requestDto.getValue()); 45 | predicates.add(greaterThan); 46 | } 47 | case LESS_THAN -> { 48 | Predicate lessThan = criteriaBuilder.lessThan(root.get(requestDto.getColumn()), requestDto.getValue()); 49 | predicates.add(lessThan); 50 | } 51 | case BETWEEN -> { 52 | //"10, 20" 53 | String[] split1 = requestDto.getValue().split(","); 54 | Predicate between = criteriaBuilder.between(root.get(requestDto.getColumn()), Double.parseDouble(split1[0]), Double.parseDouble(split1[1])); 55 | predicates.add(between); 56 | } 57 | default -> throw new IllegalStateException("Unexpected value "); 58 | } 59 | } 60 | 61 | if (globalOperator.equals(GlobalOperator.AND)) { 62 | return criteriaBuilder.and(predicates.toArray(new Predicate[0])); 63 | } else { 64 | return criteriaBuilder.or(predicates.toArray(new Predicate[0])); 65 | } 66 | }; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /orderService/src/main/java/com/don/orderservice/service/CartServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.don.orderservice.service; 2 | 3 | import com.don.orderservice.dto.CartItemResponse; 4 | import com.don.orderservice.dto.CartResponse; 5 | import com.don.orderservice.dto.ProductResponse; 6 | import com.don.orderservice.feignClient.ProductService; 7 | import com.don.orderservice.feignClient.UserService; 8 | import com.don.orderservice.model.Cart; 9 | import com.don.orderservice.model.CartItem; 10 | import com.don.orderservice.repository.CartItemRepository; 11 | import com.don.orderservice.repository.CartRepository; 12 | import lombok.RequiredArgsConstructor; 13 | import lombok.extern.slf4j.Slf4j; 14 | import org.springframework.stereotype.Service; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import java.util.Optional; 19 | 20 | @Service 21 | @RequiredArgsConstructor 22 | @Slf4j 23 | public class CartServiceImpl implements CartService { 24 | 25 | private final CartRepository cartRepository; 26 | private final CartItemRepository cartItemRepository; 27 | private final UserService userService; 28 | private final ProductService productService; 29 | 30 | @Override 31 | public void saveToCart(CartItem cartItem, String username) { 32 | ProductResponse productByName = productService.getProductByName(cartItem.getProductName()); 33 | if (productByName != null) { 34 | log.info("saving products to cart"); 35 | } 36 | 37 | Optional userCart = cartRepository.findByName(username); 38 | 39 | Cart cart; 40 | if (userCart.isPresent()) { 41 | cart = userCart.get(); 42 | } else { 43 | cart = new Cart(); 44 | cart.setName(username); 45 | } 46 | 47 | cart.setUserId(userService.getUserId(username)); 48 | 49 | CartItem cartItemToSave = new CartItem(); 50 | cartItemToSave.setProductName(cartItem.getProductName()); 51 | if (productByName != null && productByName.getStockQuantity() > cartItem.getOrderedQuantity()) { 52 | cartItemToSave.setOrderedQuantity(cartItem.getOrderedQuantity()); 53 | } 54 | cartItemToSave.setCart(cart); 55 | 56 | cartItemRepository.save(cartItemToSave); 57 | } 58 | 59 | @Override 60 | public CartResponse getMyCart(String username) { 61 | Optional userCart = cartRepository.findByName(username); 62 | CartResponse cartResponse = new CartResponse(); 63 | 64 | if (userCart.isPresent()) { 65 | Cart cart = userCart.get(); 66 | cartResponse.setName(cart.getName()); 67 | 68 | List cartItemResponses = new ArrayList<>(); 69 | 70 | for (CartItem cartItem : cart.getCartItems()) { 71 | String productName = cartItem.getProductName(); 72 | ProductResponse productResponse = productService.getProductByName(productName); 73 | double orderedQuantity = cartItem.getOrderedQuantity(); 74 | 75 | CartItemResponse cartItemResponse = new CartItemResponse(); 76 | cartItemResponse.setOrderedQuantity(orderedQuantity); 77 | cartItemResponse.setProductName(productName); 78 | cartItemResponse.setProductDescription(productResponse.getDescription()); 79 | cartItemResponse.setPrice(productResponse.getPrice()); 80 | 81 | cartItemResponses.add(cartItemResponse); 82 | } 83 | 84 | cartResponse.setCartItemResponses(cartItemResponses); 85 | } 86 | 87 | return cartResponse; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /userService/src/main/java/com/don/userservice/controller/UserCredentialController.java: -------------------------------------------------------------------------------- 1 | package com.don.userservice.controller; 2 | 3 | import com.don.userservice.dto.JwtRequest; 4 | import com.don.userservice.dto.JwtResponse; 5 | import com.don.userservice.dto.UserLogin; 6 | import com.don.userservice.dto.UserResponse; 7 | import com.don.userservice.model.RefreshToken; 8 | import com.don.userservice.model.UserCredential; 9 | import com.don.userservice.service.RefreshTokenService; 10 | import com.don.userservice.service.UserCredentialService; 11 | import com.don.userservice.service.UserCredentialServiceImpl; 12 | import jakarta.validation.Valid; 13 | import lombok.RequiredArgsConstructor; 14 | import org.springframework.security.authentication.AuthenticationManager; 15 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 16 | import org.springframework.security.core.Authentication; 17 | import org.springframework.web.bind.annotation.*; 18 | 19 | import java.util.List; 20 | 21 | @RestController 22 | @RequiredArgsConstructor 23 | @RequestMapping("/users") 24 | public class UserCredentialController { 25 | private final UserCredentialService userCredentialService; 26 | private final UserCredentialServiceImpl userCredentialServiceImpl; 27 | private final AuthenticationManager authenticationManager; 28 | private final RefreshTokenService refreshTokenService; 29 | 30 | @PostMapping("/register") 31 | public String saveUser(@RequestBody @Valid UserCredential userCredential) { 32 | userCredentialService.saveUser(userCredential); 33 | return "User saved successfully"; 34 | } 35 | 36 | @PutMapping("/update/{userId}") 37 | public String updateUser(@RequestBody @Valid UserCredential userCredential, @PathVariable Long userId) { 38 | userCredentialService.updateUser(userCredential, userId); 39 | return "User updated successfully"; 40 | } 41 | 42 | @PostMapping("/login") 43 | public JwtResponse getToken(@RequestBody UserLogin userLogin) { 44 | Authentication authenticate = authenticationManager.authenticate( 45 | new UsernamePasswordAuthenticationToken( 46 | userLogin.getUserName(), 47 | userLogin.getPassword() 48 | ) 49 | ); 50 | 51 | if (authenticate.isAuthenticated()) { 52 | RefreshToken refreshToken = refreshTokenService.createRefreshToken(userLogin.getUserName()); 53 | return JwtResponse.builder() 54 | .accessToken(userCredentialServiceImpl.generateToken(userLogin.getUserName())) 55 | .token(refreshToken.getToken()) 56 | .build(); 57 | } else { 58 | throw new RuntimeException("Invalid Access"); 59 | } 60 | } 61 | 62 | @PostMapping("/refreshToken") 63 | public JwtResponse refreshToken(@RequestBody JwtRequest jwtRequest){ 64 | return refreshTokenService 65 | .findByToken(jwtRequest.getToken()) 66 | .map(refreshTokenService::verifyExpiration) 67 | .map(RefreshToken::getUserCredential) 68 | .map(userCredential -> { 69 | String accessToken = userCredentialServiceImpl 70 | .generateToken(userCredential.getUserName()); 71 | return JwtResponse.builder() 72 | .accessToken(accessToken) 73 | .token(jwtRequest.getToken()) 74 | .build(); 75 | }).orElseThrow( 76 | () -> new RuntimeException("Refresh token not found") 77 | ); 78 | } 79 | 80 | @GetMapping("/validate") 81 | public String validateToken(@RequestParam("token") String token) { 82 | userCredentialServiceImpl.validateToken(token); 83 | return "Token is valid"; 84 | } 85 | 86 | @GetMapping("/getUserId/{userName}") 87 | public Long getUserId(@PathVariable String userName) { 88 | return userCredentialService.getUserId(userName); 89 | } 90 | 91 | @DeleteMapping("/deleteUser/{userId}") 92 | public String deleteUser(@PathVariable Long userId) { 93 | userCredentialService.deleteUser(userId); 94 | return "user deleted successfully"; 95 | } 96 | 97 | @GetMapping("/getUserByName/{name}") 98 | public UserResponse getUserByName(@PathVariable String name) { 99 | return userCredentialService.getUserByName(name); 100 | } 101 | 102 | @GetMapping("/getAllUser") 103 | public List getAllUser() { 104 | return userCredentialService.getAllUser(); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /orderService/src/main/java/com/don/orderservice/service/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.don.orderservice.service; 2 | 3 | import com.don.orderservice.dto.CartItemResponse; 4 | import com.don.orderservice.dto.CartResponse; 5 | import com.don.orderservice.dto.order.OrderRequestDto; 6 | import com.don.orderservice.dto.order.OrderResponseDto; 7 | import com.don.orderservice.dto.order.PaymentRequestDto; 8 | import com.don.orderservice.dto.order.PaymentResponseDto; 9 | import com.don.orderservice.dto.user.UserResponse; 10 | import com.don.orderservice.enums.OrderStatus; 11 | import com.don.orderservice.feignClient.MailService; 12 | import com.don.orderservice.feignClient.PaymentService; 13 | import com.don.orderservice.feignClient.ProductService; 14 | import com.don.orderservice.feignClient.UserService; 15 | import com.don.orderservice.model.mail.Mail; 16 | import com.don.orderservice.model.order.Order; 17 | import com.don.orderservice.repository.OrderRepository; 18 | import com.don.orderservice.util.OrderTotalUtil; 19 | import lombok.RequiredArgsConstructor; 20 | import lombok.extern.slf4j.Slf4j; 21 | import org.springframework.stereotype.Service; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | @Service 27 | @Slf4j 28 | @RequiredArgsConstructor 29 | public class OrderServiceImpl implements OrderService { 30 | private final OrderRepository orderRepository; 31 | private final UserService userService; 32 | private final CartService cartService; 33 | private final OrderTotalUtil totalUtil; 34 | private final PaymentService paymentService; 35 | private final MailService mailService; 36 | private final ProductService productService; 37 | 38 | @Override 39 | public void placeOrder(OrderRequestDto order, String userName) { 40 | 41 | Order saveOrderToDatabase = new Order(); 42 | saveOrderToDatabase.setOrderStatus(OrderStatus.PROCESSING); 43 | saveOrderToDatabase.setAddress(order.getAddress()); 44 | saveOrderToDatabase.setUserId(userService.getUserId(userName)); 45 | 46 | CartResponse cartResponse = cartService.getMyCart(userName); 47 | saveOrderToDatabase.setTotalPayment(totalUtil.calculateTotal(cartResponse)); 48 | saveOrderToDatabase.setPaymentMethod(order.getPaymentMethod()); 49 | 50 | orderRepository.save(saveOrderToDatabase); 51 | log.info("order saved successfully"); 52 | 53 | PaymentRequestDto requestDto = new PaymentRequestDto(); 54 | requestDto.setAmount(saveOrderToDatabase.getTotalPayment()); 55 | PaymentResponseDto paymentResponseDto = paymentService.makePayment(requestDto); 56 | log.info(paymentResponseDto.getTransaction_code()); 57 | 58 | Mail mail = new Mail(); 59 | UserResponse user = userService.getUserByName(userName); 60 | mail.setTo(user.getEmail()); 61 | mail.setSubject("Order placed"); 62 | mail.setBody("Thank you for your order"); 63 | mailService.sendEmail(mail); 64 | log.info("mail send successfully"); 65 | 66 | List cartItemResponses = cartResponse.getCartItemResponses(); 67 | for (CartItemResponse cartItemResponse : cartItemResponses) { 68 | double orderedQuantity = cartItemResponse.getOrderedQuantity(); 69 | String productName = cartItemResponse.getProductName(); 70 | 71 | 72 | productService.updateProductStock(productName,orderedQuantity); 73 | 74 | } 75 | 76 | 77 | //TODO: create new service PaymentServiceCaller 78 | //TODO: call the server using restTemplate 79 | //TODO: get payment url,username,password from prop file 80 | //TODO; url baseUrl -> from property, endpoint code 81 | } 82 | 83 | @Override 84 | public List getMyOrder(String userName) { 85 | 86 | log.info("fetching orders"); 87 | List orders = orderRepository.findByUserId( 88 | userService.getUserId(userName)); 89 | 90 | List orderResponse = new ArrayList<>(); 91 | for (Order order : orders) { 92 | OrderResponseDto responseDto = new OrderResponseDto(); 93 | responseDto.setOrderStatus(order.getOrderStatus()); 94 | responseDto.setAddress(order.getAddress()); 95 | responseDto.setOrderedDate(order.getOrderedDate()); 96 | responseDto.setUserId(order.getUserId()); 97 | responseDto.setTotalPayment(order.getTotalPayment()); 98 | responseDto.setCartResponse(cartService.getMyCart(userName)); 99 | responseDto.setPaymentMethod(order.getPaymentMethod()); 100 | 101 | orderResponse.add(responseDto); 102 | } 103 | return orderResponse; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /userService/src/main/java/com/don/userservice/service/UserCredentialServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.don.userservice.service; 2 | 3 | import com.don.userservice.dto.UserResponse; 4 | import com.don.userservice.enums.UserStatus; 5 | import com.don.userservice.exception.UserAlreadyExistException; 6 | import com.don.userservice.exception.UserDoNotExistException; 7 | import com.don.userservice.mapper.UserToResponseMapper; 8 | import com.don.userservice.model.UserCredential; 9 | import com.don.userservice.repository.UserCredentialRepository; 10 | import lombok.RequiredArgsConstructor; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.security.crypto.password.PasswordEncoder; 13 | import org.springframework.stereotype.Service; 14 | 15 | import java.util.List; 16 | import java.util.stream.Collectors; 17 | 18 | @Service 19 | @RequiredArgsConstructor 20 | @Slf4j 21 | public class UserCredentialServiceImpl implements UserCredentialService { 22 | 23 | private final UserCredentialRepository userCredentialRepository; 24 | private final UserToResponseMapper mapper; 25 | private final PasswordEncoder passwordEncoder; 26 | private final JwtService jwtService; 27 | 28 | @Override 29 | public void saveUser(UserCredential userCredential) { 30 | 31 | if (userCredentialRepository.findByUserName(userCredential.getUserName()).isPresent()) { 32 | log.error("user already exist in database"); 33 | throw new UserAlreadyExistException("This user already exist"); 34 | } 35 | 36 | userCredential.setPassword( 37 | passwordEncoder.encode(userCredential.getPassword()) 38 | ); 39 | userCredential.setRole("ROLE_USER"); 40 | userCredential.setStatus(UserStatus.ACTIVE); 41 | 42 | userCredentialRepository.save(userCredential); 43 | log.info("user saved successfully"); 44 | } 45 | 46 | @Override 47 | public Long getUserId(String userName) { 48 | log.info("Fetching user"); 49 | return userCredentialRepository.getUserId(userName) 50 | .orElseThrow(() -> { 51 | log.error("user does not exist"); 52 | return new UserDoNotExistException( 53 | "User with name " + userName + " do not exist"); 54 | } 55 | ); 56 | } 57 | @Override 58 | public void updateUser(UserCredential userCredential, Long userId) { 59 | UserCredential user = userCredentialRepository.findById(userId) 60 | .orElseThrow( 61 | () -> { 62 | log.error("user not found"); 63 | return new UserDoNotExistException("User does not exist"); 64 | } 65 | ); 66 | user.setUserId(userId); 67 | user.setUserName(userCredential.getUserName()); 68 | user.setEmail(userCredential.getEmail()); 69 | user.setPassword(passwordEncoder.encode(userCredential.getPassword())); 70 | 71 | userCredentialRepository.save(user); 72 | log.info("user updated successfully"); 73 | } 74 | 75 | @Override 76 | public void deleteUser(Long userId) { 77 | UserCredential user = userCredentialRepository.findById(userId) 78 | .orElseThrow( 79 | () -> { 80 | log.error("user not found"); 81 | return new UserDoNotExistException("User does not exist"); 82 | } 83 | ); 84 | 85 | user.setStatus(UserStatus.DELETED); 86 | userCredentialRepository.save(user); 87 | } 88 | 89 | @Override 90 | public UserResponse getUserByName(String name) { 91 | log.info("fetching user"); 92 | return userCredentialRepository.findByUserName(name) 93 | .map(mapper) 94 | .orElseThrow( 95 | () -> { 96 | log.error("user not found"); 97 | return new UserDoNotExistException("user does not exist"); 98 | } 99 | ); 100 | } 101 | 102 | @Override 103 | public List getAllUser() { 104 | return userCredentialRepository.findByStatus(UserStatus.ACTIVE) 105 | .stream() 106 | .map(mapper) 107 | .collect(Collectors.toList()); 108 | } 109 | 110 | public String generateToken(String userName) { 111 | log.info("generating token"); 112 | String role = userCredentialRepository.getUserRole(userName) 113 | .orElseThrow(() -> { 114 | log.error("user do not exist"); 115 | return new UserDoNotExistException( 116 | "User with name " + userName + " do not exist"); 117 | }); 118 | return jwtService.generateToken(userName, role); 119 | } 120 | 121 | public void validateToken(String token) { 122 | log.info("validating token"); 123 | jwtService.validateToken(token); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /productService/src/main/java/com/don/productservice/service/ProductServiceImpl.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.eunm.ProductStatus; 7 | import com.don.productservice.exception.ProductAlreadyExistException; 8 | import com.don.productservice.exception.ProductCategoryDoNotExistException; 9 | import com.don.productservice.exception.ProductDoNotExistException; 10 | import com.don.productservice.mapper.ProductCategoryResponseMapper; 11 | import com.don.productservice.mapper.ProductResponseMapper; 12 | import com.don.productservice.model.Image; 13 | import com.don.productservice.model.Product; 14 | import com.don.productservice.model.ProductCategory; 15 | import com.don.productservice.repository.ProductCategoryRepository; 16 | import com.don.productservice.repository.ProductRepository; 17 | import lombok.RequiredArgsConstructor; 18 | import lombok.extern.slf4j.Slf4j; 19 | import org.springframework.data.domain.Page; 20 | import org.springframework.data.domain.PageRequest; 21 | import org.springframework.data.domain.Sort; 22 | import org.springframework.data.jpa.domain.Specification; 23 | import org.springframework.stereotype.Service; 24 | import org.springframework.web.multipart.MultipartFile; 25 | 26 | import java.io.File; 27 | import java.io.IOException; 28 | import java.nio.file.Files; 29 | import java.nio.file.Paths; 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | import java.util.Optional; 33 | import java.util.stream.Collectors; 34 | 35 | @Service 36 | @RequiredArgsConstructor 37 | @Slf4j 38 | public class ProductServiceImpl implements ProductService { 39 | 40 | private final ProductRepository productRepository; 41 | private final ProductCategoryRepository categoryRepository; 42 | private final ProductResponseMapper productMapper; 43 | private final ProductCategoryResponseMapper categoryMapper; 44 | 45 | private final FilterSpecification productFilterSpecification; 46 | 47 | @Override 48 | public void saveProducts(Product product, String path, List images) throws IOException { 49 | 50 | // Checking if product category already exist in database 51 | Optional productCategory = 52 | categoryRepository.findByCategoryName(product.getCategory().getCategoryName().toLowerCase()); 53 | 54 | // If exist then will save into old category else makes new category 55 | ProductCategory saveProductCategoryToDatabase = productCategory 56 | .orElse(ProductCategory.builder() 57 | .categoryName(product.getCategory().getCategoryName().toLowerCase()) 58 | .description(product.getCategory().getDescription()) 59 | .build()); 60 | 61 | if (productRepository.findByProductName( 62 | product.getProductName()).isPresent()) { 63 | log.info("Unable to add duplicate product"); 64 | throw new ProductAlreadyExistException("This product already exist"); 65 | } else { 66 | 67 | String relativePath = path + "images/" + product.getProductName(); 68 | String absolutePath = System.getProperty("user.dir") + File.separator + relativePath; 69 | 70 | File filePath = new File(absolutePath); 71 | if (!filePath.exists()) { 72 | filePath.mkdirs(); 73 | } 74 | 75 | List imagesToSave = new ArrayList<>(); 76 | 77 | for (MultipartFile image : images) { 78 | Files.copy(image.getInputStream(), 79 | Paths.get(absolutePath, image.getOriginalFilename())); 80 | Image imageMultiPartToImage = new Image(); 81 | imageMultiPartToImage.setUrl(relativePath + File.separator + image.getOriginalFilename()); 82 | 83 | imagesToSave.add(imageMultiPartToImage); 84 | } 85 | 86 | Product saveProductInDatabase = Product.builder() 87 | .productName(product.getProductName().toLowerCase()) 88 | .description(product.getDescription()) 89 | .availability(ProductStatus.AVAILABLE) 90 | .images(imagesToSave) 91 | .price(product.getPrice()) 92 | .stockQuantity(product.getStockQuantity()) 93 | .category(saveProductCategoryToDatabase) 94 | .build(); 95 | 96 | productRepository.save(saveProductInDatabase); 97 | log.info("product successfully saved to database"); 98 | } 99 | } 100 | 101 | @Override 102 | public List getAllProductByName( 103 | int offSet, int pageSize, String productAttribute) { 104 | 105 | Page allProductsByName = productRepository.findAll( 106 | PageRequest.of(offSet, pageSize) 107 | .withSort(Sort.Direction.ASC, productAttribute)); 108 | 109 | log.info("Fetching all products by name"); 110 | return allProductsByName 111 | .stream() 112 | .map(productMapper) 113 | .collect(Collectors.toList()); 114 | } 115 | 116 | @Override 117 | public ProductResponse getProductById(Long id) { 118 | return productRepository.findById(id) 119 | .map(productMapper) 120 | .orElseThrow(() -> new ProductDoNotExistException( 121 | "Product with id " + id + " doesn't exist")); 122 | } 123 | 124 | @Override 125 | public void deleteProduct(Long id) { 126 | Product product = productRepository.findById(id) 127 | .orElseThrow(() -> new ProductDoNotExistException( 128 | "Product with id " + id + " doesn't exist")); 129 | 130 | product.setAvailability(ProductStatus.DELETED); 131 | productRepository.save(product); 132 | } 133 | 134 | @Override 135 | public ProductCategoryResponse getProductByCategory(String name) { 136 | return categoryRepository.findByCategoryName(name) 137 | .map(categoryMapper) 138 | .orElseThrow(() -> new ProductCategoryDoNotExistException( 139 | "Product with name " + name + " do not exist" 140 | )); 141 | } 142 | 143 | @Override 144 | public List getAll() { 145 | return productRepository.findAll() 146 | .stream() 147 | .map(productMapper) 148 | .collect(Collectors.toList()); 149 | } 150 | 151 | @Override 152 | public ProductResponse getProductByName(String name) { 153 | return productRepository.findByProductName(name) 154 | .map(productMapper) 155 | .orElseThrow(() -> { 156 | log.error("Error retrieving product by name: {}", name); 157 | return new ProductDoNotExistException("This product does not exist"); 158 | }); 159 | } 160 | 161 | @Override 162 | public List getBySpecification(RequestDto requestDto) { 163 | Specification searchSpecification = productFilterSpecification.getSearchSpecification( 164 | requestDto.getSearchRequestDto(), requestDto.getGlobalOperator()); 165 | return productRepository.findAll(searchSpecification) 166 | .stream() 167 | .map(productMapper) 168 | .collect(Collectors.toList()); 169 | } 170 | 171 | @Override 172 | public void updateStock(String productName, double quantity) { 173 | Product product = productRepository.findByProductName(productName) 174 | .orElseThrow(() -> { 175 | log.error("product not found"); 176 | return new ProductDoNotExistException("this product does not exist"); 177 | }); 178 | 179 | product.setStockQuantity(product.getStockQuantity() - quantity); 180 | productRepository.save(product); 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /productService/src/test/java/com/don/productservice/service/ProductServiceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.don.productservice.service; 2 | 3 | import com.don.productservice.dto.ProductResponse; 4 | import com.don.productservice.eunm.ProductStatus; 5 | import com.don.productservice.exception.ProductAlreadyExistException; 6 | import com.don.productservice.exception.ProductDoNotExistException; 7 | import com.don.productservice.mapper.ProductResponseMapper; 8 | import com.don.productservice.model.Image; 9 | import com.don.productservice.model.Product; 10 | import com.don.productservice.model.ProductCategory; 11 | import com.don.productservice.repository.ProductCategoryRepository; 12 | import com.don.productservice.repository.ProductRepository; 13 | import org.junit.jupiter.api.Test; 14 | import org.junit.jupiter.api.extension.ExtendWith; 15 | import org.mockito.InjectMocks; 16 | import org.mockito.Mock; 17 | import org.mockito.junit.jupiter.MockitoExtension; 18 | import org.springframework.mock.web.MockMultipartFile; 19 | import org.springframework.web.multipart.MultipartFile; 20 | 21 | import java.io.IOException; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import java.util.Optional; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | import static org.junit.jupiter.api.Assertions.assertThrows; 28 | import static org.mockito.Mockito.*; 29 | 30 | @ExtendWith(MockitoExtension.class) 31 | class ProductServiceImplTest { 32 | 33 | @Mock 34 | private ProductRepository productRepository; 35 | @Mock 36 | private ProductCategoryRepository categoryRepository; 37 | @Mock 38 | private ProductResponseMapper productResponseMapper; 39 | @InjectMocks 40 | private ProductServiceImpl productService; 41 | 42 | @Test 43 | void saveProducts_WhenProductDoesNotExist_ShouldSaveProductToDatabase() throws IOException { 44 | // Arrange 45 | String productName = "Test Product"; 46 | String categoryName = "Test Category"; 47 | String description = "Test Description"; 48 | double price = 10.0; 49 | int stockQuantity = 100; 50 | 51 | ProductCategory productCategory = ProductCategory.builder() 52 | .categoryName(categoryName) 53 | .description(description) 54 | .build(); 55 | 56 | Product product = new Product(); 57 | product.setProductName(productName); 58 | product.setDescription(description); 59 | product.setPrice(price); 60 | product.setStockQuantity(stockQuantity); 61 | product.setCategory(productCategory); // Assign the product category to the product 62 | 63 | List images = new ArrayList<>(); 64 | MockMultipartFile image1 = new MockMultipartFile("image", "image1.jpg", "image/jpeg", "data".getBytes()); 65 | images.add(image1); 66 | 67 | // Configure the mock categoryRepository 68 | when(categoryRepository.findByCategoryName(categoryName.toLowerCase())).thenReturn(Optional.ofNullable(productCategory)); 69 | when(categoryRepository.save(any(ProductCategory.class))).thenAnswer(invocation -> invocation.getArgument(0)); 70 | 71 | // Configure the mock productRepository 72 | when(productRepository.findByProductName(productName)).thenReturn(Optional.empty()); 73 | 74 | // Act 75 | productService.saveProducts(product, "path/to/images/", images); 76 | 77 | // Assert 78 | verify(categoryRepository, times(1)).findByCategoryName(categoryName.toLowerCase()); 79 | verify(categoryRepository, times(1)).save(any(ProductCategory.class)); 80 | verify(productRepository, times(1)).findByProductName(productName); 81 | verify(productRepository, times(1)).save(any(Product.class)); 82 | } 83 | 84 | 85 | 86 | @Test 87 | void saveProducts_WhenProductAlreadyExists_ShouldThrowProductAlreadyExistException(){ 88 | // Arrange 89 | String productName = "Existing Product"; 90 | String categoryName = "Test Category"; 91 | String description = "Test Description"; 92 | double price = 10.0; 93 | int stockQuantity = 100; 94 | 95 | Product product = new Product(); 96 | product.setProductName(productName); 97 | product.setDescription(description); 98 | product.setPrice(price); 99 | product.setStockQuantity(stockQuantity); 100 | 101 | ProductCategory productCategory = ProductCategory.builder() 102 | .categoryName(categoryName) 103 | .description(description) 104 | .build(); 105 | 106 | List images = new ArrayList<>(); 107 | MockMultipartFile image1 = new MockMultipartFile("image", "image1.jpg", "image/jpeg", "data".getBytes()); 108 | images.add(image1); 109 | 110 | // Configure the mock categoryRepository 111 | when(categoryRepository.findByCategoryName(categoryName.toLowerCase())).thenReturn(Optional.empty()); 112 | when(categoryRepository.save(any(ProductCategory.class))).thenReturn(productCategory); 113 | 114 | // Configure the mock productRepository 115 | when(productRepository.findByProductName(productName.toLowerCase())).thenReturn(Optional.of(product)); 116 | 117 | // Act & Assert 118 | assertThrows(ProductAlreadyExistException.class, 119 | () -> productService.saveProducts(product, "path/to/images/", images)); 120 | 121 | // Assert 122 | verify(categoryRepository, times(1)).findByCategoryName(categoryName.toLowerCase()); 123 | verify(categoryRepository, times(1)).save(any(ProductCategory.class)); 124 | verify(productRepository, times(1)).findByProductName(productName.toLowerCase()); 125 | verify(productRepository, never()).save(any(Product.class)); 126 | } 127 | 128 | @Test 129 | void getProductById_WhenProductExists_ShouldReturnProductResponse() { 130 | // Arrange 131 | Long productId = 1L; 132 | 133 | // Create a mock Product object 134 | Product product = new Product(); 135 | product.setDescription("Test Description"); 136 | product.setProductName("Test Product"); 137 | product.setPrice(10.0); 138 | product.setStockQuantity(100); 139 | product.setAvailability(ProductStatus.AVAILABLE); 140 | 141 | List images = new ArrayList<>(); 142 | Image image = new Image(); 143 | image.setImageId(1L); 144 | image.setUrl("productService/src/main/resources/static/test.jpg"); 145 | images.add(image); 146 | product.setImages(images); 147 | 148 | // Configure the mock productRepository 149 | when(productRepository.findById(productId)).thenReturn(Optional.of(product)); 150 | 151 | // Create the expected ProductResponse 152 | List expectedImages = new ArrayList<>(); 153 | Image expectedImage = new Image(); 154 | expectedImage.setImageId(1L); 155 | expectedImage.setUrl("http://localhost:8080/test.jpg"); 156 | expectedImages.add(expectedImage); 157 | 158 | ProductResponse expectedProductResponse = new ProductResponse( 159 | "Test Description", 160 | "Test Product", 161 | 10.0, 162 | 100, 163 | ProductStatus.AVAILABLE, 164 | expectedImages 165 | ); 166 | 167 | // Configure the mock productResponseMapper 168 | when(productResponseMapper.apply(product)).thenReturn(expectedProductResponse); 169 | 170 | // Act 171 | ProductResponse actualProductResponse = productService.getProductById(productId); 172 | 173 | // Assert 174 | assertEquals(expectedProductResponse, actualProductResponse); 175 | } 176 | 177 | @Test 178 | void getProductById_WhenProductDoesNotExist_ShouldThrowProductDoNotExistException() { 179 | // Arrange 180 | Long productId = 1L; 181 | 182 | // Configure the mock productRepository 183 | when(productRepository.findById(productId)).thenReturn(Optional.empty()); 184 | 185 | // Act & Assert 186 | assertThrows(ProductDoNotExistException.class, () -> productService.getProductById(productId)); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /.idea/uiDesigner.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 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | --------------------------------------------------------------------------------