├── search-service ├── .gitattributes ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── os │ │ │ └── search_service │ │ │ └── SearchServiceApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── os │ │ │ └── search_service │ │ │ ├── dto │ │ │ └── DeleteProductRequest.java │ │ │ ├── SearchServiceApplication.java │ │ │ ├── document │ │ │ └── Product.java │ │ │ ├── service │ │ │ ├── ProductElasticSearchService.java │ │ │ └── impl │ │ │ │ └── ProductElasticSearchServiceImpl.java │ │ │ ├── repository │ │ │ └── ProductElasticSearchRepository.java │ │ │ ├── controller │ │ │ └── ProductElasticSearchController.java │ │ │ └── kafka │ │ │ └── ProductConsumer.java │ │ └── resources │ │ └── application.properties ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── customer-service ├── Task ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── os │ │ │ │ └── customer_service │ │ │ │ ├── exception │ │ │ │ ├── type │ │ │ │ │ ├── EmailAdressInUseException.java │ │ │ │ │ ├── WrongUsernameOrPassword.java │ │ │ │ │ ├── PasswordNotMatchException.java │ │ │ │ │ └── ContactInfoNotFoundException.java │ │ │ │ ├── exceptionMessage │ │ │ │ │ ├── ContactInfoMessage.java │ │ │ │ │ └── UserMessage.java │ │ │ │ └── GlobalExceptionHandler.java │ │ │ │ ├── repository │ │ │ │ ├── RoleRepository.java │ │ │ │ ├── ContactInfoRepository.java │ │ │ │ └── UserRepository.java │ │ │ │ ├── dto │ │ │ │ ├── request │ │ │ │ │ ├── role │ │ │ │ │ │ └── RoleRequest.java │ │ │ │ │ ├── user │ │ │ │ │ │ ├── LoginRequest.java │ │ │ │ │ │ ├── UpdateUserRequest.java │ │ │ │ │ │ └── RegisterRequest.java │ │ │ │ │ └── contactinfo │ │ │ │ │ │ ├── UpdateContactInfoRequest.java │ │ │ │ │ │ └── CreateContactInfoRequest.java │ │ │ │ └── response │ │ │ │ │ ├── user │ │ │ │ │ ├── LoginResponse.java │ │ │ │ │ ├── UpdateUserResponse.java │ │ │ │ │ ├── GetByIdUserResponse.java │ │ │ │ │ └── UserResponse.java │ │ │ │ │ ├── role │ │ │ │ │ └── RoleWithUserResponse.java │ │ │ │ │ └── contactinfo │ │ │ │ │ ├── CreateContactInfoResponse.java │ │ │ │ │ ├── GetAllContactInfoResponse.java │ │ │ │ │ ├── UpdateContactInfoResponse.java │ │ │ │ │ ├── GetByIdContactInfoResponse.java │ │ │ │ │ └── GetByContactInfoWithCustomerIdResponse.java │ │ │ │ ├── service │ │ │ │ ├── RoleService.java │ │ │ │ ├── AuthService.java │ │ │ │ ├── ContactInfoService.java │ │ │ │ ├── UserService.java │ │ │ │ └── impl │ │ │ │ │ ├── RoleServiceImpl.java │ │ │ │ │ └── UserServiceImpl.java │ │ │ │ ├── CustomerServiceApplication.java │ │ │ │ ├── model │ │ │ │ ├── ContactInfo.java │ │ │ │ ├── Role.java │ │ │ │ └── User.java │ │ │ │ ├── mapper │ │ │ │ ├── RoleMapper.java │ │ │ │ ├── UserMapper.java │ │ │ │ └── ContactInfoMapper.java │ │ │ │ ├── controller │ │ │ │ ├── AuthController.java │ │ │ │ ├── UserController.java │ │ │ │ ├── RoleController.java │ │ │ │ └── ContactInfoController.java │ │ │ │ └── config │ │ │ │ └── SecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── os │ │ └── customer_service │ │ └── CustomerServiceApplicationTests.java ├── .gitignore └── .mvn │ └── wrapper │ └── maven-wrapper.properties ├── .idea ├── vcs.xml ├── .gitignore ├── modules.xml ├── material_theme_project_new.xml ├── jarRepositories.xml ├── encodings.xml ├── misc.xml └── compiler.xml ├── config-server ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── gezi_rehberim │ │ │ └── config_server │ │ │ └── ConfigServerApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── gezi_rehberim │ │ └── config_server │ │ └── ConfigServerApplicationTests.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── product-service ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── os │ │ │ │ └── product_service │ │ │ │ ├── utils │ │ │ │ └── message │ │ │ │ │ ├── CategoryMessage.java │ │ │ │ │ └── ProductMessage.java │ │ │ │ ├── service │ │ │ │ ├── CustomerService.java │ │ │ │ ├── impl │ │ │ │ │ ├── CustomerServiceImpl.java │ │ │ │ │ └── CategoryServiceImpl.java │ │ │ │ ├── CategoryService.java │ │ │ │ └── ProductService.java │ │ │ │ ├── exception │ │ │ │ ├── type │ │ │ │ │ ├── CategoryNotFoundException.java │ │ │ │ │ └── ProductNotFoundException.java │ │ │ │ ├── error │ │ │ │ │ └── ApiError.java │ │ │ │ └── GlobalExceptionHandler.java │ │ │ │ ├── repository │ │ │ │ ├── CategoryRepository.java │ │ │ │ ├── CustomerRepository.java │ │ │ │ └── ProductRepository.java │ │ │ │ ├── dto │ │ │ │ ├── request │ │ │ │ │ ├── category │ │ │ │ │ │ ├── UpdateCategoryRequest.java │ │ │ │ │ │ └── CreateCategoryRequest.java │ │ │ │ │ └── product │ │ │ │ │ │ ├── DeleteProductRequest.java │ │ │ │ │ │ ├── CreateProductRequest.java │ │ │ │ │ │ └── UpdateProductRequest.java │ │ │ │ └── response │ │ │ │ │ ├── category │ │ │ │ │ ├── CreateCategoryResponse.java │ │ │ │ │ ├── UpdateCategoryResponse.java │ │ │ │ │ ├── GetAllCategoryResponse.java │ │ │ │ │ └── GetByIdCategoryResponse.java │ │ │ │ │ └── product │ │ │ │ │ ├── CreateProductResponse.java │ │ │ │ │ ├── UpdateProductResponse.java │ │ │ │ │ ├── GetByCategoryIdWithProductResponse.java │ │ │ │ │ ├── GetAllProductResponse.java │ │ │ │ │ └── GetByIdProductResponse.java │ │ │ │ ├── ProductServiceApplication.java │ │ │ │ ├── model │ │ │ │ ├── Category.java │ │ │ │ ├── Customer.java │ │ │ │ └── Product.java │ │ │ │ ├── config │ │ │ │ ├── WebConfig.java │ │ │ │ └── SearchServiceProducerConfig.java │ │ │ │ ├── mapper │ │ │ │ ├── CategoryMapping.java │ │ │ │ └── ProductMapping.java │ │ │ │ ├── aop │ │ │ │ └── PerformanceAspect.java │ │ │ │ ├── controller │ │ │ │ ├── CustomerController.java │ │ │ │ ├── CategoryController.java │ │ │ │ └── ProductController.java │ │ │ │ └── kafka │ │ │ │ └── SearchServiceProducer.java │ │ └── resources │ │ │ ├── prometheus.yml │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── os │ │ └── product_service │ │ └── ProductServiceApplicationTests.java ├── .gitignore └── .mvn │ └── wrapper │ └── maven-wrapper.properties ├── payment-service ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── os │ │ │ │ └── payment_service │ │ │ │ ├── utils │ │ │ │ └── message │ │ │ │ │ └── ContactInfosMessage.java │ │ │ │ ├── service │ │ │ │ └── PaymentService.java │ │ │ │ ├── exception │ │ │ │ ├── type │ │ │ │ │ └── ContactInfosNotFoundException.java │ │ │ │ ├── error │ │ │ │ │ └── ApiError.java │ │ │ │ └── GlobalExceptionHandler.java │ │ │ │ ├── model │ │ │ │ ├── OrderItem.java │ │ │ │ ├── Customer.java │ │ │ │ ├── PaymentRequest.java │ │ │ │ ├── ProductDto.java │ │ │ │ ├── ProductNotification.java │ │ │ │ ├── CustomerContactInfo.java │ │ │ │ ├── Order.java │ │ │ │ └── Notification.java │ │ │ │ ├── client │ │ │ │ ├── BasketClient.java │ │ │ │ ├── OrderClient.java │ │ │ │ └── CustomerClient.java │ │ │ │ ├── PaymentServiceApplication.java │ │ │ │ ├── kafka │ │ │ │ └── NotificationProducer.java │ │ │ │ ├── controller │ │ │ │ └── PaymentController.java │ │ │ │ └── config │ │ │ │ ├── SecuirtyConfig.java │ │ │ │ ├── FeignClientConfig.java │ │ │ │ ├── KafkaProducerConfig.java │ │ │ │ └── SwaggerConfig.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── os │ │ └── payment_service │ │ └── PaymentServiceApplicationTests.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── iyzicoimpl.iml ├── order-service ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── os │ │ │ └── order_service │ │ │ └── OrderServiceApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── os │ │ │ └── order_service │ │ │ ├── model │ │ │ ├── CustomerDto.java │ │ │ ├── BasketItem.java │ │ │ ├── Basket.java │ │ │ ├── ProductDto.java │ │ │ └── Order.java │ │ │ ├── repository │ │ │ └── OrderRepository.java │ │ │ ├── service │ │ │ ├── OrderService.java │ │ │ └── impl │ │ │ │ └── OrderServiceImpl.java │ │ │ ├── client │ │ │ ├── CustomerClient.java │ │ │ └── BasketClient.java │ │ │ ├── OrderServiceApplication.java │ │ │ ├── config │ │ │ ├── SecuirtyConfig.java │ │ │ ├── FeignClientConfig.java │ │ │ └── SwaggerConfig.java │ │ │ └── controller │ │ │ └── OrderController.java │ │ └── resources │ │ └── application.properties ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── basket-service ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── os │ │ │ └── basket_service │ │ │ └── BasketServiceApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── os │ │ │ └── basket_service │ │ │ ├── repository │ │ │ └── BasketRepository.java │ │ │ ├── model │ │ │ ├── CustomerDto.java │ │ │ ├── BasketItem.java │ │ │ ├── ProductDto.java │ │ │ └── Basket.java │ │ │ ├── service │ │ │ └── BasketService.java │ │ │ ├── client │ │ │ ├── CustomerClient.java │ │ │ └── ProductClient.java │ │ │ ├── BasketServiceApplication.java │ │ │ ├── config │ │ │ ├── SecuirtyConfig.java │ │ │ ├── FeignClientConfig.java │ │ │ └── SwaggerConfig.java │ │ │ └── controller │ │ │ └── BasketController.java │ │ └── resources │ │ └── application.properties ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── discovery-server ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── gezi_rehberim │ │ │ └── discovery_server │ │ │ └── DiscoveryServerApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── com │ │ └── gezi_rehberim │ │ └── discovery_server │ │ └── DiscoveryServerApplication.java ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml ├── notification-service ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── os │ │ │ └── notification_service │ │ │ └── NotificationServiceApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── os │ │ │ └── notification_service │ │ │ ├── service │ │ │ ├── OrderNotificationService.java │ │ │ └── impl │ │ │ │ └── OrderNotificationServiceImpl.java │ │ │ ├── NotificationServiceApplication.java │ │ │ ├── model │ │ │ ├── ProductNotification.java │ │ │ └── OrderNotification.java │ │ │ ├── kafka │ │ │ └── PaymentConsumer.java │ │ │ └── config │ │ │ └── KafkaConsumerConfig.java │ │ └── resources │ │ └── application.properties ├── .gitignore ├── .mvn │ └── wrapper │ │ └── maven-wrapper.properties └── pom.xml └── docker-compose.yaml /search-service/.gitattributes: -------------------------------------------------------------------------------- 1 | /mvnw text eol=lf 2 | *.cmd text eol=crlf 3 | -------------------------------------------------------------------------------- /customer-service/Task: -------------------------------------------------------------------------------- 1 | -- Exception 2 | - User, ContactInfo exception tanımlamaları. 3 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /config-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=config-server 2 | spring.cloud.config.server.git.uri=https://github.com/oguzhansecgel/iyzico-JavaSpringBoot-ConfigServer 3 | 4 | server.port=8079 5 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/utils/message/CategoryMessage.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.utils.message; 2 | 3 | public class CategoryMessage { 4 | public static final String CATEGORY_NOT_FOUND="Category Not Found"; 5 | } 6 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/utils/message/ProductMessage.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.utils.message; 2 | 3 | public class ProductMessage { 4 | public static final String PRODUCT_NOT_FOUND = "Product Not Found"; 5 | 6 | 7 | } 8 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/utils/message/ContactInfosMessage.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.utils.message; 2 | 3 | public class ContactInfosMessage { 4 | public static final String CONTACT_INFOS_NOT_FOUND="Contact Infos Not Found"; 5 | } 6 | -------------------------------------------------------------------------------- /product-service/src/main/resources/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 15s 3 | 4 | scrape_configs: 5 | - job_name: 'spring-actuator' 6 | metrics_path: '/actuator/prometheus' 7 | scrape_interval: 5s 8 | static_configs: 9 | - targets: ['localhost:8082'] -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/service/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.service; 2 | 3 | import com.os.payment_service.model.PaymentRequest; 4 | 5 | public interface PaymentService { 6 | String makePayment(String orderId,PaymentRequest paymentRequest); 7 | 8 | } 9 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/service/CustomerService.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.service; 2 | 3 | import com.os.product_service.model.Customer; 4 | 5 | public interface CustomerService { 6 | Customer addCustomer(Customer customer); 7 | Customer getCustomerById(Long id); 8 | } 9 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/exception/type/CategoryNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.exception.type; 2 | 3 | public class CategoryNotFoundException extends RuntimeException { 4 | public CategoryNotFoundException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/exception/type/ProductNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.exception.type; 2 | 3 | public class ProductNotFoundException extends RuntimeException { 4 | public ProductNotFoundException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/type/EmailAdressInUseException.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception.type; 2 | 3 | public class EmailAdressInUseException extends RuntimeException{ 4 | public EmailAdressInUseException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/repository/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.repository; 2 | 3 | import com.os.customer_service.model.Role; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface RoleRepository extends JpaRepository { 7 | } -------------------------------------------------------------------------------- /iyzicoimpl.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/exception/type/ContactInfosNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.exception.type; 2 | 3 | public class ContactInfosNotFoundException extends RuntimeException { 4 | public ContactInfosNotFoundException(String message) { 5 | super(message); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/repository/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.repository; 2 | 3 | import com.os.product_service.model.Category; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | public interface CategoryRepository extends JpaRepository { 7 | } 8 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/exceptionMessage/ContactInfoMessage.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception.exceptionMessage; 2 | 3 | public class ContactInfoMessage { 4 | 5 | public static final String CONTACT_INFO_NOT_FOUND ="Contact not found"; 6 | 7 | private ContactInfoMessage() { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /order-service/src/test/java/com/os/order_service/OrderServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.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 | -------------------------------------------------------------------------------- /basket-service/src/test/java/com/os/basket_service/BasketServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BasketServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /search-service/src/test/java/com/os/search_service/SearchServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SearchServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /payment-service/src/test/java/com/os/payment_service/PaymentServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class PaymentServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /product-service/src/test/java/com/os/product_service/ProductServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ProductServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /customer-service/src/test/java/com/os/customer_service/CustomerServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class CustomerServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /config-server/src/test/java/com/gezi_rehberim/config_server/ConfigServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.gezi_rehberim.config_server; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ConfigServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /discovery-server/src/test/java/com/gezi_rehberim/discovery_server/DiscoveryServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.gezi_rehberim.discovery_server; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class DiscoveryServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /notification-service/src/test/java/com/os/notification_service/NotificationServiceApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class NotificationServiceApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /discovery-server/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=discovery-server 2 | 3 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 4 | eureka.client.register-with-eureka=false 5 | eureka.client.fetch-registry=false 6 | 7 | spring.cloud.config.profile=local 8 | spring.config.import=configserver:${configurl} 9 | configurl= http://localhost:8079 10 | 11 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/service/OrderNotificationService.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service.service; 2 | 3 | import com.os.notification_service.model.OrderNotification; 4 | 5 | import javax.management.Notification; 6 | 7 | public interface OrderNotificationService { 8 | 9 | void sendOrderCompletedEmail(OrderNotification notification); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/type/WrongUsernameOrPassword.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception.type; 2 | 3 | 4 | import org.springframework.security.core.AuthenticationException; 5 | 6 | public class WrongUsernameOrPassword extends AuthenticationException { 7 | 8 | public WrongUsernameOrPassword(String msg) { 9 | super(msg); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/dto/DeleteProductRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.dto; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class DeleteProductRequest { 13 | private Long id; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/repository/CustomerRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.repository; 2 | 3 | import com.os.product_service.model.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 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/request/role/RoleRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.request.role; 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 RoleRequest { 13 | private String name; 14 | } 15 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/type/PasswordNotMatchException.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception.type; 2 | 3 | import org.turkcell.tcell.exception.exceptions.type.BaseBusinessException; 4 | 5 | public class PasswordNotMatchException extends BaseBusinessException { 6 | public PasswordNotMatchException(String message) { 7 | super(message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/type/ContactInfoNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception.type; 2 | 3 | import org.turkcell.tcell.exception.exceptions.type.BaseBusinessException; 4 | 5 | public class ContactInfoNotFoundException extends BaseBusinessException { 6 | public ContactInfoNotFoundException(String message) { 7 | super(message); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/request/category/UpdateCategoryRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.request.category; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class UpdateCategoryRequest { 12 | private String name; 13 | } 14 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/repository/BasketRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.repository; 2 | 3 | import com.os.basket_service.model.Basket; 4 | import com.os.basket_service.model.BasketItem; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | 7 | public interface BasketRepository extends MongoRepository { 8 | Basket findByCustomerId(Long customerId); 9 | } 10 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/user/LoginResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.user; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class LoginResponse { 13 | private Long id; 14 | private String token; 15 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/request/product/DeleteProductRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.request.product; 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 DeleteProductRequest { 13 | 14 | private Long id; 15 | } 16 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/request/user/LoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.request.user; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class LoginRequest { 13 | 14 | private String email; 15 | private String password; 16 | } -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/repository/ContactInfoRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.repository; 2 | 3 | import com.os.customer_service.model.ContactInfo; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | 6 | import java.util.List; 7 | 8 | public interface ContactInfoRepository extends JpaRepository { 9 | List findByCustomerId(Long contactId); 10 | } 11 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/model/CustomerDto.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CustomerDto { 13 | private Object id; 14 | private String firstName; 15 | private String lastName; 16 | } 17 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/role/RoleWithUserResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.role; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class RoleWithUserResponse { 13 | private Long userId; 14 | 15 | private Long roleId; 16 | } -------------------------------------------------------------------------------- /order-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=order-service 2 | spring.data.mongodb.uri=mongodb://localhost:27017/iyzico-orderdb 3 | 4 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 5 | eureka.client.register-with-eureka=true 6 | eureka.client.fetch-registry=true 7 | 8 | spring.cloud.config.profile=local 9 | spring.config.import=configserver:${configurl} 10 | configurl= http://localhost:8079 11 | 12 | 13 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/repository/OrderRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.repository; 2 | 3 | import com.os.order_service.model.CustomerDto; 4 | import com.os.order_service.model.Order; 5 | import org.springframework.data.mongodb.repository.MongoRepository; 6 | 7 | import java.util.List; 8 | 9 | public interface OrderRepository extends MongoRepository { 10 | List findByCustomerId(Long customerId); 11 | } 12 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/category/CreateCategoryResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.category; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CreateCategoryResponse { 13 | private Long id; 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/category/UpdateCategoryResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.category; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdateCategoryResponse { 13 | private Long id; 14 | private String name; 15 | } 16 | -------------------------------------------------------------------------------- /.idea/material_theme_project_new.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/NotificationServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class NotificationServiceApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(NotificationServiceApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/model/BasketItem.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class BasketItem { 15 | private ProductDto product; 16 | private int quantity; 17 | private BigDecimal totalPrice; 18 | } 19 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/repository/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.repository; 2 | 3 | import com.os.product_service.model.Product; 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 ProductRepository extends JpaRepository { 11 | List findByCategoryId(Long categoryId); 12 | } 13 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/exceptionMessage/UserMessage.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception.exceptionMessage; 2 | 3 | public class UserMessage { 4 | 5 | public static final String PASSWORD_NOT_MATCH = "password not match"; 6 | public static final String WRONG_USER_NAME_PASSWORD = "wrong user name password"; 7 | public static final String EMAIL_ADDRESS_IN_USE = "Email address is in use"; 8 | private UserMessage() { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/OrderItem.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class OrderItem { 15 | private ProductDto product; 16 | private int quantity; 17 | private BigDecimal totalPrice; 18 | } 19 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/request/category/CreateCategoryRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.request.category; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.io.Serializable; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class CreateCategoryRequest implements Serializable { 15 | private String name; 16 | } 17 | -------------------------------------------------------------------------------- /payment-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=payment-service 2 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 3 | eureka.client.register-with-eureka=true 4 | eureka.client.fetch-registry=true 5 | 6 | spring.kafka.bootstrap-servers=localhost:9092 7 | spring.kafka.template.default-topic=notification-topic 8 | 9 | 10 | spring.cloud.config.profile=local 11 | spring.config.import=configserver:${configurl} 12 | configurl= http://localhost:8079 13 | 14 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/model/CustomerDto.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.io.Serializable; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class CustomerDto implements Serializable { 15 | private int id; 16 | private String firstName; 17 | private String lastName; 18 | } 19 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.repository; 2 | 3 | import com.os.customer_service.model.User; 4 | import org.springframework.data.jpa.repository.JpaRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.Optional; 8 | 9 | @Repository 10 | public interface UserRepository extends JpaRepository { 11 | Optional findByEmail(String email); 12 | Optional findById(Long id); 13 | } -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.service; 2 | 3 | import com.os.customer_service.dto.request.role.RoleRequest; 4 | import com.os.customer_service.model.Role; 5 | 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | public interface RoleService { 10 | 11 | Role addRole(RoleRequest request); 12 | 13 | void deleteRole(Long id); 14 | 15 | Optional getRoleById(Long id); 16 | 17 | List getAllRoles(); 18 | } -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.service; 2 | 3 | import com.os.order_service.model.CustomerDto; 4 | import com.os.order_service.model.Order; 5 | 6 | import java.util.List; 7 | import java.util.Optional; 8 | 9 | public interface OrderService { 10 | Order createOrder(String basketId); 11 | List getAllOrder(); 12 | Optional getByIdOrder(String orderId); 13 | List getOrderHistoryForCustomer(Long customerId); 14 | } 15 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/Customer.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class Customer { 13 | private Long id; 14 | private String email; 15 | private String firstName; 16 | private String lastName; 17 | private CustomerContactInfo contactInfo; 18 | } 19 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/PaymentRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | @Getter 7 | @Setter 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class PaymentRequest { 11 | private String cardHolderName; 12 | private String cardNumber; 13 | private String expireMonth; 14 | private String expireYear; 15 | private String cvc; 16 | } 17 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/category/GetAllCategoryResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.category; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class GetAllCategoryResponse implements Serializable { 15 | private Long id; 16 | private String name; 17 | } 18 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/category/GetByIdCategoryResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.category; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class GetByIdCategoryResponse implements Serializable { 15 | private Long id; 16 | private String name; 17 | } 18 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.service; 2 | 3 | import com.os.customer_service.dto.request.user.LoginRequest; 4 | import com.os.customer_service.dto.request.user.RegisterRequest; 5 | import com.os.customer_service.dto.response.user.LoginResponse; 6 | import jakarta.servlet.http.HttpSession; 7 | 8 | public interface AuthService { 9 | void register(RegisterRequest request); 10 | 11 | LoginResponse login(LoginRequest loginRequest, HttpSession session); 12 | } -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | prometheus: 4 | image: prom/prometheus 5 | container_name: prometheus 6 | volumes: 7 | - ./product-service/src/main/resources/prometheus.yml:/etc/prometheus/prometheus.yml 8 | ports: 9 | - "9090:9090" 10 | networks: 11 | - monitoring 12 | grafana: 13 | image: grafana/grafana 14 | container_name: grafana 15 | ports: 16 | - "3000:3000" 17 | networks: 18 | - monitoring 19 | 20 | networks: 21 | monitoring: 22 | driver: bridge 23 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/ProductServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | 7 | @SpringBootApplication 8 | @EnableCaching 9 | public class ProductServiceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ProductServiceApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/model/Basket.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class Basket { 16 | private String id; 17 | private CustomerDto customer; 18 | private List items; 19 | private BigDecimal totalPrice; 20 | } -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/model/ProductDto.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class ProductDto { 15 | private Long id; 16 | private String name; 17 | private String description; 18 | private BigDecimal price; 19 | private Long categoryId; 20 | } 21 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/model/BasketItem.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.io.Serializable; 9 | import java.math.BigDecimal; 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class BasketItem implements Serializable { 15 | private ProductDto product; 16 | private int quantity; 17 | private BigDecimal totalPrice; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /basket-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=basket-service 2 | spring.data.mongodb.uri=mongodb://localhost:27017/iyzico-basketdb 3 | 4 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 5 | eureka.client.register-with-eureka=true 6 | eureka.client.fetch-registry=true 7 | 8 | spring.cloud.config.profile=local 9 | spring.config.import=configserver:${configurl} 10 | configurl= http://localhost:8079 11 | 12 | spring.cache.type=redis 13 | spring.data.redis.host=localhost 14 | spring.data.redis.port=6379 15 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/client/BasketClient.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.client; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.web.bind.annotation.DeleteMapping; 5 | import org.springframework.web.bind.annotation.PathVariable; 6 | 7 | @FeignClient("basket-service") 8 | public interface BasketClient { 9 | 10 | @DeleteMapping("/api/v1/basket/delete/basket/beforeOrder/{basketId}") 11 | void deleteBasketBeforeOrder(@PathVariable("basketId") String basketId); 12 | } 13 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/ProductDto.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class ProductDto { 15 | private Long id; 16 | private String name; 17 | private String description; 18 | private BigDecimal price; 19 | private Long categoryId; 20 | } 21 | -------------------------------------------------------------------------------- /basket-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 | -------------------------------------------------------------------------------- /config-server/.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 | -------------------------------------------------------------------------------- /config-server/src/main/java/com/gezi_rehberim/config_server/ConfigServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.gezi_rehberim.config_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | 7 | @SpringBootApplication 8 | @EnableConfigServer 9 | public class ConfigServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(ConfigServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /customer-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 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/user/UpdateUserResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.user; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdateUserResponse { 13 | private Long id; 14 | private String password; 15 | private String passwordRepeat; 16 | private String firstName; 17 | private String lastName; 18 | } 19 | -------------------------------------------------------------------------------- /discovery-server/.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /payment-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 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/client/OrderClient.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.client; 2 | 3 | import com.os.payment_service.model.Order; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | 9 | @FeignClient("order-service") 10 | public interface OrderClient { 11 | 12 | @GetMapping("/api/v1/order/getById/orders/{orderId}") 13 | Order getByIdOrder(@PathVariable String orderId); 14 | } 15 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/ProductNotification.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class ProductNotification { 15 | private Long id; 16 | private String name; 17 | private String description; 18 | private BigDecimal price; 19 | private int quantity; 20 | } -------------------------------------------------------------------------------- /product-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 | -------------------------------------------------------------------------------- /search-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 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/service/BasketService.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.service; 2 | 3 | import com.os.basket_service.model.Basket; 4 | 5 | import java.util.Map; 6 | import java.util.Optional; 7 | 8 | public interface BasketService { 9 | Basket createBasketItem(Long customerId, Map productQuantities); 10 | Basket productController(Long productId); 11 | Basket findByCustomersBasket(Long customerId); 12 | Optional findByBasketId(String basketId); 13 | void deleteBasket(String basketId); 14 | } 15 | -------------------------------------------------------------------------------- /notification-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 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/request/product/CreateProductRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.request.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class CreateProductRequest { 14 | private String name; 15 | private String description; 16 | private BigDecimal price; 17 | private Long categoryId; 18 | } 19 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/request/product/UpdateProductRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.request.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class UpdateProductRequest { 14 | private String name; 15 | private String description; 16 | private BigDecimal price; 17 | private Long categoryId; 18 | } 19 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/model/ProductNotification.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service.model; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class ProductNotification { 14 | private Long id; 15 | private String name; 16 | private String description; 17 | private BigDecimal price; 18 | private int quantity; 19 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/exception/error/ApiError.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.exception.error; 2 | 3 | public class ApiError { 4 | private String message; 5 | private String path; 6 | 7 | public String getMessage() { 8 | return message; 9 | } 10 | 11 | public void setMessage(String message) { 12 | this.message = message; 13 | } 14 | 15 | public String getPath() { 16 | return path; 17 | } 18 | 19 | public void setPath(String path) { 20 | this.path = path; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/exception/error/ApiError.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.exception.error; 2 | 3 | public class ApiError { 4 | 5 | private String path; 6 | private String message; 7 | 8 | public String getPath() { 9 | return path; 10 | } 11 | 12 | public void setPath(String path) { 13 | this.path = path; 14 | } 15 | 16 | public String getMessage() { 17 | return message; 18 | } 19 | 20 | public void setMessage(String message) { 21 | this.message = message; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /discovery-server/src/main/java/com/gezi_rehberim/discovery_server/DiscoveryServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.gezi_rehberim.discovery_server; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class DiscoveryServerApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(DiscoveryServerApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/SearchServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; 6 | 7 | @SpringBootApplication 8 | @EnableElasticsearchRepositories 9 | public class SearchServiceApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SearchServiceApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/client/CustomerClient.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.client; 2 | 3 | import com.os.basket_service.model.CustomerDto; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | import java.util.Optional; 9 | 10 | @FeignClient("customer-service") 11 | public interface CustomerClient { 12 | @GetMapping("/api/v1/users/getByIdUser/{id}") 13 | Optional getByIdUser(@PathVariable Long id); 14 | } 15 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/CustomerContactInfo.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | @Getter 9 | @Setter 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CustomerContactInfo { 13 | private Long id; 14 | private String gsmNumber; 15 | private String identityNumber; 16 | private String address; 17 | private String city; 18 | private String country; 19 | private String zipCode; 20 | } 21 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/client/ProductClient.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.client; 2 | 3 | import com.os.basket_service.model.ProductDto; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | import java.util.Optional; 9 | 10 | @FeignClient("product-service") 11 | public interface ProductClient { 12 | @GetMapping("/api/v1/product/getById/product/{id}") 13 | Optional getProductById(@PathVariable Long id); 14 | } 15 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/client/CustomerClient.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.client; 2 | 3 | import com.os.order_service.model.CustomerDto; 4 | import org.springframework.cloud.openfeign.FeignClient; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PathVariable; 7 | 8 | import java.util.Optional; 9 | 10 | @FeignClient(name = "customer-service") 11 | public interface CustomerClient { 12 | @GetMapping("/api/v1/users/getByIdUser/{id}") 13 | Optional getByIdUser(@PathVariable Long id); 14 | } 15 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/product/CreateProductResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class CreateProductResponse { 15 | private Long id; 16 | private String name; 17 | private String description; 18 | private BigDecimal price; 19 | private Long categoryId; 20 | } 21 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/product/UpdateProductResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class UpdateProductResponse { 15 | private Long id; 16 | private String name; 17 | private String description; 18 | private BigDecimal price; 19 | private Long categoryId; 20 | } 21 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/model/ProductDto.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.io.Serializable; 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class ProductDto implements Serializable { 16 | private Long id; 17 | private String name; 18 | private String description; 19 | private BigDecimal price; 20 | private Long categoryId; 21 | } 22 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/user/GetByIdUserResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.user; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class GetByIdUserResponse { 14 | private int id; 15 | private String password; 16 | private String passwordRepeat; 17 | private String email; 18 | private String firstName; 19 | private String lastName; 20 | private int roleId; 21 | } -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/OrderServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service; 2 | 3 | import com.turkcell.tcell.core.annotations.EnableSecurity; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableFeignClients 10 | @EnableSecurity 11 | public class OrderServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(OrderServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/PaymentServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service; 2 | 3 | import com.turkcell.tcell.core.annotations.EnableSecurity; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.openfeign.EnableFeignClients; 7 | 8 | @SpringBootApplication 9 | @EnableFeignClients 10 | @EnableSecurity 11 | public class PaymentServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(PaymentServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/Order.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import javax.persistence.Id; 9 | import java.math.BigDecimal; 10 | import java.util.List; 11 | 12 | @Getter 13 | @Setter 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class Order { 17 | @Id 18 | private String id; 19 | private List items; 20 | private BigDecimal totalPrice; 21 | private Customer customer; 22 | private String basketId; 23 | } 24 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/product/GetByCategoryIdWithProductResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class GetByCategoryIdWithProductResponse { 15 | private Long id; 16 | private String name; 17 | private String description; 18 | private BigDecimal price; 19 | private Long categoryId; 20 | } 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/CustomerServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service; 2 | 3 | import com.turkcell.tcell.core.annotations.EnableSecurity; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.turkcell.tcell.exception.annotations.EnableException; 7 | 8 | @SpringBootApplication 9 | @EnableSecurity 10 | @EnableException 11 | public class CustomerServiceApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(CustomerServiceApplication.class, args); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/user/UserResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.user; 2 | 3 | import jakarta.persistence.Column; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class UserResponse { 14 | private int id; 15 | private String password; 16 | private String passwordRepeat; 17 | private String email; 18 | private String firstName; 19 | private String lastName; 20 | private int roleId; 21 | } -------------------------------------------------------------------------------- /notification-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=notification-service 2 | 3 | spring.kafka.bootstrap-servers=localhost:9092 4 | spring.kafka.consumer.group-id=kafka-group 5 | spring.kafka.template.default-topic=notification-topic 6 | 7 | 8 | spring.mail.host=smtp.gmail.com 9 | spring.mail.properties.mail.smtp.auth=true 10 | spring.mail.properties.mail.smtp.starttls.enable=true 11 | spring.mail.username=mail 12 | spring.mail.password=password 13 | spring.mail.port=587 14 | 15 | spring.cloud.config.profile=local 16 | spring.config.import=configserver:${configurl} 17 | configurl= http://localhost:8079 18 | 19 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/model/Notification.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class Notification { 16 | private Long id; 17 | private String email; 18 | private String firstName; 19 | private String lastName; 20 | private BigDecimal totalPrice; 21 | private List products; 22 | } 23 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/product/GetAllProductResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | import java.math.BigDecimal; 9 | 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class GetAllProductResponse implements Serializable { 16 | private Long id; 17 | private String name; 18 | private String description; 19 | private BigDecimal price; 20 | private Long categoryId; 21 | } 22 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/dto/response/product/GetByIdProductResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.dto.response.product; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import java.io.Serializable; 8 | import java.math.BigDecimal; 9 | 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class GetByIdProductResponse implements Serializable { 16 | private Long id; 17 | private String name; 18 | private String description; 19 | private BigDecimal price; 20 | private Long categoryId; 21 | } 22 | -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/document/Product.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.document; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | import org.springframework.data.elasticsearch.annotations.Document; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Document(indexName = "products") 16 | public class Product { 17 | private String id; 18 | private String name; 19 | private String description; 20 | private BigDecimal price; 21 | private Long categoryId; 22 | } 23 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/model/OrderNotification.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class OrderNotification { 16 | private Long id; 17 | private String email; 18 | private String firstName; 19 | private String lastName; 20 | private BigDecimal totalPrice; 21 | private List products; 22 | } 23 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/contactinfo/CreateContactInfoResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.contactinfo; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class CreateContactInfoResponse { 12 | private Long id; 13 | private String gsmNumber; 14 | private String identityNumber; 15 | private String address; 16 | private String city; 17 | private String country; 18 | private String zipCode; 19 | private Long customerId; 20 | } 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/contactinfo/GetAllContactInfoResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.contactinfo; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class GetAllContactInfoResponse { 12 | private Long id; 13 | private String gsmNumber; 14 | private String identityNumber; 15 | private String address; 16 | private String city; 17 | private String country; 18 | private String zipCode; 19 | private Long customerId; 20 | } 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/contactinfo/UpdateContactInfoResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.contactinfo; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class UpdateContactInfoResponse { 12 | private Long id; 13 | private String gsmNumber; 14 | private String identityNumber; 15 | private String address; 16 | private String city; 17 | private String country; 18 | private String zipCode; 19 | private Long customerId; 20 | } 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/contactinfo/GetByIdContactInfoResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.contactinfo; 2 | import lombok.AllArgsConstructor; 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | public class GetByIdContactInfoResponse { 12 | private Long id; 13 | private String gsmNumber; 14 | private String identityNumber; 15 | private String address; 16 | private String city; 17 | private String country; 18 | private String zipCode; 19 | private Long customerId; 20 | } 21 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/BasketServiceApplication.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service; 2 | 3 | import com.os.spring_security.annotations.EnableSecurity; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cache.annotation.EnableCaching; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | 9 | @SpringBootApplication 10 | @EnableFeignClients 11 | @EnableSecurity 12 | @EnableCaching 13 | public class BasketServiceApplication { 14 | 15 | public static void main(String[] args) { 16 | SpringApplication.run(BasketServiceApplication.class, args); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/model/Category.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | import java.util.List; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Table(name = "category") 16 | @Entity 17 | public class Category { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | private String name; 23 | 24 | @OneToMany(mappedBy = "category", cascade = CascadeType.ALL, fetch = FetchType.LAZY) 25 | private List products; 26 | } 27 | -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/service/ProductElasticSearchService.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.service; 2 | 3 | import com.os.search_service.document.Product; 4 | 5 | import java.math.BigDecimal; 6 | import java.util.List; 7 | 8 | public interface ProductElasticSearchService { 9 | Product saveProduct(Product product); 10 | Iterable getAllProducts(); 11 | List searchProductByName(String productName); 12 | List findByProductPriceBetween(BigDecimal low, BigDecimal high); 13 | void deleteProduct(String id); 14 | Product updateProduct(Product product); 15 | List findAllByProductByPriceAsc(); 16 | List findAllByProductByPriceDesc(); 17 | } 18 | -------------------------------------------------------------------------------- /search-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=search-service 2 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 3 | eureka.client.register-with-eureka=true 4 | eureka.client.fetch-registry=true 5 | 6 | spring.kafka.bootstrap-servers=localhost:9092 7 | spring.kafka.consumer.group-id=kafka-group 8 | spring.kafka.template.product-topic=product-save-topic 9 | spring.kafka.template.product-delete-topic=product-delete-topic 10 | spring.kafka.template.product-update-topic=product-update-topic 11 | 12 | spring.elasticsearch.uris=http://localhost:9200 13 | 14 | 15 | 16 | spring.cloud.config.profile=local 17 | spring.config.import=configserver:${configurl} 18 | configurl= http://localhost:8079 19 | 20 | 21 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | @Configuration 7 | public class WebConfig implements WebMvcConfigurer { 8 | 9 | @Override 10 | public void addCorsMappings(CorsRegistry registry) { 11 | registry.addMapping("/api/**") 12 | .allowedOrigins("http://localhost:3000") 13 | .allowedMethods("GET", "POST", "PUT", "DELETE") 14 | .allowedHeaders("*") 15 | .allowCredentials(true); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/response/contactinfo/GetByContactInfoWithCustomerIdResponse.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.response.contactinfo; 2 | 3 | import com.os.customer_service.dto.response.user.UserResponse; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class GetByContactInfoWithCustomerIdResponse { 14 | private Long id; 15 | private String gsmNumber; 16 | private String identityNumber; 17 | private String address; 18 | private String city; 19 | private String country; 20 | private String zipCode; 21 | private Long customerId; 22 | } 23 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/model/Order.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | import java.math.BigDecimal; 11 | import java.util.List; 12 | 13 | @Getter 14 | @Setter 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @Document(collection = "orders") 18 | public class Order { 19 | @Id 20 | private String id; 21 | private CustomerDto customer; 22 | private List items; 23 | private BigDecimal totalPrice; 24 | private String status; 25 | private String basketId; 26 | } 27 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/model/Customer.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @Table(name = "customers") 14 | @Entity 15 | public class Customer { 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private int id; 19 | private String name; 20 | private String surname; 21 | private String gsmNumber; 22 | private String email; 23 | private String identityNumber; 24 | private String address; 25 | private String city; 26 | private String country; 27 | } 28 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/client/CustomerClient.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.client; 2 | 3 | import com.os.payment_service.model.Customer; 4 | import com.os.payment_service.model.CustomerContactInfo; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | import java.util.List; 10 | 11 | @FeignClient("customer-service") 12 | public interface CustomerClient { 13 | @GetMapping("/api/v1/users/getByIdUser/{id}") 14 | Customer getByIdUser(@PathVariable Long id); 15 | @GetMapping("/api/v1/contactInfo/customer/{customerId}") 16 | List getContactInfosByCustomerId(@PathVariable Long customerId); 17 | } 18 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/client/BasketClient.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.client; 2 | 3 | import com.os.order_service.model.Basket; 4 | import com.os.order_service.model.BasketItem; 5 | import org.springframework.cloud.openfeign.FeignClient; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | 9 | import java.util.List; 10 | 11 | @FeignClient(name = "basket-service") 12 | public interface BasketClient { 13 | 14 | @GetMapping("/api/v1/basket/findBy/customersBasket/{customerId}") 15 | List findByCustomerBasket(@PathVariable Long customerId); 16 | @GetMapping("/api/v1/basket/basket/findById/{basketId}") 17 | Basket findById(@PathVariable("basketId") String basketId); 18 | } 19 | -------------------------------------------------------------------------------- /customer-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=customer-service 2 | spring.datasource.url=jdbc:postgresql://localhost:5432/iyzico-customerdb 3 | spring.datasource.username=postgres 4 | spring.datasource.password=test 5 | spring.jpa.hibernate.ddl-auto=update 6 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect 7 | 8 | spring.cloud.config.profile=local 9 | spring.config.import=configserver:${configurl} 10 | configurl= http://localhost:8079 11 | 12 | 13 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 14 | eureka.client.register-with-eureka=true 15 | eureka.client.fetch-registry=true 16 | 17 | 18 | server.servlet.session.cookie.name=customer_service_cookie 19 | server.servlet.session.cookie.http-only=true 20 | server.servlet.session.cookie.secure=true -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/model/Product.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | import java.math.BigDecimal; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Entity 16 | @Table(name = "products") 17 | public class Product { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | private Long id; 22 | private String name; 23 | private String description; 24 | private BigDecimal price; 25 | 26 | @ManyToOne(fetch = FetchType.LAZY) 27 | @JoinColumn(name = "category_id") // Foreign key olarak category_id kullanılacak 28 | private Category category; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/model/ContactInfo.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | @Entity 14 | @Table(name = "contact_info") 15 | public class ContactInfo { 16 | 17 | @Id 18 | @GeneratedValue(strategy = GenerationType.IDENTITY) 19 | private Long id; 20 | private String gsmNumber; 21 | private String identityNumber; 22 | private String address; 23 | private String city; 24 | private String country; 25 | private String zipCode; 26 | @ManyToOne 27 | @JoinColumn(name = "customer_id", referencedColumnName = "id") 28 | private User customer; 29 | } 30 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/mapper/RoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.mapper; 2 | 3 | import com.os.customer_service.dto.request.role.RoleRequest; 4 | import com.os.customer_service.dto.response.role.RoleWithUserResponse; 5 | import com.os.customer_service.model.Role; 6 | import com.os.customer_service.model.User; 7 | import org.mapstruct.Mapper; 8 | import org.mapstruct.Mapping; 9 | import org.mapstruct.factory.Mappers; 10 | 11 | @Mapper 12 | public interface RoleMapper { 13 | 14 | RoleMapper INSTANCE = Mappers.getMapper(RoleMapper.class); 15 | 16 | Role roleFromRequest(RoleRequest request); 17 | 18 | @Mapping(source = "roleId", target = "id") 19 | Role toRole(RoleWithUserResponse roleWithUserResponse); 20 | 21 | @Mapping(source = "userId", target = "id") 22 | User toUser(RoleWithUserResponse roleWithUserResponse); 23 | } 24 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.model; 2 | import jakarta.persistence.*; 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | import org.springframework.security.core.GrantedAuthority; 8 | import java.util.Set; 9 | 10 | @Entity 11 | @Table(name="roles") 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Getter 15 | @Setter 16 | public class Role implements GrantedAuthority { 17 | 18 | @Id 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | @Column(name="id") 21 | private int id; 22 | 23 | @Column(name="name") 24 | private String name; 25 | 26 | @ManyToMany(mappedBy = "roles") 27 | private Set users; 28 | @Override 29 | public String getAuthority() { 30 | return name; 31 | } 32 | } -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/repository/ProductElasticSearchRepository.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.repository; 2 | 3 | import com.os.search_service.document.Product; 4 | import org.springframework.data.elasticsearch.annotations.Query; 5 | import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | 11 | @Repository 12 | public interface ProductElasticSearchRepository extends ElasticsearchRepository { 13 | 14 | @Query("{\"wildcard\": {\"name\": \"*?0*\"}}") 15 | List searchByProductName(String productName); 16 | 17 | List findByPriceBetween(BigDecimal lower, BigDecimal upper); 18 | 19 | List findAllByOrderByPriceAsc(); 20 | List findAllByOrderByPriceDesc(); 21 | } 22 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/service/ContactInfoService.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.service; 2 | 3 | import com.os.customer_service.dto.request.contactinfo.CreateContactInfoRequest; 4 | import com.os.customer_service.dto.request.contactinfo.UpdateContactInfoRequest; 5 | import com.os.customer_service.dto.response.contactinfo.*; 6 | 7 | import java.util.List; 8 | import java.util.Optional; 9 | 10 | public interface ContactInfoService { 11 | 12 | CreateContactInfoResponse createContactInfo(CreateContactInfoRequest request); 13 | UpdateContactInfoResponse updateContactInfo(Long contactInfoId, UpdateContactInfoRequest request); 14 | List getAllContactInfo(); 15 | Optional getByIdContactInfo(Long id); 16 | void deleteContactInfo(Long id); 17 | List getByCustomerId(Long id); 18 | } 19 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/request/user/UpdateUserRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.request.user; 2 | 3 | import jakarta.validation.constraints.Pattern; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.NoArgsConstructor; 7 | import lombok.Setter; 8 | 9 | @Getter 10 | @Setter 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class UpdateUserRequest { 14 | @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,}$", message = "Password must be at least 8 characters long, contain an uppercase letter, a lowercase letter, and a number.") 15 | private String password; 16 | @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,}$", message = "Password must be at least 8 characters long, contain an uppercase letter, a lowercase letter, and a number.") 17 | private String passwordRepeat; 18 | private String firstName; 19 | private String lastName; 20 | } 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.service; 2 | 3 | import com.os.customer_service.dto.request.user.UpdateUserRequest; 4 | import com.os.customer_service.dto.response.user.GetByIdUserResponse; 5 | import com.os.customer_service.dto.response.user.UpdateUserResponse; 6 | import com.os.customer_service.dto.response.user.UserResponse; 7 | import com.os.customer_service.model.User; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | public interface UserService extends UserDetailsService { 14 | 15 | void add(User user); 16 | Optional getUserById(Long id); 17 | Optional getUserByIdForRole(Long id); 18 | List getAllUser(); 19 | UpdateUserResponse updateUser(UpdateUserRequest updateUserRequest,Long id); 20 | void deleteUser(Long id); 21 | } -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/kafka/NotificationProducer.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.kafka; 2 | 3 | import com.os.payment_service.model.Notification; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.kafka.core.KafkaTemplate; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | @Slf4j 11 | public class NotificationProducer { 12 | 13 | private final KafkaTemplate kafkaTemplate; 14 | 15 | public NotificationProducer(KafkaTemplate kafkaTemplate) { 16 | this.kafkaTemplate = kafkaTemplate; 17 | } 18 | 19 | 20 | @Value("${spring.kafka.template.default-topic}") 21 | private String defaultTopic; 22 | 23 | public void sendMessage(Notification message) { 24 | log.info("Sending message: " + message); 25 | kafkaTemplate.send(defaultTopic, message); 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/model/Basket.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.model; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.NoArgsConstructor; 6 | import lombok.Setter; 7 | import org.springframework.data.annotation.Id; 8 | import org.springframework.data.mongodb.core.mapping.Document; 9 | 10 | import java.io.Serializable; 11 | import java.math.BigDecimal; 12 | import java.util.List; 13 | 14 | @Getter 15 | @Setter 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Document(collection = "baskets") 19 | public class Basket implements Serializable { 20 | @Id 21 | private String id; 22 | private CustomerDto customer; 23 | private List items; 24 | private BigDecimal totalPrice; 25 | 26 | public void updateTotalPrice() { 27 | totalPrice = items.stream() 28 | .map(BasketItem::getTotalPrice) 29 | .reduce(BigDecimal.ZERO, BigDecimal::add); 30 | } 31 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/service/impl/CustomerServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.service.impl; 2 | 3 | import com.os.product_service.model.Customer; 4 | import com.os.product_service.repository.CustomerRepository; 5 | import com.os.product_service.service.CustomerService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.io.Serial; 9 | 10 | @Service 11 | public class CustomerServiceImpl implements CustomerService { 12 | 13 | private final CustomerRepository customerRepository; 14 | 15 | public CustomerServiceImpl(CustomerRepository customerRepository) { 16 | this.customerRepository = customerRepository; 17 | } 18 | @Override 19 | public Customer addCustomer(Customer customer) { 20 | return customerRepository.save(customer); 21 | } 22 | 23 | @Override 24 | public Customer getCustomerById(Long id) { 25 | return customerRepository.findById(id).orElse(null); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/request/contactinfo/UpdateContactInfoRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.request.contactinfo; 2 | 3 | import jakarta.validation.constraints.Pattern; 4 | import jakarta.validation.constraints.Size; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class UpdateContactInfoRequest { 15 | @Size(min = 11, max = 11) 16 | @Pattern(regexp = "^[0-9]{11}$", message = "GSM number must be numeric and exactly 11 digits long.") 17 | private String gsmNumber; 18 | @Size(min = 11, max = 11) 19 | @Pattern(regexp = "^[0-9]{11}$", message = "GSM number must be numeric and exactly 11 digits long.") 20 | private String identityNumber; 21 | private String address; 22 | private String city; 23 | private String country; 24 | private String zipCode; 25 | private Long customerId; 26 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.service; 2 | 3 | import com.os.product_service.dto.request.category.CreateCategoryRequest; 4 | import com.os.product_service.dto.request.category.UpdateCategoryRequest; 5 | import com.os.product_service.dto.response.category.CreateCategoryResponse; 6 | import com.os.product_service.dto.response.category.GetAllCategoryResponse; 7 | import com.os.product_service.dto.response.category.GetByIdCategoryResponse; 8 | import com.os.product_service.dto.response.category.UpdateCategoryResponse; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | public interface CategoryService { 14 | 15 | CreateCategoryResponse createCategory(CreateCategoryRequest request); 16 | UpdateCategoryResponse updateCategory(Long id,UpdateCategoryRequest request); 17 | List getAllCategories(); 18 | Optional getCategory(Long id); 19 | void deleteCategory(Long id); 20 | } 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/request/contactinfo/CreateContactInfoRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.request.contactinfo; 2 | 3 | 4 | import jakarta.validation.constraints.Pattern; 5 | import jakarta.validation.constraints.Size; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class CreateContactInfoRequest { 16 | @Size(min = 11, max = 11) 17 | @Pattern(regexp = "^[0-9]{11}$", message = "GSM number must be numeric and exactly 11 digits long.") 18 | private String gsmNumber; 19 | @Size(min = 11, max = 11) 20 | @Pattern(regexp = "^[0-9]{11}$", message = "GSM number must be numeric and exactly 11 digits long.") 21 | private String identityNumber; 22 | private String address; 23 | private String city; 24 | private String country; 25 | private String zipCode; 26 | private Long customerId; 27 | } 28 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/dto/request/user/RegisterRequest.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.dto.request.user; 2 | 3 | import jakarta.validation.constraints.Email; 4 | import jakarta.validation.constraints.Pattern; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.NoArgsConstructor; 8 | import lombok.Setter; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class RegisterRequest { 15 | @Email 16 | private String email; 17 | @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,}$", message = "Password must be at least 8 characters long, contain an uppercase letter, a lowercase letter, and a number.") 18 | private String password; 19 | @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,}$", message = "Password must be at least 8 characters long, contain an uppercase letter, a lowercase letter, and a number.") 20 | private String passwordRepeat; 21 | private String firstName; 22 | private String lastName; 23 | } -------------------------------------------------------------------------------- /config-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /order-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /basket-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /customer-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /discovery-server/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /payment-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /product-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /notification-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/kafka/PaymentConsumer.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service.kafka; 2 | 3 | import com.os.notification_service.model.OrderNotification; 4 | import com.os.notification_service.service.OrderNotificationService; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.apache.kafka.clients.consumer.ConsumerRecord; 8 | import org.springframework.kafka.annotation.KafkaListener; 9 | import org.springframework.stereotype.Service; 10 | 11 | @Service 12 | @RequiredArgsConstructor 13 | @Slf4j 14 | public class PaymentConsumer { 15 | 16 | private final OrderNotificationService orderNotificationService; 17 | @KafkaListener(topics = "${spring.kafka.template.default-topic}", groupId = "${spring.kafka.consumer.group-id}") 18 | public void createConsumer(ConsumerRecord payload) { 19 | orderNotificationService.sendOrderCompletedEmail(payload.value()); 20 | System.out.println("Consumer tarafından mesaj alındı : " + payload.value()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/service/ProductService.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.service; 2 | 3 | import com.os.product_service.dto.request.product.CreateProductRequest; 4 | import com.os.product_service.dto.request.product.UpdateProductRequest; 5 | import com.os.product_service.dto.response.product.CreateProductResponse; 6 | import com.os.product_service.dto.response.product.GetAllProductResponse; 7 | import com.os.product_service.dto.response.product.GetByIdProductResponse; 8 | import com.os.product_service.dto.response.product.UpdateProductResponse; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | public interface ProductService { 14 | CreateProductResponse addProduct(CreateProductRequest request); 15 | UpdateProductResponse updateProduct(Long id, UpdateProductRequest request); 16 | List getAllProducts(); 17 | Optional getProductById(Long id); 18 | void deleteProduct(Long id); 19 | List findByProductWithCategoryId(Long categoryId); 20 | } 21 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.exception; 2 | 3 | import com.os.payment_service.exception.error.ApiError; 4 | import com.os.payment_service.exception.type.ContactInfosNotFoundException; 5 | import jakarta.servlet.http.HttpServletRequest; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.ControllerAdvice; 9 | import org.springframework.web.bind.annotation.ExceptionHandler; 10 | 11 | @ControllerAdvice 12 | public class GlobalExceptionHandler { 13 | @ExceptionHandler(ContactInfosNotFoundException.class) 14 | public ResponseEntity handleProductNotFoundException(ContactInfosNotFoundException exception, HttpServletRequest request) 15 | { 16 | ApiError apiError = new ApiError(); 17 | apiError.setMessage(exception.getMessage()); 18 | apiError.setPath(request.getRequestURI()); 19 | return new ResponseEntity<>(apiError, HttpStatus.NOT_FOUND); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /search-service/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | wrapperVersion=3.3.2 18 | distributionType=only-script 19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip 20 | distributionSha256Sum=4ec3f26fb1a692473aea0235c300bd20f0f9fe741947c82c1234cefd76ac3a3c 21 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/controller/AuthController.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.controller; 2 | 3 | import com.os.customer_service.dto.request.user.LoginRequest; 4 | import com.os.customer_service.dto.request.user.RegisterRequest; 5 | import com.os.customer_service.dto.response.user.LoginResponse; 6 | import com.os.customer_service.service.AuthService; 7 | import jakarta.servlet.http.HttpSession; 8 | import jakarta.validation.Valid; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | @RestController 12 | @RequestMapping("/api/v1/auth") 13 | public class AuthController { 14 | 15 | 16 | private final AuthService authService; 17 | 18 | public AuthController(AuthService authService) { 19 | this.authService = authService; 20 | } 21 | 22 | @PostMapping("register") 23 | public void register(@Valid @RequestBody RegisterRequest request) 24 | { 25 | authService.register(request); 26 | } 27 | 28 | @PostMapping("login") 29 | public LoginResponse login(@RequestBody LoginRequest request, HttpSession session) 30 | { 31 | return authService.login(request,session); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/mapper/CategoryMapping.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.mapper; 2 | 3 | import com.os.product_service.dto.request.category.CreateCategoryRequest; 4 | import com.os.product_service.dto.request.category.UpdateCategoryRequest; 5 | import com.os.product_service.dto.response.category.GetAllCategoryResponse; 6 | import com.os.product_service.dto.response.category.GetByIdCategoryResponse; 7 | import com.os.product_service.model.Category; 8 | import org.mapstruct.Mapper; 9 | import org.mapstruct.MappingTarget; 10 | import org.mapstruct.factory.Mappers; 11 | 12 | import java.util.List; 13 | 14 | @Mapper 15 | public interface CategoryMapping { 16 | 17 | 18 | CategoryMapping INSTANCE = Mappers.getMapper(CategoryMapping.class); 19 | 20 | Category createCategory(CreateCategoryRequest request); 21 | Category updateCategory(UpdateCategoryRequest request,@MappingTarget Category category); 22 | GetByIdCategoryResponse getByIdCategory(Category category); 23 | 24 | GetAllCategoryResponse getAllCategory(Category category); 25 | List listToGetAllCategory(List categoryList); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /product-service/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.application.name=product-service 2 | spring.datasource.url=jdbc:postgresql://localhost:5432/iyzico-productdb 3 | spring.datasource.username=postgres 4 | spring.datasource.password=test 5 | spring.jpa.hibernate.ddl-auto=update 6 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect 7 | 8 | 9 | spring.cloud.config.profile=local 10 | spring.config.import=configserver:${configurl} 11 | configurl= http://localhost:8079 12 | 13 | 14 | eureka.client.service-url.defaultZone = http://localhost:8888/eureka/ 15 | eureka.client.register-with-eureka=true 16 | eureka.client.fetch-registry=true 17 | 18 | spring.kafka.bootstrap-servers=localhost:9092 19 | spring.kafka.consumer.group-id=kafka-group 20 | spring.kafka.template.product-topic=product-save-topic 21 | spring.kafka.template.product-delete-topic=product-delete-topic 22 | spring.kafka.template.product-update-topic=product-update-topic 23 | 24 | spring.cache.type=redis 25 | spring.data.redis.host=localhost 26 | spring.data.redis.port=6379 27 | 28 | 29 | management.endpoints.web.exposure.include=* 30 | management.endpoint.health.show-details=always 31 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/controller/PaymentController.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.controller; 2 | 3 | import com.os.payment_service.model.PaymentRequest; 4 | import com.os.payment_service.service.PaymentService; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | @RestController 10 | @RequestMapping("/api/v1/payment") 11 | public class PaymentController { 12 | private final PaymentService paymentService; 13 | 14 | public PaymentController(PaymentService paymentService) { 15 | this.paymentService = paymentService; 16 | } 17 | 18 | @PostMapping("/{orderId}") 19 | public ResponseEntity makePayment( 20 | @PathVariable String orderId, 21 | @RequestBody PaymentRequest paymentRequest) { 22 | try { 23 | String paymentResult = paymentService.makePayment(orderId, paymentRequest); 24 | return new ResponseEntity<>(paymentResult, HttpStatus.OK); 25 | } catch (Exception e) { 26 | return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/config/SecuirtyConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.config; 2 | import com.os.spring_security.security.BaseSecurityService; 3 | import lombok.RequiredArgsConstructor; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 8 | import org.springframework.security.web.SecurityFilterChain; 9 | 10 | @Configuration 11 | @EnableWebSecurity 12 | @RequiredArgsConstructor 13 | public class SecuirtyConfig { 14 | private final BaseSecurityService baseSecurityService; 15 | 16 | @Bean 17 | public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 18 | baseSecurityService.configureCommonSecurityRules(http); 19 | http.authorizeHttpRequests(authorizeRequests -> 20 | authorizeRequests 21 | .requestMatchers("/api/v1/basket/**").authenticated() 22 | .anyRequest().permitAll() 23 | ); 24 | return http.build(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/config/SecuirtyConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.config; 2 | 3 | import com.turkcell.tcell.core.security.BaseSecurityService; 4 | import lombok.RequiredArgsConstructor; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 9 | import org.springframework.security.web.SecurityFilterChain; 10 | 11 | @Configuration 12 | @EnableWebSecurity 13 | @RequiredArgsConstructor 14 | public class SecuirtyConfig { 15 | private final BaseSecurityService baseSecurityService; 16 | 17 | @Bean 18 | public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 19 | baseSecurityService.configureCommonSecurityRules(http); 20 | http.authorizeHttpRequests(authorizeRequests -> 21 | authorizeRequests 22 | .requestMatchers("/api/v1/order/**").authenticated() 23 | .anyRequest().permitAll() 24 | ); 25 | return http.build(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/config/SecuirtyConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.config; 2 | 3 | import com.turkcell.tcell.core.security.BaseSecurityService; 4 | import lombok.RequiredArgsConstructor; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 9 | import org.springframework.security.web.SecurityFilterChain; 10 | 11 | @Configuration 12 | @EnableWebSecurity 13 | @RequiredArgsConstructor 14 | public class SecuirtyConfig { 15 | private final BaseSecurityService baseSecurityService; 16 | 17 | @Bean 18 | public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 19 | baseSecurityService.configureCommonSecurityRules(http); 20 | http.authorizeHttpRequests(authorizeRequests -> 21 | authorizeRequests 22 | .requestMatchers("/api/v1/payment/**").authenticated() 23 | .anyRequest().permitAll() 24 | ); 25 | return http.build(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/config/FeignClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.config; 2 | 3 | import com.turkcell.tcell.core.security.BaseJwtService; 4 | import feign.RequestInterceptor; 5 | import feign.RequestTemplate; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.core.context.SecurityContextHolder; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @Configuration 14 | public class FeignClientConfig { 15 | 16 | private final BaseJwtService jwtService; 17 | 18 | public FeignClientConfig(BaseJwtService jwtService) { 19 | this.jwtService = jwtService; 20 | } 21 | 22 | @Bean 23 | public RequestInterceptor requestInterceptor() { 24 | return new RequestInterceptor() { 25 | @Override 26 | public void apply(RequestTemplate requestTemplate) { 27 | String username = SecurityContextHolder.getContext().getAuthentication().getName(); 28 | String token = jwtService.generateToken(username, Map.of("roles", List.of("USER"))); 29 | requestTemplate.header("Authorization", "Bearer " + token); 30 | } 31 | }; 32 | } 33 | } -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/config/FeignClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.config; 2 | 3 | import com.os.spring_security.security.BaseJwtService; 4 | import feign.RequestInterceptor; 5 | import feign.RequestTemplate; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.core.context.SecurityContextHolder; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @Configuration 14 | public class FeignClientConfig { 15 | 16 | private final BaseJwtService jwtService; 17 | 18 | public FeignClientConfig(BaseJwtService jwtService) { 19 | this.jwtService = jwtService; 20 | } 21 | 22 | @Bean 23 | public RequestInterceptor requestInterceptor() { 24 | return new RequestInterceptor() { 25 | @Override 26 | public void apply(RequestTemplate requestTemplate) { 27 | String username = SecurityContextHolder.getContext().getAuthentication().getName(); 28 | String token = jwtService.generateToken(username, Map.of("roles", List.of("USER"))); 29 | requestTemplate.header("Authorization", "Bearer " + token); 30 | } 31 | }; 32 | } 33 | } -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/config/FeignClientConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.config; 2 | 3 | import com.turkcell.tcell.core.security.BaseJwtService; 4 | import feign.RequestInterceptor; 5 | import feign.RequestTemplate; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.core.context.SecurityContextHolder; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @Configuration 14 | public class FeignClientConfig { 15 | 16 | private final BaseJwtService jwtService; 17 | 18 | public FeignClientConfig(BaseJwtService jwtService) { 19 | this.jwtService = jwtService; 20 | } 21 | 22 | @Bean 23 | public RequestInterceptor requestInterceptor() { 24 | return new RequestInterceptor() { 25 | @Override 26 | public void apply(RequestTemplate requestTemplate) { 27 | String username = SecurityContextHolder.getContext().getAuthentication().getName(); 28 | String token = jwtService.generateToken(username, Map.of("roles", List.of("USER"))); 29 | requestTemplate.header("Authorization", "Bearer " + token); 30 | } 31 | }; 32 | } 33 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/aop/PerformanceAspect.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.aop; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.aspectj.lang.ProceedingJoinPoint; 5 | import org.aspectj.lang.annotation.Around; 6 | import org.aspectj.lang.annotation.Aspect; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Aspect 10 | @Component 11 | @Slf4j 12 | public class PerformanceAspect { 13 | 14 | 15 | // @Before : Metot devreye girmeden önce çalışır 16 | // @After : Metot devreye girdikten sonra çalışır 17 | // @Around : Metot devreye girmeden ve bittikten sonra çalışır 18 | // AfterReturning : Metot başarılı olduktan sonra çalışır 19 | // AfterThrowing : Metot exception döndükten sonra çalışır 20 | 21 | @Around("execution(* com.os.product_service.service.impl.*.*(..))") 22 | public Object measureGetAllExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable { 23 | long startTime = System.currentTimeMillis(); 24 | 25 | Object result = joinPoint.proceed(); 26 | 27 | long endTime = System.currentTimeMillis(); 28 | long duration = endTime - startTime; 29 | 30 | log.info("{} executed in {}ms to create category", joinPoint.getSignature(), duration); 31 | 32 | return result; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.service.impl; 2 | 3 | import com.os.customer_service.dto.request.role.RoleRequest; 4 | import com.os.customer_service.mapper.RoleMapper; 5 | import com.os.customer_service.model.Role; 6 | import com.os.customer_service.repository.RoleRepository; 7 | import com.os.customer_service.service.RoleService; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | @Service 14 | public class RoleServiceImpl implements RoleService { 15 | 16 | private final RoleRepository roleRepositories; 17 | 18 | public RoleServiceImpl(RoleRepository roleRepositories) { 19 | this.roleRepositories = roleRepositories; 20 | } 21 | 22 | @Override 23 | public Role addRole(RoleRequest request) { 24 | Role role = RoleMapper.INSTANCE.roleFromRequest(request); 25 | System.out.println("Mapped Role Name: " + role.getName()); 26 | return roleRepositories.save(role); 27 | } 28 | 29 | @Override 30 | public void deleteRole(Long id) { 31 | } 32 | 33 | @Override 34 | public Optional getRoleById(Long id) { 35 | return roleRepositories.findById(id); 36 | } 37 | 38 | @Override 39 | public List getAllRoles() { 40 | return List.of(); 41 | } 42 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/controller/CustomerController.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.controller; 2 | 3 | import com.os.product_service.model.Customer; 4 | import com.os.product_service.service.CustomerService; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | @RestController 10 | @RequestMapping("/api/v1/customer") 11 | public class CustomerController { 12 | 13 | private final CustomerService customerService; 14 | 15 | public CustomerController(CustomerService customerService) { 16 | this.customerService = customerService; 17 | } 18 | @PostMapping 19 | public ResponseEntity addCustomer(@RequestBody Customer customer) { 20 | Customer savedCustomer = customerService.addCustomer(customer); 21 | return ResponseEntity.status(HttpStatus.CREATED).body(savedCustomer); 22 | } 23 | 24 | // ID'ye göre müşteri getirme 25 | @GetMapping("/{id}") 26 | public ResponseEntity getCustomerById(@PathVariable Long id) { 27 | Customer customer = customerService.getCustomerById(id); 28 | if (customer != null) { 29 | return ResponseEntity.ok(customer); 30 | } else { 31 | return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/mapper/ProductMapping.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.mapper; 2 | 3 | import com.os.product_service.dto.request.product.CreateProductRequest; 4 | import com.os.product_service.dto.request.product.UpdateProductRequest; 5 | import com.os.product_service.dto.response.product.GetAllProductResponse; 6 | import com.os.product_service.dto.response.product.GetByIdProductResponse; 7 | import com.os.product_service.model.Product; 8 | import org.mapstruct.Mapper; 9 | import org.mapstruct.Mapping; 10 | import org.mapstruct.MappingTarget; 11 | import org.mapstruct.factory.Mappers; 12 | 13 | import java.util.List; 14 | 15 | @Mapper 16 | public interface ProductMapping { 17 | 18 | ProductMapping INSTANCE = Mappers.getMapper(ProductMapping.class); 19 | 20 | @Mapping(source = "categoryId",target = "category.id") 21 | Product createProduct(CreateProductRequest request); 22 | Product updateProduct(UpdateProductRequest request, @MappingTarget Product product); 23 | @Mapping(source = "category.id",target = "categoryId") 24 | GetByIdProductResponse getByIdProduct(Product product); 25 | 26 | @Mapping(source = "category.id",target = "categoryId") 27 | GetAllProductResponse getAllProduct(Product product); 28 | List listGetAllProduct(List products); 29 | 30 | } 31 | 32 | 33 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.exception; 2 | 3 | import com.os.product_service.exception.error.ApiError; 4 | import com.os.product_service.exception.type.CategoryNotFoundException; 5 | import com.os.product_service.exception.type.ProductNotFoundException; 6 | import jakarta.servlet.http.HttpServletRequest; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.ControllerAdvice; 10 | import org.springframework.web.bind.annotation.ExceptionHandler; 11 | 12 | 13 | @ControllerAdvice 14 | public class GlobalExceptionHandler { 15 | 16 | @ExceptionHandler(ProductNotFoundException.class) 17 | public ResponseEntity handleProductNotFoundException(ProductNotFoundException exception, HttpServletRequest request) 18 | { 19 | ApiError apiError = new ApiError(); 20 | apiError.setMessage(exception.getMessage()); 21 | apiError.setPath(request.getRequestURI()); 22 | return new ResponseEntity<>(apiError, HttpStatus.NOT_FOUND); 23 | } 24 | @ExceptionHandler(CategoryNotFoundException.class) 25 | public ResponseEntity handleCategoryNotFoundException(CategoryNotFoundException exception, HttpServletRequest request) 26 | { 27 | ApiError apiError = new ApiError(); 28 | apiError.setMessage(exception.getMessage()); 29 | apiError.setPath(request.getRequestURI()); 30 | return new ResponseEntity<>(apiError, HttpStatus.NOT_FOUND); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.controller; 2 | 3 | import com.os.customer_service.dto.request.user.UpdateUserRequest; 4 | import com.os.customer_service.dto.response.user.GetByIdUserResponse; 5 | import com.os.customer_service.dto.response.user.UpdateUserResponse; 6 | import com.os.customer_service.dto.response.user.UserResponse; 7 | import com.os.customer_service.service.UserService; 8 | import jakarta.validation.Valid; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import java.util.List; 12 | import java.util.Optional; 13 | 14 | @RestController 15 | @RequestMapping("/api/v1/users") 16 | public class UserController { 17 | private final UserService userService; 18 | 19 | public UserController(UserService userService) { 20 | this.userService = userService; 21 | } 22 | 23 | @GetMapping("/getByIdUser/{id}") 24 | public Optional getByIdUser(@PathVariable Long id) 25 | { 26 | return userService.getUserById(id); 27 | } 28 | @GetMapping("/getAllUsers") 29 | public List getAllUsers() { 30 | return userService.getAllUser(); 31 | } 32 | @PutMapping("/update/users/{userId}") 33 | public UpdateUserResponse updateUser(@PathVariable Long userId, @Valid @RequestBody UpdateUserRequest request) 34 | { 35 | return userService.updateUser(request,userId); 36 | } 37 | @DeleteMapping("/delete/account/{id}") 38 | public void deleteAccount(@PathVariable Long id) 39 | { 40 | userService.deleteUser(id); 41 | } 42 | } -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.controller; 2 | 3 | import com.os.order_service.model.CustomerDto; 4 | import com.os.order_service.model.Order; 5 | import com.os.order_service.service.OrderService; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | @RestController 14 | @RequestMapping("/api/v1/order") 15 | public class OrderController { 16 | 17 | private final OrderService orderService; 18 | 19 | public OrderController(OrderService orderService) { 20 | this.orderService = orderService; 21 | } 22 | @GetMapping("/getAll/orders") 23 | public List getAllOrders() 24 | { 25 | return orderService.getAllOrder(); 26 | } 27 | @GetMapping("/getById/orders/{orderId}") 28 | public Optional getByIdOrder(@PathVariable String orderId) 29 | { 30 | return orderService.getByIdOrder(orderId); 31 | } 32 | @GetMapping("/getOrderHistoryForCustomer/{customerId}") 33 | public List getOrderHistoryForCustomer(@PathVariable Long customerId) 34 | { 35 | return orderService.getOrderHistoryForCustomer(customerId); 36 | } 37 | @PostMapping("/create-order/{basketId}") 38 | public ResponseEntity createOrder(@PathVariable String basketId) { 39 | Order order = orderService.createOrder(basketId); 40 | return new ResponseEntity<>(order, HttpStatus.CREATED); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/config/KafkaProducerConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.config; 2 | 3 | import com.os.payment_service.model.Notification; 4 | import org.apache.kafka.clients.producer.ProducerConfig; 5 | import org.apache.kafka.common.serialization.StringSerializer; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.kafka.annotation.EnableKafka; 10 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; 11 | import org.springframework.kafka.core.KafkaTemplate; 12 | import org.springframework.kafka.core.ProducerFactory; 13 | import org.springframework.kafka.support.serializer.JsonSerializer; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | @Configuration 19 | @EnableKafka 20 | public class KafkaProducerConfig { 21 | @Value("${spring.kafka.bootstrap-servers}") 22 | private String kafkaAddress; 23 | 24 | @Bean 25 | public ProducerFactory createPlaceProducerFactory() { 26 | Map configProps = new HashMap<>(); 27 | configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaAddress); 28 | configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 29 | configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); 30 | return new DefaultKafkaProducerFactory<>(configProps); 31 | } 32 | 33 | @Bean 34 | public KafkaTemplate createPlaceKafkaTemplate() { 35 | return new KafkaTemplate<>(createPlaceProducerFactory()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.mapper; 2 | 3 | import com.os.customer_service.dto.request.user.RegisterRequest; 4 | import com.os.customer_service.dto.request.user.UpdateUserRequest; 5 | import com.os.customer_service.dto.response.user.GetByIdUserResponse; 6 | import com.os.customer_service.dto.response.user.UserResponse; 7 | import com.os.customer_service.model.Role; 8 | import com.os.customer_service.model.User; 9 | import org.mapstruct.Mapper; 10 | import org.mapstruct.Mapping; 11 | import org.mapstruct.MappingTarget; 12 | import org.mapstruct.Named; 13 | import org.mapstruct.factory.Mappers; 14 | 15 | import java.util.List; 16 | import java.util.Set; 17 | 18 | @Mapper 19 | public interface UserMapper { 20 | UserMapper INSTANCE = Mappers.getMapper(UserMapper.class); 21 | 22 | User userFromRequest(RegisterRequest request); 23 | 24 | User updateUser(UpdateUserRequest request,@MappingTarget User user); 25 | 26 | @Mapping(target = "roleId", source = "roles", qualifiedByName = "mapRolesToRoleId") 27 | @Mapping(target = "firstName", source = "firstName") 28 | @Mapping(target = "lastName", source = "lastName") 29 | GetByIdUserResponse getByIdUserResponse(User user); 30 | 31 | @Mapping(target = "firstName", source = "firstName") 32 | @Mapping(target = "lastName", source = "lastName") 33 | @Mapping(target = "roleId", source = "roles", qualifiedByName = "mapRolesToRoleId") 34 | UserResponse userFromResponse(User user); 35 | List usersFromResponse(List users); 36 | 37 | @Named("mapRolesToRoleId") 38 | default int mapRolesToRoleId(Set roles) { 39 | return roles.isEmpty() ? 0 : roles.iterator().next().getId(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.config; 2 | 3 | import io.swagger.v3.oas.annotations.OpenAPIDefinition; 4 | import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; 5 | import io.swagger.v3.oas.annotations.info.Info; 6 | import io.swagger.v3.oas.annotations.security.SecurityRequirement; 7 | import io.swagger.v3.oas.annotations.security.SecurityScheme; 8 | import io.swagger.v3.oas.annotations.servers.Server; 9 | import io.swagger.v3.oas.models.Components; 10 | import io.swagger.v3.oas.models.OpenAPI; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | @Configuration 15 | @OpenAPIDefinition( 16 | info = @Info(title = "Order Service API", version = "1.0", description = "Order Service API Documentation"), 17 | security = @SecurityRequirement(name = "bearerAuth"), 18 | servers = @Server(url = "http://localhost:8084") 19 | ) 20 | @SecurityScheme( 21 | name = "bearerAuth", 22 | type = SecuritySchemeType.HTTP, 23 | scheme = "bearer", 24 | bearerFormat = "JWT" 25 | ) 26 | 27 | public class SwaggerConfig { 28 | @Bean 29 | public OpenAPI customOpenAPI() { 30 | return new OpenAPI() 31 | .components(new Components() 32 | .addSecuritySchemes("bearerAuth", new io.swagger.v3.oas.models.security.SecurityScheme() 33 | .type(io.swagger.v3.oas.models.security.SecurityScheme.Type.HTTP) 34 | .scheme("bearer") 35 | .bearerFormat("JWT") 36 | .in(io.swagger.v3.oas.models.security.SecurityScheme.In.HEADER) 37 | .name("Authorization") 38 | ) 39 | ); 40 | } 41 | } -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.config; 2 | 3 | import io.swagger.v3.oas.annotations.OpenAPIDefinition; 4 | import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; 5 | import io.swagger.v3.oas.annotations.info.Info; 6 | import io.swagger.v3.oas.annotations.security.SecurityRequirement; 7 | import io.swagger.v3.oas.annotations.security.SecurityScheme; 8 | import io.swagger.v3.oas.annotations.servers.Server; 9 | import io.swagger.v3.oas.models.Components; 10 | import io.swagger.v3.oas.models.OpenAPI; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | @Configuration 15 | @OpenAPIDefinition( 16 | info = @Info(title = "Basket Service API", version = "1.0", description = "Basket Service API Documentation"), 17 | security = @SecurityRequirement(name = "bearerAuth"), 18 | servers = @Server(url = "http://localhost:8083") 19 | ) 20 | @SecurityScheme( 21 | name = "bearerAuth", 22 | type = SecuritySchemeType.HTTP, 23 | scheme = "bearer", 24 | bearerFormat = "JWT" 25 | ) 26 | 27 | public class SwaggerConfig { 28 | @Bean 29 | public OpenAPI customOpenAPI() { 30 | return new OpenAPI() 31 | .components(new Components() 32 | .addSecuritySchemes("bearerAuth", new io.swagger.v3.oas.models.security.SecurityScheme() 33 | .type(io.swagger.v3.oas.models.security.SecurityScheme.Type.HTTP) 34 | .scheme("bearer") 35 | .bearerFormat("JWT") 36 | .in(io.swagger.v3.oas.models.security.SecurityScheme.In.HEADER) 37 | .name("Authorization") 38 | ) 39 | ); 40 | } 41 | } -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/mapper/ContactInfoMapper.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.mapper; 2 | 3 | import com.os.customer_service.dto.request.contactinfo.CreateContactInfoRequest; 4 | import com.os.customer_service.dto.request.contactinfo.UpdateContactInfoRequest; 5 | import com.os.customer_service.dto.response.contactinfo.GetAllContactInfoResponse; 6 | import com.os.customer_service.dto.response.contactinfo.GetByContactInfoWithCustomerIdResponse; 7 | import com.os.customer_service.dto.response.contactinfo.GetByIdContactInfoResponse; 8 | import com.os.customer_service.model.ContactInfo; 9 | import org.mapstruct.Mapper; 10 | import org.mapstruct.Mapping; 11 | import org.mapstruct.MappingTarget; 12 | import org.mapstruct.factory.Mappers; 13 | 14 | import java.util.List; 15 | 16 | @Mapper 17 | public interface ContactInfoMapper { 18 | 19 | ContactInfoMapper INSTANCE = Mappers.getMapper(ContactInfoMapper.class); 20 | 21 | ContactInfo createContactInfo(CreateContactInfoRequest createContactInfoRequest); 22 | 23 | ContactInfo updateContactInfo(UpdateContactInfoRequest updateContactInfoRequest, @MappingTarget ContactInfo contactInfo); 24 | 25 | GetByIdContactInfoResponse getByIdContactInfoResponse(ContactInfo contactInfo); 26 | 27 | @Mapping(source = "customer.id",target = "customerId") 28 | GetAllContactInfoResponse getAllContactInfo(ContactInfo contactInfo); 29 | List contactInfoToContactInfoList(List contactInfoList); 30 | 31 | @Mapping(source = "customer.id", target = "customerId") 32 | GetByContactInfoWithCustomerIdResponse contactInfoToContactInfoWithCustomerIdResponse(ContactInfo contactInfo); 33 | 34 | List contactInfoListToContactInfoWithCustomerIdResponseList(List contactInfoList); 35 | } 36 | -------------------------------------------------------------------------------- /payment-service/src/main/java/com/os/payment_service/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.payment_service.config; 2 | 3 | import io.swagger.v3.oas.annotations.OpenAPIDefinition; 4 | import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; 5 | import io.swagger.v3.oas.annotations.info.Info; 6 | import io.swagger.v3.oas.annotations.security.SecurityRequirement; 7 | import io.swagger.v3.oas.annotations.security.SecurityScheme; 8 | import io.swagger.v3.oas.annotations.servers.Server; 9 | import io.swagger.v3.oas.models.Components; 10 | import io.swagger.v3.oas.models.OpenAPI; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | @Configuration 15 | @OpenAPIDefinition( 16 | info = @Info(title = "Payment Service API", version = "1.0", description = "Payment Service API Documentation"), 17 | security = @SecurityRequirement(name = "bearerAuth"), 18 | servers = @Server(url = "http://localhost:8085") 19 | ) 20 | @SecurityScheme( 21 | name = "bearerAuth", 22 | type = SecuritySchemeType.HTTP, 23 | scheme = "bearer", 24 | bearerFormat = "JWT" 25 | ) 26 | 27 | public class SwaggerConfig { 28 | @Bean 29 | public OpenAPI customOpenAPI() { 30 | return new OpenAPI() 31 | .components(new Components() 32 | .addSecuritySchemes("bearerAuth", new io.swagger.v3.oas.models.security.SecurityScheme() 33 | .type(io.swagger.v3.oas.models.security.SecurityScheme.Type.HTTP) 34 | .scheme("bearer") 35 | .bearerFormat("JWT") 36 | .in(io.swagger.v3.oas.models.security.SecurityScheme.In.HEADER) 37 | .name("Authorization") 38 | ) 39 | ); 40 | } 41 | } -------------------------------------------------------------------------------- /order-service/src/main/java/com/os/order_service/service/impl/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.order_service.service.impl; 2 | 3 | import com.os.order_service.client.BasketClient; 4 | import com.os.order_service.model.Basket; 5 | import com.os.order_service.model.CustomerDto; 6 | import com.os.order_service.model.Order; 7 | import com.os.order_service.repository.OrderRepository; 8 | import com.os.order_service.service.OrderService; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | import java.util.Optional; 13 | 14 | 15 | @Service 16 | public class OrderServiceImpl implements OrderService { 17 | 18 | private final OrderRepository orderRepository; 19 | private final BasketClient basketClient; 20 | 21 | public OrderServiceImpl(OrderRepository orderRepository, BasketClient basketClient) { 22 | this.orderRepository = orderRepository; 23 | this.basketClient = basketClient; 24 | } 25 | 26 | @Override 27 | public Order createOrder(String basketId) { 28 | Basket basket = basketClient.findById(basketId); 29 | 30 | CustomerDto customer = basket.getCustomer(); 31 | 32 | Order order = new Order(); 33 | order.setCustomer(customer); 34 | order.setItems(basket.getItems()); 35 | order.setTotalPrice(basket.getTotalPrice()); 36 | order.setStatus("PENDING"); 37 | order.setBasketId(basketId); 38 | 39 | return orderRepository.save(order); 40 | 41 | } 42 | 43 | @Override 44 | public List getAllOrder() { 45 | return orderRepository.findAll(); 46 | } 47 | 48 | @Override 49 | public Optional getByIdOrder(String orderId) { 50 | 51 | return orderRepository.findById(orderId); 52 | } 53 | 54 | @Override 55 | public List getOrderHistoryForCustomer(Long customerId) { 56 | return orderRepository.findByCustomerId(customerId); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/controller/ProductElasticSearchController.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.controller; 2 | 3 | import com.os.search_service.document.Product; 4 | import com.os.search_service.service.ProductElasticSearchService; 5 | import org.springframework.web.bind.annotation.*; 6 | 7 | import java.math.BigDecimal; 8 | import java.util.List; 9 | 10 | @RestController 11 | @RequestMapping("/api/v1/productSearchService") 12 | public class ProductElasticSearchController { 13 | 14 | private final ProductElasticSearchService productElasticSearchService; 15 | 16 | public ProductElasticSearchController(ProductElasticSearchService productElasticSearchService) { 17 | this.productElasticSearchService = productElasticSearchService; 18 | } 19 | @GetMapping("/getAll/products") 20 | public Iterable getAllProducts() 21 | { 22 | return productElasticSearchService.getAllProducts(); 23 | } 24 | @GetMapping("/searchBy/productName") 25 | public List searchByProductName(@RequestParam String productName) 26 | { 27 | return productElasticSearchService.searchProductByName(productName); 28 | } 29 | @GetMapping("/findBy/priceBetween/{lowPrice}/{highPrice}") 30 | public List productPriceBetween(@PathVariable BigDecimal lowPrice, @PathVariable BigDecimal highPrice) 31 | { 32 | return productElasticSearchService.findByProductPriceBetween(lowPrice, highPrice); 33 | } 34 | @GetMapping("/findBy/productPriceAsc") 35 | public List findAllByProductByPriceAsc() 36 | { 37 | return productElasticSearchService.findAllByProductByPriceAsc(); 38 | } 39 | @GetMapping("/findBy/productPriceDesc") 40 | public List findAllByProductByPriceDesc() 41 | { 42 | return productElasticSearchService.findAllByProductByPriceDesc(); 43 | } 44 | @DeleteMapping("{id}") 45 | public void delete(@PathVariable String id) 46 | { 47 | productElasticSearchService.deleteProduct(id); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/model/User.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.model; 2 | 3 | import jakarta.persistence.*; 4 | import jakarta.validation.constraints.Email; 5 | import jakarta.validation.constraints.Pattern; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | import lombok.NoArgsConstructor; 9 | import lombok.Setter; 10 | import org.springframework.security.core.GrantedAuthority; 11 | import org.springframework.security.core.userdetails.UserDetails; 12 | 13 | import java.util.Collection; 14 | import java.util.List; 15 | import java.util.Set; 16 | 17 | @Getter 18 | @Setter 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Table(name = "users") 22 | @Entity 23 | public class User implements UserDetails { 24 | 25 | @Id 26 | @GeneratedValue 27 | private Long id; 28 | @Column(name = "password") 29 | private String password; 30 | @Column(name = "password_repeat") 31 | private String passwordRepeat; 32 | @Column(name = "email") 33 | private String email; 34 | @Column(name = "name") 35 | private String firstName; 36 | @Column(name = "surname") 37 | private String lastName; 38 | 39 | @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL) 40 | private Set contactInfo; 41 | 42 | @ManyToMany 43 | @JoinTable( 44 | name="user_roles", 45 | joinColumns = @JoinColumn(name="user_id"), 46 | inverseJoinColumns = @JoinColumn(name="role_id") 47 | ) 48 | private Set roles; 49 | @Override 50 | public Collection getAuthorities() { 51 | return roles; 52 | } 53 | 54 | @Override 55 | public String getUsername() { 56 | return email; 57 | } 58 | 59 | @Override 60 | public boolean isAccountNonExpired() { 61 | return true; 62 | } 63 | 64 | @Override 65 | public boolean isAccountNonLocked() { 66 | return true; 67 | } 68 | 69 | @Override 70 | public boolean isCredentialsNonExpired() { 71 | return true; 72 | } 73 | 74 | @Override 75 | public boolean isEnabled() { 76 | return true; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /config-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.gezi-rehberim 12 | config-server 13 | 0.0.1-SNAPSHOT 14 | config-server 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-config-server 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-test 46 | test 47 | 48 | 49 | 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-dependencies 54 | ${spring-cloud.version} 55 | pom 56 | import 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-maven-plugin 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/controller/CategoryController.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.controller; 2 | 3 | import com.os.product_service.dto.request.category.CreateCategoryRequest; 4 | import com.os.product_service.dto.request.category.UpdateCategoryRequest; 5 | import com.os.product_service.dto.response.category.CreateCategoryResponse; 6 | import com.os.product_service.dto.response.category.GetAllCategoryResponse; 7 | import com.os.product_service.dto.response.category.GetByIdCategoryResponse; 8 | import com.os.product_service.dto.response.category.UpdateCategoryResponse; 9 | import com.os.product_service.service.CategoryService; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.util.List; 13 | import java.util.Optional; 14 | 15 | @RestController 16 | @RequestMapping("/api/v1/category") 17 | public class CategoryController { 18 | 19 | private final CategoryService categoryService; 20 | 21 | public CategoryController(CategoryService categoryService) { 22 | this.categoryService = categoryService; 23 | } 24 | 25 | @GetMapping("/getById/category/{categoryId}") 26 | public Optional getById(@PathVariable Long categoryId) 27 | { 28 | return categoryService.getCategory(categoryId); 29 | } 30 | @GetMapping("/listOf/category") 31 | public List listOfCategory() 32 | { 33 | return categoryService.getAllCategories(); 34 | } 35 | @DeleteMapping("/delete/category/{categoryId}") 36 | public void deleteCategory(@PathVariable Long categoryId) 37 | { 38 | categoryService.deleteCategory(categoryId); 39 | } 40 | @PostMapping("/create/category") 41 | public CreateCategoryResponse createCategory(@RequestBody CreateCategoryRequest createCategoryRequest) 42 | { 43 | return categoryService.createCategory(createCategoryRequest); 44 | } 45 | @PutMapping("/update/category/{categoryId}") 46 | public UpdateCategoryResponse updateCategory(@PathVariable Long categoryId, @RequestBody UpdateCategoryRequest updateCategoryRequest) 47 | { 48 | return categoryService.updateCategory(categoryId,updateCategoryRequest); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /discovery-server/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.gezi-rehberim 12 | discovery-server 13 | 0.0.1-SNAPSHOT 14 | discovery-server 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-netflix-eureka-server 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-config 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-dependencies 53 | ${spring-cloud.version} 54 | pom 55 | import 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.controller; 2 | 3 | import com.os.customer_service.dto.request.role.RoleRequest; 4 | import com.os.customer_service.dto.response.role.RoleWithUserResponse; 5 | import com.os.customer_service.dto.response.user.GetByIdUserResponse; 6 | import com.os.customer_service.model.Role; 7 | import com.os.customer_service.model.User; 8 | import com.os.customer_service.service.RoleService; 9 | import com.os.customer_service.service.UserService; 10 | import org.springframework.http.ResponseEntity; 11 | import org.springframework.web.bind.annotation.*; 12 | 13 | import java.util.Optional; 14 | 15 | @RestController 16 | @RequestMapping("/api/v1/roles") 17 | public class RoleController { 18 | private final RoleService roleService; 19 | private final UserService userService; 20 | 21 | public RoleController(RoleService roleService, UserService userService) { 22 | this.roleService = roleService; 23 | this.userService = userService; 24 | } 25 | 26 | @PostMapping("/createRoles") 27 | public ResponseEntity addRole(@RequestBody RoleRequest role) { 28 | Role newRole = roleService.addRole(role); 29 | return ResponseEntity.ok(newRole); 30 | } 31 | @PostMapping("/{userId}/roles/{roleId}") 32 | public ResponseEntity assignRoleToUser(@PathVariable Long userId, @PathVariable Long roleId) { 33 | Optional userOptional = userService.getUserByIdForRole(userId); 34 | Optional roleOptional = roleService.getRoleById(roleId); 35 | 36 | if (userOptional.isPresent() && roleOptional.isPresent()) { 37 | User user = userOptional.get(); 38 | Role role = roleOptional.get(); 39 | 40 | // Rolü kullanıcının rollerine ekle 41 | user.getRoles().add(role); 42 | 43 | // Kullanıcıyı güncelle 44 | userService.add(user); // Bu metodun implementasyonunu kontrol edin 45 | 46 | RoleWithUserResponse roleWithUserResponse = new RoleWithUserResponse(userId, roleId); 47 | return ResponseEntity.ok(roleWithUserResponse); 48 | } else { 49 | return ResponseEntity.notFound().build(); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/exception/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.exception; 2 | 3 | import com.os.customer_service.exception.type.WrongUsernameOrPassword; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.validation.FieldError; 7 | import org.springframework.web.bind.MethodArgumentNotValidException; 8 | import org.springframework.web.bind.annotation.ExceptionHandler; 9 | import org.springframework.web.bind.annotation.ResponseStatus; 10 | import org.springframework.web.bind.annotation.RestControllerAdvice; 11 | import org.turkcell.tcell.exception.exceptions.details.BusinessExceptionDetails; 12 | import org.turkcell.tcell.exception.exceptions.type.BaseBusinessException; 13 | 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | @RestControllerAdvice 18 | public class GlobalExceptionHandler { 19 | 20 | @ExceptionHandler(MethodArgumentNotValidException.class) 21 | @ResponseStatus(HttpStatus.BAD_REQUEST) 22 | public Map handleValidationExceptions(MethodArgumentNotValidException ex) { 23 | Map errors = new HashMap<>(); 24 | ex.getBindingResult().getAllErrors().forEach((error) -> { 25 | String fieldName = ((FieldError) error).getField(); 26 | String errorMessage = error.getDefaultMessage(); 27 | errors.put(fieldName, errorMessage); 28 | }); 29 | return errors; 30 | } 31 | @ExceptionHandler(BaseBusinessException.class) 32 | @ResponseStatus(HttpStatus.BAD_REQUEST) 33 | public ResponseEntity handleBusinessException(BaseBusinessException exception) { 34 | BusinessExceptionDetails businessExceptionDetails = new BusinessExceptionDetails(); 35 | businessExceptionDetails.setTitle(exception.getMessage()); 36 | return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(businessExceptionDetails); 37 | } 38 | @ExceptionHandler(WrongUsernameOrPassword.class) 39 | public ResponseEntity handleWrongUsernameOrPassword(WrongUsernameOrPassword ex) { 40 | return ResponseEntity 41 | .status(HttpStatus.UNAUTHORIZED) 42 | .body(ex.getMessage()); 43 | } 44 | } -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/kafka/ProductConsumer.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.kafka; 2 | 3 | import com.os.search_service.document.Product; 4 | import com.os.search_service.dto.DeleteProductRequest; 5 | import com.os.search_service.service.ProductElasticSearchService; 6 | import lombok.RequiredArgsConstructor; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.apache.kafka.clients.consumer.ConsumerRecord; 9 | import org.springframework.kafka.annotation.KafkaListener; 10 | import org.springframework.stereotype.Service; 11 | 12 | @Service 13 | @RequiredArgsConstructor 14 | @Slf4j 15 | public class ProductConsumer { 16 | 17 | private final ProductElasticSearchService productElasticSearchService; 18 | 19 | // ekleme 20 | @KafkaListener(topics = "${spring.kafka.template.product-topic}", 21 | groupId = "${spring.kafka.consumer.group-id}", 22 | containerFactory = "kafkaListenerContainerFactory") 23 | public void createConsumer(ConsumerRecord payload) { 24 | productElasticSearchService.saveProduct(payload.value()); 25 | System.out.println("Consumer tarafından oluştur mesaj alındı : " + payload.value()); 26 | } 27 | // silme 28 | @KafkaListener(topics = "${spring.kafka.template.product-delete-topic}", 29 | groupId = "${spring.kafka.consumer.group-id}", 30 | containerFactory = "kafkaListenerDeleteProductContainerFactory") 31 | public void deleteProductConsumer(ConsumerRecord payload) { 32 | DeleteProductRequest product = payload.value(); 33 | productElasticSearchService.deleteProduct(product.getId().toString()); 34 | System.out.println("Consumer tarafından sil mesaj alındı : " + payload.value()); 35 | } 36 | 37 | //güncelleme 38 | @KafkaListener(topics = "${spring.kafka.template.product-update-topic}", 39 | groupId = "${spring.kafka.consumer.group-id}", 40 | containerFactory = "kafkaListenerUpdateProductContainerFactory") 41 | public void updateProductConsumer(ConsumerRecord payload) { 42 | productElasticSearchService.updateProduct(payload.value()); 43 | System.out.println("Consumer tarafından güncelle mesaj alındı : " + payload.value()); 44 | } 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /basket-service/src/main/java/com/os/basket_service/controller/BasketController.java: -------------------------------------------------------------------------------- 1 | package com.os.basket_service.controller; 2 | 3 | import com.os.basket_service.model.Basket; 4 | import com.os.basket_service.model.BasketItem; 5 | import com.os.basket_service.service.BasketService; 6 | import com.os.spring_security.security.BaseJwtService; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.Optional; 14 | 15 | @RestController 16 | @RequestMapping("/api/v1/basket") 17 | public class BasketController { 18 | 19 | private final BasketService basketService; 20 | private final BaseJwtService baseJwtService; 21 | 22 | public BasketController(BasketService basketService, BaseJwtService baseJwtService) { 23 | this.basketService = basketService; 24 | this.baseJwtService = baseJwtService; 25 | } 26 | @GetMapping("/basket/findById/{basketId}") 27 | public Optional findById(@PathVariable("basketId") String basketId) 28 | { 29 | return basketService.findByBasketId(basketId); 30 | } 31 | @GetMapping("/product/{productId}") 32 | public void product(@PathVariable Long productId) 33 | { 34 | basketService.productController(productId); 35 | } 36 | @GetMapping("/findBy/customersBasket/{customerId}") 37 | public Basket findByCustomerBasket(@PathVariable Long customerId) 38 | { 39 | return basketService.findByCustomersBasket(customerId); 40 | } 41 | @PostMapping("/create") 42 | public ResponseEntity createBasketItem(@RequestHeader("Authorization") String token, @RequestBody Map productQuantities) { 43 | String tokenTrim = token.trim(); 44 | String substring = tokenTrim.substring(7); 45 | Integer customerId = baseJwtService.extractUserId(substring); 46 | Basket basket = basketService.createBasketItem(Long.valueOf(customerId), productQuantities); 47 | return new ResponseEntity<>(basket, HttpStatus.CREATED); 48 | } 49 | @DeleteMapping("/delete/basket/beforeOrder/{basketId}") 50 | public void deleteBasketBeforeOrder(@PathVariable("basketId") String basketId) 51 | { 52 | basketService.deleteBasket(basketId); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/kafka/SearchServiceProducer.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.kafka; 2 | 3 | import com.os.product_service.dto.request.product.CreateProductRequest; 4 | import com.os.product_service.dto.request.product.DeleteProductRequest; 5 | import com.os.product_service.dto.response.product.CreateProductResponse; 6 | import com.os.product_service.dto.response.product.UpdateProductResponse; 7 | import com.os.product_service.model.Product; 8 | import lombok.AllArgsConstructor; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.beans.factory.annotation.Value; 11 | import org.springframework.kafka.core.KafkaTemplate; 12 | import org.springframework.stereotype.Service; 13 | 14 | @Service 15 | public class SearchServiceProducer { 16 | 17 | private final KafkaTemplate kafkaTemplate; 18 | private final KafkaTemplate kafkaDeleteTemplate; 19 | private final KafkaTemplate kafkaUpdateTemplate; 20 | 21 | public SearchServiceProducer(KafkaTemplate kafkaTemplate, KafkaTemplate kafkaDeleteTemplate, KafkaTemplate kafkaUpdateTemplate) { 22 | this.kafkaTemplate = kafkaTemplate; 23 | this.kafkaDeleteTemplate = kafkaDeleteTemplate; 24 | this.kafkaUpdateTemplate = kafkaUpdateTemplate; 25 | } 26 | 27 | @Value("${spring.kafka.template.product-topic}") 28 | private String defaultTopic; 29 | 30 | @Value("${spring.kafka.template.product-delete-topic}") 31 | private String deleteTopic; 32 | 33 | @Value("${spring.kafka.template.product-update-topic}") 34 | private String updateTopic; 35 | 36 | public void sendMessage(CreateProductResponse message) { 37 | System.out.println("Sending message: " + message); 38 | kafkaTemplate.send(defaultTopic, message); 39 | 40 | } 41 | public void deleteSendMessage(DeleteProductRequest message) 42 | { 43 | System.out.println("Deleting message: " + message); 44 | kafkaDeleteTemplate.send(deleteTopic,message); 45 | } 46 | public void updateSendMessage(UpdateProductResponse message) 47 | { 48 | System.out.println("Update message: " + message); 49 | kafkaUpdateTemplate.send(updateTopic,message); 50 | } 51 | 52 | } 53 | //spring.kafka.template.product-delete-topic -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/controller/ContactInfoController.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.controller; 2 | 3 | import com.os.customer_service.dto.request.contactinfo.CreateContactInfoRequest; 4 | import com.os.customer_service.dto.request.contactinfo.UpdateContactInfoRequest; 5 | import com.os.customer_service.dto.response.contactinfo.*; 6 | import com.os.customer_service.service.ContactInfoService; 7 | import jakarta.validation.Valid; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import java.util.List; 11 | import java.util.Optional; 12 | 13 | @RestController 14 | @RequestMapping("/api/v1/contactInfo") 15 | public class ContactInfoController { 16 | 17 | private final ContactInfoService contactInfoService; 18 | 19 | public ContactInfoController(ContactInfoService contactInfoService) { 20 | this.contactInfoService = contactInfoService; 21 | } 22 | 23 | @GetMapping("/list/contactInfo") 24 | public List getAllContactInfoResponse() 25 | { 26 | return contactInfoService.getAllContactInfo(); 27 | } 28 | 29 | @GetMapping("/getById/contactInfo/{contactInfoId}") 30 | public Optional getByIdContactInfoResponse(@PathVariable Long contactInfoId) 31 | { 32 | return contactInfoService.getByIdContactInfo(contactInfoId); 33 | } 34 | @GetMapping("/customer/{customerId}") 35 | public List getContactInfosByCustomerId(@PathVariable Long customerId) { 36 | return contactInfoService.getByCustomerId(customerId); 37 | } 38 | @DeleteMapping("/delete/contactInfo/{contactInfoId}") 39 | public void deleteContactInfo(@PathVariable Long contactInfoId) 40 | { 41 | contactInfoService.deleteContactInfo(contactInfoId); 42 | } 43 | @PostMapping("/create/contactInfo") 44 | public CreateContactInfoResponse createContactInfo(@Valid @RequestBody CreateContactInfoRequest createContactInfoRequest) 45 | { 46 | return contactInfoService.createContactInfo(createContactInfoRequest); 47 | } 48 | @PutMapping("/update/contactInfo/{contactInfoId}") 49 | public UpdateContactInfoResponse updateContactInfo(@PathVariable Long contactInfoId,@RequestBody UpdateContactInfoRequest updateContactInfoRequest) 50 | { 51 | return contactInfoService.updateContactInfo(contactInfoId, updateContactInfoRequest); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/config/KafkaConsumerConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service.config; 2 | 3 | import com.os.notification_service.model.OrderNotification; 4 | import org.apache.kafka.clients.consumer.ConsumerConfig; 5 | import org.apache.kafka.common.serialization.StringDeserializer; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.kafka.annotation.EnableKafka; 10 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; 11 | import org.springframework.kafka.core.ConsumerFactory; 12 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; 13 | import org.springframework.kafka.support.serializer.JsonDeserializer; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | @Configuration 19 | @EnableKafka 20 | public class KafkaConsumerConfig { 21 | 22 | @Value("${spring.kafka.bootstrap-servers}") 23 | private String kafkaAddress; 24 | 25 | @Value("${spring.kafka.consumer.group-id}") 26 | private String groupId; 27 | 28 | @Bean 29 | public ConsumerFactory consumerFactory() { 30 | JsonDeserializer jsonDeserializer = new JsonDeserializer<>(OrderNotification.class); 31 | jsonDeserializer.addTrustedPackages("*"); // Specify trusted packages 32 | jsonDeserializer.setUseTypeHeaders(false); // If type headers are not used 33 | 34 | Map props = new HashMap<>(); 35 | props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaAddress); 36 | props.put(ConsumerConfig.GROUP_ID_CONFIG, groupId); 37 | props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 38 | props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class.getName()); // Use class name 39 | 40 | return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), jsonDeserializer); 41 | } 42 | 43 | @Bean 44 | public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() { 45 | ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>(); 46 | factory.setConsumerFactory(consumerFactory()); 47 | return factory; 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/config/SearchServiceProducerConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.config; 2 | 3 | import com.os.product_service.dto.request.product.CreateProductRequest; 4 | import com.os.product_service.dto.request.product.DeleteProductRequest; 5 | import com.os.product_service.dto.response.product.CreateProductResponse; 6 | import com.os.product_service.dto.response.product.UpdateProductResponse; 7 | import com.os.product_service.model.Product; 8 | import org.apache.kafka.clients.producer.ProducerConfig; 9 | import org.apache.kafka.common.serialization.StringSerializer; 10 | import org.springframework.beans.factory.annotation.Value; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.kafka.annotation.EnableKafka; 14 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; 15 | import org.springframework.kafka.core.KafkaTemplate; 16 | import org.springframework.kafka.core.ProducerFactory; 17 | import org.springframework.kafka.support.serializer.JsonSerializer; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | @Configuration 23 | @EnableKafka 24 | public class SearchServiceProducerConfig { 25 | 26 | @Value("${spring.kafka.bootstrap-servers}") 27 | private String kafkaAddress; 28 | 29 | private ProducerFactory producerFactory(Class valueType) { 30 | Map configProps = new HashMap<>(); 31 | configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaAddress); 32 | configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 33 | configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); 34 | return new DefaultKafkaProducerFactory<>(configProps); 35 | } 36 | 37 | @Bean 38 | public KafkaTemplate createProductKafkaTemplate() { 39 | return new KafkaTemplate<>(producerFactory(CreateProductResponse.class)); 40 | } 41 | 42 | @Bean 43 | public KafkaTemplate deleteProductKafkaTemplate() { 44 | return new KafkaTemplate<>(producerFactory(DeleteProductRequest.class)); 45 | } 46 | 47 | @Bean 48 | public KafkaTemplate updateProductKafkaTemplate() { 49 | return new KafkaTemplate<>(producerFactory(UpdateProductResponse.class)); 50 | } 51 | 52 | 53 | 54 | } 55 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.config; 2 | 3 | import com.os.customer_service.service.UserService; 4 | import com.turkcell.tcell.core.security.BaseSecurityService; 5 | import lombok.RequiredArgsConstructor; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.authentication.AuthenticationManager; 9 | import org.springframework.security.authentication.AuthenticationProvider; 10 | import org.springframework.security.authentication.dao.DaoAuthenticationProvider; 11 | import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; 12 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 13 | import org.springframework.security.crypto.password.PasswordEncoder; 14 | import org.springframework.security.web.SecurityFilterChain; 15 | 16 | @Configuration 17 | @RequiredArgsConstructor 18 | public class SecurityConfig { 19 | private final UserService userService; 20 | private final PasswordEncoder passwordEncoder; 21 | private final BaseSecurityService baseSecurityService; 22 | 23 | private static final String[] WHITE_LIST = { 24 | "/api/v1/auth/**", 25 | "/swagger-ui/**", 26 | "/v2/api-docs", 27 | "/v3/api-docs", 28 | "/v3/api-docs/**", 29 | "/api/v1/**", 30 | }; 31 | @Bean 32 | public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { 33 | baseSecurityService.configureCommonSecurityRules(http); 34 | http 35 | .authorizeHttpRequests(authorizeRequests -> 36 | authorizeRequests 37 | 38 | .anyRequest().permitAll() 39 | ); 40 | return http.build(); 41 | } 42 | @Bean 43 | public AuthenticationProvider authenticationProvider() { 44 | DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); 45 | daoAuthenticationProvider.setPasswordEncoder(passwordEncoder); 46 | daoAuthenticationProvider.setUserDetailsService(userService); 47 | return daoAuthenticationProvider; 48 | } 49 | 50 | @Bean 51 | public AuthenticationManager authenticationManager(AuthenticationConfiguration configuration) throws Exception { 52 | return configuration.getAuthenticationManager(); 53 | } 54 | } -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.controller; 2 | 3 | import com.os.product_service.dto.request.product.CreateProductRequest; 4 | import com.os.product_service.dto.request.product.UpdateProductRequest; 5 | import com.os.product_service.dto.response.product.CreateProductResponse; 6 | import com.os.product_service.dto.response.product.GetAllProductResponse; 7 | import com.os.product_service.dto.response.product.GetByIdProductResponse; 8 | import com.os.product_service.dto.response.product.UpdateProductResponse; 9 | import com.os.product_service.service.ProductService; 10 | import jakarta.ws.rs.Path; 11 | import org.springframework.http.HttpStatus; 12 | import org.springframework.http.ResponseEntity; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | @RestController 19 | @RequestMapping("/api/v1/product") 20 | public class ProductController { 21 | 22 | private final ProductService productService; 23 | 24 | public ProductController(ProductService productService) { 25 | this.productService = productService; 26 | } 27 | 28 | @GetMapping("/getAllProducts") 29 | public List getAllProducts() { 30 | return productService.getAllProducts(); 31 | } 32 | 33 | @GetMapping("/getById/product/{id}") 34 | public Optional getProductById(@PathVariable Long id) { 35 | return productService.getProductById(id); 36 | } 37 | @GetMapping("/products/category/{categoryId}") 38 | public List getAllProductWithCategory(@PathVariable Long categoryId) 39 | { 40 | return productService.findByProductWithCategoryId(categoryId); 41 | } 42 | @DeleteMapping("/delete/product/{id}") 43 | public ResponseEntity deleteProduct(@PathVariable Long id) { 44 | productService.deleteProduct(id); 45 | return new ResponseEntity<>(HttpStatus.NO_CONTENT); 46 | } 47 | @PostMapping("/create/product") 48 | @ResponseStatus(HttpStatus.CREATED) 49 | public CreateProductResponse addProduct(@RequestBody CreateProductRequest request) { 50 | return productService.addProduct(request); 51 | } 52 | 53 | @PutMapping("/update/product/{id}") 54 | public UpdateProductResponse updateProduct(@PathVariable Long id, @RequestBody UpdateProductRequest request) { 55 | return productService.updateProduct(id, request); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 44 | 45 | -------------------------------------------------------------------------------- /search-service/src/main/java/com/os/search_service/service/impl/ProductElasticSearchServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.search_service.service.impl; 2 | 3 | import com.os.search_service.document.Product; 4 | import com.os.search_service.repository.ProductElasticSearchRepository; 5 | import com.os.search_service.service.ProductElasticSearchService; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.math.BigDecimal; 9 | import java.util.List; 10 | import java.util.Optional; 11 | 12 | @Service 13 | public class ProductElasticSearchServiceImpl implements ProductElasticSearchService { 14 | 15 | private final ProductElasticSearchRepository productElasticSearchRepository; 16 | 17 | public ProductElasticSearchServiceImpl(ProductElasticSearchRepository productElasticSearchRepository) { 18 | this.productElasticSearchRepository = productElasticSearchRepository; 19 | } 20 | 21 | @Override 22 | public Product saveProduct(Product product) { 23 | return productElasticSearchRepository.save(product); 24 | } 25 | 26 | @Override 27 | public Iterable getAllProducts() { 28 | return productElasticSearchRepository.findAll(); 29 | } 30 | 31 | @Override 32 | public List searchProductByName(String productName) { 33 | return productElasticSearchRepository.searchByProductName(productName); 34 | } 35 | 36 | @Override 37 | public List findByProductPriceBetween(BigDecimal low, BigDecimal high) { 38 | return productElasticSearchRepository.findByPriceBetween(low,high); 39 | } 40 | 41 | @Override 42 | public void deleteProduct(String id) { 43 | productElasticSearchRepository.deleteById(id); 44 | } 45 | 46 | @Override 47 | public Product updateProduct(Product product) { 48 | Optional optionalProduct = productElasticSearchRepository.findById(product.getId().toString()); 49 | Product existingProduct = optionalProduct.get(); 50 | 51 | existingProduct.setName(product.getName()); 52 | existingProduct.setDescription(product.getDescription()); 53 | existingProduct.setPrice(product.getPrice()); 54 | existingProduct.setCategoryId(product.getCategoryId()); 55 | 56 | return productElasticSearchRepository.save(existingProduct); 57 | } 58 | 59 | @Override 60 | public List findAllByProductByPriceAsc() { 61 | return productElasticSearchRepository.findAllByOrderByPriceAsc(); 62 | } 63 | 64 | @Override 65 | public List findAllByProductByPriceDesc() { 66 | return productElasticSearchRepository.findAllByOrderByPriceDesc(); 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /customer-service/src/main/java/com/os/customer_service/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.customer_service.service.impl; 2 | 3 | import com.os.customer_service.dto.request.user.UpdateUserRequest; 4 | import com.os.customer_service.dto.response.user.GetByIdUserResponse; 5 | import com.os.customer_service.dto.response.user.UpdateUserResponse; 6 | import com.os.customer_service.dto.response.user.UserResponse; 7 | import com.os.customer_service.mapper.UserMapper; 8 | import com.os.customer_service.model.User; 9 | import com.os.customer_service.repository.UserRepository; 10 | import com.os.customer_service.service.UserService; 11 | import org.springframework.security.core.userdetails.UserDetails; 12 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 13 | import org.springframework.stereotype.Service; 14 | 15 | import java.util.List; 16 | import java.util.Optional; 17 | 18 | @Service 19 | public class UserServiceImpl implements UserService { 20 | 21 | private final UserRepository userRepositories; 22 | 23 | public UserServiceImpl(UserRepository userRepositories) { 24 | this.userRepositories = userRepositories; 25 | } 26 | 27 | @Override 28 | public void add(User user) { 29 | userRepositories.save(user); 30 | } 31 | @Override 32 | public Optional getUserById(Long id) { 33 | Optional user = userRepositories.findById(id); 34 | if (user.isEmpty()) 35 | { 36 | throw new RuntimeException("UserMessage.USER_NOT_FOUND"); 37 | } 38 | return user.map(UserMapper.INSTANCE::getByIdUserResponse); 39 | } 40 | 41 | @Override 42 | public Optional getUserByIdForRole(Long id) { 43 | Optional user = userRepositories.findById(id); 44 | return user; 45 | } 46 | 47 | @Override 48 | public List getAllUser() { 49 | List users = userRepositories.findAll(); 50 | return UserMapper.INSTANCE.usersFromResponse(users); 51 | } 52 | 53 | @Override 54 | public UpdateUserResponse updateUser(UpdateUserRequest updateUserRequest, Long id) { 55 | Optional userOptional = userRepositories.findById(id); 56 | if (userOptional.isEmpty()){} 57 | User existingUser = userOptional.get(); 58 | User user = UserMapper.INSTANCE.updateUser(updateUserRequest, existingUser); 59 | User savedUser = userRepositories.save(user); 60 | return new UpdateUserResponse(savedUser.getId(),savedUser.getPassword(), savedUser.getPasswordRepeat(),savedUser.getFirstName(),savedUser.getLastName()); 61 | } 62 | 63 | @Override 64 | public void deleteUser(Long id) { 65 | userRepositories.deleteById(id); 66 | } 67 | 68 | @Override 69 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 70 | return userRepositories.findByEmail(username) 71 | .orElseThrow(() -> new RuntimeException("User not found with email or password ")); 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /notification-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.os 12 | notification-service 13 | 0.0.1-SNAPSHOT 14 | notification-service 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-mail 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-netflix-eureka-client 45 | 46 | 47 | org.springframework.kafka 48 | spring-kafka 49 | 50 | 51 | org.springframework.cloud 52 | spring-cloud-starter-config 53 | 54 | 55 | org.springframework.boot 56 | spring-boot-devtools 57 | runtime 58 | true 59 | 60 | 61 | org.projectlombok 62 | lombok 63 | true 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-starter-test 68 | test 69 | 70 | 71 | org.springframework.kafka 72 | spring-kafka-test 73 | test 74 | 75 | 76 | 77 | 78 | 79 | org.springframework.cloud 80 | spring-cloud-dependencies 81 | ${spring-cloud.version} 82 | pom 83 | import 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | org.springframework.boot 92 | spring-boot-maven-plugin 93 | 94 | 95 | 96 | org.projectlombok 97 | lombok 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /order-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.os 12 | order-service 13 | 0.0.1-SNAPSHOT 14 | order-service 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-mongodb 37 | 38 | 39 | io.github.oguzhansecgel 40 | tcell.core 41 | 2.0.7 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-web 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-starter-config 50 | 51 | 52 | org.springframework.cloud 53 | spring-cloud-starter-netflix-eureka-client 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-openfeign 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-devtools 62 | runtime 63 | true 64 | 65 | 66 | org.projectlombok 67 | lombok 68 | true 69 | 70 | 71 | org.springdoc 72 | springdoc-openapi-starter-webmvc-ui 73 | 2.2.0 74 | 75 | 76 | 77 | org.springframework.boot 78 | spring-boot-starter-test 79 | test 80 | 81 | 82 | 83 | 84 | 85 | org.springframework.cloud 86 | spring-cloud-dependencies 87 | ${spring-cloud.version} 88 | pom 89 | import 90 | 91 | 92 | 93 | 94 | 95 | 96 | org.springframework.boot 97 | spring-boot-maven-plugin 98 | 99 | 100 | 101 | org.projectlombok 102 | lombok 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /search-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.os 12 | search-service 13 | 0.0.1-SNAPSHOT 14 | search-service 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-elasticsearch 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-config 45 | 46 | 47 | org.springframework.cloud 48 | spring-cloud-starter-netflix-eureka-client 49 | 50 | 51 | org.springframework.kafka 52 | spring-kafka 53 | 54 | 55 | org.springdoc 56 | springdoc-openapi-starter-webmvc-ui 57 | 2.2.0 58 | 59 | 60 | 61 | org.springframework.boot 62 | spring-boot-devtools 63 | runtime 64 | true 65 | 66 | 67 | org.projectlombok 68 | lombok 69 | true 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-starter-test 74 | test 75 | 76 | 77 | org.springframework.kafka 78 | spring-kafka-test 79 | test 80 | 81 | 82 | 83 | 84 | 85 | org.springframework.cloud 86 | spring-cloud-dependencies 87 | ${spring-cloud.version} 88 | pom 89 | import 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | org.springframework.boot 98 | spring-boot-maven-plugin 99 | 100 | 101 | 102 | org.projectlombok 103 | lombok 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /product-service/src/main/java/com/os/product_service/service/impl/CategoryServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.product_service.service.impl; 2 | 3 | import com.os.product_service.dto.request.category.CreateCategoryRequest; 4 | import com.os.product_service.dto.request.category.UpdateCategoryRequest; 5 | import com.os.product_service.dto.response.category.CreateCategoryResponse; 6 | import com.os.product_service.dto.response.category.GetAllCategoryResponse; 7 | import com.os.product_service.dto.response.category.GetByIdCategoryResponse; 8 | import com.os.product_service.dto.response.category.UpdateCategoryResponse; 9 | import com.os.product_service.exception.type.CategoryNotFoundException; 10 | import com.os.product_service.mapper.CategoryMapping; 11 | import com.os.product_service.model.Category; 12 | import com.os.product_service.repository.CategoryRepository; 13 | import com.os.product_service.service.CategoryService; 14 | import com.os.product_service.utils.message.CategoryMessage; 15 | import org.springframework.cache.annotation.CacheEvict; 16 | import org.springframework.cache.annotation.Cacheable; 17 | import org.springframework.stereotype.Service; 18 | 19 | import java.util.List; 20 | import java.util.Optional; 21 | 22 | 23 | @Service 24 | public class CategoryServiceImpl implements CategoryService { 25 | 26 | private final CategoryRepository categoryRepository; 27 | 28 | public CategoryServiceImpl(CategoryRepository categoryRepository) { 29 | this.categoryRepository = categoryRepository; 30 | } 31 | 32 | @Override 33 | @CacheEvict(value = "category",key = "'getAll'") 34 | public CreateCategoryResponse createCategory(CreateCategoryRequest request) { 35 | Category category = CategoryMapping.INSTANCE.createCategory(request); 36 | Category savedCategory = categoryRepository.save(category); 37 | return new CreateCategoryResponse(savedCategory.getId(),savedCategory.getName()); 38 | } 39 | 40 | @Override 41 | @CacheEvict(value = "category",key = "'getAll'") 42 | public UpdateCategoryResponse updateCategory(Long id, UpdateCategoryRequest request) { 43 | Optional optionalCategory = categoryRepository.findById(id); 44 | if (optionalCategory.isEmpty()) 45 | { 46 | throw new CategoryNotFoundException(CategoryMessage.CATEGORY_NOT_FOUND); 47 | } 48 | Category categoryExisting = optionalCategory.get(); 49 | Category category = CategoryMapping.INSTANCE.updateCategory(request,categoryExisting); 50 | Category savedCategory = categoryRepository.save(category); 51 | return new UpdateCategoryResponse(savedCategory.getId(),savedCategory.getName()); 52 | } 53 | 54 | @Override 55 | @Cacheable(value = "category",key = "'getAll'") 56 | public List getAllCategories() { 57 | List categories = categoryRepository.findAll(); 58 | return CategoryMapping.INSTANCE.listToGetAllCategory(categories); 59 | } 60 | 61 | @Override 62 | @Cacheable(value = "category",key = "#id") 63 | public Optional getCategory(Long id) { 64 | Optional optionalCategory = categoryRepository.findById(id); 65 | if (optionalCategory.isEmpty()) 66 | { 67 | throw new CategoryNotFoundException(CategoryMessage.CATEGORY_NOT_FOUND); 68 | } 69 | return optionalCategory.map(CategoryMapping.INSTANCE::getByIdCategory); 70 | } 71 | 72 | @Override 73 | @CacheEvict(value = "category",key = "#id",allEntries = true) 74 | public void deleteCategory(Long id) { 75 | Optional optionalCategory = categoryRepository.findById(id); 76 | if (optionalCategory.isEmpty()) 77 | { 78 | throw new CategoryNotFoundException(CategoryMessage.CATEGORY_NOT_FOUND); 79 | } 80 | categoryRepository.deleteById(id); 81 | } 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /payment-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.os 12 | payment-service 13 | 0.0.1-SNAPSHOT 14 | payment-service 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-config 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-devtools 45 | runtime 46 | true 47 | 48 | 49 | org.projectlombok 50 | lombok 51 | true 52 | 53 | 54 | 55 | io.github.oguzhansecgel 56 | tcell.core 57 | 2.0.7 58 | 59 | 60 | 61 | org.springframework.cloud 62 | spring-cloud-starter-netflix-eureka-client 63 | 64 | 65 | org.springframework.cloud 66 | spring-cloud-starter-openfeign 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-starter-test 71 | test 72 | 73 | 74 | org.springdoc 75 | springdoc-openapi-starter-webmvc-ui 76 | 2.2.0 77 | 78 | 79 | 80 | com.iyzipay 81 | iyzipay-java 82 | 2.0.127 83 | 84 | 85 | org.springframework.kafka 86 | spring-kafka 87 | 88 | 89 | 90 | 91 | 92 | org.springframework.cloud 93 | spring-cloud-dependencies 94 | ${spring-cloud.version} 95 | pom 96 | import 97 | 98 | 99 | 100 | 101 | 102 | 103 | org.springframework.boot 104 | spring-boot-maven-plugin 105 | 106 | 107 | 108 | org.projectlombok 109 | lombok 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /basket-service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 3.3.4 9 | 10 | 11 | com.os 12 | basket-service 13 | 0.0.1-SNAPSHOT 14 | basket-service 15 | Demo project for Spring Boot 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 17 31 | 2023.0.3 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-data-mongodb 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | 48 | 49 | com.os 50 | spring-security 51 | 1.0.0 52 | 53 | 54 | 55 | 56 | org.springframework.cloud 57 | spring-cloud-starter-netflix-eureka-client 58 | 59 | 60 | org.springframework.cloud 61 | spring-cloud-starter-openfeign 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-devtools 66 | runtime 67 | true 68 | 69 | 70 | org.springdoc 71 | springdoc-openapi-starter-webmvc-ui 72 | 2.2.0 73 | 74 | 75 | org.springframework.cloud 76 | spring-cloud-starter-config 77 | 78 | 79 | org.projectlombok 80 | lombok 81 | true 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-starter-cache 86 | 87 | 88 | org.springframework.boot 89 | spring-boot-starter-data-redis 90 | 91 | 92 | org.springframework.boot 93 | spring-boot-starter-test 94 | test 95 | 96 | 97 | org.springframework.boot 98 | spring-boot-starter-security 99 | 100 | 101 | 102 | 103 | 104 | org.springframework.cloud 105 | spring-cloud-dependencies 106 | ${spring-cloud.version} 107 | pom 108 | import 109 | 110 | 111 | 112 | 113 | 114 | 115 | org.springframework.boot 116 | spring-boot-maven-plugin 117 | 118 | 119 | 120 | org.projectlombok 121 | lombok 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /notification-service/src/main/java/com/os/notification_service/service/impl/OrderNotificationServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.os.notification_service.service.impl; 2 | 3 | import com.os.notification_service.model.OrderNotification; 4 | import com.os.notification_service.model.ProductNotification; 5 | import com.os.notification_service.service.OrderNotificationService; 6 | import jakarta.mail.MessagingException; 7 | import jakarta.mail.internet.MimeMessage; 8 | import lombok.RequiredArgsConstructor; 9 | import org.springframework.mail.javamail.JavaMailSender; 10 | import org.springframework.mail.javamail.MimeMessageHelper; 11 | import org.springframework.stereotype.Service; 12 | 13 | @Service 14 | @RequiredArgsConstructor 15 | public class OrderNotificationServiceImpl implements OrderNotificationService { 16 | 17 | private final JavaMailSender mailSender; 18 | 19 | @Override 20 | public void sendOrderCompletedEmail(OrderNotification notification) { 21 | MimeMessage mimeMessage = mailSender.createMimeMessage(); 22 | try { 23 | MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); 24 | helper.setTo(notification.getEmail()); 25 | helper.setSubject("Siparişiniz Onaylandı..."); 26 | StringBuilder productDetails = new StringBuilder(); 27 | if (notification.getProducts() != null && !notification.getProducts().isEmpty()) { 28 | for (ProductNotification product : notification.getProducts()) { 29 | productDetails.append("
") 30 | .append("Ürün Adı: ").append(product.getName()).append("
") 31 | .append("Açıklama: ").append(product.getDescription()).append("
") 32 | .append("Fiyat: ").append(product.getPrice()).append(" TL
") 33 | .append("Adet: ").append(product.getQuantity()).append("
") 34 | .append("

"); 35 | } 36 | } else { 37 | productDetails.append("Siparişinizde ürün bulunmamaktadır."); 38 | } 39 | String htmlContent = "" 40 | + "" 41 | + "" 42 | + "" 43 | + "" 44 | + "Sipariş Onayı" 45 | + "" 51 | + "" 52 | + "" 53 | + "" 62 | + "" 63 | + ""; 64 | 65 | // E-posta içeriğini ayarla 66 | helper.setText(htmlContent, true); 67 | 68 | // E-postayı gönder 69 | mailSender.send(mimeMessage); 70 | 71 | System.out.println("E-posta başarıyla gönderildi: " + notification.getEmail()); 72 | 73 | } catch (MessagingException e) { 74 | e.printStackTrace(); 75 | System.out.println("E-posta gönderirken bir hata oluştu: " + e.getMessage()); 76 | } 77 | } 78 | } 79 | --------------------------------------------------------------------------------