├── README.md ├── Spring-Boot-CQS ├── .gitattributes ├── .gitignore ├── docker-compose-dev.yaml ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── rasitesdemir │ │ │ └── spring_boot_cqs │ │ │ ├── SpringBootCqsApplication.java │ │ │ ├── command │ │ │ ├── CommandService.java │ │ │ └── CommandServiceImpl.java │ │ │ ├── controller │ │ │ └── UserController.java │ │ │ ├── model │ │ │ ├── User.java │ │ │ └── request │ │ │ │ └── UserRequest.java │ │ │ ├── query │ │ │ ├── QueryService.java │ │ │ └── QueryServiceImpl.java │ │ │ └── repository │ │ │ └── UserRepository.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rasitesdemir │ └── spring_boot_cqs │ └── SpringBootCqsApplicationTests.java ├── docker-container-monitoring-cAdvisor ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── docker-container-monitoring-cAdvisor.iml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── misc.xml │ └── modules.xml ├── deployment │ ├── prod │ │ ├── .env │ │ ├── docker-compose-prod.yaml │ │ ├── grafana-datasources.yml │ │ └── prometheus.yml │ └── sql │ │ └── init-multiple-db.sql ├── images │ └── rs1.png ├── order-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── rasitesdmr │ │ │ │ │ └── order_service │ │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ │ ├── config │ │ │ │ │ ├── KafkaProducerConfig.java │ │ │ │ │ └── KafkaTopicConfig.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── audit │ │ │ │ │ │ └── Auditable.java │ │ │ │ │ ├── constant │ │ │ │ │ │ └── Constants.java │ │ │ │ │ ├── enums │ │ │ │ │ │ └── OrderStatus.java │ │ │ │ │ └── exception │ │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ │ └── exceptions │ │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ │ ├── feign │ │ │ │ │ └── StockFeignClient.java │ │ │ │ │ ├── interceptor │ │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ │ ├── order │ │ │ │ │ ├── Order.java │ │ │ │ │ ├── controller │ │ │ │ │ │ └── OrderController.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderService.java │ │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ │ ├── orderitem │ │ │ │ │ ├── OrderItem.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderItemCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderItemRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderItemService.java │ │ │ │ │ │ └── OrderItemServiceImpl.java │ │ │ │ │ └── producer │ │ │ │ │ └── KafkaProducer.java │ │ │ └── event │ │ │ │ ├── OrderCreatedEvent.java │ │ │ │ └── OrderItemCreatedEvent.java │ │ └── resources │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ ├── application-test.properties │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── rasitesdmr │ │ └── order_service │ │ └── OrderServiceApplicationTests.java └── stock-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ ├── com │ │ │ └── rasitesdmr │ │ │ │ └── stock_service │ │ │ │ ├── StockServiceApplication.java │ │ │ │ ├── config │ │ │ │ ├── KafkaConsumerConfig.java │ │ │ │ └── KafkaProducerConfig.java │ │ │ │ ├── consumer │ │ │ │ └── OrderCreatedConsumer.java │ │ │ │ ├── domain │ │ │ │ ├── audit │ │ │ │ │ └── Auditable.java │ │ │ │ ├── constant │ │ │ │ │ └── Constants.java │ │ │ │ ├── enums │ │ │ │ │ └── OrderStatus.java │ │ │ │ └── exception │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ └── exceptions │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ ├── feign │ │ │ │ └── OrderFeignClient.java │ │ │ │ ├── interceptor │ │ │ │ ├── KafkaConsumerInterceptor.java │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ └── stock │ │ │ │ ├── Stock.java │ │ │ │ ├── controller │ │ │ │ └── StockController.java │ │ │ │ ├── model │ │ │ │ └── request │ │ │ │ │ └── StockCreateRequest.java │ │ │ │ ├── repository │ │ │ │ └── StockRepository.java │ │ │ │ └── service │ │ │ │ ├── StockService.java │ │ │ │ └── StockServiceImpl.java │ │ └── event │ │ │ ├── OrderCreatedEvent.java │ │ │ └── OrderItemCreatedEvent.java │ └── resources │ │ ├── application-dev.properties │ │ ├── application-prod.properties │ │ ├── application-test.properties │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rasitesdmr │ └── stock_service │ └── StockServiceApplicationTests.java ├── spring-boot-dynamic-proxy ├── .gitignore ├── .idea │ ├── .gitignore │ ├── encodings.xml │ ├── misc.xml │ └── uiDesigner.xml ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── rasitesdmr │ ├── Main.java │ ├── annotation │ ├── Component.java │ ├── Repository.java │ ├── Service.java │ └── Transaction.java │ ├── domain │ └── request │ │ └── UserCreateRequest.java │ ├── handler │ └── TransactionInvocationHandler.java │ ├── model │ └── User.java │ ├── proxy │ ├── CustomProxy.java │ └── ProxyFactory.java │ ├── repository │ ├── JpaRepository.java │ └── UserRepository.java │ └── service │ ├── UserService.java │ └── UserServiceImpl.java ├── spring-boot-kafka-retry-dead-letter-queue ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── jpa.xml │ ├── misc.xml │ ├── modules.xml │ └── spring-boot-retry-dead-letter-queue.iml ├── deployment │ ├── .env │ ├── docker-compose.yaml │ └── init-multiple-db.sql ├── images │ ├── kafka.excalidraw │ ├── rs1.png │ ├── rs1.svg │ ├── rs10.png │ ├── rs11.png │ ├── rs12.png │ ├── rs13.png │ ├── rs14.png │ ├── rs15.png │ ├── rs16.png │ ├── rs17.png │ ├── rs18.png │ ├── rs19.png │ ├── rs2.png │ ├── rs20.png │ ├── rs21.png │ ├── rs22.png │ ├── rs23.png │ ├── rs24.png │ ├── rs25.png │ ├── rs3.png │ ├── rs4.png │ ├── rs5.png │ ├── rs6-new.png │ ├── rs6.png │ ├── rs7.png │ ├── rs8.png │ └── rs9.png ├── order-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── rasitesdmr │ │ │ │ │ └── order_service │ │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ │ ├── config │ │ │ │ │ ├── KafkaProducerConfig.java │ │ │ │ │ └── KafkaTopicConfig.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── audit │ │ │ │ │ │ └── Auditable.java │ │ │ │ │ ├── constant │ │ │ │ │ │ └── Constants.java │ │ │ │ │ ├── enums │ │ │ │ │ │ └── OrderStatus.java │ │ │ │ │ └── exception │ │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ │ └── exceptions │ │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ │ ├── feign │ │ │ │ │ └── StockFeignClient.java │ │ │ │ │ ├── interceptor │ │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ │ ├── order │ │ │ │ │ ├── Order.java │ │ │ │ │ ├── controller │ │ │ │ │ │ └── OrderController.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderService.java │ │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ │ ├── orderitem │ │ │ │ │ ├── OrderItem.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderItemCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderItemRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderItemService.java │ │ │ │ │ │ └── OrderItemServiceImpl.java │ │ │ │ │ └── producer │ │ │ │ │ └── KafkaProducer.java │ │ │ └── event │ │ │ │ ├── OrderCreatedEvent.java │ │ │ │ └── OrderItemCreatedEvent.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── rasitesdmr │ │ └── order_service │ │ └── OrderServiceApplicationTests.java └── stock-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ ├── com │ │ │ └── rasitesdmr │ │ │ │ └── stock_service │ │ │ │ ├── StockServiceApplication.java │ │ │ │ ├── config │ │ │ │ ├── KafkaConsumerConfig.java │ │ │ │ └── KafkaProducerConfig.java │ │ │ │ ├── consumer │ │ │ │ └── OrderCreatedConsumer.java │ │ │ │ ├── domain │ │ │ │ ├── audit │ │ │ │ │ └── Auditable.java │ │ │ │ ├── constant │ │ │ │ │ └── Constants.java │ │ │ │ ├── enums │ │ │ │ │ └── OrderStatus.java │ │ │ │ └── exception │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ └── exceptions │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ ├── feign │ │ │ │ └── OrderFeignClient.java │ │ │ │ ├── interceptor │ │ │ │ ├── KafkaConsumerInterceptor.java │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ └── stock │ │ │ │ ├── Stock.java │ │ │ │ ├── controller │ │ │ │ └── StockController.java │ │ │ │ ├── model │ │ │ │ └── request │ │ │ │ │ └── StockCreateRequest.java │ │ │ │ ├── repository │ │ │ │ └── StockRepository.java │ │ │ │ └── service │ │ │ │ ├── StockService.java │ │ │ │ └── StockServiceImpl.java │ │ └── event │ │ │ ├── OrderCreatedEvent.java │ │ │ └── OrderItemCreatedEvent.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rasitesdmr │ └── stock_service │ └── StockServiceApplicationTests.java ├── spring-boot-opentelemetry-java-agent ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ └── spring-boot-opentelemetry-java-agent.iml ├── deployment │ ├── dev │ │ └── docker-compose-dev.yaml │ ├── javaagent │ │ └── opentelemetry-javaagent.jar │ ├── prod │ │ ├── .env │ │ ├── docker-compose-prod.yaml │ │ ├── grafana-datasources.yml │ │ ├── otel-collector.yml │ │ └── prometheus.yml │ └── sql │ │ └── init-multiple-db.sql ├── images │ ├── exca.excalidraw │ ├── rs1.png │ ├── rs2.png │ ├── rs3.png │ ├── rs4.png │ └── rs5.png ├── order-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── rasitesdmr │ │ │ │ │ └── order_service │ │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ │ ├── config │ │ │ │ │ ├── KafkaProducerConfig.java │ │ │ │ │ └── KafkaTopicConfig.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── audit │ │ │ │ │ │ └── Auditable.java │ │ │ │ │ ├── constant │ │ │ │ │ │ └── Constants.java │ │ │ │ │ ├── enums │ │ │ │ │ │ └── OrderStatus.java │ │ │ │ │ └── exception │ │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ │ └── exceptions │ │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ │ ├── feign │ │ │ │ │ └── StockFeignClient.java │ │ │ │ │ ├── interceptor │ │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ │ ├── order │ │ │ │ │ ├── Order.java │ │ │ │ │ ├── controller │ │ │ │ │ │ └── OrderController.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderService.java │ │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ │ ├── orderitem │ │ │ │ │ ├── OrderItem.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderItemCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderItemRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderItemService.java │ │ │ │ │ │ └── OrderItemServiceImpl.java │ │ │ │ │ └── producer │ │ │ │ │ └── KafkaProducer.java │ │ │ └── event │ │ │ │ ├── OrderCreatedEvent.java │ │ │ │ └── OrderItemCreatedEvent.java │ │ └── resources │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ ├── application-test.properties │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── rasitesdmr │ │ └── order_service │ │ └── OrderServiceApplicationTests.java └── stock-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ ├── com │ │ │ └── rasitesdmr │ │ │ │ └── stock_service │ │ │ │ ├── StockServiceApplication.java │ │ │ │ ├── config │ │ │ │ ├── KafkaConsumerConfig.java │ │ │ │ └── KafkaProducerConfig.java │ │ │ │ ├── consumer │ │ │ │ └── OrderCreatedConsumer.java │ │ │ │ ├── domain │ │ │ │ ├── audit │ │ │ │ │ └── Auditable.java │ │ │ │ ├── constant │ │ │ │ │ └── Constants.java │ │ │ │ ├── enums │ │ │ │ │ └── OrderStatus.java │ │ │ │ └── exception │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ └── exceptions │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ ├── feign │ │ │ │ └── OrderFeignClient.java │ │ │ │ ├── interceptor │ │ │ │ ├── KafkaConsumerInterceptor.java │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ └── stock │ │ │ │ ├── Stock.java │ │ │ │ ├── controller │ │ │ │ └── StockController.java │ │ │ │ ├── model │ │ │ │ └── request │ │ │ │ │ └── StockCreateRequest.java │ │ │ │ ├── repository │ │ │ │ └── StockRepository.java │ │ │ │ └── service │ │ │ │ ├── StockService.java │ │ │ │ └── StockServiceImpl.java │ │ └── event │ │ │ ├── OrderCreatedEvent.java │ │ │ └── OrderItemCreatedEvent.java │ └── resources │ │ ├── application-dev.properties │ │ ├── application-prod.properties │ │ ├── application-test.properties │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rasitesdmr │ └── stock_service │ └── StockServiceApplicationTests.java ├── spring-boot-security-unit-test ├── .gitattributes ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── docker-compose.yaml ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── rasitesdmr │ │ │ └── springbootsecurityunittest │ │ │ ├── SpringBootSecurityUnitTestApplication.java │ │ │ ├── auth │ │ │ ├── controller │ │ │ │ └── AuthController.java │ │ │ └── service │ │ │ │ ├── AuthService.java │ │ │ │ └── AuthServiceImpl.java │ │ │ ├── config │ │ │ ├── OpenApiConfig.java │ │ │ ├── SecurityConfig.java │ │ │ └── WebMvcConfig.java │ │ │ ├── domain │ │ │ ├── enums │ │ │ │ └── RoleEnum.java │ │ │ ├── exception │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ └── exceptions │ │ │ │ │ ├── AlreadyAvailableException.java │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ ├── InvalidException.java │ │ │ │ │ ├── NotAvailableException.java │ │ │ │ │ └── UnauthorizedException.java │ │ │ └── model │ │ │ │ └── request │ │ │ │ ├── auth │ │ │ │ ├── AuthLoginRequest.java │ │ │ │ └── AuthRegisterRequest.java │ │ │ │ └── user │ │ │ │ └── UserCreateRequest.java │ │ │ ├── role │ │ │ ├── Role.java │ │ │ ├── repository │ │ │ │ └── RoleRepository.java │ │ │ └── service │ │ │ │ ├── RoleService.java │ │ │ │ └── RoleServiceImpl.java │ │ │ ├── security │ │ │ ├── jwt │ │ │ │ ├── JwtFilter.java │ │ │ │ └── JwtService.java │ │ │ └── userdetails │ │ │ │ ├── CustomUserDetails.java │ │ │ │ └── CustomUserDetailsService.java │ │ │ ├── starter │ │ │ └── RoleStarter.java │ │ │ ├── user │ │ │ ├── User.java │ │ │ ├── controller │ │ │ │ └── UserController.java │ │ │ ├── repository │ │ │ │ └── UserRepository.java │ │ │ └── service │ │ │ │ ├── UserService.java │ │ │ │ └── UserServiceImpl.java │ │ │ └── util │ │ │ └── AuthUtil.java │ └── resources │ │ ├── application-dev.properties │ │ ├── application-prod.properties │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rasitesdmr │ └── springbootsecurityunittest │ ├── SpringBootSecurityUnitTestApplicationTests.java │ ├── auth │ ├── controller │ │ └── AuthControllerUnitTest.java │ └── service │ │ └── AuthServiceUnitTest.java │ ├── data │ └── TestData.java │ ├── security │ └── jwt │ │ ├── JwtFilterUnitTest.java │ │ └── JwtServiceUnitTest.java │ └── user │ ├── controller │ └── UserControllerUnitTest.java │ └── service │ └── UserServiceUnitTest.java ├── spring-boot-sonarQube-docker ├── .idea │ ├── .gitignore │ ├── compiler.xml │ ├── encodings.xml │ ├── jarRepositories.xml │ ├── misc.xml │ ├── modules.xml │ └── spring-boot-sonarQube-Docker.iml ├── deployment │ ├── dev │ │ └── docker-compose-dev.yaml │ └── sonarqube │ │ └── docker-compose-sonarqube.yaml ├── order-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ ├── com │ │ │ │ └── rasitesdmr │ │ │ │ │ └── order_service │ │ │ │ │ ├── OrderServiceApplication.java │ │ │ │ │ ├── config │ │ │ │ │ ├── KafkaProducerConfig.java │ │ │ │ │ └── KafkaTopicConfig.java │ │ │ │ │ ├── domain │ │ │ │ │ ├── audit │ │ │ │ │ │ └── Auditable.java │ │ │ │ │ ├── constant │ │ │ │ │ │ └── Constants.java │ │ │ │ │ ├── enums │ │ │ │ │ │ └── OrderStatus.java │ │ │ │ │ └── exception │ │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ │ └── exceptions │ │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ │ ├── feign │ │ │ │ │ └── StockFeignClient.java │ │ │ │ │ ├── interceptor │ │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ │ ├── order │ │ │ │ │ ├── Order.java │ │ │ │ │ ├── controller │ │ │ │ │ │ └── OrderController.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderService.java │ │ │ │ │ │ └── OrderServiceImpl.java │ │ │ │ │ ├── orderitem │ │ │ │ │ ├── OrderItem.java │ │ │ │ │ ├── model │ │ │ │ │ │ └── request │ │ │ │ │ │ │ └── OrderItemCreateRequest.java │ │ │ │ │ ├── repository │ │ │ │ │ │ └── OrderItemRepository.java │ │ │ │ │ └── service │ │ │ │ │ │ ├── OrderItemService.java │ │ │ │ │ │ └── OrderItemServiceImpl.java │ │ │ │ │ └── producer │ │ │ │ │ └── KafkaProducer.java │ │ │ └── event │ │ │ │ ├── OrderCreatedEvent.java │ │ │ │ └── OrderItemCreatedEvent.java │ │ └── resources │ │ │ ├── application-dev.properties │ │ │ ├── application-prod.properties │ │ │ ├── application-test.properties │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── rasitesdmr │ │ └── order_service │ │ └── OrderServiceApplicationTests.java └── stock-service │ ├── .gitattributes │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties │ ├── Dockerfile │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ ├── com │ │ │ └── rasitesdmr │ │ │ │ └── stock_service │ │ │ │ ├── StockServiceApplication.java │ │ │ │ ├── config │ │ │ │ ├── KafkaConsumerConfig.java │ │ │ │ └── KafkaProducerConfig.java │ │ │ │ ├── consumer │ │ │ │ └── OrderCreatedConsumer.java │ │ │ │ ├── domain │ │ │ │ ├── audit │ │ │ │ │ └── Auditable.java │ │ │ │ ├── constant │ │ │ │ │ └── Constants.java │ │ │ │ ├── enums │ │ │ │ │ └── OrderStatus.java │ │ │ │ └── exception │ │ │ │ │ ├── GlobalExceptionHandler.java │ │ │ │ │ └── exceptions │ │ │ │ │ ├── BadRequestException.java │ │ │ │ │ ├── ConflictException.java │ │ │ │ │ ├── ForbiddenException.java │ │ │ │ │ ├── InternalServerErrorException.java │ │ │ │ │ ├── NotAcceptableException.java │ │ │ │ │ ├── NotFoundException.java │ │ │ │ │ └── UnauthorizedException.java │ │ │ │ ├── feign │ │ │ │ └── OrderFeignClient.java │ │ │ │ ├── interceptor │ │ │ │ ├── KafkaConsumerInterceptor.java │ │ │ │ └── KafkaProducerInterceptor.java │ │ │ │ └── stock │ │ │ │ ├── Stock.java │ │ │ │ ├── controller │ │ │ │ └── StockController.java │ │ │ │ ├── model │ │ │ │ └── request │ │ │ │ │ └── StockCreateRequest.java │ │ │ │ ├── repository │ │ │ │ └── StockRepository.java │ │ │ │ └── service │ │ │ │ ├── StockService.java │ │ │ │ └── StockServiceImpl.java │ │ └── event │ │ │ ├── OrderCreatedEvent.java │ │ │ └── OrderItemCreatedEvent.java │ └── resources │ │ ├── application-dev.properties │ │ ├── application-prod.properties │ │ ├── application-test.properties │ │ └── application.properties │ └── test │ └── java │ └── com │ └── rasitesdmr │ └── stock_service │ └── StockServiceApplicationTests.java ├── spring-boot-static-proxy ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── rasitesdmr │ └── springbootstaticproxy │ ├── Main.java │ ├── domain │ └── request │ │ └── UserCreateRequest.java │ ├── model │ └── User.java │ ├── proxy │ └── UserServiceProxy.java │ ├── repository │ └── UserRepository.java │ └── service │ ├── UserService.java │ └── UserServiceImpl.java └── spring-boot-transaction-management ├── .gitattributes ├── .gitignore ├── .mvn └── wrapper │ └── maven-wrapper.properties ├── README.md ├── docker-compose.yaml ├── images ├── rs1.png ├── rs10.png ├── rs11.png ├── rs12.png ├── rs13.png ├── rs14.png ├── rs15.png ├── rs16.png ├── rs17.png ├── rs18.png ├── rs19.png ├── rs2.png ├── rs20.png ├── rs21.png ├── rs22.png ├── rs23.png ├── rs24.png ├── rs25.png ├── rs26.png ├── rs27.png ├── rs28.png ├── rs29.png ├── rs3.png ├── rs30.png ├── rs31.png ├── rs32.png ├── rs33.png ├── rs34.png ├── rs35.png ├── rs36.png ├── rs37.png ├── rs38.png ├── rs39.png ├── rs4.png ├── rs40.png ├── rs41.png ├── rs5.png ├── rs6.png ├── rs7.png ├── rs8.png └── rs9.png ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── rasitesdmr │ │ └── springboottransactionmanagement │ │ ├── SpringBootTransactionManagementApplication.java │ │ ├── cart │ │ ├── Cart.java │ │ ├── repository │ │ │ └── CartRepository.java │ │ └── service │ │ │ ├── CartService.java │ │ │ └── CartServiceImpl.java │ │ ├── cartitem │ │ ├── CartItem.java │ │ ├── controller │ │ │ └── CartItemController.java │ │ ├── repository │ │ │ └── CartItemRepository.java │ │ └── service │ │ │ ├── CartItemService.java │ │ │ └── CartItemServiceImpl.java │ │ ├── customer │ │ ├── Customer.java │ │ ├── controller │ │ │ └── CustomerController.java │ │ ├── model │ │ │ ├── request │ │ │ │ └── CustomerCreateRequest.java │ │ │ └── response │ │ │ │ └── CustomerResponse.java │ │ ├── repository │ │ │ └── CustomerRepository.java │ │ └── service │ │ │ ├── CustomerService.java │ │ │ └── CustomerServiceImpl.java │ │ ├── exception │ │ ├── GlobalExceptionHandler.java │ │ └── exceptions │ │ │ ├── AlreadyAvailableException.java │ │ │ ├── BadRequestException.java │ │ │ ├── ForbiddenException.java │ │ │ ├── InternalServerErrorException.java │ │ │ ├── InvalidException.java │ │ │ ├── NotAvailableException.java │ │ │ └── UnauthorizedException.java │ │ ├── mail │ │ ├── controller │ │ │ └── MailController.java │ │ ├── enums │ │ │ └── MailTypeEnum.java │ │ └── service │ │ │ ├── MailService.java │ │ │ └── MailServiceImpl.java │ │ ├── order │ │ ├── Order.java │ │ ├── controller │ │ │ └── OrderController.java │ │ ├── repository │ │ │ └── OrderRepository.java │ │ └── service │ │ │ ├── OrderService.java │ │ │ └── OrderServiceImpl.java │ │ ├── orderitem │ │ ├── OrderItem.java │ │ ├── repository │ │ │ └── OrderItemRepository.java │ │ └── service │ │ │ ├── OrderItemService.java │ │ │ └── OrderItemServiceImpl.java │ │ ├── product │ │ ├── Product.java │ │ ├── controller │ │ │ └── ProductController.java │ │ ├── repository │ │ │ └── ProductRepository.java │ │ └── service │ │ │ ├── ProductService.java │ │ │ └── ProductServiceImpl.java │ │ └── stock │ │ ├── Stock.java │ │ ├── controller │ │ └── StockController.java │ │ ├── model │ │ ├── request │ │ │ └── StockUpdateRequest.java │ │ └── response │ │ │ └── StockUpdateResponse.java │ │ ├── repository │ │ └── StockRepository.java │ │ └── service │ │ ├── StockService.java │ │ └── StockServiceImpl.java └── resources │ └── application.properties └── test └── java └── com └── rasitesdmr └── springboottransactionmanagement └── SpringBootTransactionManagementApplicationTests.java /README.md: -------------------------------------------------------------------------------- 1 | # Medium-Projects -------------------------------------------------------------------------------- /Spring-Boot-CQS/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/docker-compose-dev.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | 4 | db-container: 5 | container_name: postgresql 6 | image: postgres:16.2 7 | ports: 8 | - "5432:5432" 9 | restart: always 10 | environment: 11 | POSTGRES_USER: root 12 | POSTGRES_PASSWORD: root 13 | POSTGRES_DB: cqs_db 14 | networks: 15 | - network 16 | 17 | networks: 18 | network: 19 | driver: bridge 20 | name: postgresql -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/java/com/rasitesdemir/spring_boot_cqs/SpringBootCqsApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootCqsApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootCqsApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/java/com/rasitesdemir/spring_boot_cqs/command/CommandService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs.command; 2 | 3 | import com.rasitesdemir.spring_boot_cqs.model.User; 4 | import com.rasitesdemir.spring_boot_cqs.model.request.UserRequest; 5 | 6 | import java.util.UUID; 7 | 8 | public interface CommandService { 9 | 10 | void saveUser(User user); 11 | 12 | void createUser(UserRequest userRequest); 13 | 14 | void deleteUser(UUID userID); 15 | 16 | void updateUser(UUID userID, UserRequest userRequest); 17 | } 18 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/java/com/rasitesdemir/spring_boot_cqs/model/User.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.*; 5 | 6 | import java.util.UUID; 7 | 8 | @Entity 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @Builder 14 | @Table(name = "users") 15 | public class User { 16 | 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.UUID) 19 | private UUID id; 20 | 21 | private String firstName; 22 | 23 | private String lastName; 24 | 25 | private String username; 26 | 27 | private String email; 28 | 29 | private String password; 30 | } 31 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/java/com/rasitesdemir/spring_boot_cqs/model/request/UserRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs.model.request; 2 | 3 | import lombok.*; 4 | 5 | @Getter 6 | @Setter 7 | @AllArgsConstructor 8 | @NoArgsConstructor 9 | @Builder 10 | public class UserRequest { 11 | 12 | private String firstName; 13 | 14 | private String lastName; 15 | 16 | private String username; 17 | 18 | private String email; 19 | 20 | private String password; 21 | } 22 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/java/com/rasitesdemir/spring_boot_cqs/query/QueryService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs.query; 2 | 3 | import com.rasitesdemir.spring_boot_cqs.model.User; 4 | 5 | import java.util.List; 6 | import java.util.UUID; 7 | 8 | public interface QueryService { 9 | 10 | User getUserById(UUID userID); 11 | 12 | List getAllUser(); 13 | } 14 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/java/com/rasitesdemir/spring_boot_cqs/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs.repository; 2 | 3 | import com.rasitesdemir.spring_boot_cqs.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.UUID; 8 | 9 | @Repository 10 | public interface UserRepository extends JpaRepository { 11 | } 12 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=spring-boot-cqs 2 | 3 | # Jpa & Postgresql Dev 4 | spring.jpa.database=POSTGRESQL 5 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 6 | spring.jpa.show-sql=true 7 | spring.jpa.hibernate.ddl-auto= update 8 | 9 | spring.datasource.url=jdbc:postgresql://localhost:5432/cqs_db 10 | spring.datasource.username=root 11 | spring.datasource.password=root 12 | 13 | 14 | # Swagger path 15 | springdoc.swagger-ui.path=/api 16 | -------------------------------------------------------------------------------- /Spring-Boot-CQS/src/test/java/com/rasitesdemir/spring_boot_cqs/SpringBootCqsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdemir.spring_boot_cqs; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootCqsApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/.idea/docker-container-monitoring-cAdvisor.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/deployment/prod/.env: -------------------------------------------------------------------------------- 1 | # Postgresql env 2 | POSTGRES_HOST=postgresql-database 3 | POSTGRES_DB=postgresql 4 | POSTGRES_USER=rasitesdmr 5 | POSTGRES_PASSWORD=rasitesdmr 6 | 7 | # Order Service env 8 | POSTGRES_ORDER_DB=order_db 9 | POSTGRES_STOCK_DB=stock_db 10 | 11 | # Kafka Env 12 | KAFKA_HOST=kafka 13 | KAFKA_PORT=9092 14 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/deployment/prod/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 15s # Her 15 saniyede bir hedeflerden metrik veri çekilir. 3 | scrape_timeout: 10s # Hedef yanıt vermezse 10 saniye sonra zaman aşımına düşer. 4 | evaluation_interval: 15s # Prometheus’un kurallar (alert/record) varsa onları ne sıklıkla çalıştıracağı. 5 | 6 | # Note : http://prometheus:9090/api/v1/write bu zaten anlık olarak push eder. Scrape ile de manuel pull eder. 7 | scrape_configs: # Bu bir “job” tanımıdır. Her bir kaynak grubu (Collector, Node Exporter, App) ayrı job_name ile tanımlanır. 8 | - job_name: 'cadvisor' 9 | static_configs: 10 | - targets: [ 'cadvisor:8080' ] -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/deployment/sql/init-multiple-db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE "stock_db"; 2 | CREATE DATABASE "order_db"; 3 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/images/rs1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/docker-container-monitoring-cAdvisor/images/rs1.png -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.9.5-eclipse-temurin-21-alpine AS build 2 | COPY ./src /usr/src/app/src 3 | COPY ./pom.xml /usr/src/app 4 | RUN mvn -f /usr/src/app/pom.xml clean install -DskipTests 5 | FROM openjdk:21-slim 6 | COPY --from=build /usr/src/app/target/*.jar /usr/local/lib/app.jar 7 | EXPOSE 8084 8 | ENTRYPOINT ["java", "-jar", "/usr/local/lib/app.jar"] -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableFeignClients 11 | @EnableJpaAuditing 12 | @EnableKafka 13 | public class OrderServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(OrderServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/feign/StockFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "stockFeignClient", url = "http://stock-service:8083/api/v1/stocks") 9 | public interface StockFeignClient { 10 | 11 | @GetMapping(path = "/sufficient") 12 | ResponseEntity feignIsStockSufficient(@RequestParam Long productId, @RequestParam int requestedStockQuantity); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/order/Order.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order; 2 | 3 | import com.rasitesdmr.order_service.domain.audit.Auditable; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import jakarta.persistence.*; 6 | import lombok.*; 7 | 8 | import java.util.List; 9 | 10 | @Entity 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Builder 16 | @Table(name = "orders") 17 | public class Order extends Auditable { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | 23 | private Long userId; 24 | 25 | private String orderStatus; 26 | 27 | @OneToMany(mappedBy = "order", cascade = CascadeType.ALL) 28 | private List orderItems; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/order/model/request/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.model.request; 2 | 3 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 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 OrderCreateRequest { 16 | private Long userId; 17 | List itemCreateRequests; 18 | } 19 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/order/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.repository; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.order.model.request.OrderCreateRequest; 5 | 6 | public interface OrderService { 7 | void saveOrder(Order order); 8 | String createOrder(OrderCreateRequest orderCreateRequest); 9 | Boolean updateOrderConfirmationStatus(Long orderId, String orderStatus); 10 | Order getById(Long id); 11 | } 12 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem; 2 | import com.rasitesdmr.order_service.domain.audit.Auditable; 3 | import com.rasitesdmr.order_service.order.Order; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | import java.math.BigDecimal; 8 | 9 | @Entity 10 | @Getter 11 | @Setter 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Builder 15 | @Table(name = "order_items") 16 | public class OrderItem extends Auditable { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | private Long id; 21 | 22 | private int quantity; 23 | 24 | private BigDecimal totalPrice; 25 | 26 | private Long productId; 27 | 28 | @ManyToOne 29 | @JoinColumn(name = "order_id") 30 | private Order order; 31 | } 32 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/model/request/OrderItemCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.model.request; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class OrderItemCreateRequest { 16 | 17 | private int quantity; 18 | 19 | private BigDecimal totalPrice; 20 | 21 | private Long productId; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/repository/OrderItemRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.repository; 2 | 3 | import com.rasitesdmr.order_service.orderitem.OrderItem; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderItemRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 6 | 7 | public interface OrderItemService { 8 | void saveOrderItem(OrderItem orderItem); 9 | OrderItem createOrderItem(Order order, OrderItemCreateRequest orderItemCreateRequest); 10 | } 11 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/com/rasitesdmr/order_service/producer/KafkaProducer.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.producer; 2 | 3 | import com.rasitesdmr.order_service.config.KafkaTopicConfig; 4 | import event.OrderCreatedEvent; 5 | import org.springframework.kafka.core.KafkaTemplate; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class KafkaProducer { 10 | private final KafkaTemplate kafkaTemplate; 11 | 12 | public KafkaProducer(KafkaTemplate kafkaTemplate) { 13 | this.kafkaTemplate = kafkaTemplate; 14 | } 15 | 16 | public void producerOrderCreatedEvent(OrderCreatedEvent orderCreatedEvent){ 17 | kafkaTemplate.send(KafkaTopicConfig.ORDER_CREATED_TOPIC, orderCreatedEvent); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/order_db 6 | spring.datasource.username=rasitesdmr 7 | spring.datasource.password=rasitesdmr 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_ORDER_DB} 6 | spring.datasource.username=${POSTGRES_USER} 7 | spring.datasource.password=${POSTGRES_PASSWORD} 8 | 9 | # Kafka 10 | spring.kafka.host=${KAFKA_HOST} 11 | spring.kafka.port=${KAFKA_PORT} -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # H2 Database Test 2 | spring.h2.console.enabled=true 3 | spring.datasource.url=jdbc:h2:mem:dcbapp 4 | spring.datasource.driver-class-name=org.h2.Driver 5 | spring.datasource.username=sa 6 | spring.datasource.password=password 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application profile 2 | spring.profiles.active=prod 3 | # Aplication Prot 4 | server.port=8084 5 | # Application Name 6 | spring.application.name=order-service 7 | # Log 8 | spring.output.ansi.enabled=ALWAYS 9 | # Swagger path 10 | springdoc.swagger-ui.path=/api 11 | 12 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/order-service/src/test/java/com/rasitesdmr/order_service/OrderServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 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 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.9.5-eclipse-temurin-21-alpine AS build 2 | COPY ./src /usr/src/app/src 3 | COPY ./pom.xml /usr/src/app 4 | RUN mvn -f /usr/src/app/pom.xml clean install -DskipTests 5 | FROM openjdk:21-slim 6 | COPY --from=build /usr/src/app/target/*.jar /usr/local/lib/app.jar 7 | EXPOSE 8083 8 | ENTRYPOINT ["java", "-jar", "/usr/local/lib/app.jar"] -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/StockServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableJpaAuditing 11 | @EnableKafka 12 | @EnableFeignClients 13 | public class StockServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(StockServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/feign/OrderFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "orderFeignClient", url = "http://order-service:8081/api/v1/orders") 9 | public interface OrderFeignClient { 10 | 11 | @PostMapping(path = "/confirmation/status") 12 | ResponseEntity feignUpdateOrderConfirmationStatus(@RequestParam Long orderId, @RequestParam String orderStatus); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/Stock.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock; 2 | 3 | import com.rasitesdmr.stock_service.domain.audit.Auditable; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | @Entity 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | @Builder 13 | @Table(name = "stocks") 14 | public class Stock extends Auditable { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Long id; 19 | 20 | private int quantity; 21 | 22 | private Long productId; 23 | } 24 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/model/request/StockCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.model.request; 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 StockCreateRequest { 13 | 14 | private int quantity; 15 | private Long productId; 16 | } 17 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/repository/StockRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.repository; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface StockRepository extends JpaRepository { 9 | 10 | Stock findStockByProductId(Long productId); 11 | } 12 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/service/StockService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.service; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import com.rasitesdmr.stock_service.stock.model.request.StockCreateRequest; 5 | import event.OrderCreatedEvent; 6 | 7 | public interface StockService { 8 | void saveStock(Stock stock); 9 | 10 | Stock createStock(StockCreateRequest stockCreateRequest); 11 | 12 | Boolean isStockSufficient(Long productId, int requestedStockQuantity); 13 | 14 | Stock getStockByProductId(Long productId); 15 | 16 | void decreaseStockQuantity(OrderCreatedEvent orderCreatedEvent); 17 | 18 | void updateOrderConfirmationStatus(Long orderId, String orderStatus); 19 | } 20 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/stock_db 6 | spring.datasource.username=rasitesdmr 7 | spring.datasource.password=rasitesdmr 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_ORDER_DB} 6 | spring.datasource.username=${POSTGRES_USER} 7 | spring.datasource.password=${POSTGRES_PASSWORD} 8 | 9 | # Kafka 10 | spring.kafka.host=${KAFKA_HOST} 11 | spring.kafka.port=${KAFKA_PORT} -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # H2 Database Test 2 | spring.h2.console.enabled=true 3 | spring.datasource.url=jdbc:h2:mem:dcbapp 4 | spring.datasource.driver-class-name=org.h2.Driver 5 | spring.datasource.username=sa 6 | spring.datasource.password=password 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application profile 2 | spring.profiles.active=prod 3 | # Aplication Prot 4 | server.port=8083 5 | # Application Name 6 | spring.application.name=stock-service 7 | # Log 8 | spring.output.ansi.enabled=ALWAYS 9 | # Swagger path 10 | springdoc.swagger-ui.path=/api 11 | 12 | -------------------------------------------------------------------------------- /docker-container-monitoring-cAdvisor/stock-service/src/test/java/com/rasitesdmr/stock_service/StockServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StockServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/.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 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/Main.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr; 2 | 3 | import com.rasitesdmr.domain.request.UserCreateRequest; 4 | import com.rasitesdmr.model.User; 5 | import com.rasitesdmr.proxy.ProxyFactory; 6 | import com.rasitesdmr.service.UserService; 7 | 8 | public class Main { 9 | public static void main(String[] args) { 10 | ProxyFactory proxyFactory = new ProxyFactory(Main.class.getPackage()); 11 | 12 | UserService userService = proxyFactory.getBean(UserService.class); 13 | UserCreateRequest request = new UserCreateRequest("rasitesdmr", "test@gmail.com"); 14 | User user = userService.createUser(request); 15 | User expectedUser = userService.getUserById(user.getId()); 16 | System.out.println("Expected user Id : " + expectedUser.getId()); 17 | } 18 | } -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/annotation/Component.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface Component { 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/annotation/Repository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Component 11 | public @interface Repository { 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/annotation/Service.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Component 11 | public @interface Service { 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/annotation/Transaction.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface Transaction { 11 | String value() default "default custom Transaction"; 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/domain/request/UserCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.domain.request; 2 | 3 | public class UserCreateRequest { 4 | 5 | private String username; 6 | private String email; 7 | 8 | public UserCreateRequest() { 9 | } 10 | 11 | public UserCreateRequest(String username, String email) { 12 | this.username = username; 13 | this.email = email; 14 | } 15 | 16 | public String getUsername() { 17 | return username; 18 | } 19 | 20 | public void setUsername(String username) { 21 | this.username = username; 22 | } 23 | 24 | public String getEmail() { 25 | return email; 26 | } 27 | 28 | public void setEmail(String email) { 29 | this.email = email; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/repository/JpaRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.repository; 2 | 3 | import com.rasitesdmr.model.User; 4 | 5 | import java.util.UUID; 6 | 7 | public interface JpaRepository { 8 | User save(User user); 9 | User findById(UUID id); 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.repository; 2 | 3 | import com.rasitesdmr.annotation.Repository; 4 | import com.rasitesdmr.model.User; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import java.util.UUID; 9 | 10 | 11 | @Repository 12 | public class UserRepository implements JpaRepository { 13 | 14 | private final List createUsers = new ArrayList<>(); 15 | 16 | @Override 17 | public User save(User user) { 18 | user.setId(UUID.randomUUID()); 19 | createUsers.add(user); 20 | return user; 21 | } 22 | 23 | @Override 24 | public User findById(UUID id) { 25 | return createUsers.stream().filter(user -> user.getId().equals(id)).findFirst().get(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-dynamic-proxy/src/main/java/com/rasitesdmr/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.service; 2 | 3 | import com.rasitesdmr.domain.request.UserCreateRequest; 4 | import com.rasitesdmr.model.User; 5 | 6 | import java.util.UUID; 7 | 8 | public interface UserService { 9 | User saveUser(User user); 10 | User createUser(UserCreateRequest userCreateRequest); 11 | User getUserById(UUID id); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/.idea/jpa.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/.idea/spring-boot-retry-dead-letter-queue.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/deployment/.env: -------------------------------------------------------------------------------- 1 | 2 | # Postgresql env 3 | POSTGRES_HOST=localhost 4 | POSTGRES_DB=postgresql 5 | POSTGRES_USER=rasitesdmr 6 | POSTGRES_PASSWORD=rasitesdmr 7 | 8 | # Order Service env 9 | POSTGRES_ORDER_DB=order-db 10 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/deployment/init-multiple-db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE "stock-db"; 2 | CREATE DATABASE "order-db"; 3 | 4 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs1.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs1.svg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs1.svg -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs10.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs11.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs12.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs13.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs14.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs15.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs16.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs17.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs18.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs19.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs2.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs20.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs21.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs22.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs23.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs24.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs25.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs3.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs4.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs5.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs6-new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs6-new.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs6.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs7.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs8.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/images/rs9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-kafka-retry-dead-letter-queue/images/rs9.png -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableFeignClients 11 | @EnableJpaAuditing 12 | @EnableKafka 13 | public class OrderServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(OrderServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/feign/StockFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "stockFeignClient", url = "http://localhost:8083/api/v1/stocks") 9 | public interface StockFeignClient { 10 | 11 | @GetMapping(path = "/sufficient") 12 | ResponseEntity feignIsStockSufficient(@RequestParam Long productId, @RequestParam int requestedStockQuantity); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/order/Order.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order; 2 | 3 | import com.rasitesdmr.order_service.domain.audit.Auditable; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import jakarta.persistence.*; 6 | import lombok.*; 7 | 8 | import java.util.List; 9 | 10 | @Entity 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Builder 16 | @Table(name = "orders") 17 | public class Order extends Auditable { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | 23 | private Long userId; 24 | 25 | private String orderStatus; 26 | 27 | @OneToMany(mappedBy = "order", cascade = CascadeType.ALL) 28 | private List orderItems; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/order/model/request/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.model.request; 2 | 3 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 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 OrderCreateRequest { 16 | private Long userId; 17 | List itemCreateRequests; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/order/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.repository; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.order.model.request.OrderCreateRequest; 5 | 6 | public interface OrderService { 7 | void saveOrder(Order order); 8 | String createOrder(OrderCreateRequest orderCreateRequest); 9 | Boolean updateOrderConfirmationStatus(Long orderId, String orderStatus); 10 | Order getById(Long id); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/model/request/OrderItemCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.model.request; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class OrderItemCreateRequest { 16 | 17 | private int quantity; 18 | 19 | private BigDecimal totalPrice; 20 | 21 | private Long productId; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/repository/OrderItemRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.repository; 2 | 3 | import com.rasitesdmr.order_service.orderitem.OrderItem; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderItemRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 6 | 7 | public interface OrderItemService { 8 | void saveOrderItem(OrderItem orderItem); 9 | OrderItem createOrderItem(Order order, OrderItemCreateRequest orderItemCreateRequest); 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/com/rasitesdmr/order_service/producer/KafkaProducer.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.producer; 2 | 3 | import com.rasitesdmr.order_service.config.KafkaTopicConfig; 4 | import event.OrderCreatedEvent; 5 | import org.springframework.kafka.core.KafkaTemplate; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class KafkaProducer { 10 | private final KafkaTemplate kafkaTemplate; 11 | 12 | public KafkaProducer(KafkaTemplate kafkaTemplate) { 13 | this.kafkaTemplate = kafkaTemplate; 14 | } 15 | 16 | public void producerOrderCreatedEvent(OrderCreatedEvent orderCreatedEvent){ 17 | kafkaTemplate.send(KafkaTopicConfig.ORDER_CREATED_TOPIC, orderCreatedEvent); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application settings 2 | server.port=8080 3 | spring.application.name=order-service 4 | 5 | # Log 6 | spring.output.ansi.enabled=ALWAYS 7 | 8 | # Swagger path 9 | springdoc.swagger-ui.path=/api 10 | 11 | # Jpa & Postgresql 12 | spring.jpa.database=POSTGRESQL 13 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 14 | spring.jpa.hibernate.ddl-auto= update 15 | 16 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST:localhost}:5432/${POSTGRES_ORDER_DB:order-db} 17 | spring.datasource.username=${POSTGRES_USER:rasitesdmr} 18 | spring.datasource.password=${POSTGRES_PASSWORD:rasitesdmr} -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/order-service/src/test/java/com/rasitesdmr/order_service/OrderServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 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 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/StockServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableJpaAuditing 11 | @EnableKafka 12 | @EnableFeignClients 13 | public class StockServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(StockServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/feign/OrderFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "orderFeignClient", url = "http://localhost:8080/api/v1/orders") 9 | public interface OrderFeignClient { 10 | 11 | @PostMapping(path = "/confirmation/status") 12 | ResponseEntity feignUpdateOrderConfirmationStatus(@RequestParam Long orderId, @RequestParam String orderStatus); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/Stock.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock; 2 | 3 | import com.rasitesdmr.stock_service.domain.audit.Auditable; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | @Entity 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | @Builder 13 | @Table(name = "stocks") 14 | public class Stock extends Auditable { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Long id; 19 | 20 | private int quantity; 21 | 22 | private Long productId; 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/model/request/StockCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.model.request; 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 StockCreateRequest { 13 | 14 | private int quantity; 15 | private Long productId; 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/repository/StockRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.repository; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface StockRepository extends JpaRepository { 9 | 10 | Stock findStockByProductId(Long productId); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/service/StockService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.service; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import com.rasitesdmr.stock_service.stock.model.request.StockCreateRequest; 5 | import event.OrderCreatedEvent; 6 | 7 | public interface StockService { 8 | void saveStock(Stock stock); 9 | 10 | Stock createStock(StockCreateRequest stockCreateRequest); 11 | 12 | Boolean isStockSufficient(Long productId, int requestedStockQuantity); 13 | 14 | Stock getStockByProductId(Long productId); 15 | 16 | void decreaseStockQuantity(OrderCreatedEvent orderCreatedEvent); 17 | 18 | void updateOrderConfirmationStatus(Long orderId, String orderStatus); 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=8083 2 | spring.application.name=stock-service 3 | 4 | 5 | spring.output.ansi.enabled=ALWAYS 6 | 7 | # Swagger path 8 | springdoc.swagger-ui.path=/api 9 | 10 | # Jpa & Postgresql Dev 11 | spring.jpa.database=POSTGRESQL 12 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 13 | spring.jpa.hibernate.ddl-auto= update 14 | 15 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST:localhost}:5432/${POSTGRES_ORDER_DB:stock-db} 16 | spring.datasource.username=${POSTGRES_USER:rasitesdmr} 17 | spring.datasource.password=${POSTGRES_PASSWORD:rasitesdmr} -------------------------------------------------------------------------------- /spring-boot-kafka-retry-dead-letter-queue/stock-service/src/test/java/com/rasitesdmr/stock_service/StockServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StockServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/.idea/spring-boot-opentelemetry-java-agent.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/deployment/javaagent/opentelemetry-javaagent.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-opentelemetry-java-agent/deployment/javaagent/opentelemetry-javaagent.jar -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/deployment/sql/init-multiple-db.sql: -------------------------------------------------------------------------------- 1 | CREATE DATABASE "stock_db"; 2 | CREATE DATABASE "order_db"; 3 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/images/rs1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-opentelemetry-java-agent/images/rs1.png -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/images/rs2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-opentelemetry-java-agent/images/rs2.png -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/images/rs3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-opentelemetry-java-agent/images/rs3.png -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/images/rs4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-opentelemetry-java-agent/images/rs4.png -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/images/rs5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-opentelemetry-java-agent/images/rs5.png -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableFeignClients 11 | @EnableJpaAuditing 12 | @EnableKafka 13 | public class OrderServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(OrderServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/feign/StockFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "stockFeignClient", url = "http://stock-service:8083/api/v1/stocks") 9 | public interface StockFeignClient { 10 | 11 | @GetMapping(path = "/sufficient") 12 | ResponseEntity feignIsStockSufficient(@RequestParam Long productId, @RequestParam int requestedStockQuantity); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/order/Order.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order; 2 | 3 | import com.rasitesdmr.order_service.domain.audit.Auditable; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import jakarta.persistence.*; 6 | import lombok.*; 7 | 8 | import java.util.List; 9 | 10 | @Entity 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Builder 16 | @Table(name = "orders") 17 | public class Order extends Auditable { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | 23 | private Long userId; 24 | 25 | private String orderStatus; 26 | 27 | @OneToMany(mappedBy = "order", cascade = CascadeType.ALL) 28 | private List orderItems; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/order/model/request/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.model.request; 2 | 3 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 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 OrderCreateRequest { 16 | private Long userId; 17 | List itemCreateRequests; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/order/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.repository; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.order.model.request.OrderCreateRequest; 5 | 6 | public interface OrderService { 7 | void saveOrder(Order order); 8 | String createOrder(OrderCreateRequest orderCreateRequest); 9 | Boolean updateOrderConfirmationStatus(Long orderId, String orderStatus); 10 | Order getById(Long id); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/model/request/OrderItemCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.model.request; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class OrderItemCreateRequest { 16 | 17 | private int quantity; 18 | 19 | private BigDecimal totalPrice; 20 | 21 | private Long productId; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/repository/OrderItemRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.repository; 2 | 3 | import com.rasitesdmr.order_service.orderitem.OrderItem; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderItemRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 6 | 7 | public interface OrderItemService { 8 | void saveOrderItem(OrderItem orderItem); 9 | OrderItem createOrderItem(Order order, OrderItemCreateRequest orderItemCreateRequest); 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/com/rasitesdmr/order_service/producer/KafkaProducer.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.producer; 2 | 3 | import com.rasitesdmr.order_service.config.KafkaTopicConfig; 4 | import event.OrderCreatedEvent; 5 | import org.springframework.kafka.core.KafkaTemplate; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class KafkaProducer { 10 | private final KafkaTemplate kafkaTemplate; 11 | 12 | public KafkaProducer(KafkaTemplate kafkaTemplate) { 13 | this.kafkaTemplate = kafkaTemplate; 14 | } 15 | 16 | public void producerOrderCreatedEvent(OrderCreatedEvent orderCreatedEvent){ 17 | kafkaTemplate.send(KafkaTopicConfig.ORDER_CREATED_TOPIC, orderCreatedEvent); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/order_db 6 | spring.datasource.username=rasitesdmr 7 | spring.datasource.password=rasitesdmr 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_ORDER_DB} 6 | spring.datasource.username=${POSTGRES_USER} 7 | spring.datasource.password=${POSTGRES_PASSWORD} 8 | 9 | # Kafka 10 | spring.kafka.host=${KAFKA_HOST} 11 | spring.kafka.port=${KAFKA_PORT} -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # H2 Database Test 2 | spring.h2.console.enabled=true 3 | spring.datasource.url=jdbc:h2:mem:dcbapp 4 | spring.datasource.driver-class-name=org.h2.Driver 5 | spring.datasource.username=sa 6 | spring.datasource.password=password 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application profile 2 | spring.profiles.active=prod 3 | # Aplication Prot 4 | server.port=8084 5 | # Application Name 6 | spring.application.name=order-service 7 | # Log 8 | spring.output.ansi.enabled=ALWAYS 9 | # Swagger path 10 | springdoc.swagger-ui.path=/api 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/order-service/src/test/java/com/rasitesdmr/order_service/OrderServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 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 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/StockServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableJpaAuditing 11 | @EnableKafka 12 | @EnableFeignClients 13 | public class StockServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(StockServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/feign/OrderFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "orderFeignClient", url = "http://order-service:8081/api/v1/orders") 9 | public interface OrderFeignClient { 10 | 11 | @PostMapping(path = "/confirmation/status") 12 | ResponseEntity feignUpdateOrderConfirmationStatus(@RequestParam Long orderId, @RequestParam String orderStatus); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/Stock.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock; 2 | 3 | import com.rasitesdmr.stock_service.domain.audit.Auditable; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | @Entity 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | @Builder 13 | @Table(name = "stocks") 14 | public class Stock extends Auditable { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Long id; 19 | 20 | private int quantity; 21 | 22 | private Long productId; 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/model/request/StockCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.model.request; 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 StockCreateRequest { 13 | 14 | private int quantity; 15 | private Long productId; 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/repository/StockRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.repository; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface StockRepository extends JpaRepository { 9 | 10 | Stock findStockByProductId(Long productId); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/service/StockService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.service; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import com.rasitesdmr.stock_service.stock.model.request.StockCreateRequest; 5 | import event.OrderCreatedEvent; 6 | 7 | public interface StockService { 8 | void saveStock(Stock stock); 9 | 10 | Stock createStock(StockCreateRequest stockCreateRequest); 11 | 12 | Boolean isStockSufficient(Long productId, int requestedStockQuantity); 13 | 14 | Stock getStockByProductId(Long productId); 15 | 16 | void decreaseStockQuantity(OrderCreatedEvent orderCreatedEvent); 17 | 18 | void updateOrderConfirmationStatus(Long orderId, String orderStatus); 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/stock_db 6 | spring.datasource.username=rasitesdmr 7 | spring.datasource.password=rasitesdmr 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_ORDER_DB} 6 | spring.datasource.username=${POSTGRES_USER} 7 | spring.datasource.password=${POSTGRES_PASSWORD} 8 | 9 | # Kafka 10 | spring.kafka.host=${KAFKA_HOST} 11 | spring.kafka.port=${KAFKA_PORT} -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # H2 Database Test 2 | spring.h2.console.enabled=true 3 | spring.datasource.url=jdbc:h2:mem:dcbapp 4 | spring.datasource.driver-class-name=org.h2.Driver 5 | spring.datasource.username=sa 6 | spring.datasource.password=password 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application profile 2 | spring.profiles.active=prod 3 | # Aplication Prot 4 | server.port=8083 5 | # Application Name 6 | spring.application.name=stock-service 7 | # Log 8 | spring.output.ansi.enabled=ALWAYS 9 | # Swagger path 10 | springdoc.swagger-ui.path=/api 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-opentelemetry-java-agent/stock-service/src/test/java/com/rasitesdmr/stock_service/StockServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StockServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.9.5-eclipse-temurin-21-alpine AS build 2 | COPY ./src /usr/src/app/src 3 | COPY ./pom.xml /usr/src/app 4 | RUN mvn -f /usr/src/app/pom.xml clean package -P prod -D skipTests 5 | 6 | FROM openjdk:21-slim 7 | COPY --from=build /usr/src/app/target/*.jar /usr/local/lib/app.jar 8 | 9 | EXPOSE 6090 10 | ENTRYPOINT ["java","-jar","/usr/local/lib/app.jar"] -------------------------------------------------------------------------------- /spring-boot-security-unit-test/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | 4 | db-container: 5 | container_name: postgresql 6 | image: postgres:16.2 7 | ports: 8 | - "5432:5432" 9 | restart: always 10 | environment: 11 | POSTGRES_USER: rasitesdmr 12 | POSTGRES_PASSWORD: rasitesdmr 13 | POSTGRES_DB: unit-test 14 | networks: 15 | - network 16 | 17 | networks: 18 | network: 19 | driver: bridge 20 | name: postgresql -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/SpringBootSecurityUnitTestApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringBootSecurityUnitTestApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(SpringBootSecurityUnitTestApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/auth/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.auth.service; 2 | 3 | 4 | import com.rasitesdmr.springbootsecurityunittest.domain.model.request.auth.AuthLoginRequest; 5 | import com.rasitesdmr.springbootsecurityunittest.domain.model.request.auth.AuthRegisterRequest; 6 | 7 | public interface AuthService { 8 | String authRegister(AuthRegisterRequest authRegisterRequest); 9 | String authLogin(AuthLoginRequest authLoginRequest); 10 | String encodePassword(String password); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/enums/RoleEnum.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.enums; 2 | 3 | public enum RoleEnum { 4 | ROLE_USER, 5 | ROLE_ADMIN 6 | } 7 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/AlreadyAvailableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class AlreadyAvailableException extends RuntimeException { 6 | private final HttpStatus status; 7 | 8 | public AlreadyAvailableException(String message) { 9 | super(message); 10 | this.status = HttpStatus.CONFLICT; 11 | } 12 | 13 | public HttpStatus getStatus() { 14 | return status; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class BadRequestException extends RuntimeException{ 6 | private final HttpStatus status; 7 | 8 | public BadRequestException(String message) { 9 | super(message); 10 | this.status = HttpStatus.BAD_REQUEST; 11 | } 12 | public HttpStatus getStatus() { 13 | return status; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class ForbiddenException extends RuntimeException { 6 | private final HttpStatus status; 7 | 8 | public ForbiddenException(String message) { 9 | super(message); 10 | this.status = HttpStatus.FORBIDDEN; 11 | } 12 | 13 | public HttpStatus getStatus() { 14 | return status; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class InternalServerErrorException extends RuntimeException { 6 | private final HttpStatus status; 7 | 8 | public InternalServerErrorException(String message) { 9 | super(message); 10 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 11 | } 12 | 13 | public HttpStatus getStatus() { 14 | return status; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/InvalidException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class InvalidException extends RuntimeException { 6 | private final HttpStatus status; 7 | 8 | public InvalidException(String message) { 9 | super(message); 10 | this.status = HttpStatus.NOT_ACCEPTABLE; 11 | } 12 | 13 | public HttpStatus getStatus() { 14 | return status; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/NotAvailableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class NotAvailableException extends RuntimeException { 6 | 7 | private final HttpStatus status; 8 | 9 | public NotAvailableException(String message) { 10 | super(message); 11 | this.status = HttpStatus.NOT_FOUND; 12 | } 13 | 14 | public HttpStatus getStatus() { 15 | return status; 16 | } 17 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.domain.exception.exceptions; 2 | 3 | import org.springframework.http.HttpStatus; 4 | 5 | public class UnauthorizedException extends RuntimeException { 6 | private final HttpStatus status; 7 | 8 | public UnauthorizedException(String message) { 9 | super(message); 10 | this.status = HttpStatus.UNAUTHORIZED; 11 | } 12 | 13 | public HttpStatus getStatus() { 14 | return status; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/role/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.role.repository; 2 | 3 | import com.rasitesdmr.springbootsecurityunittest.role.Role; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.Optional; 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface RoleRepository extends JpaRepository { 12 | 13 | Optional findByRoleName(String roleName); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/role/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.role.service; 2 | 3 | 4 | import com.rasitesdmr.springbootsecurityunittest.role.Role; 5 | 6 | public interface RoleService { 7 | Role getRoleByName(String roleName); 8 | } 9 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/user/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.user.repository; 2 | 3 | import com.rasitesdmr.springbootsecurityunittest.user.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.Optional; 8 | import java.util.UUID; 9 | 10 | @Repository 11 | public interface UserRepository extends JpaRepository { 12 | 13 | Optional findByUserName(String username); 14 | boolean existsByUserName(String username); 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/java/com/rasitesdmr/springbootsecurityunittest/user/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest.user.service; 2 | 3 | import com.rasitesdmr.springbootsecurityunittest.domain.model.request.user.UserCreateRequest; 4 | import com.rasitesdmr.springbootsecurityunittest.user.User; 5 | 6 | import java.util.List; 7 | 8 | 9 | public interface UserService { 10 | void saveUser(User user); 11 | void createUser(UserCreateRequest userCreateRequest); 12 | User getUserByUsername(String username); 13 | boolean checkExistUserName(String username); 14 | List getAllUsers(); 15 | User getUserByToken(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql Dev 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.show-sql=true 5 | spring.jpa.hibernate.ddl-auto= update 6 | 7 | spring.datasource.url=jdbc:postgresql://localhost:5432/unit-test 8 | spring.datasource.username=rasitesdmr 9 | spring.datasource.password=rasitesdmr 10 | 11 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql Dev 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.show-sql=true 5 | spring.jpa.hibernate.ddl-auto= update 6 | 7 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST:localhost}:${POSTGRES_PORT:5432}/${POSTGRES_DB:unit-test} 8 | spring.datasource.username=${POSTGRES_USER:rasitesdmr} 9 | spring.datasource.password=${POSTGRES_PASSWORD:rasitesdmr} 10 | 11 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Profile 2 | spring.profiles.active=@activatedProperties@ 3 | 4 | spring.application.name=spring-boot-security-unit-test 5 | 6 | # Server Port 7 | server.port=6090 8 | 9 | # Security Secret Key 10 | secret.key=413DSEKRYFJSUFN235u23423153958SDFUY482485200CN 11 | 12 | # Swagger path 13 | springdoc.swagger-ui.path=/api 14 | -------------------------------------------------------------------------------- /spring-boot-security-unit-test/src/test/java/com/rasitesdmr/springbootsecurityunittest/SpringBootSecurityUnitTestApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootsecurityunittest; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootSecurityUnitTestApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/.idea/spring-boot-sonarQube-Docker.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableFeignClients 11 | @EnableJpaAuditing 12 | @EnableKafka 13 | public class OrderServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(OrderServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/feign/StockFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "stockFeignClient", url = "http://stock-service:8083/api/v1/stocks") 9 | public interface StockFeignClient { 10 | 11 | @GetMapping(path = "/sufficient") 12 | ResponseEntity feignIsStockSufficient(@RequestParam Long productId, @RequestParam int requestedStockQuantity); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/order/Order.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order; 2 | 3 | import com.rasitesdmr.order_service.domain.audit.Auditable; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import jakarta.persistence.*; 6 | import lombok.*; 7 | 8 | import java.util.List; 9 | 10 | @Entity 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Builder 16 | @Table(name = "orders") 17 | public class Order extends Auditable { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | 23 | private Long userId; 24 | 25 | private String orderStatus; 26 | 27 | @OneToMany(mappedBy = "order", cascade = CascadeType.ALL) 28 | private List orderItems; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/order/model/request/OrderCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.model.request; 2 | 3 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 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 OrderCreateRequest { 16 | private Long userId; 17 | List itemCreateRequests; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/order/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.repository; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.order.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.order.model.request.OrderCreateRequest; 5 | 6 | public interface OrderService { 7 | void saveOrder(Order order); 8 | String createOrder(OrderCreateRequest orderCreateRequest); 9 | Boolean updateOrderConfirmationStatus(Long orderId, String orderStatus); 10 | Order getById(Long id); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem; 2 | import com.rasitesdmr.order_service.domain.audit.Auditable; 3 | import com.rasitesdmr.order_service.order.Order; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | import java.math.BigDecimal; 8 | 9 | @Entity 10 | @Getter 11 | @Setter 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Builder 15 | @Table(name = "order_items") 16 | public class OrderItem extends Auditable { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | private Long id; 21 | 22 | private int quantity; 23 | 24 | private BigDecimal totalPrice; 25 | 26 | private Long productId; 27 | 28 | @ManyToOne 29 | @JoinColumn(name = "order_id") 30 | private Order order; 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/model/request/OrderItemCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.model.request; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class OrderItemCreateRequest { 16 | 17 | private int quantity; 18 | 19 | private BigDecimal totalPrice; 20 | 21 | private Long productId; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/repository/OrderItemRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.repository; 2 | 3 | import com.rasitesdmr.order_service.orderitem.OrderItem; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderItemRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/orderitem/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.orderitem.service; 2 | 3 | import com.rasitesdmr.order_service.order.Order; 4 | import com.rasitesdmr.order_service.orderitem.OrderItem; 5 | import com.rasitesdmr.order_service.orderitem.model.request.OrderItemCreateRequest; 6 | 7 | public interface OrderItemService { 8 | void saveOrderItem(OrderItem orderItem); 9 | OrderItem createOrderItem(Order order, OrderItemCreateRequest orderItemCreateRequest); 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/com/rasitesdmr/order_service/producer/KafkaProducer.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service.producer; 2 | 3 | import com.rasitesdmr.order_service.config.KafkaTopicConfig; 4 | import event.OrderCreatedEvent; 5 | import org.springframework.kafka.core.KafkaTemplate; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class KafkaProducer { 10 | private final KafkaTemplate kafkaTemplate; 11 | 12 | public KafkaProducer(KafkaTemplate kafkaTemplate) { 13 | this.kafkaTemplate = kafkaTemplate; 14 | } 15 | 16 | public void producerOrderCreatedEvent(OrderCreatedEvent orderCreatedEvent){ 17 | kafkaTemplate.send(KafkaTopicConfig.ORDER_CREATED_TOPIC, orderCreatedEvent); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/order_db 6 | spring.datasource.username=rasitesdmr 7 | spring.datasource.password=rasitesdmr 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_ORDER_DB} 6 | spring.datasource.username=${POSTGRES_USER} 7 | spring.datasource.password=${POSTGRES_PASSWORD} 8 | 9 | # Kafka 10 | spring.kafka.host=${KAFKA_HOST} 11 | spring.kafka.port=${KAFKA_PORT} -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # H2 Database Test 2 | spring.h2.console.enabled=true 3 | spring.datasource.url=jdbc:h2:mem:dcbapp 4 | spring.datasource.driver-class-name=org.h2.Driver 5 | spring.datasource.username=sa 6 | spring.datasource.password=password 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application profile 2 | spring.profiles.active=test 3 | # Aplication Prot 4 | server.port=8084 5 | # Application Name 6 | spring.application.name=order-service 7 | # Log 8 | spring.output.ansi.enabled=ALWAYS 9 | # Swagger path 10 | springdoc.swagger-ui.path=/api 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/order-service/src/test/java/com/rasitesdmr/order_service/OrderServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.order_service; 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 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/StockServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.openfeign.EnableFeignClients; 6 | import org.springframework.data.jpa.repository.config.EnableJpaAuditing; 7 | import org.springframework.kafka.annotation.EnableKafka; 8 | 9 | @SpringBootApplication 10 | @EnableJpaAuditing 11 | @EnableKafka 12 | @EnableFeignClients 13 | public class StockServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(StockServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/enums/OrderStatus.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.enums; 2 | 3 | public enum OrderStatus { 4 | PENDING, 5 | CONFIRMED, 6 | FAILED, 7 | } 8 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ConflictException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ConflictException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public ConflictException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | 16 | 17 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotAcceptableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAcceptableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAcceptableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/NotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotFoundException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotFoundException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/domain/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.domain.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/feign/OrderFeignClient.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.feign; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | 8 | @FeignClient(name = "orderFeignClient", url = "http://order-service:8081/api/v1/orders") 9 | public interface OrderFeignClient { 10 | 11 | @PostMapping(path = "/confirmation/status") 12 | ResponseEntity feignUpdateOrderConfirmationStatus(@RequestParam Long orderId, @RequestParam String orderStatus); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/Stock.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock; 2 | 3 | import com.rasitesdmr.stock_service.domain.audit.Auditable; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | @Entity 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | @Builder 13 | @Table(name = "stocks") 14 | public class Stock extends Auditable { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Long id; 19 | 20 | private int quantity; 21 | 22 | private Long productId; 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/model/request/StockCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.model.request; 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 StockCreateRequest { 13 | 14 | private int quantity; 15 | private Long productId; 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/repository/StockRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.repository; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface StockRepository extends JpaRepository { 9 | 10 | Stock findStockByProductId(Long productId); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/com/rasitesdmr/stock_service/stock/service/StockService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service.stock.service; 2 | 3 | import com.rasitesdmr.stock_service.stock.Stock; 4 | import com.rasitesdmr.stock_service.stock.model.request.StockCreateRequest; 5 | import event.OrderCreatedEvent; 6 | 7 | public interface StockService { 8 | void saveStock(Stock stock); 9 | 10 | Stock createStock(StockCreateRequest stockCreateRequest); 11 | 12 | Boolean isStockSufficient(Long productId, int requestedStockQuantity); 13 | 14 | Stock getStockByProductId(Long productId); 15 | 16 | void decreaseStockQuantity(OrderCreatedEvent orderCreatedEvent); 17 | 18 | void updateOrderConfirmationStatus(Long orderId, String orderStatus); 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/event/OrderCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.util.List; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderCreatedEvent { 13 | 14 | private Long orderId; 15 | private Long userId; 16 | private String orderStatus; 17 | private List itemEvent; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/java/event/OrderItemCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package event; 2 | 3 | import lombok.*; 4 | 5 | import java.math.BigDecimal; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class OrderItemCreatedEvent { 13 | 14 | private Long orderItemId; 15 | private int quantity; 16 | private BigDecimal totalPrice; 17 | private Long productId; 18 | } 19 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/resources/application-dev.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://localhost:5432/stock_db 6 | spring.datasource.username=rasitesdmr 7 | spring.datasource.password=rasitesdmr 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/resources/application-prod.properties: -------------------------------------------------------------------------------- 1 | # Jpa & Postgresql 2 | spring.jpa.database=POSTGRESQL 3 | spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect 4 | spring.jpa.hibernate.ddl-auto= update 5 | spring.datasource.url=jdbc:postgresql://${POSTGRES_HOST}:5432/${POSTGRES_ORDER_DB} 6 | spring.datasource.username=${POSTGRES_USER} 7 | spring.datasource.password=${POSTGRES_PASSWORD} 8 | 9 | # Kafka 10 | spring.kafka.host=${KAFKA_HOST} 11 | spring.kafka.port=${KAFKA_PORT} -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | # H2 Database Test 2 | spring.h2.console.enabled=true 3 | spring.datasource.url=jdbc:h2:mem:dcbapp 4 | spring.datasource.driver-class-name=org.h2.Driver 5 | spring.datasource.username=sa 6 | spring.datasource.password=password 7 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 8 | 9 | # Kafka 10 | spring.kafka.host=localhost 11 | spring.kafka.port=9092 -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Application profile 2 | spring.profiles.active=test 3 | # Aplication Prot 4 | server.port=8083 5 | # Application Name 6 | spring.application.name=stock-service 7 | # Log 8 | spring.output.ansi.enabled=ALWAYS 9 | # Swagger path 10 | springdoc.swagger-ui.path=/api 11 | 12 | -------------------------------------------------------------------------------- /spring-boot-sonarQube-docker/stock-service/src/test/java/com/rasitesdmr/stock_service/StockServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.stock_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StockServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-static-proxy/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-static-proxy/src/main/java/com/rasitesdmr/springbootstaticproxy/domain/request/UserCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootstaticproxy.domain.request; 2 | 3 | public class UserCreateRequest { 4 | 5 | private String username; 6 | private String email; 7 | 8 | public UserCreateRequest() { 9 | } 10 | 11 | public UserCreateRequest(String username, String email) { 12 | this.username = username; 13 | this.email = email; 14 | } 15 | 16 | public String getUsername() { 17 | return username; 18 | } 19 | 20 | public void setUsername(String username) { 21 | this.username = username; 22 | } 23 | 24 | public String getEmail() { 25 | return email; 26 | } 27 | 28 | public void setEmail(String email) { 29 | this.email = email; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /spring-boot-static-proxy/src/main/java/com/rasitesdmr/springbootstaticproxy/model/User.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootstaticproxy.model; 2 | 3 | import lombok.*; 4 | 5 | import java.util.UUID; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @ToString 12 | public class User { 13 | private UUID id; 14 | private String username; 15 | private String email; 16 | private boolean isSave; 17 | 18 | public User(String username, String email) { 19 | this.username = username; 20 | this.email = email; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /spring-boot-static-proxy/src/main/java/com/rasitesdmr/springbootstaticproxy/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootstaticproxy.repository; 2 | 3 | import com.rasitesdmr.springbootstaticproxy.model.User; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.UUID; 8 | 9 | public class UserRepository { 10 | 11 | private final List createUsers = new ArrayList<>(); 12 | 13 | public User save(User user) { 14 | user.setId(UUID.randomUUID()); 15 | user.setSave(true); 16 | createUsers.add(user); 17 | return user; 18 | } 19 | 20 | public User findById(UUID id) { 21 | return createUsers.stream().filter(user -> user.getId().equals(id)).findFirst().get(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /spring-boot-static-proxy/src/main/java/com/rasitesdmr/springbootstaticproxy/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springbootstaticproxy.service; 2 | 3 | import com.rasitesdmr.springbootstaticproxy.domain.request.UserCreateRequest; 4 | import com.rasitesdmr.springbootstaticproxy.model.User; 5 | 6 | import java.util.UUID; 7 | 8 | public interface UserService { 9 | User saveUser(User user); 10 | User createUser(UserCreateRequest userCreateRequest); 11 | User getUserById(UUID id); 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/README.md -------------------------------------------------------------------------------- /spring-boot-transaction-management/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | 4 | db-container: 5 | container_name: transaction-database 6 | image: postgres:16.2 7 | ports: 8 | - "5432:5432" 9 | restart: always 10 | environment: 11 | POSTGRES_USER: root 12 | POSTGRES_PASSWORD: root 13 | POSTGRES_DB: transaction 14 | networks: 15 | - network 16 | 17 | networks: 18 | network: 19 | driver: bridge 20 | name: postgresql -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs1.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs10.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs11.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs12.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs13.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs14.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs15.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs16.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs17.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs18.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs19.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs2.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs20.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs21.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs22.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs23.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs24.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs25.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs26.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs27.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs28.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs29.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs3.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs30.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs31.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs32.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs33.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs34.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs35.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs36.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs37.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs38.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs39.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs4.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs40.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs41.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs5.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs6.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs7.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs8.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/images/rs9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rasitesdmr/Medium-Projects/e33217a22413e956e5684cb289658a70988e83ae/spring-boot-transaction-management/images/rs9.png -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/SpringBootTransactionManagementApplication.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @SpringBootApplication 8 | @EnableScheduling 9 | public class SpringBootTransactionManagementApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringBootTransactionManagementApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/cart/repository/CartRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.cart.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.cart.Cart; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CartRepository extends JpaRepository { 9 | 10 | Cart findByCustomerId(Long customerId); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/cart/service/CartService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.cart.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.cart.Cart; 4 | 5 | public interface CartService { 6 | 7 | Cart getById(Long id); 8 | Cart getByCustomerId(Long customerId); 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/cartitem/repository/CartItemRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.cartitem.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.cartitem.CartItem; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface CartItemRepository extends JpaRepository { 11 | 12 | List findAllByCartId(Long cartId); 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/cartitem/service/CartItemService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.cartitem.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.cartitem.CartItem; 4 | 5 | import java.util.List; 6 | 7 | public interface CartItemService { 8 | 9 | List getAllByCartId(Long cartId); 10 | void deleteById(Long id); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/customer/Customer.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.customer; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.order.Order; 4 | import jakarta.persistence.*; 5 | import lombok.*; 6 | 7 | import java.util.List; 8 | 9 | @Entity 10 | @Getter 11 | @Setter 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Builder 15 | @Table(name = "customers") 16 | public class Customer { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | private Long id; 21 | private String firstName; 22 | private String lastName; 23 | private String email; 24 | 25 | @OneToMany(mappedBy = "customer") 26 | private List orders; 27 | } 28 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/customer/model/request/CustomerCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.customer.model.request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class CustomerCreateRequest { 9 | private String firstName; 10 | private String lastName; 11 | private String email; 12 | } 13 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/customer/model/response/CustomerResponse.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.customer.model.response; 2 | 3 | import lombok.Builder; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @Builder 10 | public class CustomerResponse { 11 | 12 | private Long id; 13 | private String firstName; 14 | private String lastName; 15 | private String email; 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/customer/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.customer.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.customer.Customer; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface CustomerRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/customer/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.customer.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.customer.Customer; 4 | import com.rasitesdmr.springboottransactionmanagement.customer.model.request.CustomerCreateRequest; 5 | import com.rasitesdmr.springboottransactionmanagement.customer.model.response.CustomerResponse; 6 | 7 | public interface CustomerService { 8 | 9 | void saveCustomer(Customer customer); 10 | CustomerResponse createCustomer(CustomerCreateRequest customerCreateRequest); 11 | Customer getById(Long id); 12 | String getCustomerCardDataById(Long id); 13 | } 14 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/AlreadyAvailableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class AlreadyAvailableException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public AlreadyAvailableException(String message) { 12 | super(message); 13 | this.status = HttpStatus.CONFLICT; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class BadRequestException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public BadRequestException(String message) { 11 | super(message); 12 | this.status = HttpStatus.BAD_REQUEST; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/ForbiddenException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class ForbiddenException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public ForbiddenException(String message) { 11 | super(message); 12 | this.status = HttpStatus.FORBIDDEN; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/InternalServerErrorException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InternalServerErrorException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InternalServerErrorException(String message) { 11 | super(message); 12 | this.status = HttpStatus.INTERNAL_SERVER_ERROR; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/InvalidException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class InvalidException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public InvalidException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_ACCEPTABLE; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/NotAvailableException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class NotAvailableException extends RuntimeException { 8 | private final HttpStatus status; 9 | 10 | public NotAvailableException(String message) { 11 | super(message); 12 | this.status = HttpStatus.NOT_FOUND; 13 | } 14 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/exception/exceptions/UnauthorizedException.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.exception.exceptions; 2 | 3 | import lombok.Getter; 4 | import org.springframework.http.HttpStatus; 5 | 6 | @Getter 7 | public class UnauthorizedException extends RuntimeException { 8 | 9 | private final HttpStatus status; 10 | 11 | public UnauthorizedException(String message) { 12 | super(message); 13 | status = HttpStatus.UNAUTHORIZED; 14 | } 15 | } -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/mail/enums/MailTypeEnum.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.mail.enums; 2 | 3 | public enum MailTypeEnum { 4 | ORDER, 5 | CARGO 6 | } 7 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/mail/service/MailService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.mail.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.mail.enums.MailTypeEnum; 4 | 5 | public interface MailService { 6 | 7 | String sendMail(MailTypeEnum mailTypeEnum, Long orderId); 8 | void sendInvoiceByEmail(String email); 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/order/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.order.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.order.Order; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.Date; 8 | import java.util.List; 9 | 10 | @Repository 11 | public interface OrderRepository extends JpaRepository { 12 | 13 | List findAllByCreatedDateBetween(Date startOfDay , Date endOfDay); 14 | } 15 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/order/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.order.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.customer.Customer; 4 | import com.rasitesdmr.springboottransactionmanagement.order.Order; 5 | import org.aspectj.weaver.ast.Or; 6 | 7 | import java.time.LocalDateTime; 8 | import java.util.List; 9 | 10 | public interface OrderService { 11 | void saveOrder(Order order); 12 | String approveOrder(Long authCustomerId); 13 | Order createOrder(Customer customer); 14 | Order getById(Long id); 15 | List getAllByCreatedDateBetween(); 16 | void logDailyOrderCount(); 17 | } 18 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/orderitem/repository/OrderItemRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.orderitem.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.orderitem.OrderItem; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface OrderItemRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/orderitem/service/OrderItemService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.orderitem.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.cartitem.CartItem; 4 | import com.rasitesdmr.springboottransactionmanagement.order.Order; 5 | import com.rasitesdmr.springboottransactionmanagement.orderitem.OrderItem; 6 | 7 | public interface OrderItemService { 8 | 9 | void saveOrderItem(OrderItem orderItem); 10 | OrderItem createOrderItem(CartItem cartItem, Order order); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/product/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.product.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.product.Product; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface ProductRepository extends JpaRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/product/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.product.service; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.product.Product; 4 | 5 | public interface ProductService { 6 | 7 | void processProductPaymentWithCard(Long customerId); 8 | Product getById(Long id); 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/stock/Stock.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.stock; 2 | import com.rasitesdmr.springboottransactionmanagement.product.Product; 3 | import jakarta.persistence.*; 4 | import lombok.*; 5 | 6 | 7 | @Entity 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | @Builder 13 | @Table(name = "stocks") 14 | public class Stock { 15 | 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Long id; 19 | 20 | private int quantity; 21 | 22 | @OneToOne 23 | @JoinColumn(name = "product_id") 24 | private Product product; 25 | } 26 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/stock/model/request/StockUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.stock.model.request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class StockUpdateRequest { 9 | private Long productId; 10 | private int stockQuantity; 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/stock/model/response/StockUpdateResponse.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.stock.model.response; 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 StockUpdateResponse { 13 | private Long productId; 14 | private int stockQuantity; 15 | private boolean isError; 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/main/java/com/rasitesdmr/springboottransactionmanagement/stock/repository/StockRepository.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement.stock.repository; 2 | 3 | import com.rasitesdmr.springboottransactionmanagement.stock.Stock; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface StockRepository extends JpaRepository { 9 | 10 | Stock findByProductId(Long productId); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-transaction-management/src/test/java/com/rasitesdmr/springboottransactionmanagement/SpringBootTransactionManagementApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.rasitesdmr.springboottransactionmanagement; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringBootTransactionManagementApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------