├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src ├── main │ ├── java │ │ └── com │ │ │ └── btkAkademi │ │ │ └── rentACar │ │ │ ├── core │ │ │ ├── constants │ │ │ │ └── Languages.java │ │ │ ├── utilities │ │ │ │ ├── mapping │ │ │ │ │ ├── ModelMapperService.java │ │ │ │ │ └── ModelMapperManager.java │ │ │ │ ├── results │ │ │ │ │ ├── ErrorResult.java │ │ │ │ │ ├── SuccessResult.java │ │ │ │ │ ├── DataResult.java │ │ │ │ │ ├── ErrorDataResult.java │ │ │ │ │ ├── SuccessDataResult.java │ │ │ │ │ ├── Result.java │ │ │ │ │ └── LanguageSelector.java │ │ │ │ ├── business │ │ │ │ │ └── BusinessRules.java │ │ │ │ └── loaders │ │ │ │ │ ├── AdminDataLoader.java │ │ │ │ │ ├── CityDataLoader.java │ │ │ │ │ ├── ColorDataLoader.java │ │ │ │ │ └── AdditionalServiceItemDataLoader.java │ │ │ ├── externalServices │ │ │ │ ├── banks │ │ │ │ │ └── IsBankFakePos.java │ │ │ │ └── creditScoreServices │ │ │ │ │ └── FindexFake.java │ │ │ └── adapters │ │ │ │ ├── banks │ │ │ │ ├── abstracts │ │ │ │ │ └── BankAdapterService.java │ │ │ │ └── conctrates │ │ │ │ │ └── IsBankAdapterManager.java │ │ │ │ └── creditScore │ │ │ │ ├── abstracts │ │ │ │ └── CreditScoreAdapterService.java │ │ │ │ └── concrates │ │ │ │ └── FindexAdapterManager.java │ │ │ ├── auth │ │ │ ├── AuthService.java │ │ │ ├── LoginRequest.java │ │ │ ├── LoginResponse.java │ │ │ ├── AuthController.java │ │ │ └── PrimitiveAuthManager.java │ │ │ ├── business │ │ │ ├── abstracts │ │ │ │ ├── CustomerService.java │ │ │ │ ├── UserService.java │ │ │ │ ├── CityService.java │ │ │ │ ├── BrandService.java │ │ │ │ ├── ColorService.java │ │ │ │ ├── SegmentService.java │ │ │ │ ├── CarDamageService.java │ │ │ │ ├── WordService.java │ │ │ │ ├── PromoCodeService.java │ │ │ │ ├── CorporateCustomerService.java │ │ │ │ ├── IndividualCustomerService.java │ │ │ │ ├── AdditionalServiceItemService.java │ │ │ │ ├── AdditionalServiceService.java │ │ │ │ ├── CustomerCardDetailService.java │ │ │ │ ├── LanguageService.java │ │ │ │ ├── CarMaintenanceService.java │ │ │ │ ├── TranslationService.java │ │ │ │ ├── InvoiceService.java │ │ │ │ ├── PaymentService.java │ │ │ │ ├── RentalService.java │ │ │ │ └── CarService.java │ │ │ ├── dtos │ │ │ │ ├── CityListDto.java │ │ │ │ ├── WordSearchListDto.java │ │ │ │ ├── ColorListDto.java │ │ │ │ ├── BrandListDto.java │ │ │ │ ├── LanguageSearchListDto.java │ │ │ │ ├── RentalAddResponse.java │ │ │ │ ├── SegmentListDto.java │ │ │ │ ├── UserListDto.java │ │ │ │ ├── CarDamageListDto.java │ │ │ │ ├── AdditionalServiceItemListDto.java │ │ │ │ ├── AdditionalServiceListDto.java │ │ │ │ ├── CorporateCustomerListDto.java │ │ │ │ ├── InvoiceListDto.java │ │ │ │ ├── TranslationSearchListDto.java │ │ │ │ ├── PaymentListDto.java │ │ │ │ ├── CarMaintenanceListDto.java │ │ │ │ ├── CustomerCardDetailListDto.java │ │ │ │ ├── PromoCodeDto.java │ │ │ │ ├── IndividualCustomerListDto.java │ │ │ │ ├── RentalListDto.java │ │ │ │ ├── MyRentalListDto.java │ │ │ │ ├── CarListDto.java │ │ │ │ ├── InvoiceCorporateCustomerDto.java │ │ │ │ └── InvoiceIndividualCustomerDto.java │ │ │ ├── requests │ │ │ │ ├── wordRequests │ │ │ │ │ ├── DeleteWordRequest.java │ │ │ │ │ ├── UpdateWordRequest.java │ │ │ │ │ └── CreateWordRequest.java │ │ │ │ ├── languageRequests │ │ │ │ │ ├── DeleteLanguageRequest.java │ │ │ │ │ ├── UpdateLanguageRequest.java │ │ │ │ │ └── CreateLanguageRequest.java │ │ │ │ ├── invoiceRequests │ │ │ │ │ ├── CreateInvoiceRequest.java │ │ │ │ │ └── UpdateInvoiceRequest.java │ │ │ │ ├── segmentRequest │ │ │ │ │ ├── CreateSegmentRequest.java │ │ │ │ │ └── UpdateSegmentRequest.java │ │ │ │ ├── translationRequests │ │ │ │ │ ├── DeleteTranslationRequest.java │ │ │ │ │ ├── CreateTranslationRequest.java │ │ │ │ │ └── UpdateTranslationRequest.java │ │ │ │ ├── additionalServiceRequests │ │ │ │ │ ├── CreateAdditionalServiceRequest.java │ │ │ │ │ └── UpdateAdditionalServiceRequest.java │ │ │ │ ├── paymentRequests │ │ │ │ │ ├── CalculateTotalPriceRequest.java │ │ │ │ │ ├── UpdatePaymentRequest.java │ │ │ │ │ └── CreatePaymentRequest.java │ │ │ │ ├── cityRequests │ │ │ │ │ ├── CreateCityRequest.java │ │ │ │ │ └── UpdateCityRequest.java │ │ │ │ ├── rentalRequests │ │ │ │ │ ├── UpdateRentalRequest.java │ │ │ │ │ └── CreateRentalRequest.java │ │ │ │ ├── carMaintananceRequests │ │ │ │ │ ├── UpdateCarMaintananceRequest.java │ │ │ │ │ └── CreateCarMaintenanceRequest.java │ │ │ │ ├── carDamageRequests │ │ │ │ │ ├── CreateCarDamageRequest.java │ │ │ │ │ └── UpdateCarDamageRequest.java │ │ │ │ ├── colorRequests │ │ │ │ │ ├── CreateColorRequest.java │ │ │ │ │ └── UpdateColorRequest.java │ │ │ │ ├── brandRequests │ │ │ │ │ ├── CreateBrandRequest.java │ │ │ │ │ └── UpdateBrandRequest.java │ │ │ │ ├── promoCodeRequests │ │ │ │ │ ├── CreatePromoCodeRequest.java │ │ │ │ │ └── UpdatePromoCodeRequest.java │ │ │ │ ├── additionalServiceItemRequests │ │ │ │ │ ├── CreateAdditionalServiceItemRequest.java │ │ │ │ │ └── UpdateAdditionalServiceItemRequest.java │ │ │ │ ├── corporateCustomerRequests │ │ │ │ │ ├── UpdateCorporateCustomerRequest.java │ │ │ │ │ └── CreateCorporateCustomerRequest.java │ │ │ │ ├── individualCustomerRequests │ │ │ │ │ ├── UpdateIndividualCustomerRequest.java │ │ │ │ │ └── CreateIndividualCustomerRequest.java │ │ │ │ ├── carRequests │ │ │ │ │ ├── UpdateCarRequest.java │ │ │ │ │ └── CreateCarRequest.java │ │ │ │ └── customerCardDetailRequests │ │ │ │ │ ├── CreateCustomerCardDetailRequest.java │ │ │ │ │ └── UpdateCustomerCardDetailsRequest.java │ │ │ ├── constants │ │ │ │ └── Role.java │ │ │ ├── concretes │ │ │ │ ├── CustomerManager.java │ │ │ │ ├── TranslationManager.java │ │ │ │ ├── UserManager.java │ │ │ │ ├── LanguageManager.java │ │ │ │ ├── CityManager.java │ │ │ │ └── SegmentManager.java │ │ │ └── exception │ │ │ │ └── ExceptionHandling.java │ │ │ ├── dataAccess │ │ │ └── abstracts │ │ │ │ ├── CustomerDao.java │ │ │ │ ├── InvoiceDao.java │ │ │ │ ├── AdditionalServiceItemDao.java │ │ │ │ ├── LanguageDao.java │ │ │ │ ├── SegmentDao.java │ │ │ │ ├── WordDao.java │ │ │ │ ├── BrandDao.java │ │ │ │ ├── ColorDao.java │ │ │ │ ├── UserDao.java │ │ │ │ ├── TranslationDao.java │ │ │ │ ├── PaymentDao.java │ │ │ │ ├── CarDamageDao.java │ │ │ │ ├── AdditionalServiceDao.java │ │ │ │ ├── IndividualCustomerDao.java │ │ │ │ ├── CityDao.java │ │ │ │ ├── RentalDao.java │ │ │ │ ├── CustomerCardDetailDao.java │ │ │ │ ├── PromoCodeDao.java │ │ │ │ ├── CarMaintenanceDao.java │ │ │ │ ├── CorporateCustomerDao.java │ │ │ │ └── CarDao.java │ │ │ ├── entities │ │ │ └── concretes │ │ │ │ ├── Employee.java │ │ │ │ ├── CorporateCustomer.java │ │ │ │ ├── Customer.java │ │ │ │ ├── Word.java │ │ │ │ ├── IndividualCustomer.java │ │ │ │ ├── Segment.java │ │ │ │ ├── Language.java │ │ │ │ ├── CarDamage.java │ │ │ │ ├── Brand.java │ │ │ │ ├── Color.java │ │ │ │ ├── Invoice.java │ │ │ │ ├── User.java │ │ │ │ ├── AdditionalService.java │ │ │ │ ├── AdditionalServiceItem.java │ │ │ │ ├── Translation.java │ │ │ │ ├── Payment.java │ │ │ │ ├── CarMaintenance.java │ │ │ │ ├── City.java │ │ │ │ ├── CustomerCardDetail.java │ │ │ │ ├── PromoCode.java │ │ │ │ ├── Car.java │ │ │ │ └── Rental.java │ │ │ ├── RentACarApplication.java │ │ │ └── ws │ │ │ └── controllers │ │ │ ├── UserController.java │ │ │ ├── SegmentController.java │ │ │ ├── BrandsController.java │ │ │ ├── WordsController.java │ │ │ ├── ColorsContoller.java │ │ │ ├── TranslationsController.java │ │ │ ├── CarDamagesController.java │ │ │ ├── CitiesController.java │ │ │ ├── LanguagesController.java │ │ │ ├── PromoCodeController.java │ │ │ ├── AdditionalServicesController.java │ │ │ ├── CarMaintenancesController.java │ │ │ ├── InvoiceControllers.java │ │ │ ├── AdditionalServiceItemsController.java │ │ │ ├── CustomerCardDetailsController.java │ │ │ ├── CorporateCustomersController.java │ │ │ ├── IndividualCustomersController.java │ │ │ ├── PaymentsController.java │ │ │ ├── CarsController.java │ │ │ └── RentalsController.java │ └── resources │ │ ├── application.properties │ │ └── static │ │ └── ister.txt └── test │ └── java │ └── com │ └── btkAkademi │ └── rentACar │ └── RentACarApplicationTests.java ├── README.md ├── .gitignore └── pom.xml /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mertyalcin-code/rentACar/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/constants/Languages.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.constants; 2 | 3 | public class Languages { 4 | 5 | public static final String ENGLISH = "English"; 6 | public static final String TURKISH = "Turkish"; 7 | 8 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/auth/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.auth; 2 | 3 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 4 | 5 | public interface AuthService { 6 | 7 | DataResult login(LoginRequest loginRequest); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/mapping/ModelMapperService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.mapping; 2 | 3 | import org.modelmapper.ModelMapper; 4 | 5 | public interface ModelMapperService { 6 | 7 | ModelMapper forDto(); 8 | 9 | ModelMapper forRequest(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/externalServices/banks/IsBankFakePos.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.externalServices.banks; 2 | 3 | public class IsBankFakePos { 4 | 5 | public boolean posService(String cardNo,String day,String mounth,String cVV,double amount) { 6 | return false; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/test/java/com/btkAkademi/rentACar/RentACarApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class RentACarApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/ErrorResult.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | //Custom response with error 4 | public class ErrorResult extends Result { 5 | public ErrorResult() { 6 | super(false); 7 | } 8 | 9 | public ErrorResult(String message) { 10 | super(false, message); 11 | } 12 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/auth/LoginRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.auth; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class LoginRequest { 11 | private String email; 12 | private String password; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CustomerService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 4 | import com.btkAkademi.rentACar.entities.concretes.Customer; 5 | 6 | public interface CustomerService { 7 | DataResult findCustomerById(int id); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Customer; 6 | 7 | public interface CustomerDao extends JpaRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/adapters/banks/abstracts/BankAdapterService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.adapters.banks.abstracts; 2 | 3 | import com.btkAkademi.rentACar.core.utilities.results.Result; 4 | 5 | public interface BankAdapterService { 6 | 7 | Result makePayment(String cardNo, String year, String mounth, String cVV, double amount); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/CityListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CityListDto { 11 | private int id; 12 | private String cityName; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/WordSearchListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class WordSearchListDto { 11 | private int id; 12 | private String key; 13 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/SuccessResult.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | //Custom response with success 4 | public class SuccessResult extends Result { 5 | public SuccessResult() { 6 | super(true); 7 | } 8 | 9 | public SuccessResult(String message) { 10 | super(true, message); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/ColorListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class ColorListDto { 11 | 12 | private int id; 13 | private String name; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/BrandListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class BrandListDto { 11 | 12 | private int id; 13 | private String name; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rent A Car 2 | ### Development Process 3 | This application was developed in Innova -BTK bootcamp under the supervision of trainer Engin Demiroğ. 4 | ### Summary 5 | This is a web application platform for renting cars. 6 | ### Technologies 7 | Backend: Java 11, Spring Boot, Spring Data JPA 8 | Frontend: Angular 13 9 | ### Requirements 10 | Requirements will be added soon 11 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/auth/LoginResponse.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.auth; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class LoginResponse { 11 | private int id; 12 | private String email; 13 | private String role; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/LanguageSearchListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class LanguageSearchListDto { 11 | 12 | private int id; 13 | private String name; 14 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/RentalAddResponse.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class RentalAddResponse { 11 | private int rentalId; 12 | private int carId; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/SegmentListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class SegmentListDto { 11 | private int id; 12 | private String segmentName; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/wordRequests/DeleteWordRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.wordRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class DeleteWordRequest { 11 | 12 | private int id; 13 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/UserListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UserListDto { 11 | private int id; 12 | private String email; 13 | private String role; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/languageRequests/DeleteLanguageRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.languageRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class DeleteLanguageRequest { 11 | private int id; 12 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/InvoiceDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Invoice; 6 | 7 | public interface InvoiceDao extends JpaRepository { 8 | Invoice findByRentalId(int rentalId); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/invoiceRequests/CreateInvoiceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.invoiceRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CreateInvoiceRequest { 11 | private int rentalId; 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/CarDamageListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CarDamageListDto { 11 | private int id; 12 | private String description; 13 | private int carId; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/wordRequests/UpdateWordRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.wordRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UpdateWordRequest { 11 | 12 | private int id; 13 | private String key; 14 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/AdditionalServiceItemDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.AdditionalServiceItem; 6 | 7 | public interface AdditionalServiceItemDao extends JpaRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/LanguageDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Language; 6 | 7 | public interface LanguageDao extends JpaRepository { 8 | 9 | Language getLanguagesByName(String languageName); 10 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/SegmentDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Segment; 6 | 7 | public interface SegmentDao extends JpaRepository { 8 | 9 | Segment findBySegmentName(String segmentName); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/segmentRequest/CreateSegmentRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.segmentRequest; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CreateSegmentRequest { 11 | private String segmentName; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/translationRequests/DeleteTranslationRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.translationRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @AllArgsConstructor 8 | @NoArgsConstructor 9 | @Data 10 | public class DeleteTranslationRequest { 11 | 12 | private int id; 13 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/WordDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Word; 6 | 7 | public interface WordDao extends JpaRepository { 8 | Word getWordsByKey(String key); 9 | 10 | boolean existsByKey(String key); 11 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/constants/Role.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.constants; 2 | 3 | public enum Role { 4 | EMPLOYEE("EMPLOYEE"), INDIVIDUAL_CUSTOMER("INDIVIDUAL_CUSTOMER"), CORPORATE_CUSTOMER("CORPORATE_CUSTOMER"); 5 | 6 | private String role; 7 | 8 | Role(String role) { 9 | this.role = role; 10 | } 11 | 12 | public String getRole() { 13 | return role; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/BrandDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Brand; 6 | 7 | public interface BrandDao extends JpaRepository { 8 | // finds Brand with brandName 9 | Brand findByName(String brandName); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/ColorDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Color; 6 | 7 | public interface ColorDao extends JpaRepository { 8 | // finds Color with color name 9 | Color findByName(String colorName); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.User; 6 | 7 | public interface UserDao extends JpaRepository { 8 | 9 | User findByEmail(String email); 10 | 11 | User findByRole(String role); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/AdditionalServiceItemListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class AdditionalServiceItemListDto { 11 | private int id; 12 | private String name; 13 | private double price; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/segmentRequest/UpdateSegmentRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.segmentRequest; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UpdateSegmentRequest { 11 | private int id; 12 | private String segmentName; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Employee.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Table; 5 | 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | //@AllArgsConstructor 11 | @NoArgsConstructor 12 | @Entity 13 | @Table(name = "employees") 14 | public class Employee extends User { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/AdditionalServiceListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class AdditionalServiceListDto { 11 | private int id; 12 | private int rentalId; 13 | private int additionalServiceItemId; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/languageRequests/UpdateLanguageRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.languageRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class UpdateLanguageRequest { 11 | 12 | private int id; 13 | 14 | private String name; 15 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/TranslationDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.Translation; 6 | 7 | public interface TranslationDao extends JpaRepository { 8 | Translation getTranslationByLanguage_IdAndWord_Id(int languageId, int wordId); 9 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/PaymentDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.Payment; 8 | 9 | public interface PaymentDao extends JpaRepository { 10 | 11 | List getAllByRentalId(int rentalId); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CarDamageDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.CarDamage; 8 | 9 | public interface CarDamageDao extends JpaRepository { 10 | 11 | List findAllByCarId(int id); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/CorporateCustomerListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CorporateCustomerListDto { 11 | private int id; 12 | private String email; 13 | private String companyName; 14 | private String taxNumber; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/adapters/creditScore/abstracts/CreditScoreAdapterService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.adapters.creditScore.abstracts; 2 | 3 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 4 | 5 | public interface CreditScoreAdapterService { 6 | DataResult getScoreOfIndividualCustomer(String nationalityId); 7 | 8 | DataResult getScoreOfCorporateCustomer(String taxNumber); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/InvoiceListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class InvoiceListDto { 13 | private int id; 14 | private LocalDate creationDate; 15 | private int rentalId; 16 | private String customerRole; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/TranslationSearchListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class TranslationSearchListDto { 11 | 12 | private int id; 13 | private String translation; 14 | private int wordId; 15 | private String wordKey; 16 | private int languageId; 17 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/additionalServiceRequests/CreateAdditionalServiceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.additionalServiceRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class CreateAdditionalServiceRequest { 11 | private int rentalId; 12 | private int additionalServiceItemId; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/PaymentListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class PaymentListDto { 13 | private int id; 14 | private LocalDate paymentTime; 15 | private double totalPaymentAmount; 16 | private int rentalId; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/AdditionalServiceDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.AdditionalService; 8 | 9 | public interface AdditionalServiceDao extends JpaRepository { 10 | 11 | List findAllByRentalId(int RentalId); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/IndividualCustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.IndividualCustomer; 6 | 7 | public interface IndividualCustomerDao extends JpaRepository { 8 | // finds individual customer by email 9 | IndividualCustomer findByEmail(String email); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/additionalServiceRequests/UpdateAdditionalServiceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.additionalServiceRequests; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @NoArgsConstructor 9 | @AllArgsConstructor 10 | public class UpdateAdditionalServiceRequest { 11 | 12 | private int rentalId; 13 | private int additionalServiceItemId; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/paymentRequests/CalculateTotalPriceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.paymentRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CalculateTotalPriceRequest { 13 | private int rentalId; 14 | private LocalDate returnDate; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/wordRequests/CreateWordRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.wordRequests; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CreateWordRequest { 13 | 14 | @JsonIgnore 15 | private int id; 16 | 17 | private String key; 18 | } -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect 2 | spring.jpa.hibernate.ddl-auto=update 3 | spring.jpa.show-sql=true 4 | spring.datasource.url=jdbc:postgresql://localhost:5432/rentACar 5 | spring.datasource.username=postgres 6 | spring.datasource.password=12345 7 | spring.jpa.properties.javax.persistence.validation.mode = none 8 | logging.file.name=./log/rentacar.log 9 | logging.level.root=info 10 | 11 | current_language=Turkish -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/CarMaintenanceListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CarMaintenanceListDto { 13 | private int id; 14 | private int carId; 15 | private LocalDate maintenanceStart; 16 | private LocalDate maintenanceEnd; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/invoiceRequests/UpdateInvoiceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.invoiceRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdateInvoiceRequest { 13 | private int id; 14 | private int rentalId; 15 | private LocalDate creationDate; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CityDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.City; 8 | 9 | public interface CityDao extends JpaRepository { 10 | 11 | // Finds city by name 12 | List findAllByOrderByCityNameAsc(); 13 | 14 | City findByCityName(String CityName); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/CustomerCardDetailListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CustomerCardDetailListDto { 11 | private int id; 12 | private String cardNo; 13 | private String year; 14 | private String month; 15 | private String cvv; 16 | private int customerId; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/languageRequests/CreateLanguageRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.languageRequests; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CreateLanguageRequest { 13 | 14 | @JsonIgnore 15 | private int id; 16 | 17 | private String name; 18 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/cityRequests/CreateCityRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.cityRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class CreateCityRequest { 14 | @NotBlank 15 | @Size(max = 250) 16 | private String cityName; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/RentalDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.Rental; 8 | 9 | public interface RentalDao extends JpaRepository { 10 | // Finds car if it is rented 11 | Rental findByCarIdAndReturnDateIsNull(int carId); 12 | 13 | List findAllByCustomerId(int customerId); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/PromoCodeDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class PromoCodeDto { 13 | private int id; 14 | private String code; 15 | private double discountRate; 16 | private LocalDate startDate; 17 | private LocalDate endDate; 18 | private String description; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/paymentRequests/UpdatePaymentRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.paymentRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdatePaymentRequest { 13 | private int id; 14 | private LocalDate paymentTime; 15 | private double totalPaymentAmount; 16 | private int rentalId; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/rentalRequests/UpdateRentalRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.rentalRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdateRentalRequest { 13 | private int id; 14 | private LocalDate returnDate; 15 | private Integer returnedKilometer; 16 | private int returnCityId; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/business/BusinessRules.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.business; 2 | 3 | import com.btkAkademi.rentACar.core.utilities.results.Result; 4 | 5 | public class BusinessRules { 6 | // takes business logic array and controls each of them. If there is an 7 | // ErrorResult, then returns it 8 | public static Result run(Result... logics) { 9 | for (Result logic : logics) { 10 | if (!logic.isSuccess()) { 11 | return logic; 12 | } 13 | } 14 | return null; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CustomerCardDetailDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.CustomerCardDetail; 8 | 9 | public interface CustomerCardDetailDao extends JpaRepository { 10 | List findAllByCustomerId(int customerId); 11 | 12 | CustomerCardDetail findByCardNo(String cardNo); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/cityRequests/UpdateCityRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.cityRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class UpdateCityRequest { 14 | private int id; 15 | @NotBlank 16 | @Size(max = 250) 17 | private String cityName; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/carMaintananceRequests/UpdateCarMaintananceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.carMaintananceRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class UpdateCarMaintananceRequest { 13 | private int id; 14 | private int carId; 15 | private LocalDate maintenanceStart; 16 | private LocalDate maintenanceEnd; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/DataResult.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | // Custom response with data 4 | public class DataResult extends Result { 5 | 6 | private T data; 7 | 8 | public DataResult(T data, boolean success, String message) { 9 | super(success, message); 10 | this.data = data; 11 | } 12 | 13 | public DataResult(T data, boolean success) { 14 | super(success); 15 | this.data = data; 16 | } 17 | 18 | public T getData() { 19 | return this.data; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/IndividualCustomerListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class IndividualCustomerListDto { 13 | private int id; 14 | private String nationalityNo; 15 | private String email; 16 | private String firstName; 17 | private String lastName; 18 | private LocalDate birthDate; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/carMaintananceRequests/CreateCarMaintenanceRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.carMaintananceRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.validation.constraints.Size; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class CreateCarMaintenanceRequest { 15 | 16 | private int carId; 17 | 18 | private LocalDate maintenanceStart; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/rentalRequests/CreateRentalRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.rentalRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | @NoArgsConstructor 12 | public class CreateRentalRequest { 13 | 14 | private LocalDate rentDate; 15 | private LocalDate returnDate; 16 | private int customerId; 17 | private int carId; 18 | private int promoCodeId; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/PromoCodeDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.PromoCode; 6 | 7 | public interface PromoCodeDao extends JpaRepository { 8 | 9 | PromoCode findByCode(String code); 10 | 11 | /* 12 | * @Query("select p from PromoCode p where p.EndDate <= :today") List 13 | * findAllActiveCodes(@Param("today") LocalDate today); 14 | */ 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CarMaintenanceDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | 7 | import com.btkAkademi.rentACar.entities.concretes.CarMaintenance; 8 | 9 | public interface CarMaintenanceDao extends JpaRepository { 10 | 11 | // Finds specific car is in maintenance 12 | CarMaintenance findByCarIdAndMaintenanceEndIsNull(int carId); 13 | 14 | List findAllByCarId(int carId); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/carDamageRequests/CreateCarDamageRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.carDamageRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class CreateCarDamageRequest { 14 | @NotBlank 15 | @Size(min = 0, max = 255) 16 | private String description; 17 | private int carId; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CorporateCustomerDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | 5 | import com.btkAkademi.rentACar.entities.concretes.CorporateCustomer; 6 | 7 | public interface CorporateCustomerDao extends JpaRepository { 8 | // Finds Corporate Customer by Email 9 | CorporateCustomer findByEmail(String email); 10 | 11 | // Finds Corporate Customer by companyName 12 | CorporateCustomer findByCompanyName(String companyName); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/ErrorDataResult.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | //Custom response with error 4 | public class ErrorDataResult extends DataResult { 5 | 6 | public ErrorDataResult(T data, String message) { 7 | super(data, false, message); 8 | } 9 | /* 10 | public ErrorDataResult(T data) { 11 | super(data, false); 12 | }*/ 13 | 14 | public ErrorDataResult(String message) { 15 | super(null, false, message); 16 | } 17 | 18 | public ErrorDataResult() { 19 | super(null, false); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/RentalListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class RentalListDto { 13 | private int id; 14 | private LocalDate rentDate; 15 | private LocalDate returnDate; 16 | private Integer rentedKilometer; 17 | private Integer returnedKilometer; 18 | private int customerId; 19 | private int carId; 20 | private int promoCodeId; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/carDamageRequests/UpdateCarDamageRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.carDamageRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Data; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | public class UpdateCarDamageRequest { 14 | private int id; 15 | @NotBlank 16 | @Size(min = 0, max = 255) 17 | private String description; 18 | private int carId; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/SuccessDataResult.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | //Custom response with successful data 4 | public class SuccessDataResult extends DataResult { 5 | 6 | public SuccessDataResult(T data, String message) { 7 | super(data, true, message); 8 | } 9 | 10 | public SuccessDataResult(T data) { 11 | super(data, true); 12 | } 13 | 14 | public SuccessDataResult(String message) { 15 | super(null, true, message); 16 | } 17 | 18 | public SuccessDataResult() { 19 | super(null, true); 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/colorRequests/CreateColorRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.colorRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import com.btkAkademi.rentACar.business.constants.Messages; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class CreateColorRequest { 16 | @NotBlank 17 | @Size(min = 2, message = Messages.COLORNAMEERROR) 18 | private String name; 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/UserService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.UserListDto; 6 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 7 | import com.btkAkademi.rentACar.core.utilities.results.Result; 8 | import com.btkAkademi.rentACar.entities.concretes.User; 9 | 10 | public interface UserService { 11 | DataResult findByEmail(String Email); 12 | 13 | DataResult findById(int id); 14 | 15 | DataResult> findAll(); 16 | 17 | Result delete(int id); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/brandRequests/CreateBrandRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.brandRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import com.btkAkademi.rentACar.business.constants.Messages; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class CreateBrandRequest { 16 | 17 | @NotBlank 18 | @Size(min = 3, max = 20, message = Messages.BRANDNAMEERROR) 19 | private String name; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/promoCodeRequests/CreatePromoCodeRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.promoCodeRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | public class CreatePromoCodeRequest { 15 | @NotEmpty 16 | private String code; 17 | private double discountRate; 18 | private LocalDate startDate; 19 | private LocalDate endDate; 20 | private String description; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/colorRequests/UpdateColorRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.colorRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import com.btkAkademi.rentACar.business.constants.Messages; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class UpdateColorRequest { 16 | 17 | private int id; 18 | @NotBlank 19 | @Size(min = 2, message = Messages.COLORNAMEERROR) 20 | private String name; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/brandRequests/UpdateBrandRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.brandRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Size; 5 | 6 | import com.btkAkademi.rentACar.business.constants.Messages; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | public class UpdateBrandRequest { 16 | 17 | private int id; 18 | @NotBlank 19 | @Size(min = 3, max = 20, message = Messages.BRANDNAMEERROR) 20 | private String name; 21 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/promoCodeRequests/UpdatePromoCodeRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.promoCodeRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.validation.constraints.NotEmpty; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | public class UpdatePromoCodeRequest { 15 | private int id; 16 | @NotEmpty 17 | private String code; 18 | private double discountRate; 19 | private LocalDate startDate; 20 | private LocalDate endDate; 21 | private String description; 22 | 23 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/additionalServiceItemRequests/CreateAdditionalServiceItemRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.additionalServiceItemRequests; 2 | 3 | import javax.validation.constraints.Min; 4 | import javax.validation.constraints.NotBlank; 5 | import javax.validation.constraints.Size; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | public class CreateAdditionalServiceItemRequest { 15 | @NotBlank 16 | @Size(min = 2, max = 250) 17 | private String name; 18 | @Min(0) 19 | private double price; 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/MyRentalListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.NoArgsConstructor; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | @AllArgsConstructor 12 | public class MyRentalListDto { 13 | private int rentalId; 14 | private String brandName; 15 | private String carName; 16 | private LocalDate RentDate; 17 | private LocalDate returnDate; 18 | private String pickUpCityName; 19 | private String returnCityName; 20 | private double totalPayment; 21 | private boolean isInvoiceCreated; 22 | private boolean isRentalFinished; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/additionalServiceItemRequests/UpdateAdditionalServiceItemRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.additionalServiceItemRequests; 2 | 3 | import javax.validation.constraints.Min; 4 | import javax.validation.constraints.NotBlank; 5 | import javax.validation.constraints.Size; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | public class UpdateAdditionalServiceItemRequest { 15 | private int id; 16 | @NotBlank 17 | @Size(min = 2, max = 250) 18 | private String name; 19 | @Min(0) 20 | private double price; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/translationRequests/CreateTranslationRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.translationRequests; 2 | 3 | import com.btkAkademi.rentACar.entities.concretes.Language; 4 | import com.btkAkademi.rentACar.entities.concretes.Word; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class CreateTranslationRequest { 15 | 16 | @JsonIgnore 17 | private int id; 18 | 19 | private String translation; 20 | 21 | private Word word; 22 | 23 | private Language language; 24 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/translationRequests/UpdateTranslationRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.translationRequests; 2 | 3 | import com.btkAkademi.rentACar.entities.concretes.Language; 4 | import com.btkAkademi.rentACar.entities.concretes.Word; 5 | import com.fasterxml.jackson.annotation.JsonIgnore; 6 | 7 | import lombok.AllArgsConstructor; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | public class UpdateTranslationRequest { 15 | 16 | @JsonIgnore 17 | private int id; 18 | 19 | private String translation; 20 | 21 | private Word word; 22 | 23 | private Language language; 24 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/RentACarApplication.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar; 2 | 3 | import org.modelmapper.ModelMapper; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | @SpringBootApplication 9 | public class RentACarApplication { 10 | 11 | public static void main(String[] args) { 12 | System.out.println("Welcome to Mert Yalçın's Project"); 13 | SpringApplication.run(RentACarApplication.class, args); 14 | } 15 | 16 | // To create an instance of Model Mapper 17 | @Bean 18 | public ModelMapper getModelMapper() { 19 | return new ModelMapper(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/Result.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | //Custom response 4 | public class Result { 5 | private boolean success; 6 | private String message; 7 | 8 | public Result(boolean success) { 9 | this.success = success; 10 | } 11 | 12 | public Result(boolean success, String message) { 13 | this(success); 14 | this.message = message; 15 | } 16 | 17 | public boolean isSuccess() { 18 | return this.success; 19 | } 20 | 21 | public String getMessage() { 22 | return get(this.message); 23 | } 24 | 25 | // for language 26 | private String get(String message) { 27 | return LanguageSelector.languageSelector(message); 28 | 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/CorporateCustomer.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.PrimaryKeyJoinColumn; 6 | import javax.persistence.Table; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @AllArgsConstructor 14 | @NoArgsConstructor 15 | @Entity 16 | @Table(name = "corporate_customers") 17 | @PrimaryKeyJoinColumn(name = "customer_id") 18 | public class CorporateCustomer extends Customer { 19 | @Column(name = "campany_name") 20 | private String companyName; 21 | @Column(name = "tax_Number") 22 | private String taxNumber; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/externalServices/creditScoreServices/FindexFake.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.externalServices.creditScoreServices; 2 | 3 | 4 | 5 | 6 | public class FindexFake { 7 | 8 | public int getScoreOfIndividualCustomer(String nationalityId) { 9 | int max= 1900; 10 | int min= 650; 11 | 12 | int score = (int) Math.floor(Math.random()*(max-min+1)+min); 13 | System.out.println("findex score :"+score); 14 | return score; 15 | } 16 | public int getScoreOfCorporateCustomer(String taxNumber) { 17 | int max= 1900; 18 | int min= 650; 19 | 20 | int score = (int) Math.floor(Math.random()*(max-min+1)+min); 21 | System.out.println("findex score :"+score); 22 | return score; 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/CarListDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | @Data 8 | @AllArgsConstructor 9 | @NoArgsConstructor 10 | public class CarListDto { 11 | private int id; 12 | private String carName; 13 | private double dailyPrice; 14 | private int model; 15 | private String description; 16 | private int findexScore; 17 | private int kilometer; 18 | private String brandName; 19 | private String colorName; 20 | private String imageUrl; 21 | private int minAge; 22 | private int segmentId; 23 | private int cityId; 24 | private String CityName; 25 | private String SegmentName; 26 | private String brandId; 27 | private int colorId; 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Customer.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.OneToMany; 7 | import javax.persistence.Table; 8 | 9 | import com.fasterxml.jackson.annotation.JsonIgnore; 10 | 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.NoArgsConstructor; 14 | 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Entity 19 | @Table(name = "customers") 20 | public class Customer extends User { 21 | 22 | @OneToMany(mappedBy = "customer") 23 | @JsonIgnore 24 | private List rentals; 25 | 26 | @OneToMany(mappedBy = "customer") 27 | @JsonIgnore 28 | private List customerPaymentDetails; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/InvoiceCorporateCustomerDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | public class InvoiceCorporateCustomerDto { 16 | private int id; 17 | private String taxNumber; 18 | private String companyName; 19 | private String email; 20 | private LocalDate rentDate; 21 | private LocalDate returnedDate; 22 | private double totalPrice; 23 | private double rentPrice; 24 | private LocalDate creationDate; 25 | private List additionalServiceItems; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CityService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.CityListDto; 6 | import com.btkAkademi.rentACar.business.requests.cityRequests.CreateCityRequest; 7 | import com.btkAkademi.rentACar.business.requests.cityRequests.UpdateCityRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface CityService { 12 | DataResult> findAll(); 13 | 14 | DataResult findById(int id); 15 | 16 | Result add(CreateCityRequest createCityRequest); 17 | 18 | Result update(UpdateCityRequest updateCityRequest); 19 | 20 | Result delete(int id); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/dtos/InvoiceIndividualCustomerDto.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.dtos; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Data; 9 | import lombok.NoArgsConstructor; 10 | 11 | @Data 12 | @AllArgsConstructor 13 | @NoArgsConstructor 14 | @Builder 15 | public class InvoiceIndividualCustomerDto { 16 | private int id; 17 | private String nationalityNo; 18 | private String firstName; 19 | private String lastName; 20 | private String email; 21 | private LocalDate rentDate; 22 | private LocalDate returnedDate; 23 | private double rentPrice; 24 | private double totalPrice; 25 | LocalDate creationDate; 26 | private List additionalServiceItems; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/corporateCustomerRequests/UpdateCorporateCustomerRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.corporateCustomerRequests; 2 | 3 | import javax.validation.constraints.Email; 4 | import javax.validation.constraints.NotBlank; 5 | import javax.validation.constraints.Pattern; 6 | import javax.validation.constraints.Size; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | public class UpdateCorporateCustomerRequest { 16 | private int id; 17 | @Email 18 | @NotBlank 19 | private String email; 20 | @Size(min = 3, max = 255) 21 | private String companyName; 22 | @Size(min = 4, max = 255) 23 | @Pattern(regexp = "[0-9]+") 24 | private String taxNumber; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/BrandService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.BrandListDto; 6 | import com.btkAkademi.rentACar.business.requests.brandRequests.CreateBrandRequest; 7 | import com.btkAkademi.rentACar.business.requests.brandRequests.UpdateBrandRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface BrandService { 12 | 13 | DataResult> findAll(); 14 | 15 | DataResult findById(int id); 16 | 17 | Result add(CreateBrandRequest createBrandRequest); 18 | 19 | Result update(UpdateBrandRequest updateBrandRequest); 20 | 21 | Result delete(int id); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/ColorService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.ColorListDto; 6 | import com.btkAkademi.rentACar.business.requests.colorRequests.CreateColorRequest; 7 | import com.btkAkademi.rentACar.business.requests.colorRequests.UpdateColorRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface ColorService { 12 | 13 | DataResult> findAll(); 14 | 15 | DataResult findById(int id); 16 | 17 | Result add(CreateColorRequest createColorRequest); 18 | 19 | Result update(UpdateColorRequest updateColorRequest); 20 | 21 | Result delete(int id); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/SegmentService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.SegmentListDto; 6 | import com.btkAkademi.rentACar.business.requests.segmentRequest.CreateSegmentRequest; 7 | import com.btkAkademi.rentACar.business.requests.segmentRequest.UpdateSegmentRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface SegmentService { 12 | 13 | DataResult> findAll(); 14 | 15 | DataResult findById(int id); 16 | 17 | Result add(CreateSegmentRequest createSegmentRequest); 18 | 19 | Result update(UpdateSegmentRequest createSegmentRequest); 20 | 21 | Result delete(int id); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/corporateCustomerRequests/CreateCorporateCustomerRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.corporateCustomerRequests; 2 | 3 | import javax.validation.constraints.Email; 4 | import javax.validation.constraints.NotBlank; 5 | import javax.validation.constraints.Pattern; 6 | import javax.validation.constraints.Size; 7 | 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | 12 | @Data 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | public class CreateCorporateCustomerRequest { 16 | @Email 17 | @NotBlank 18 | private String email; 19 | @Size(min = 4, max = 30) 20 | private String password; 21 | @Size(min = 3, max = 255) 22 | private String companyName; 23 | @Size(min = 4, max = 255) 24 | @Pattern(regexp = "[0-9]+") 25 | private String taxNumber; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/loaders/AdminDataLoader.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.loaders; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.btkAkademi.rentACar.dataAccess.abstracts.UserDao; 7 | import com.btkAkademi.rentACar.entities.concretes.User; 8 | 9 | import lombok.AllArgsConstructor; 10 | 11 | @Service 12 | @AllArgsConstructor 13 | public class AdminDataLoader implements CommandLineRunner { 14 | private UserDao userDao; 15 | 16 | @Override 17 | public void run(String... args) throws Exception { 18 | this.loadEmployee(); 19 | 20 | } 21 | 22 | private void loadEmployee() { 23 | String role = "EMPLOYEE"; 24 | if (userDao.findByRole(role) == null) { 25 | userDao.save(new User(0, "admin@admin.com", "admin", "EMPLOYEE")); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CarDamageService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.CarDamageListDto; 6 | import com.btkAkademi.rentACar.business.requests.carDamageRequests.CreateCarDamageRequest; 7 | import com.btkAkademi.rentACar.business.requests.carDamageRequests.UpdateCarDamageRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface CarDamageService { 12 | DataResult> findAllByCarId(int id); 13 | 14 | DataResult findById(int id); 15 | 16 | Result add(CreateCarDamageRequest createCarDamageRequest); 17 | 18 | Result update(UpdateCarDamageRequest updateCarDamageRequest); 19 | 20 | Result delete(int id); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Word.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @Entity 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Table(name = "words") 22 | public class Word { 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | 28 | @Column(name = "key") 29 | private String key; 30 | 31 | @OneToMany(mappedBy = "word") 32 | private List translations; 33 | 34 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/IndividualCustomer.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.PrimaryKeyJoinColumn; 8 | import javax.persistence.Table; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | @Entity 18 | @Table(name = "individual_customers") 19 | @PrimaryKeyJoinColumn(name = "customer_id") 20 | public class IndividualCustomer extends Customer { 21 | @Column(name = "nationality_no") 22 | private String nationalityNo; 23 | @Column(name = "first_name") 24 | private String firstName; 25 | @Column(name = "last_name") 26 | private String lastName; 27 | @Column(name = "birth_Date") 28 | private LocalDate birthDate; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Segment.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Entity 21 | @Table(name = "segments") 22 | public class Segment { 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | @Column(name = "segment_name", unique = true) 28 | private String segmentName; 29 | @OneToMany(mappedBy = "segment") 30 | private List cars; 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Language.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Data 20 | @Entity 21 | @Table(name = "languages") 22 | public class Language { 23 | 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | @Column(name = "id") 27 | private int id; 28 | 29 | @Column(name = "name") 30 | private String name; 31 | 32 | @OneToMany(mappedBy = "language") 33 | private List translations; 34 | 35 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/WordService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.WordSearchListDto; 6 | import com.btkAkademi.rentACar.business.requests.wordRequests.CreateWordRequest; 7 | import com.btkAkademi.rentACar.business.requests.wordRequests.DeleteWordRequest; 8 | import com.btkAkademi.rentACar.business.requests.wordRequests.UpdateWordRequest; 9 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 10 | import com.btkAkademi.rentACar.core.utilities.results.Result; 11 | 12 | public interface WordService { 13 | DataResult getByKey(String key); 14 | 15 | DataResult> getAll(); 16 | 17 | Result add(CreateWordRequest createWordRequest); 18 | 19 | Result delete(DeleteWordRequest deleteWordRequest); 20 | 21 | Result update(UpdateWordRequest updateWordRequest); 22 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/PromoCodeService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.PromoCodeDto; 6 | import com.btkAkademi.rentACar.business.requests.promoCodeRequests.CreatePromoCodeRequest; 7 | import com.btkAkademi.rentACar.business.requests.promoCodeRequests.UpdatePromoCodeRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface PromoCodeService { 12 | DataResult> findAll(); 13 | 14 | DataResult findById(int promoCodeId); 15 | 16 | DataResult findByCode(String promoCode); 17 | 18 | Result add(CreatePromoCodeRequest createPromoCodeRequest); 19 | 20 | Result update(UpdatePromoCodeRequest updatePromoCodeRequest); 21 | 22 | Result delete(int id); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/CarDamage.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | @Entity 20 | @Table(name = "car_damages") 21 | public class CarDamage { 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.IDENTITY) 24 | @Column(name = "id") 25 | private int id; 26 | @Column(name = "description") 27 | private String description; 28 | 29 | @ManyToOne 30 | @JoinColumn(name = "car_id") 31 | private Car car; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Brand.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIgnore; 14 | 15 | import lombok.AllArgsConstructor; 16 | import lombok.Data; 17 | import lombok.NoArgsConstructor; 18 | 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @Entity 23 | @Table(name = "brands") 24 | public class Brand { 25 | 26 | @Id 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | @Column(name = "id") 29 | private int id; 30 | 31 | @Column(name = "name") 32 | private String name; 33 | 34 | @OneToMany(mappedBy = "brand") 35 | @JsonIgnore 36 | private List cars; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Color.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIgnore; 14 | 15 | import lombok.AllArgsConstructor; 16 | import lombok.Data; 17 | import lombok.NoArgsConstructor; 18 | 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @Entity 23 | @Table(name = "colors") 24 | public class Color { 25 | 26 | @Id 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | @Column(name = "id") 29 | private int id; 30 | 31 | @Column(name = "name") 32 | private String name; 33 | 34 | @OneToMany(mappedBy = "color") 35 | @JsonIgnore 36 | private List cars; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CorporateCustomerService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.CorporateCustomerListDto; 6 | import com.btkAkademi.rentACar.business.requests.corporateCustomerRequests.CreateCorporateCustomerRequest; 7 | import com.btkAkademi.rentACar.business.requests.corporateCustomerRequests.UpdateCorporateCustomerRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface CorporateCustomerService { 12 | DataResult> findAll(int pageNo, int pageSize); 13 | 14 | DataResult findById(int id); 15 | 16 | Result add(CreateCorporateCustomerRequest createCorporateCustomerRequest); 17 | 18 | Result update(UpdateCorporateCustomerRequest updateCorporateCustomerRequest); 19 | 20 | Result delete(int id); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Invoice.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.OneToOne; 12 | import javax.persistence.Table; 13 | 14 | import lombok.AllArgsConstructor; 15 | import lombok.Data; 16 | import lombok.NoArgsConstructor; 17 | 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Entity 22 | @Table(name = "invoices") 23 | public class Invoice { 24 | 25 | @Id 26 | @GeneratedValue(strategy = GenerationType.IDENTITY) 27 | @Column(name = "id") 28 | private int id; 29 | @Column(name = "creation") 30 | private LocalDate creationDate; 31 | 32 | @OneToOne 33 | @JoinColumn(name = "rental_id", unique = true) 34 | private Rental rental; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/IndividualCustomerService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.IndividualCustomerListDto; 6 | import com.btkAkademi.rentACar.business.requests.individualCustomerRequests.CreateIndividualCustomerRequest; 7 | import com.btkAkademi.rentACar.business.requests.individualCustomerRequests.UpdateIndividualCustomerRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface IndividualCustomerService { 12 | DataResult> findAll(int pageNo, int pageSize); 13 | 14 | DataResult findById(int id); 15 | 16 | Result add(CreateIndividualCustomerRequest createIndividualCustomerRequest); 17 | 18 | Result update(UpdateIndividualCustomerRequest updateIndividualCustomerRequest); 19 | 20 | Result delete(int id); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/User.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Inheritance; 9 | import javax.persistence.InheritanceType; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Entity 20 | @Table(name = "users") 21 | @Inheritance(strategy = InheritanceType.JOINED) 22 | public class User { 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | @Column(name = "email", unique = true) 28 | private String email; 29 | @Column(name = "password") 30 | private String password; 31 | @Column(name = "role") 32 | private String role; 33 | } 34 | // 35 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/AdditionalServiceItemService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.AdditionalServiceItemListDto; 6 | import com.btkAkademi.rentACar.business.requests.additionalServiceItemRequests.CreateAdditionalServiceItemRequest; 7 | import com.btkAkademi.rentACar.business.requests.additionalServiceItemRequests.UpdateAdditionalServiceItemRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface AdditionalServiceItemService { 12 | 13 | Result add(CreateAdditionalServiceItemRequest createAdditionalServiceItemRequest); 14 | 15 | Result update(UpdateAdditionalServiceItemRequest updateAdditionalServiceItemRequest); 16 | 17 | Result delete(int id); 18 | 19 | DataResult findById(int id); 20 | 21 | DataResult> findAll(); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/AdditionalServiceService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.AdditionalServiceListDto; 6 | import com.btkAkademi.rentACar.business.requests.additionalServiceRequests.CreateAdditionalServiceRequest; 7 | import com.btkAkademi.rentACar.business.requests.additionalServiceRequests.UpdateAdditionalServiceRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface AdditionalServiceService { 12 | DataResult> findAllByRentalId(int rentalId); 13 | 14 | Result add(CreateAdditionalServiceRequest createAdditionalServiceRequest); 15 | 16 | Result addAll(List createAdditionalServiceRequests); 17 | 18 | Result update(UpdateAdditionalServiceRequest updateAdditionalServiceRequest); 19 | 20 | Result delete(int id); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CustomerCardDetailService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.CustomerCardDetailListDto; 6 | import com.btkAkademi.rentACar.business.requests.customerCardDetailRequests.CreateCustomerCardDetailRequest; 7 | import com.btkAkademi.rentACar.business.requests.customerCardDetailRequests.UpdateCustomerCardDetailsRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface CustomerCardDetailService { 12 | DataResult> findCustomerCardDetailsByCustomerId(int customerId); 13 | 14 | DataResult findById(int id); 15 | 16 | Result add(CreateCustomerCardDetailRequest createCustomerPaymentDetailRequest); 17 | 18 | Result update(UpdateCustomerCardDetailsRequest updateCustomerPamentDetails); 19 | 20 | Result delete(int id); 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/LanguageService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.LanguageSearchListDto; 6 | import com.btkAkademi.rentACar.business.requests.languageRequests.CreateLanguageRequest; 7 | import com.btkAkademi.rentACar.business.requests.languageRequests.DeleteLanguageRequest; 8 | import com.btkAkademi.rentACar.business.requests.languageRequests.UpdateLanguageRequest; 9 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 10 | import com.btkAkademi.rentACar.core.utilities.results.Result; 11 | 12 | public interface LanguageService { 13 | 14 | DataResult> getAll(); 15 | 16 | Result add(CreateLanguageRequest createLanguageRequest); 17 | 18 | Result delete(DeleteLanguageRequest deleteLanguageRequest); 19 | 20 | Result update(UpdateLanguageRequest updateLanguageRequests); 21 | 22 | DataResult getByLanguageName(String languageName); 23 | 24 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/individualCustomerRequests/UpdateIndividualCustomerRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.individualCustomerRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.validation.constraints.Email; 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import javax.validation.constraints.Pattern; 9 | import javax.validation.constraints.Size; 10 | 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.NoArgsConstructor; 14 | 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class UpdateIndividualCustomerRequest { 19 | 20 | private int id; 21 | 22 | @Pattern(regexp = "[0-9]+") 23 | @Size(min = 11, max = 11) 24 | private String nationalityNo; 25 | @Email 26 | @NotBlank 27 | private String email; 28 | @Size(min = 2, max = 100) 29 | private String firstName; 30 | @Size(min = 2, max = 100) 31 | private String lastName; 32 | private LocalDate birthDate; 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/AdditionalService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | @Entity 20 | @Table(name = "additional_services") 21 | public class AdditionalService { 22 | @Id 23 | @GeneratedValue(strategy = GenerationType.IDENTITY) 24 | @Column(name = "id") 25 | private int id; 26 | 27 | @ManyToOne 28 | @JoinColumn(name = "additional_service_item_id") 29 | private AdditionalServiceItem additionalServiceItem; 30 | 31 | @ManyToOne 32 | @JoinColumn(name = "rental_id") 33 | private Rental rental; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/AdditionalServiceItem.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | @Entity 21 | @Table(name = "additional_service_items") 22 | public class AdditionalServiceItem { 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | @Column(name = "name") 28 | private String name; 29 | @Column(name = "price") 30 | private double price; 31 | 32 | @OneToMany(mappedBy = "additionalServiceItem") 33 | private List additionalServices; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Translation.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | @Data 19 | @Entity 20 | @Table(name = "translations") 21 | public class Translation { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | 28 | @Column(name = "translation") 29 | private String translation; 30 | 31 | @ManyToOne 32 | @JoinColumn(name = "word_id") 33 | private Word word; 34 | 35 | @ManyToOne 36 | @JoinColumn(name = "language_id") 37 | private Language language; 38 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Payment.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.Table; 13 | 14 | import lombok.AllArgsConstructor; 15 | import lombok.Data; 16 | import lombok.NoArgsConstructor; 17 | 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Entity 22 | @Table(name = "payments") 23 | public class Payment { 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | @Column(name = "id") 27 | private int id; 28 | @Column(name = "paymen_time") 29 | private LocalDate paymentTime; 30 | @Column(name = "total_payment_amount") 31 | private double totalPaymentAmount; 32 | @ManyToOne 33 | @JoinColumn(name = "rental_id") 34 | private Rental rental; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/auth/AuthController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.auth; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.CrossOrigin; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 12 | @CrossOrigin 13 | @RestController 14 | @RequestMapping("/api/auth") 15 | public class AuthController { 16 | private AuthService authService; 17 | @Autowired 18 | public AuthController(AuthService authService) { 19 | super(); 20 | this.authService = authService; 21 | } 22 | @PostMapping("login") 23 | public DataResult login(@RequestBody LoginRequest loginRequest){ 24 | return this.authService.login(loginRequest); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CarMaintenanceService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.CarMaintenanceListDto; 6 | import com.btkAkademi.rentACar.business.requests.carMaintananceRequests.CreateCarMaintenanceRequest; 7 | import com.btkAkademi.rentACar.business.requests.carMaintananceRequests.UpdateCarMaintananceRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface CarMaintenanceService { 12 | 13 | DataResult> findAll(); 14 | 15 | DataResult> findAllByCarId(int id); 16 | 17 | DataResult findById(int id); 18 | 19 | Result add(CreateCarMaintenanceRequest createCarMaintananceRequest); 20 | 21 | Result update(UpdateCarMaintananceRequest updateCarMaintananceRequest); 22 | 23 | Result delete(int id); 24 | 25 | boolean isCarInMaintenance(int carId); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/individualCustomerRequests/CreateIndividualCustomerRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.individualCustomerRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.validation.constraints.Email; 6 | import javax.validation.constraints.NotBlank; 7 | import javax.validation.constraints.NotNull; 8 | import javax.validation.constraints.Pattern; 9 | import javax.validation.constraints.Size; 10 | 11 | import lombok.AllArgsConstructor; 12 | import lombok.Data; 13 | import lombok.NoArgsConstructor; 14 | 15 | @Data 16 | @AllArgsConstructor 17 | @NoArgsConstructor 18 | public class CreateIndividualCustomerRequest { 19 | 20 | @Email 21 | @NotBlank 22 | private String email; 23 | @Size(min = 4, max = 30) 24 | private String password; 25 | @Size(min = 2, max = 100) 26 | private String firstName; 27 | @Size(min = 2, max = 100) 28 | private String lastName; 29 | @NotNull 30 | private LocalDate birthDate; 31 | @Pattern(regexp = "[0-9]+") 32 | @Size(min = 11, max = 11) 33 | private String nationalityNo; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/CarMaintenance.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.Table; 13 | 14 | import lombok.AllArgsConstructor; 15 | import lombok.Data; 16 | import lombok.NoArgsConstructor; 17 | 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Entity 22 | @Table(name = "car_maintenances") 23 | public class CarMaintenance { 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | @Column(name = "id") 27 | private int id; 28 | @Column(name = "maintenance_start") 29 | private LocalDate maintenanceStart; 30 | @Column(name = "maintenance_end") 31 | private LocalDate maintenanceEnd; 32 | 33 | @ManyToOne 34 | @JoinColumn(name = "car_id") 35 | private Car car; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/adapters/banks/conctrates/IsBankAdapterManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.adapters.banks.conctrates; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import com.btkAkademi.rentACar.business.constants.Messages; 6 | import com.btkAkademi.rentACar.core.adapters.banks.abstracts.BankAdapterService; 7 | import com.btkAkademi.rentACar.core.externalServices.banks.IsBankFakePos; 8 | import com.btkAkademi.rentACar.core.utilities.results.ErrorResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 11 | 12 | @Service 13 | public class IsBankAdapterManager implements BankAdapterService { 14 | 15 | @Override 16 | public Result makePayment(String cardNo, String day, String mounth, String cVV, double amount) { 17 | IsBankFakePos isBank = new IsBankFakePos(); 18 | if (isBank.posService(cardNo, day, mounth, cVV, amount)) { 19 | return new SuccessResult(); 20 | } else { 21 | return new ErrorResult(Messages.NOTFOUND); 22 | } 23 | 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/City.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import lombok.AllArgsConstructor; 14 | import lombok.Data; 15 | import lombok.NoArgsConstructor; 16 | 17 | @Data 18 | @NoArgsConstructor 19 | @AllArgsConstructor 20 | @Entity 21 | @Table(name = "cities") 22 | public class City { 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | 28 | @Column(name = "city_name") 29 | private String cityName; 30 | 31 | @OneToMany(mappedBy = "pickUpCity") 32 | private List pickUpCityRentals; 33 | 34 | @OneToMany(mappedBy = "returnCity") 35 | private List returnCityRentals; 36 | 37 | @OneToMany(mappedBy = "city") 38 | private List cars; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/TranslationService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.TranslationSearchListDto; 6 | import com.btkAkademi.rentACar.business.requests.translationRequests.CreateTranslationRequest; 7 | import com.btkAkademi.rentACar.business.requests.translationRequests.DeleteTranslationRequest; 8 | import com.btkAkademi.rentACar.business.requests.translationRequests.UpdateTranslationRequest; 9 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 10 | import com.btkAkademi.rentACar.core.utilities.results.Result; 11 | import com.btkAkademi.rentACar.entities.concretes.Translation; 12 | 13 | public interface TranslationService { 14 | DataResult> getAll(); 15 | 16 | Result add(CreateTranslationRequest createTranslationRequest); 17 | 18 | Result delete(DeleteTranslationRequest deleteTranslationRequest); 19 | 20 | Result update(UpdateTranslationRequest updateTranslationRequest); 21 | 22 | Translation getTranslationByLanguage_IdAndWord_Id(int languageId, int wordId); 23 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/CustomerCardDetail.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.JoinColumn; 9 | import javax.persistence.ManyToOne; 10 | import javax.persistence.Table; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | @Entity 20 | @Table(name = "customer_card_details") 21 | public class CustomerCardDetail { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | @Column(name = "id") 26 | private int id; 27 | @Column(name = "card_no") 28 | private String cardNo; 29 | @Column(name = "year") 30 | private String year; 31 | @Column(name = "month") 32 | private String month; 33 | @Column(name = "cvv") 34 | private String cvv; 35 | 36 | @ManyToOne 37 | @JoinColumn(name = "customer_id") 38 | private Customer customer; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/InvoiceService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.InvoiceCorporateCustomerDto; 6 | import com.btkAkademi.rentACar.business.dtos.InvoiceIndividualCustomerDto; 7 | import com.btkAkademi.rentACar.business.dtos.InvoiceListDto; 8 | import com.btkAkademi.rentACar.business.requests.invoiceRequests.CreateInvoiceRequest; 9 | import com.btkAkademi.rentACar.business.requests.invoiceRequests.UpdateInvoiceRequest; 10 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 11 | import com.btkAkademi.rentACar.core.utilities.results.Result; 12 | 13 | public interface InvoiceService { 14 | 15 | DataResult getInvoiceForIndividualCustomer(int rentalId); 16 | 17 | DataResult getInvoiceForCorporateCustomer(int rentalId); 18 | 19 | Result add(CreateInvoiceRequest createInvoiceRequest); 20 | 21 | Result update(UpdateInvoiceRequest updateInvoiceRequest); 22 | 23 | Result delete(int id); 24 | 25 | DataResult> findAll(); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/PaymentService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.PaymentListDto; 6 | import com.btkAkademi.rentACar.business.requests.paymentRequests.CalculateTotalPriceRequest; 7 | import com.btkAkademi.rentACar.business.requests.paymentRequests.CreatePaymentRequest; 8 | import com.btkAkademi.rentACar.business.requests.paymentRequests.UpdatePaymentRequest; 9 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 10 | import com.btkAkademi.rentACar.core.utilities.results.Result; 11 | 12 | public interface PaymentService { 13 | DataResult> findAll(int pageNo, int pageSize); 14 | 15 | DataResult> findAllByRentalId(int id); 16 | 17 | DataResult calculateTotalPriceForDisplay(CalculateTotalPriceRequest calculateTotalPriceRequest); 18 | 19 | DataResult findById(int id); 20 | 21 | Result add(CreatePaymentRequest createPaymentRequest); 22 | 23 | Result update(UpdatePaymentRequest updatePaymentRequest); 24 | 25 | Result delete(int id); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/adapters/creditScore/concrates/FindexAdapterManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.adapters.creditScore.concrates; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import com.btkAkademi.rentACar.core.adapters.creditScore.abstracts.CreditScoreAdapterService; 6 | import com.btkAkademi.rentACar.core.externalServices.creditScoreServices.FindexFake; 7 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 8 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 9 | 10 | @Service 11 | public class FindexAdapterManager implements CreditScoreAdapterService { 12 | 13 | @Override 14 | public DataResult getScoreOfIndividualCustomer(String nationalityId) { 15 | FindexFake findexFake = new FindexFake(); 16 | return new SuccessDataResult(findexFake.getScoreOfIndividualCustomer(nationalityId)); 17 | } 18 | 19 | @Override 20 | public DataResult getScoreOfCorporateCustomer(String taxNumber) { 21 | FindexFake findexFake = new FindexFake(); 22 | return new SuccessDataResult(findexFake.getScoreOfIndividualCustomer(taxNumber)); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/carRequests/UpdateCarRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.carRequests; 2 | 3 | import javax.validation.constraints.Max; 4 | import javax.validation.constraints.Min; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.NotNull; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class UpdateCarRequest { 17 | @NotEmpty 18 | private String carName; 19 | private int id; 20 | private int brandId; 21 | private int colorId; 22 | @NotNull 23 | @Min(0) 24 | private double dailyPrice; 25 | 26 | @NotNull 27 | @Min(1900) 28 | private int model; 29 | 30 | @NotNull 31 | @Min(650) 32 | @Max(1900) 33 | private int findexScore; 34 | 35 | @NotNull 36 | @Min(0) 37 | @Max(2500000) 38 | private int kilometer; 39 | 40 | private String imageUrl; 41 | @NotBlank 42 | private String description; 43 | @Min(18) 44 | private int minAge; 45 | private int segmentId; 46 | private int cityId; 47 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/loaders/CityDataLoader.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.loaders; 2 | 3 | import java.util.HashSet; 4 | 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.btkAkademi.rentACar.dataAccess.abstracts.CityDao; 9 | import com.btkAkademi.rentACar.entities.concretes.City; 10 | 11 | import lombok.AllArgsConstructor; 12 | 13 | @Component 14 | @AllArgsConstructor 15 | public class CityDataLoader implements CommandLineRunner { 16 | private CityDao cityDao; 17 | 18 | @Override 19 | public void run(String... args) throws Exception { 20 | loadCities(); 21 | 22 | } 23 | 24 | private void loadCities() { 25 | if (cityDao.count() == 0) { 26 | HashSet cities = new HashSet<>(); 27 | cities.add(new City(0, "Ankara", null, null, null)); 28 | cities.add(new City(0, "İzmir", null, null, null)); 29 | cities.add(new City(0, "İstanbul", null, null, null)); 30 | cities.add(new City(0, "Antalya", null, null, null)); 31 | cities.add(new City(0, "Konya", null, null, null)); 32 | cityDao.saveAll(cities); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/mapping/ModelMapperManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.mapping; 2 | 3 | import org.modelmapper.ModelMapper; 4 | import org.modelmapper.convention.MatchingStrategies; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | 10 | public class ModelMapperManager implements ModelMapperService { 11 | // Dependencies 12 | private ModelMapper modelMapper; 13 | 14 | // Dependency Injection 15 | @Autowired 16 | public ModelMapperManager(ModelMapper modelMapper) { 17 | this.modelMapper = modelMapper; 18 | } 19 | 20 | // Mapping Configuration for Original to Dto 21 | @Override 22 | public ModelMapper forDto() { 23 | this.modelMapper.getConfiguration().setAmbiguityIgnored(true).setMatchingStrategy(MatchingStrategies.LOOSE); 24 | return modelMapper; 25 | } 26 | 27 | // Mapping Configuration for Request to Original 28 | @Override 29 | public ModelMapper forRequest() { 30 | this.modelMapper.getConfiguration().setAmbiguityIgnored(true).setMatchingStrategy(MatchingStrategies.STANDARD); 31 | return modelMapper; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/PromoCode.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.GenerationType; 10 | import javax.persistence.Id; 11 | import javax.persistence.OneToMany; 12 | import javax.persistence.Table; 13 | 14 | import lombok.AllArgsConstructor; 15 | import lombok.Data; 16 | import lombok.NoArgsConstructor; 17 | 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Entity 22 | @Table(name = "promo_codes") 23 | public class PromoCode { 24 | @Id 25 | @GeneratedValue(strategy = GenerationType.IDENTITY) 26 | @Column(name = "id") 27 | private int id; 28 | @Column(name = "code") 29 | private String code; 30 | @Column(name = "discount_rate") 31 | private double discountRate; 32 | @Column(name = "start_date") 33 | private LocalDate startDate; 34 | @Column(name = "end_date") 35 | private LocalDate endDate; 36 | @Column(name = "description") 37 | private String description; 38 | 39 | @OneToMany(mappedBy = "promoCode") 40 | private List rentals; 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/customerCardDetailRequests/CreateCustomerCardDetailRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.customerCardDetailRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Pattern; 5 | import javax.validation.constraints.Size; 6 | 7 | import com.btkAkademi.rentACar.business.constants.Messages; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class CreateCustomerCardDetailRequest { 17 | 18 | @NotBlank 19 | @Size(min = 16, max = 16) 20 | @Pattern(regexp = "[0-9]+",message = Messages.CREDITCARDNUMBERERROR) 21 | private String cardNo; 22 | @NotBlank 23 | @Size(min = 2, max = 2) 24 | @Pattern(regexp = "([2][2-9])|([3][0-9])",message = Messages.CREDITCARDDATEERROR) 25 | private String year; 26 | @NotBlank 27 | @Size(min = 2, max = 2) 28 | @Pattern(regexp = "[0][1-9]|[1][0-2]",message = Messages.CREDITCARDDATEERROR) 29 | private String month; 30 | @NotBlank 31 | @Size(min = 3, max = 3) 32 | @Pattern(regexp = "[0-9][0-9][0-9]",message = Messages.CREDITCARDCVVERROR) 33 | private String cvv; 34 | private int customerId; 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/customerCardDetailRequests/UpdateCustomerCardDetailsRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.customerCardDetailRequests; 2 | 3 | import javax.validation.constraints.NotBlank; 4 | import javax.validation.constraints.Pattern; 5 | import javax.validation.constraints.Size; 6 | 7 | import com.btkAkademi.rentACar.business.constants.Messages; 8 | 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | @Data 14 | @AllArgsConstructor 15 | @NoArgsConstructor 16 | public class UpdateCustomerCardDetailsRequest { 17 | private int id; 18 | @NotBlank 19 | @Size(min = 16, max = 16) 20 | @Pattern(regexp = "[0-9]+",message = Messages.CREDITCARDNUMBERERROR) 21 | private String cardNo; 22 | @NotBlank 23 | @Size(min = 2, max = 2) 24 | @Pattern(regexp = "([2][2-9])|([3][0-9])",message = Messages.CREDITCARDDATEERROR) 25 | private String year; 26 | @NotBlank 27 | @Size(min = 2, max = 2) 28 | @Pattern(regexp = "[0][1-9]|[1][0-2]",message = Messages.CREDITCARDDATEERROR) 29 | private String month; 30 | @NotBlank 31 | @Size(min = 3, max = 3) 32 | @Pattern(regexp = "[0-9][0-9][0-9]",message = Messages.CREDITCARDCVVERROR) 33 | private String cvv; 34 | private int customerId; 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/carRequests/CreateCarRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.carRequests; 2 | 3 | import javax.validation.constraints.Max; 4 | import javax.validation.constraints.Min; 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotNull; 7 | import javax.validation.constraints.Pattern; 8 | import javax.validation.constraints.Size; 9 | 10 | import lombok.AllArgsConstructor; 11 | import lombok.Data; 12 | import lombok.NoArgsConstructor; 13 | 14 | @Data 15 | @AllArgsConstructor 16 | @NoArgsConstructor 17 | public class CreateCarRequest { 18 | @NotNull 19 | @Size(min=3,max=50) 20 | private String carName; 21 | 22 | private int brandId; 23 | 24 | private int colorId; 25 | @NotNull 26 | @Min(0) 27 | private double dailyPrice; 28 | 29 | @NotNull 30 | @Min(1900) 31 | private int model; 32 | 33 | @NotNull 34 | @Min(650) 35 | @Max(1900) 36 | private int findexScore; 37 | 38 | @NotNull 39 | @Min(0) 40 | @Max(2500000) 41 | private int kilometer; 42 | @Pattern(regexp = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]") 43 | private String imageUrl; 44 | @NotBlank 45 | private String description; 46 | @Min(18) 47 | private int minAge; 48 | private int segmentId; 49 | private int cityId; 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/RentalService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.MyRentalListDto; 6 | import com.btkAkademi.rentACar.business.dtos.RentalAddResponse; 7 | import com.btkAkademi.rentACar.business.dtos.RentalListDto; 8 | import com.btkAkademi.rentACar.business.requests.rentalRequests.CreateRentalRequest; 9 | import com.btkAkademi.rentACar.business.requests.rentalRequests.UpdateRentalRequest; 10 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 11 | import com.btkAkademi.rentACar.core.utilities.results.Result; 12 | 13 | public interface RentalService { 14 | DataResult> findAll(int pageNo, int pageSize); 15 | 16 | DataResult> findAllByCustomerId(int id); 17 | 18 | DataResult findById(int id); 19 | 20 | DataResult addForIndividualCustomer(CreateRentalRequest createRentalRequest); 21 | 22 | DataResult addForCorporateCustomer(CreateRentalRequest createRentalRequest); 23 | 24 | Result update(UpdateRentalRequest updateRentalRequest); 25 | 26 | Result delete(int id); 27 | 28 | boolean isCarRented(int carId); 29 | 30 | DataResult findActiveRentalByCarId(int id); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/requests/paymentRequests/CreatePaymentRequest.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.requests.paymentRequests; 2 | 3 | import java.time.LocalDate; 4 | 5 | import javax.validation.constraints.NotBlank; 6 | import javax.validation.constraints.NotEmpty; 7 | import javax.validation.constraints.Pattern; 8 | import javax.validation.constraints.Size; 9 | 10 | import com.btkAkademi.rentACar.business.constants.Messages; 11 | 12 | import lombok.AllArgsConstructor; 13 | import lombok.Data; 14 | import lombok.NoArgsConstructor; 15 | 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class CreatePaymentRequest { 20 | private LocalDate paymentTime; 21 | private int rentalId; 22 | private LocalDate returnDate; 23 | @NotBlank 24 | @Size(min = 16, max = 16) 25 | @Pattern(regexp = "[0-9]+",message = Messages.CREDITCARDNUMBERERROR) 26 | private String cardNo; 27 | @NotBlank 28 | @Size(min = 2, max = 2) 29 | @Pattern(regexp = "([2][2-9])|([3][0-9])",message = Messages.CREDITCARDDATEERROR) 30 | private String year; 31 | @NotBlank 32 | @Size(min = 2, max = 2) 33 | @Pattern(regexp = "[0][1-9]|[1][0-2]",message = Messages.CREDITCARDDATEERROR) 34 | private String month; 35 | @NotBlank 36 | @Size(min = 3, max = 3) 37 | @Pattern(regexp = "[0-9][0-9][0-9]",message = Messages.CREDITCARDCVVERROR) 38 | private String cvv; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/loaders/ColorDataLoader.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.loaders; 2 | 3 | import java.util.HashSet; 4 | 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.btkAkademi.rentACar.dataAccess.abstracts.ColorDao; 9 | import com.btkAkademi.rentACar.entities.concretes.Color; 10 | 11 | import lombok.AllArgsConstructor; 12 | 13 | @Component 14 | @AllArgsConstructor 15 | public class ColorDataLoader implements CommandLineRunner { 16 | private ColorDao colorDao; 17 | 18 | @Override 19 | public void run(String... args) throws Exception { 20 | loadColors(); 21 | 22 | } 23 | 24 | private void loadColors() { 25 | if (colorDao.count() == 0) { 26 | HashSet colors = new HashSet<>(); 27 | colors.add(new Color(0, "Beyaz", null)); 28 | colors.add(new Color(0, "Siyah", null)); 29 | colors.add(new Color(0, "Gri", null)); 30 | colors.add(new Color(0, "Gümüş", null)); 31 | colors.add(new Color(0, "Mavi", null)); 32 | colors.add(new Color(0, "Kırmızı", null)); 33 | colors.add(new Color(0, "Kahverengi", null)); 34 | colors.add(new Color(0, "Bej", null)); 35 | colors.add(new Color(0, "Sarı", null)); 36 | colors.add(new Color(0, "Altın", null)); 37 | colors.add(new Color(0, "Yeşil", null)); 38 | colorDao.saveAll(colors); 39 | } 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/abstracts/CarService.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import com.btkAkademi.rentACar.business.dtos.CarListDto; 6 | import com.btkAkademi.rentACar.business.requests.carRequests.CreateCarRequest; 7 | import com.btkAkademi.rentACar.business.requests.carRequests.UpdateCarRequest; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.Result; 10 | 11 | public interface CarService { 12 | 13 | DataResult> findAll(int pageNo, int pageSize); 14 | 15 | DataResult> findAllAvailable(int pageNo, int pageSize); 16 | 17 | DataResult> findAllByBrandId(int brandId, int pageNo, int pageSize); 18 | 19 | DataResult> findAllByColorId(int colorId, int pageNo, int pageSize); 20 | 21 | DataResult findById(int id); 22 | 23 | DataResult> findAllBySegmentId(int segmentId); 24 | 25 | DataResult> findAvailableCarsBySegmentIdAndCityId(int segmentId, int cityId); 26 | 27 | Result add(CreateCarRequest createCarRequest); 28 | 29 | Result update(UpdateCarRequest updateCarRequest); 30 | 31 | Result updateCarKilometer(int carId, int kilometer); 32 | 33 | Result updateCarCity(int carId, int cityId); 34 | 35 | Result delete(int id); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/concretes/CustomerManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.concretes; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.btkAkademi.rentACar.business.abstracts.CustomerService; 7 | import com.btkAkademi.rentACar.business.constants.Messages; 8 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 9 | import com.btkAkademi.rentACar.core.utilities.results.ErrorDataResult; 10 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 11 | import com.btkAkademi.rentACar.dataAccess.abstracts.CustomerDao; 12 | import com.btkAkademi.rentACar.entities.concretes.Customer; 13 | 14 | @Service 15 | 16 | public class CustomerManager implements CustomerService { 17 | // Dependencies 18 | private CustomerDao customerDao; 19 | 20 | // Dependency Injection 21 | @Autowired 22 | public CustomerManager(CustomerDao customerDao) { 23 | super(); 24 | this.customerDao = customerDao; 25 | } 26 | 27 | // Finds Customer with that id 28 | @Override 29 | public DataResult findCustomerById(int id) { 30 | if (customerDao.existsById(id)) { 31 | return new SuccessDataResult(customerDao.findById(id).get(), Messages.CUSTOMERLIST); 32 | 33 | } else 34 | return new ErrorDataResult(Messages.CUSTOMERNOTFOUND); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/UserController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RestController; 13 | 14 | import com.btkAkademi.rentACar.business.abstracts.UserService; 15 | import com.btkAkademi.rentACar.business.dtos.UserListDto; 16 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 17 | import com.btkAkademi.rentACar.core.utilities.results.Result; 18 | 19 | @CrossOrigin 20 | @RestController 21 | @RequestMapping("/api/users") 22 | public class UserController { 23 | // Dependencies 24 | private UserService userService; 25 | 26 | // Dependency Injection 27 | public UserController(UserService userService) { 28 | super(); 29 | this.userService = userService; 30 | } 31 | 32 | // lists all users 33 | @GetMapping("find-all") 34 | public DataResult> findAll() { 35 | return this.userService.findAll(); 36 | } 37 | 38 | // deletes a user 39 | @DeleteMapping("delete/{id}") 40 | public Result delete(@Valid @PathVariable int id) { 41 | 42 | return this.userService.delete(id); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/loaders/AdditionalServiceItemDataLoader.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.loaders; 2 | 3 | import java.util.HashSet; 4 | 5 | import org.springframework.boot.CommandLineRunner; 6 | import org.springframework.stereotype.Component; 7 | 8 | import com.btkAkademi.rentACar.dataAccess.abstracts.AdditionalServiceItemDao; 9 | import com.btkAkademi.rentACar.entities.concretes.AdditionalServiceItem; 10 | 11 | import lombok.AllArgsConstructor; 12 | 13 | @Component 14 | @AllArgsConstructor 15 | public class AdditionalServiceItemDataLoader implements CommandLineRunner { 16 | private AdditionalServiceItemDao additionalServiceItemDao; 17 | 18 | @Override 19 | public void run(String... args) throws Exception { 20 | loadAdditionalServiceItems(); 21 | 22 | } 23 | 24 | private void loadAdditionalServiceItems() { 25 | if (additionalServiceItemDao.count() == 0) { 26 | HashSet items = new HashSet<>(); 27 | items.add(new AdditionalServiceItem(0, "Bebek Koltuğu", 75, null)); 28 | items.add(new AdditionalServiceItem(0, "Navigasyon Aleti", 150, null)); 29 | items.add(new AdditionalServiceItem(0, "Ek Sürücü", 500, null)); 30 | items.add(new AdditionalServiceItem(0, "Kaza Sigortası", 300, null)); 31 | items.add(new AdditionalServiceItem(0, "Süper Kaza Sigortası", 500, null)); 32 | items.add(new AdditionalServiceItem(0, "Kış Lastiği", 160, null)); 33 | items.add(new AdditionalServiceItem(0, "Wifi Modem", 300, null)); 34 | additionalServiceItemDao.saveAll(items); 35 | } 36 | 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/dataAccess/abstracts/CarDao.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.dataAccess.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.jpa.repository.JpaRepository; 7 | import org.springframework.data.jpa.repository.Query; 8 | 9 | import com.btkAkademi.rentACar.entities.concretes.Car; 10 | 11 | public interface CarDao extends JpaRepository { 12 | 13 | List findAllByBrandId(int brandId, Pageable pagable); 14 | 15 | List findAllByColorId(int colorId, Pageable pagable); 16 | 17 | List findAllBySegmentId(int segmentId); 18 | 19 | @Query(value = "select cars.id as rental_id,\r\n" + " rentals.return_date\r\n" + "from cars\r\n" 20 | + "left join car_maintenances on cars.id = car_maintenances.car_id and car_maintenances.maintenance_end is null\r\n" 21 | + "left join rentals on cars.id = rentals.car_id and (rentals.return_date is null or rentals.return_date>NOW())\r\n" 22 | + "where car_maintenances.id is null and rentals.id is null and cars.segment_id =?1 and cars.city_id =?2 limit 1", nativeQuery = true) 23 | List findAvailableCarBySegmentAndCity(Integer segmentId, Integer cityId); 24 | 25 | @Query(value = "select cars.* from cars \r\n" 26 | + "left join car_maintenances on cars.id=car_maintenances.car_id and car_maintenances.maintenance_end is null\r\n" 27 | + "left join rentals on cars.id=rentals.car_id and rentals.return_date is null\r\n" 28 | + "where car_maintenances.id is null and rentals.id is null order by cars.segment_id asc,cars.brand_id asc, cars.car_name asc\r\n" 29 | 30 | , nativeQuery = true) 31 | List findAvailableCars(Pageable pageable); 32 | 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Car.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.JoinColumn; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.OneToMany; 13 | import javax.persistence.Table; 14 | 15 | import lombok.AllArgsConstructor; 16 | import lombok.Data; 17 | import lombok.NoArgsConstructor; 18 | 19 | @Data 20 | @AllArgsConstructor 21 | @NoArgsConstructor 22 | @Entity 23 | @Table(name = "cars") 24 | public class Car { 25 | 26 | @Id 27 | @GeneratedValue(strategy = GenerationType.IDENTITY) 28 | @Column(name = "id") 29 | private int id; 30 | @Column(name = "car_name") 31 | private String carName; 32 | @Column(name = "daily_price") 33 | private double dailyPrice; 34 | @Column(name = "model") 35 | private int model; 36 | @Column(name = "description") 37 | private String description; 38 | @Column(name = "findex_score") 39 | private int findexScore; 40 | @Column(name = "kilometer") 41 | private int kilometer; 42 | @Column(name = "min_age") 43 | private int minAge; 44 | @Column(name = "image_url", length = 3000) 45 | private String imageUrl; 46 | 47 | @ManyToOne 48 | @JoinColumn(name = "brand_id") 49 | private Brand brand; 50 | @ManyToOne 51 | @JoinColumn(name = "color_id") 52 | private Color color; 53 | @ManyToOne 54 | @JoinColumn(name = "segment_id") 55 | private Segment segment; 56 | @ManyToOne 57 | @JoinColumn(name = "city_id") 58 | private City city; 59 | 60 | @OneToMany(mappedBy = "car") 61 | private List carMaintenances; 62 | 63 | @OneToMany(mappedBy = "car") 64 | private List rentals; 65 | 66 | @OneToMany(mappedBy = "car") 67 | private List carDamages; 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/entities/concretes/Rental.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.entities.concretes; 2 | 3 | import java.time.LocalDate; 4 | import java.util.List; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.GenerationType; 10 | import javax.persistence.Id; 11 | import javax.persistence.JoinColumn; 12 | import javax.persistence.ManyToOne; 13 | import javax.persistence.OneToMany; 14 | import javax.persistence.OneToOne; 15 | import javax.persistence.Table; 16 | 17 | import lombok.AllArgsConstructor; 18 | import lombok.Data; 19 | import lombok.NoArgsConstructor; 20 | 21 | @Data 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | @Entity 25 | @Table(name = "rentals") 26 | public class Rental { 27 | @Id 28 | @GeneratedValue(strategy = GenerationType.IDENTITY) 29 | @Column(name = "id") 30 | private int id; 31 | @Column(name = "rent_date") 32 | private LocalDate rentDate; 33 | @Column(name = "return_date") 34 | private LocalDate returnDate; 35 | @Column(name = "rented_kilometer") 36 | private Integer rentedKilometer; 37 | @Column(name = "returned_kilometer") 38 | private Integer returnedKilometer; 39 | 40 | @ManyToOne 41 | @JoinColumn(name = "pick_up_city_id") 42 | private City pickUpCity; 43 | 44 | @ManyToOne 45 | @JoinColumn(name = "return_city_id") 46 | private City returnCity; 47 | 48 | @ManyToOne 49 | @JoinColumn(name = "customer_id") 50 | private Customer customer; 51 | 52 | @ManyToOne 53 | @JoinColumn(name = "car_id") 54 | private Car car; 55 | 56 | @ManyToOne 57 | @JoinColumn(name = "promo_code_id") 58 | private PromoCode promoCode; 59 | 60 | @OneToMany(mappedBy = "rental") 61 | private List additionalService; 62 | 63 | @OneToMany(mappedBy = "rental") 64 | private List payments; 65 | 66 | @OneToOne(mappedBy = "rental") 67 | private Invoice invoice; 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/resources/static/ister.txt: -------------------------------------------------------------------------------- 1 | // rental için ödeme yapılabilmeli yani paymentService kurulacak 2 | // ödemeyi yaparken arabanın günlük tutarı * gün sayısı + additional service 3 | // ödemee rental ile ilişkilendirilecek 4 | // //hangi kiralama için ne zaman hangi tarihte ne kadar ödeme alıntı total 5 | 6 | 7 | kişi kredi kartı bilgilerini girdiğinde ödemeyi tamamlamadan önce kişi kredi kartı limiti varsa ödeme yapıcaz 8 | 9 | fake service varmış gibi 10 | 11 | 12 | 13 | // ödev 14 | tüm operasyonlar için ekleme silme arama güncelleme listeleme gibi operasyonları implemente et 15 | 16 | 17 | Rest Api nedir Http protokolünde çalışıyor xml json gibi formatta servislerin birbiriyle iletişimde olmasını sağlar 18 | Soap Nedir - farklı protokollerde gidebilir tcp gibi genelde local servislerin birbirleri ile iletişiminde kullanılır 19 | 20 | 17.01.2020 21 | 22 | findex 650 -1900 arasında olur 23 | her arabanın min kiralabilir findex scoreunda olması gerekir.. 24 | dış servis olarak müşterinin findex scoruna bakacağız. 25 | 26 | arabalara min yaş kuralı ekliyoruz 27 | 28 | bir kiralama için fatura oluşturacaksın 29 | bireysel kurumsal ayrı fatura olacak 30 | kiralanan gün ek servis total price 31 | fatura tablosunda id - creation date - hangi rental 32 | bir kere fatura oluşturulduysa birdaha o rental için fatura oluşturulamaz 33 | 34 | ister: 35 | kiralamalarda promosyon kodu da eklenebilmeli 36 | promosyon kodunun indirim oranı neyse kiralama bedeline o kadar indirim uygulanır. 37 | kiralama tablosuna kirama birim fiyatı da eklenir. 38 | additional service olmasın 39 | promosyon kodunun id name indirim oranı promosyon başlangıç tarihi promosyon bitiş tarihi 40 | eğer girilen promosyon kod geçerli değilse indirim uygulanmayacak. 41 | 42 | 43 | 44 | 45 | // 18.01.2022 46 | 47 | -- first mission 48 | 49 | -arabalar ekonomi orta ve prestij sınıflarına ayrılabilmelidir. 50 | *bir sınıfaki arabadan müsaitlik yoksa o sınıftaki başka benzer araba otomatik olarak kiralanır. 51 | * bir araba kiralamak istediğinde eğer bir araba bakımdaysa veya kirada ise aynı sınıftan başka araç kiralanır oda yoksa kiralanamaz. 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/core/utilities/results/LanguageSelector.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.core.utilities.results; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.core.env.Environment; 5 | import org.springframework.stereotype.Service; 6 | 7 | import com.btkAkademi.rentACar.business.abstracts.LanguageService; 8 | import com.btkAkademi.rentACar.business.abstracts.TranslationService; 9 | import com.btkAkademi.rentACar.business.abstracts.WordService; 10 | import com.btkAkademi.rentACar.business.dtos.LanguageSearchListDto; 11 | import com.btkAkademi.rentACar.business.dtos.WordSearchListDto; 12 | import com.btkAkademi.rentACar.core.constants.Languages; 13 | import com.btkAkademi.rentACar.entities.concretes.Translation; 14 | 15 | @Service 16 | public class LanguageSelector { 17 | 18 | private static LanguageService languageService; 19 | private static WordService wordService; 20 | private static TranslationService translationService; 21 | private static Environment environment; 22 | 23 | @Autowired 24 | public LanguageSelector(LanguageService languageService, WordService wordService, 25 | TranslationService translationService, Environment environment) { 26 | LanguageSelector.languageService = languageService; 27 | LanguageSelector.wordService = wordService; 28 | LanguageSelector.translationService = translationService; 29 | LanguageSelector.environment = environment; 30 | } 31 | 32 | public static String languageSelector(String message) { 33 | String result = environment.getProperty("current_language", Languages.ENGLISH); 34 | 35 | LanguageSearchListDto language = languageService.getByLanguageName(result).getData(); 36 | if (language == null) { 37 | language.setName(Languages.ENGLISH); 38 | } 39 | if (!wordService.getByKey(message).isSuccess() && message==null) { 40 | return "No Message Available"; 41 | } 42 | else if(!wordService.getByKey(message).isSuccess() && message!=null) { 43 | return message; 44 | } 45 | WordSearchListDto word = wordService.getByKey(message).getData(); 46 | 47 | Translation translation = translationService.getTranslationByLanguage_IdAndWord_Id(language.getId(), 48 | word.getId()); 49 | return translation == null ? "No Message Available" : translation.getTranslation(); 50 | 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/exception/ExceptionHandling.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.exception; 2 | 3 | 4 | import org.springframework.boot.web.servlet.error.ErrorController; 5 | import org.springframework.dao.DataIntegrityViolationException; 6 | import org.springframework.http.converter.HttpMessageNotReadableException; 7 | import org.springframework.web.bind.MethodArgumentNotValidException; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.ExceptionHandler; 10 | import org.springframework.web.bind.annotation.RestControllerAdvice; 11 | 12 | import com.btkAkademi.rentACar.business.constants.Messages; 13 | import com.btkAkademi.rentACar.core.utilities.results.ErrorDataResult; 14 | import com.btkAkademi.rentACar.core.utilities.results.ErrorResult; 15 | 16 | @RestControllerAdvice 17 | public class ExceptionHandling implements ErrorController{ 18 | // For Validation Exceptions 19 | @ExceptionHandler(MethodArgumentNotValidException.class) 20 | public ErrorResult handleValidationException(MethodArgumentNotValidException argumentNotValidException){ 21 | String message = argumentNotValidException.getBindingResult().getFieldErrors().get(0).getDefaultMessage(); 22 | ErrorResult errorResult = new ErrorResult(message); 23 | return errorResult; 24 | } 25 | 26 | // for NullPointerException 27 | @ExceptionHandler(NullPointerException.class) 28 | public ErrorResult handleNullPointerException(NullPointerException exception){ 29 | ErrorResult error = new ErrorResult(Messages.DATANOTFOUND); 30 | return error; 31 | } 32 | 33 | 34 | // Generally for messages in our case 35 | @ExceptionHandler(HttpMessageNotReadableException.class) 36 | public ErrorResult handHttpMessageExceptionError(HttpMessageNotReadableException httpMessageNotReadableException){ 37 | ErrorResult errorResult = new ErrorResult(Messages.FORMATERROR); 38 | return errorResult; 39 | 40 | } 41 | // For Deleting data which have relation in database 42 | @ExceptionHandler(DataIntegrityViolationException.class) 43 | public ErrorResult handHttpMessageExceptionError(DataIntegrityViolationException dataIntegrityViolationException){ 44 | ErrorResult errorResult = new ErrorResult(Messages.DATAHAVERELATIONS); 45 | return errorResult; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/SegmentController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.SegmentService; 19 | import com.btkAkademi.rentACar.business.dtos.SegmentListDto; 20 | import com.btkAkademi.rentACar.business.requests.segmentRequest.CreateSegmentRequest; 21 | import com.btkAkademi.rentACar.business.requests.segmentRequest.UpdateSegmentRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/segments") 28 | public class SegmentController { 29 | private SegmentService segmentService; 30 | 31 | @Autowired 32 | public SegmentController(SegmentService segmentService) { 33 | super(); 34 | this.segmentService = segmentService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> findAll() { 39 | return this.segmentService.findAll(); 40 | } 41 | 42 | @GetMapping("find-by-id/{id}") 43 | public DataResult findById(@PathVariable int id) { 44 | return this.segmentService.findById(id); 45 | } 46 | 47 | @PostMapping("add") 48 | public Result add(@RequestBody @Valid CreateSegmentRequest createSegmentRequest) { 49 | return this.segmentService.add(createSegmentRequest); 50 | } 51 | 52 | @PutMapping("update") 53 | public Result update(@RequestBody @Valid UpdateSegmentRequest createSegmentRequest) { 54 | return this.segmentService.update(createSegmentRequest); 55 | } 56 | 57 | @DeleteMapping("delete/{id}") 58 | public Result delete(@PathVariable int id) { 59 | return this.segmentService.delete(id); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/BrandsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.PutMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import com.btkAkademi.rentACar.business.abstracts.BrandService; 18 | import com.btkAkademi.rentACar.business.dtos.BrandListDto; 19 | import com.btkAkademi.rentACar.business.requests.brandRequests.CreateBrandRequest; 20 | import com.btkAkademi.rentACar.business.requests.brandRequests.UpdateBrandRequest; 21 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 22 | import com.btkAkademi.rentACar.core.utilities.results.Result; 23 | 24 | @CrossOrigin 25 | @RestController 26 | @RequestMapping("/api/brands") 27 | public class BrandsController { 28 | // Dependencies 29 | private BrandService brandService; 30 | 31 | // Dependency Injection 32 | public BrandsController(BrandService brandService) { 33 | super(); 34 | this.brandService = brandService; 35 | } 36 | 37 | // lists all brands 38 | @GetMapping("find-all") 39 | public DataResult> findAll() { 40 | return this.brandService.findAll(); 41 | } 42 | 43 | // finds by id 44 | @GetMapping("find-by-id/{id}") 45 | public Result findById(@PathVariable int id) { 46 | return this.brandService.findById(id); 47 | } 48 | 49 | // adds a new brand 50 | @PostMapping("add") 51 | public Result add(@RequestBody @Valid CreateBrandRequest createBrandRequest) { 52 | 53 | return this.brandService.add(createBrandRequest); 54 | } 55 | 56 | // updates a current brand 57 | @PutMapping("update") 58 | public Result update(@RequestBody @Valid UpdateBrandRequest updateBrandRequest) { 59 | 60 | return this.brandService.update(updateBrandRequest); 61 | } 62 | 63 | // deletes a brand 64 | @DeleteMapping("delete/{id}") 65 | public Result delete(@PathVariable int id) { 66 | return this.brandService.delete(id); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/WordsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.WordService; 19 | import com.btkAkademi.rentACar.business.dtos.WordSearchListDto; 20 | import com.btkAkademi.rentACar.business.requests.wordRequests.CreateWordRequest; 21 | import com.btkAkademi.rentACar.business.requests.wordRequests.DeleteWordRequest; 22 | import com.btkAkademi.rentACar.business.requests.wordRequests.UpdateWordRequest; 23 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 24 | import com.btkAkademi.rentACar.core.utilities.results.Result; 25 | 26 | @CrossOrigin 27 | @RestController 28 | @RequestMapping("/api/words") 29 | public class WordsController { 30 | private WordService wordService; 31 | 32 | @Autowired 33 | public WordsController(WordService wordService) { 34 | this.wordService = wordService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> getAll() { 39 | return this.wordService.getAll(); 40 | } 41 | 42 | @GetMapping("find-by-key/{key}") 43 | public DataResult getByKey(@PathVariable String key) { 44 | return this.wordService.getByKey(key); 45 | } 46 | 47 | @PostMapping("add") 48 | public Result add(@RequestBody @Valid CreateWordRequest createWordRequest) { 49 | return this.wordService.add(createWordRequest); 50 | } 51 | 52 | @DeleteMapping("delete") 53 | public Result delete(@RequestBody @Valid DeleteWordRequest deleteWordRequest) { 54 | return this.wordService.delete(deleteWordRequest); 55 | } 56 | 57 | @PutMapping("update") 58 | public Result update(@RequestBody @Valid UpdateWordRequest updateWordRequest) { 59 | return this.wordService.update(updateWordRequest); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/ColorsContoller.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.PutMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import com.btkAkademi.rentACar.business.abstracts.ColorService; 18 | import com.btkAkademi.rentACar.business.dtos.ColorListDto; 19 | import com.btkAkademi.rentACar.business.requests.colorRequests.CreateColorRequest; 20 | import com.btkAkademi.rentACar.business.requests.colorRequests.UpdateColorRequest; 21 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 22 | import com.btkAkademi.rentACar.core.utilities.results.Result; 23 | 24 | @CrossOrigin 25 | @RestController 26 | @RequestMapping("/api/colors") 27 | public class ColorsContoller { 28 | // Dependencies 29 | private ColorService colorService; 30 | 31 | // Dependency Injection 32 | public ColorsContoller(ColorService colorService) { 33 | super(); 34 | this.colorService = colorService; 35 | } 36 | 37 | // lists all colors 38 | @GetMapping("find-all") 39 | public DataResult> findAll() { 40 | return this.colorService.findAll(); 41 | } 42 | 43 | @GetMapping("find-by-id/{id}") 44 | public DataResult findById(@PathVariable int id) { 45 | return this.colorService.findById(id); 46 | } 47 | 48 | // adds a new color 49 | @PostMapping("add") 50 | 51 | public Result add(@RequestBody @Valid CreateColorRequest createColorRequest) { 52 | 53 | return this.colorService.add(createColorRequest); 54 | } 55 | 56 | // updates a current color 57 | @PutMapping("update") 58 | 59 | public Result update(@RequestBody @Valid UpdateColorRequest updateColorRequest) { 60 | 61 | return this.colorService.update(updateColorRequest); 62 | } 63 | 64 | // deletes a color 65 | @DeleteMapping("delete/{id}") 66 | public Result delete(@Valid @PathVariable int id) { 67 | 68 | return this.colorService.delete(id); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/TranslationsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.PutMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import com.btkAkademi.rentACar.business.abstracts.TranslationService; 18 | import com.btkAkademi.rentACar.business.dtos.TranslationSearchListDto; 19 | import com.btkAkademi.rentACar.business.requests.translationRequests.CreateTranslationRequest; 20 | import com.btkAkademi.rentACar.business.requests.translationRequests.DeleteTranslationRequest; 21 | import com.btkAkademi.rentACar.business.requests.translationRequests.UpdateTranslationRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("api/translations") 28 | public class TranslationsController { 29 | 30 | private TranslationService translationService; 31 | 32 | @Autowired 33 | public TranslationsController(TranslationService translationService) { 34 | this.translationService = translationService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> getAll() { 39 | return this.translationService.getAll(); 40 | } 41 | 42 | // find by id ekle 43 | @PostMapping("add") 44 | public Result add(@RequestBody @Valid CreateTranslationRequest createTranslationRequest) { 45 | return this.translationService.add(createTranslationRequest); 46 | } 47 | 48 | @DeleteMapping("delete") 49 | public Result delete(@RequestBody @Valid DeleteTranslationRequest deleteTranslationRequest) { 50 | return this.translationService.delete(deleteTranslationRequest); 51 | } 52 | 53 | @PutMapping("update") 54 | public Result update(@RequestBody @Valid UpdateTranslationRequest updateTranslationRequest) { 55 | return this.translationService.update(updateTranslationRequest); 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/CarDamagesController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.CarDamageService; 19 | import com.btkAkademi.rentACar.business.dtos.CarDamageListDto; 20 | import com.btkAkademi.rentACar.business.requests.carDamageRequests.CreateCarDamageRequest; 21 | import com.btkAkademi.rentACar.business.requests.carDamageRequests.UpdateCarDamageRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/car-damages") 28 | public class CarDamagesController { 29 | private CarDamageService carDamageService; 30 | 31 | @Autowired 32 | public CarDamagesController(CarDamageService carDamageService) { 33 | super(); 34 | this.carDamageService = carDamageService; 35 | } 36 | 37 | @GetMapping("find-all-by-car-id/{id}") 38 | public DataResult> findAllByCarId(@PathVariable int id) { 39 | return this.carDamageService.findAllByCarId(id); 40 | } 41 | 42 | @GetMapping("find-by-id/{id}") 43 | public Result findById(@PathVariable int id) { 44 | return this.carDamageService.findById(id); 45 | } 46 | 47 | @PostMapping("add") 48 | public Result add(@RequestBody @Valid CreateCarDamageRequest createCarDamageRequest) { 49 | return this.carDamageService.add(createCarDamageRequest); 50 | } 51 | 52 | @PutMapping("update") 53 | public Result update(@RequestBody @Valid UpdateCarDamageRequest updateCarDamageRequest) { 54 | return this.carDamageService.update(updateCarDamageRequest); 55 | } 56 | 57 | @DeleteMapping("delete/{id}") 58 | public Result delete(@PathVariable int id) { 59 | return this.carDamageService.delete(id); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/CitiesController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.CityService; 19 | import com.btkAkademi.rentACar.business.dtos.CityListDto; 20 | import com.btkAkademi.rentACar.business.requests.cityRequests.CreateCityRequest; 21 | import com.btkAkademi.rentACar.business.requests.cityRequests.UpdateCityRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/cities") 28 | public class CitiesController { 29 | // Dependencies 30 | private CityService cityService; 31 | 32 | // Dependency Injection 33 | @Autowired 34 | public CitiesController(CityService cityService) { 35 | super(); 36 | this.cityService = cityService; 37 | } 38 | 39 | // lists all cities in the database 40 | @GetMapping("find-all") 41 | public DataResult> findAll() { 42 | 43 | return cityService.findAll(); 44 | } 45 | 46 | @GetMapping("find-by-id/{id}") 47 | public DataResult findById(@PathVariable int id) { 48 | return cityService.findById(id); 49 | } 50 | 51 | // Adds a new city 52 | @PostMapping("add") 53 | public Result add(@RequestBody @Valid CreateCityRequest createCityRequest) { 54 | System.out.println(createCityRequest.getCityName()); 55 | return this.cityService.add(createCityRequest); 56 | } 57 | 58 | @PutMapping("update") 59 | public Result update(@RequestBody @Valid UpdateCityRequest updateCityRequest) { 60 | return this.cityService.update(updateCityRequest); 61 | } 62 | 63 | @DeleteMapping("delete/{id}") 64 | public Result delete(@PathVariable int id) { 65 | return this.cityService.delete(id); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/LanguagesController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | import org.springframework.web.bind.annotation.DeleteMapping; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.PutMapping; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.btkAkademi.rentACar.business.abstracts.LanguageService; 17 | import com.btkAkademi.rentACar.business.dtos.LanguageSearchListDto; 18 | import com.btkAkademi.rentACar.business.requests.languageRequests.CreateLanguageRequest; 19 | import com.btkAkademi.rentACar.business.requests.languageRequests.DeleteLanguageRequest; 20 | import com.btkAkademi.rentACar.business.requests.languageRequests.UpdateLanguageRequest; 21 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 22 | import com.btkAkademi.rentACar.core.utilities.results.Result; 23 | 24 | import lombok.var; 25 | 26 | @CrossOrigin 27 | @RestController 28 | @RequestMapping("/api/languages") 29 | public class LanguagesController { 30 | private LanguageService languageService; 31 | 32 | @Autowired 33 | public LanguagesController(LanguageService languageService) { 34 | this.languageService = languageService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> getAll() { 39 | return this.languageService.getAll(); 40 | } 41 | 42 | @GetMapping("find-by-language-name/{languageName}") 43 | public DataResult getByLanguageName(@PathVariable String languageName) { 44 | var result = this.languageService.getByLanguageName(languageName); 45 | return result; 46 | } 47 | 48 | @PostMapping("add") 49 | public Result add(@RequestBody CreateLanguageRequest createLanguageRequest) { 50 | return this.languageService.add(createLanguageRequest); 51 | } 52 | 53 | @DeleteMapping("delete") 54 | public Result delete(@RequestBody DeleteLanguageRequest deleteLanguageRequest) { 55 | return this.languageService.delete(deleteLanguageRequest); 56 | } 57 | 58 | @PutMapping("update") 59 | public Result update(@RequestBody UpdateLanguageRequest updateLanguageRequest) { 60 | return this.languageService.update(updateLanguageRequest); 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/PromoCodeController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.PromoCodeService; 19 | import com.btkAkademi.rentACar.business.dtos.PromoCodeDto; 20 | import com.btkAkademi.rentACar.business.requests.promoCodeRequests.CreatePromoCodeRequest; 21 | import com.btkAkademi.rentACar.business.requests.promoCodeRequests.UpdatePromoCodeRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/promo-codes") 28 | public class PromoCodeController { 29 | private PromoCodeService promoCodeService; 30 | 31 | @Autowired 32 | public PromoCodeController(PromoCodeService promoCodeService) { 33 | super(); 34 | this.promoCodeService = promoCodeService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> findAll() { 39 | return this.promoCodeService.findAll(); 40 | } 41 | 42 | @GetMapping("find-by-code/{code}") 43 | public DataResult findByCode(@PathVariable String code) { 44 | return this.promoCodeService.findByCode(code); 45 | } 46 | 47 | @GetMapping("find-by-id/{id}") 48 | public DataResult findByCode(@PathVariable int id) { 49 | return this.promoCodeService.findById(id); 50 | } 51 | 52 | @PostMapping("add") 53 | public Result add(@RequestBody @Valid CreatePromoCodeRequest createPromoCodeRequest) { 54 | 55 | return this.promoCodeService.add(createPromoCodeRequest); 56 | } 57 | 58 | @PutMapping("update") 59 | public Result update(@RequestBody @Valid UpdatePromoCodeRequest updatePromoCodeRequest) { 60 | return this.promoCodeService.update(updatePromoCodeRequest); 61 | } 62 | 63 | @DeleteMapping("delete/{id}") 64 | public Result delete(@PathVariable int id) { 65 | return this.promoCodeService.delete(id); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/AdditionalServicesController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.AdditionalServiceService; 19 | import com.btkAkademi.rentACar.business.dtos.AdditionalServiceListDto; 20 | import com.btkAkademi.rentACar.business.requests.additionalServiceRequests.CreateAdditionalServiceRequest; 21 | import com.btkAkademi.rentACar.business.requests.additionalServiceRequests.UpdateAdditionalServiceRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/additional-services") 28 | public class AdditionalServicesController { 29 | private AdditionalServiceService additionalServiceService; 30 | 31 | @Autowired 32 | public AdditionalServicesController(AdditionalServiceService additionalServiceService) { 33 | super(); 34 | this.additionalServiceService = additionalServiceService; 35 | } 36 | 37 | @GetMapping("find-all-by-rental-id/{id}") 38 | public DataResult> findAllByRentalId(@PathVariable int id) { 39 | return additionalServiceService.findAllByRentalId(id); 40 | 41 | } 42 | 43 | @PostMapping("add") 44 | public Result add(@RequestBody @Valid CreateAdditionalServiceRequest createAdditionalService) { 45 | return this.additionalServiceService.add(createAdditionalService); 46 | } 47 | 48 | @PostMapping("add-all") 49 | public Result addAll(@RequestBody @Valid List createAdditionalService) { 50 | return this.additionalServiceService.addAll(createAdditionalService); 51 | } 52 | 53 | @PutMapping("update") 54 | public Result update(@RequestBody @Valid UpdateAdditionalServiceRequest updateAdditionalServiceRequest) { 55 | return this.additionalServiceService.update(updateAdditionalServiceRequest); 56 | } 57 | 58 | @DeleteMapping("delete/{id}") 59 | public Result update(@PathVariable int id) { 60 | return this.additionalServiceService.delete(id); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/auth/PrimitiveAuthManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.auth; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | 6 | import com.btkAkademi.rentACar.business.abstracts.UserService; 7 | import com.btkAkademi.rentACar.business.constants.Messages; 8 | import com.btkAkademi.rentACar.business.dtos.CityListDto; 9 | import com.btkAkademi.rentACar.core.utilities.business.BusinessRules; 10 | import com.btkAkademi.rentACar.core.utilities.mapping.ModelMapperService; 11 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 12 | import com.btkAkademi.rentACar.core.utilities.results.ErrorDataResult; 13 | import com.btkAkademi.rentACar.core.utilities.results.ErrorResult; 14 | import com.btkAkademi.rentACar.core.utilities.results.Result; 15 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 16 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 17 | import com.btkAkademi.rentACar.entities.concretes.User; 18 | 19 | @Service 20 | public class PrimitiveAuthManager implements AuthService { 21 | private UserService userService; 22 | private ModelMapperService modelMapperService; 23 | 24 | @Autowired 25 | public PrimitiveAuthManager(UserService userService, ModelMapperService modelMapperService) { 26 | super(); 27 | this.userService = userService; 28 | this.modelMapperService = modelMapperService; 29 | } 30 | 31 | 32 | @Override 33 | public DataResult login(LoginRequest loginRequest) { 34 | Result result = BusinessRules.run( 35 | checkIfUserExistsByEmail(loginRequest.getEmail()), 36 | checkIfUsersPasswordIsCorrect(loginRequest.getEmail(), loginRequest.getPassword())); 37 | 38 | if (result != null) { 39 | return new ErrorDataResult<>(result.getMessage()); 40 | } 41 | 42 | User user = userService.findByEmail(loginRequest.getEmail()).getData(); 43 | LoginResponse response = modelMapperService.forDto().map(user, LoginResponse.class); 44 | return new SuccessDataResult(response, Messages.LOGINSUCCESS); 45 | 46 | } 47 | 48 | 49 | // controls there is a user with that email 50 | private Result checkIfUserExistsByEmail(String email) { 51 | if (userService.findByEmail(email).getData()==null) { 52 | return new ErrorResult(Messages.USERNOTFOUND); 53 | } else 54 | return new SuccessResult(); 55 | 56 | } 57 | 58 | // checks if password correct //fluid pattern ile mi 59 | private Result checkIfUsersPasswordIsCorrect(String email, String password) { 60 | User user = userService.findByEmail(email).getData(); 61 | if (user!=null && !password.equals(user.getPassword())) { 62 | return new ErrorResult(Messages.LOGINPASSWORDERROR); 63 | } else 64 | return new SuccessResult(); 65 | 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/CarMaintenancesController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.CarMaintenanceService; 19 | import com.btkAkademi.rentACar.business.dtos.CarMaintenanceListDto; 20 | import com.btkAkademi.rentACar.business.requests.carMaintananceRequests.CreateCarMaintenanceRequest; 21 | import com.btkAkademi.rentACar.business.requests.carMaintananceRequests.UpdateCarMaintananceRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/car-maintenances") 28 | public class CarMaintenancesController { 29 | private CarMaintenanceService carMaintenanceService; 30 | 31 | @Autowired 32 | public CarMaintenancesController(CarMaintenanceService carMaintenanceService) { 33 | super(); 34 | this.carMaintenanceService = carMaintenanceService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> findAll() { 39 | return this.carMaintenanceService.findAll(); 40 | } 41 | 42 | @GetMapping("find-all-by-car-id/{id}") 43 | public DataResult> findAllByCarId(@PathVariable int id) { 44 | return this.carMaintenanceService.findAllByCarId(id); 45 | } 46 | 47 | @GetMapping("find-by-id/{id}") 48 | public DataResult findById(@PathVariable int id) { 49 | return this.carMaintenanceService.findById(id); 50 | } 51 | 52 | @PostMapping("add") 53 | public Result add(@RequestBody @Valid CreateCarMaintenanceRequest createCarMaintananceRequest) { 54 | return this.carMaintenanceService.add(createCarMaintananceRequest); 55 | } 56 | 57 | @PutMapping("update") 58 | public Result add(@RequestBody @Valid UpdateCarMaintananceRequest updateCarMaintananceRequest) { 59 | return this.carMaintenanceService.update(updateCarMaintananceRequest); 60 | } 61 | 62 | @DeleteMapping("delete/{id}") 63 | public Result add(@PathVariable int id) { 64 | return this.carMaintenanceService.delete(id); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/InvoiceControllers.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import com.btkAkademi.rentACar.business.abstracts.InvoiceService; 17 | import com.btkAkademi.rentACar.business.dtos.InvoiceCorporateCustomerDto; 18 | import com.btkAkademi.rentACar.business.dtos.InvoiceIndividualCustomerDto; 19 | import com.btkAkademi.rentACar.business.dtos.InvoiceListDto; 20 | import com.btkAkademi.rentACar.business.requests.invoiceRequests.CreateInvoiceRequest; 21 | import com.btkAkademi.rentACar.business.requests.invoiceRequests.UpdateInvoiceRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/invoices") 28 | public class InvoiceControllers { 29 | private InvoiceService invoiceService; 30 | 31 | @Autowired 32 | public InvoiceControllers(InvoiceService invoiceService) { 33 | super(); 34 | this.invoiceService = invoiceService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> findAll() { 39 | return this.invoiceService.findAll(); 40 | } 41 | 42 | @GetMapping("find-invoice-for-corporate-customer/{rentalId}") 43 | public DataResult getInvoiceForCorporateCustomer(@PathVariable int rentalId) { 44 | return this.invoiceService.getInvoiceForCorporateCustomer(rentalId); 45 | } 46 | 47 | @GetMapping("find-invoice-for-individual-customer/{rentalId}") 48 | public DataResult getInvoiceForIndividualCustomer(@PathVariable int rentalId) { 49 | return this.invoiceService.getInvoiceForIndividualCustomer(rentalId); 50 | } 51 | 52 | @PostMapping("add") 53 | public Result add(@RequestBody @Valid CreateInvoiceRequest createInvoiceRequest) { 54 | 55 | return this.invoiceService.add(createInvoiceRequest); 56 | } 57 | 58 | @PostMapping("update") 59 | public Result update(@RequestBody @Valid UpdateInvoiceRequest updateInvoiceRequest) { 60 | 61 | return this.invoiceService.update(updateInvoiceRequest); 62 | } 63 | 64 | @PostMapping("delete/{id}") 65 | public Result delete(@PathVariable int id) { 66 | 67 | return this.invoiceService.delete(id); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/AdditionalServiceItemsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.AdditionalServiceItemService; 19 | import com.btkAkademi.rentACar.business.dtos.AdditionalServiceItemListDto; 20 | import com.btkAkademi.rentACar.business.requests.additionalServiceItemRequests.CreateAdditionalServiceItemRequest; 21 | import com.btkAkademi.rentACar.business.requests.additionalServiceItemRequests.UpdateAdditionalServiceItemRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/additional-service-items") 28 | public class AdditionalServiceItemsController { 29 | private AdditionalServiceItemService additionalServiceItemService; 30 | 31 | @Autowired 32 | public AdditionalServiceItemsController(AdditionalServiceItemService additionalServiceItemService) { 33 | super(); 34 | this.additionalServiceItemService = additionalServiceItemService; 35 | } 36 | 37 | @GetMapping("find-all") 38 | public DataResult> findAllByRentalId() { 39 | return additionalServiceItemService.findAll(); 40 | 41 | } 42 | 43 | @GetMapping("find-by-id/{id}") 44 | public DataResult findById(@PathVariable int id) { 45 | return additionalServiceItemService.findById(id); 46 | 47 | } 48 | 49 | @PostMapping("add") 50 | public Result add(@RequestBody @Valid CreateAdditionalServiceItemRequest createAdditionalServiceItemRequest) { 51 | return this.additionalServiceItemService.add(createAdditionalServiceItemRequest); 52 | } 53 | 54 | @PutMapping("update") 55 | public Result add(@RequestBody @Valid UpdateAdditionalServiceItemRequest updateAdditionalServiceItemRequest) { 56 | return this.additionalServiceItemService.update(updateAdditionalServiceItemRequest); 57 | } 58 | 59 | @DeleteMapping("delete/{id}") 60 | public Result delete(@PathVariable int id) { 61 | return this.additionalServiceItemService.delete(id); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/CustomerCardDetailsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.CustomerCardDetailService; 19 | import com.btkAkademi.rentACar.business.dtos.CustomerCardDetailListDto; 20 | import com.btkAkademi.rentACar.business.requests.customerCardDetailRequests.CreateCustomerCardDetailRequest; 21 | import com.btkAkademi.rentACar.business.requests.customerCardDetailRequests.UpdateCustomerCardDetailsRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/customer-card-details") 28 | public class CustomerCardDetailsController { 29 | private CustomerCardDetailService customerCardDetailService; 30 | 31 | @Autowired 32 | public CustomerCardDetailsController(CustomerCardDetailService customerCardDetailService) { 33 | super(); 34 | this.customerCardDetailService = customerCardDetailService; 35 | } 36 | 37 | @GetMapping("find-by-customer-id/{id}") 38 | public DataResult> findByCustomerId(@PathVariable int id) { 39 | 40 | return this.customerCardDetailService.findCustomerCardDetailsByCustomerId(id); 41 | } 42 | 43 | @GetMapping("find-by-id/{id}") 44 | public DataResult findById(@PathVariable int id) { 45 | 46 | return this.customerCardDetailService.findById(id); 47 | } 48 | 49 | @PostMapping("add") 50 | public Result add(@RequestBody @Valid CreateCustomerCardDetailRequest createCustomerCardDetailRequest) { 51 | System.out.println(createCustomerCardDetailRequest.getCardNo()); 52 | return this.customerCardDetailService.add(createCustomerCardDetailRequest); 53 | } 54 | 55 | @PutMapping("update") 56 | public Result update(@RequestBody @Valid UpdateCustomerCardDetailsRequest updateCustomerPamentDetailsRequest) { 57 | 58 | return this.customerCardDetailService.update(updateCustomerPamentDetailsRequest); 59 | } 60 | 61 | @DeleteMapping("delete/{id}") 62 | public Result delete(@PathVariable int id) { 63 | 64 | return this.customerCardDetailService.delete(id); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/CorporateCustomersController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.btkAkademi.rentACar.business.abstracts.CorporateCustomerService; 20 | import com.btkAkademi.rentACar.business.dtos.CorporateCustomerListDto; 21 | import com.btkAkademi.rentACar.business.requests.corporateCustomerRequests.CreateCorporateCustomerRequest; 22 | import com.btkAkademi.rentACar.business.requests.corporateCustomerRequests.UpdateCorporateCustomerRequest; 23 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 24 | import com.btkAkademi.rentACar.core.utilities.results.Result; 25 | 26 | @CrossOrigin 27 | @RestController 28 | @RequestMapping("/api/corporate-customers") 29 | public class CorporateCustomersController { 30 | // Dependencies 31 | private CorporateCustomerService corporateCustomerService; 32 | 33 | // Dependency Injection 34 | @Autowired 35 | public CorporateCustomersController(CorporateCustomerService corporateCustomerService) { 36 | super(); 37 | this.corporateCustomerService = corporateCustomerService; 38 | } 39 | 40 | @GetMapping("find-all") 41 | public DataResult> findAll(@RequestParam(defaultValue = "1") int pageNo, 42 | @RequestParam(defaultValue = "1000") int pageSize) { 43 | 44 | return this.corporateCustomerService.findAll(pageNo, pageSize); 45 | } 46 | 47 | @GetMapping("find-by-id/{id}") 48 | public DataResult findById(@PathVariable int id) { 49 | 50 | return this.corporateCustomerService.findById(id); 51 | } 52 | 53 | // adds a new corporate customer 54 | @PostMapping("add") 55 | public Result add(@RequestBody @Valid CreateCorporateCustomerRequest createCorporateCustomerRequest) { 56 | 57 | return this.corporateCustomerService.add(createCorporateCustomerRequest); 58 | } 59 | 60 | @PutMapping("update") 61 | public Result update(@RequestBody @Valid UpdateCorporateCustomerRequest updateCorporateCustomerRequest) { 62 | 63 | return this.corporateCustomerService.update(updateCorporateCustomerRequest); 64 | } 65 | 66 | @DeleteMapping("delete/{id}") 67 | public Result delete(@PathVariable int id) { 68 | return this.corporateCustomerService.delete(id); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/IndividualCustomersController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.btkAkademi.rentACar.business.abstracts.IndividualCustomerService; 20 | import com.btkAkademi.rentACar.business.dtos.IndividualCustomerListDto; 21 | import com.btkAkademi.rentACar.business.requests.individualCustomerRequests.CreateIndividualCustomerRequest; 22 | import com.btkAkademi.rentACar.business.requests.individualCustomerRequests.UpdateIndividualCustomerRequest; 23 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 24 | import com.btkAkademi.rentACar.core.utilities.results.Result; 25 | 26 | @CrossOrigin 27 | @RestController 28 | @RequestMapping("/api/individual-customers") 29 | public class IndividualCustomersController { 30 | // dependencies 31 | private IndividualCustomerService individualCustomerService; 32 | 33 | // dependency injection 34 | @Autowired 35 | public IndividualCustomersController(IndividualCustomerService individualCustomerService) { 36 | super(); 37 | this.individualCustomerService = individualCustomerService; 38 | } 39 | 40 | // lists individual customers according to page 41 | @GetMapping("find-all") 42 | public DataResult> findAll(@RequestParam(defaultValue = "1") int pageNo, 43 | @RequestParam(defaultValue = "10") int pageSize) { 44 | 45 | return this.individualCustomerService.findAll(pageNo, pageSize); 46 | } 47 | 48 | @GetMapping("find-by-id/{id}") 49 | public DataResult findById(@PathVariable int id) { 50 | 51 | return this.individualCustomerService.findById(id); 52 | } 53 | 54 | // adds a new individual customer 55 | @PostMapping("add") 56 | public Result add(@RequestBody @Valid CreateIndividualCustomerRequest createIndividualCustomerRequest) { 57 | 58 | return this.individualCustomerService.add(createIndividualCustomerRequest); 59 | } 60 | 61 | @PutMapping("update") 62 | public Result update(@RequestBody @Valid UpdateIndividualCustomerRequest updateIndividualCustomerRequest) { 63 | 64 | return this.individualCustomerService.update(updateIndividualCustomerRequest); 65 | } 66 | 67 | @DeleteMapping("delete/{id}") 68 | public Result delete(@PathVariable int id) { 69 | 70 | return this.individualCustomerService.delete(id); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/PaymentsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.btkAkademi.rentACar.business.abstracts.PaymentService; 20 | import com.btkAkademi.rentACar.business.dtos.PaymentListDto; 21 | import com.btkAkademi.rentACar.business.requests.paymentRequests.CalculateTotalPriceRequest; 22 | import com.btkAkademi.rentACar.business.requests.paymentRequests.CreatePaymentRequest; 23 | import com.btkAkademi.rentACar.business.requests.paymentRequests.UpdatePaymentRequest; 24 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 25 | import com.btkAkademi.rentACar.core.utilities.results.Result; 26 | 27 | @CrossOrigin 28 | @RestController 29 | @RequestMapping("/api/payments") 30 | public class PaymentsController { 31 | private PaymentService paymentService; 32 | 33 | @Autowired 34 | public PaymentsController(PaymentService paymentService) { 35 | super(); 36 | this.paymentService = paymentService; 37 | } 38 | 39 | @GetMapping("find-all") 40 | public DataResult> findAll(@RequestParam(defaultValue = "1") int pageNo, 41 | @RequestParam(defaultValue = " 10") int pageSize) { 42 | return this.paymentService.findAll(pageNo, pageSize); 43 | } 44 | 45 | @PostMapping("find-total-price") 46 | public DataResult calculateTotalPrice(@RequestBody CalculateTotalPriceRequest calculateTotalPriceRequest) { 47 | System.out.println(calculateTotalPriceRequest.getReturnDate()); 48 | return this.paymentService.calculateTotalPriceForDisplay(calculateTotalPriceRequest); 49 | } 50 | 51 | @GetMapping("find-all-by-rental-id/{rentalId}") 52 | public DataResult> getAllByRentalId(@PathVariable int rentalId) { 53 | 54 | return this.paymentService.findAllByRentalId(rentalId); 55 | } 56 | 57 | @GetMapping("find-by-id/{id}") 58 | public DataResult findById(@PathVariable int id) { 59 | return this.paymentService.findById(id); 60 | } 61 | 62 | // adds a new payment 63 | @PostMapping("add") 64 | public Result add(@RequestBody @Valid CreatePaymentRequest createPaymentRequest) { 65 | 66 | return this.paymentService.add(createPaymentRequest); 67 | } 68 | 69 | @PutMapping("update") 70 | public Result update(@RequestBody @Valid UpdatePaymentRequest updatePaymentRequest) { 71 | 72 | return this.paymentService.update(updatePaymentRequest); 73 | } 74 | 75 | @DeleteMapping("delete/{id}") 76 | public Result delete(@PathVariable int id) { 77 | return this.paymentService.delete(id); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 2.6.2 8 | 9 | 10 | com.btkAkademi 11 | rentACar 12 | 0.0.1-SNAPSHOT 13 | rentACar 14 | Rent A Car project for BTK & Innova Camp 15 | 16 | 11 17 | 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-data-jpa 23 | 24 | 25 | 26 | org.postgresql 27 | postgresql 28 | runtime 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-web 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-devtools 39 | runtime 40 | true 41 | 42 | 43 | 44 | org.modelmapper 45 | modelmapper 46 | 3.0.0 47 | 48 | 49 | 50 | org.projectlombok 51 | lombok 52 | true 53 | 54 | 55 | 56 | org.springdoc 57 | springdoc-openapi-ui 58 | 1.6.4 59 | 60 | 61 | 62 | org.springframework.boot 63 | spring-boot-starter-validation 64 | 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-starter-test 69 | test 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-compiler-plugin 81 | 82 | 1.8 83 | 1.8 84 | 85 | 86 | 87 | 88 | org.springframework.boot 89 | spring-boot-maven-plugin 90 | 91 | 92 | 93 | org.projectlombok 94 | lombok 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/CarsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.web.bind.annotation.CrossOrigin; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.PutMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RequestMapping; 15 | import org.springframework.web.bind.annotation.RequestParam; 16 | import org.springframework.web.bind.annotation.RestController; 17 | 18 | import com.btkAkademi.rentACar.business.abstracts.CarService; 19 | import com.btkAkademi.rentACar.business.dtos.CarListDto; 20 | import com.btkAkademi.rentACar.business.requests.carRequests.CreateCarRequest; 21 | import com.btkAkademi.rentACar.business.requests.carRequests.UpdateCarRequest; 22 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 23 | import com.btkAkademi.rentACar.core.utilities.results.Result; 24 | 25 | @CrossOrigin 26 | @RestController 27 | @RequestMapping("/api/cars") 28 | public class CarsController { 29 | // Dependencies 30 | private CarService carService; 31 | 32 | // Dependency Injection 33 | public CarsController(CarService carService) { 34 | super(); 35 | this.carService = carService; 36 | } 37 | 38 | // lists all cars with pageSize 39 | @GetMapping("find-all") 40 | public DataResult> findAll(@RequestParam(defaultValue = " 1") int pageNo, 41 | @RequestParam(defaultValue = " 100") int pageSize) { 42 | return this.carService.findAll(pageNo, pageSize); 43 | } 44 | 45 | @GetMapping("find-all-available") 46 | public DataResult> findAllAvailable(@RequestParam(defaultValue = " 1") int pageNo, 47 | @RequestParam(defaultValue = " 1000") int pageSize) { 48 | return this.carService.findAllAvailable(pageNo, pageSize); 49 | } 50 | 51 | @GetMapping("find-all-by-brand-id") 52 | public DataResult> findAllByBrandId(@RequestParam int brandId, @RequestParam int pageNo, 53 | @RequestParam(defaultValue = " 100") int pageSize) { 54 | return this.carService.findAllByBrandId(brandId, pageNo, pageSize); 55 | } 56 | 57 | @GetMapping("find-all-by-color-id") 58 | public DataResult> findAllByColorId(@RequestParam int colorId, @RequestParam int pageNo, 59 | @RequestParam(defaultValue = " 100") int pageSize) { 60 | return this.carService.findAllByColorId(colorId, pageNo, pageSize); 61 | } 62 | 63 | @GetMapping("find-by-id/{id}") 64 | public DataResult findById(@PathVariable int id) { 65 | return this.carService.findById(id); 66 | } 67 | 68 | // adds a new car 69 | @PostMapping("add") 70 | public Result add(@RequestBody @Valid CreateCarRequest createCarRequest) { 71 | return this.carService.add(createCarRequest); 72 | } 73 | 74 | // updates a current car 75 | @PutMapping("update") 76 | public Result update(@RequestBody @Valid UpdateCarRequest updateCarRequest) { 77 | return this.carService.update(updateCarRequest); 78 | } 79 | 80 | // deletes a car 81 | @DeleteMapping("delete/{id}") 82 | public Result delete(@Valid @PathVariable int id) { 83 | return this.carService.delete(id); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/ws/controllers/RentalsController.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.ws.controllers; 2 | 3 | import java.util.List; 4 | 5 | import javax.validation.Valid; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.CrossOrigin; 9 | import org.springframework.web.bind.annotation.DeleteMapping; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.PutMapping; 14 | import org.springframework.web.bind.annotation.RequestBody; 15 | import org.springframework.web.bind.annotation.RequestMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import com.btkAkademi.rentACar.business.abstracts.RentalService; 20 | import com.btkAkademi.rentACar.business.dtos.MyRentalListDto; 21 | import com.btkAkademi.rentACar.business.dtos.RentalAddResponse; 22 | import com.btkAkademi.rentACar.business.dtos.RentalListDto; 23 | import com.btkAkademi.rentACar.business.requests.rentalRequests.CreateRentalRequest; 24 | import com.btkAkademi.rentACar.business.requests.rentalRequests.UpdateRentalRequest; 25 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 26 | import com.btkAkademi.rentACar.core.utilities.results.Result; 27 | 28 | @CrossOrigin 29 | @RestController 30 | @RequestMapping("/api/rentals") 31 | public class RentalsController { 32 | // Dependencies 33 | private RentalService rentalService; 34 | 35 | // Dependency Injection 36 | @Autowired 37 | public RentalsController(RentalService rentalService) { 38 | super(); 39 | this.rentalService = rentalService; 40 | } 41 | 42 | // lists all rentals in the system 43 | @GetMapping("find-all") 44 | public DataResult> findAll(@RequestParam(defaultValue = "1") int pageNo, 45 | @RequestParam(defaultValue = "1000") int pageSize) { 46 | return rentalService.findAll(pageNo, pageSize); 47 | } 48 | 49 | @GetMapping("find-all-by-customer-id/{id}") 50 | public DataResult> findAllByCustomerId(@PathVariable int id) { 51 | return rentalService.findAllByCustomerId(id); 52 | } 53 | 54 | @GetMapping("find-active-rental-by-car-id/{id}") 55 | public DataResult findActiveRentalByCarId(@PathVariable int id) { 56 | return rentalService.findActiveRentalByCarId(id); 57 | } 58 | 59 | @GetMapping("find-by-id/{id}") 60 | public DataResult findById(@PathVariable int id) { 61 | return rentalService.findById(id); 62 | } 63 | 64 | // Adds a new rental 65 | @PostMapping("add-for-individual-customer") 66 | public DataResult addForIndividualCustomer( 67 | @RequestBody @Valid CreateRentalRequest createRentalRequest) { 68 | return this.rentalService.addForIndividualCustomer(createRentalRequest); 69 | } 70 | 71 | @PostMapping("add-for-corporate-customer") 72 | public DataResult addForCorporateCustomer( 73 | @RequestBody @Valid CreateRentalRequest createRentalRequest) { 74 | return this.rentalService.addForCorporateCustomer(createRentalRequest); 75 | } 76 | 77 | @PutMapping("update") 78 | public Result update(@RequestBody @Valid UpdateRentalRequest updateRentalRequest) { 79 | return this.rentalService.update(updateRentalRequest); 80 | } 81 | 82 | @DeleteMapping("delete/{id}") 83 | public Result delete(@PathVariable int id) { 84 | return this.rentalService.delete(id); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/concretes/TranslationManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.concretes; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.btkAkademi.rentACar.business.abstracts.TranslationService; 10 | import com.btkAkademi.rentACar.business.constants.Messages; 11 | import com.btkAkademi.rentACar.business.dtos.TranslationSearchListDto; 12 | import com.btkAkademi.rentACar.business.requests.translationRequests.CreateTranslationRequest; 13 | import com.btkAkademi.rentACar.business.requests.translationRequests.DeleteTranslationRequest; 14 | import com.btkAkademi.rentACar.business.requests.translationRequests.UpdateTranslationRequest; 15 | import com.btkAkademi.rentACar.core.utilities.mapping.ModelMapperService; 16 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 17 | import com.btkAkademi.rentACar.core.utilities.results.Result; 18 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 19 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 20 | import com.btkAkademi.rentACar.dataAccess.abstracts.TranslationDao; 21 | import com.btkAkademi.rentACar.entities.concretes.Translation; 22 | 23 | @Service 24 | public class TranslationManager implements TranslationService { 25 | // Dependencies 26 | private TranslationDao translationDao; 27 | private ModelMapperService modelMapperService; 28 | 29 | // Dependency Injection 30 | @Autowired 31 | public TranslationManager(TranslationDao translationDao, ModelMapperService modelMapperService) { 32 | this.translationDao = translationDao; 33 | this.modelMapperService = modelMapperService; 34 | } 35 | 36 | // Finds all Translations 37 | @Override 38 | public DataResult> getAll() { 39 | List translations = this.translationDao.findAll(); 40 | List translationSearchListDtos = translations.stream() 41 | .map(translation -> modelMapperService.forDto().map(translation, TranslationSearchListDto.class)) 42 | .collect(Collectors.toList()); 43 | return new SuccessDataResult>(translationSearchListDtos, 44 | Messages.TRANSLATIONSLISTED); 45 | } 46 | 47 | // Adds a new Translation 48 | @Override 49 | public Result add(CreateTranslationRequest createTranslationRequest) { 50 | Translation translation = modelMapperService.forRequest().map(createTranslationRequest, Translation.class); 51 | translationDao.save(translation); 52 | return new SuccessResult(Messages.TRANSLATIONADD); 53 | } 54 | 55 | // Deletes a traslation 56 | @Override 57 | public Result delete(DeleteTranslationRequest deleteTranslationRequest) { 58 | Translation translation = modelMapperService.forRequest().map(deleteTranslationRequest, Translation.class); 59 | translationDao.delete(translation); 60 | return new SuccessResult(Messages.TRANSLATIONDELETE); 61 | } 62 | 63 | // Updates a Translation 64 | @Override 65 | public Result update(UpdateTranslationRequest updateTranslationRequest) { 66 | Translation translation = modelMapperService.forRequest().map(updateTranslationRequest, Translation.class); 67 | translationDao.save(translation); 68 | return new SuccessResult(Messages.TRANSLATIONUPDATE); 69 | } 70 | 71 | // Finds a spesific translation 72 | @Override 73 | public Translation getTranslationByLanguage_IdAndWord_Id(int languageId, int wordId) { 74 | return this.translationDao.getTranslationByLanguage_IdAndWord_Id(languageId, wordId); 75 | } 76 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/concretes/UserManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.concretes; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.btkAkademi.rentACar.business.abstracts.UserService; 10 | import com.btkAkademi.rentACar.business.constants.Messages; 11 | import com.btkAkademi.rentACar.business.dtos.UserListDto; 12 | import com.btkAkademi.rentACar.core.utilities.business.BusinessRules; 13 | import com.btkAkademi.rentACar.core.utilities.mapping.ModelMapperService; 14 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 15 | import com.btkAkademi.rentACar.core.utilities.results.ErrorDataResult; 16 | import com.btkAkademi.rentACar.core.utilities.results.ErrorResult; 17 | import com.btkAkademi.rentACar.core.utilities.results.Result; 18 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 19 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 20 | import com.btkAkademi.rentACar.dataAccess.abstracts.UserDao; 21 | import com.btkAkademi.rentACar.entities.concretes.User; 22 | 23 | @Service 24 | public class UserManager implements UserService { 25 | // Dependencies 26 | private UserDao userDao; 27 | private ModelMapperService modelMapperService; 28 | 29 | // Dependency Injection 30 | @Autowired 31 | public UserManager(UserDao userDao, ModelMapperService modelMapperService) { 32 | super(); 33 | this.userDao = userDao; 34 | this.modelMapperService = modelMapperService; 35 | } 36 | 37 | // finds user by id 38 | @Override 39 | public DataResult findById(int id) { 40 | Result result = BusinessRules.run(checkIsUsersExistsById(id)); 41 | if (result != null) { 42 | return new ErrorDataResult(result.getMessage()); 43 | } 44 | UserListDto response = modelMapperService.forDto().map(this.userDao.findById(id).get(), UserListDto.class); 45 | return new SuccessDataResult(response, Messages.USERLIST); 46 | 47 | } 48 | 49 | // Finds User By Email 50 | @Override 51 | public DataResult findByEmail(String email) { 52 | Result result = BusinessRules.run(checkIsUsersExistsByEmail(email)); 53 | if (result != null) { 54 | return new ErrorDataResult(result.getMessage()); 55 | } 56 | return new SuccessDataResult(userDao.findByEmail(email), Messages.USERFOUND); 57 | } 58 | 59 | // Finds all users in the system 60 | @Override 61 | public DataResult> findAll() { 62 | List userList = this.userDao.findAll(); 63 | List response = userList.stream() 64 | .map(user -> modelMapperService.forDto().map(user, UserListDto.class)).collect(Collectors.toList()); 65 | return new SuccessDataResult>(response, Messages.USERLIST); 66 | 67 | } 68 | 69 | // Deletes a user if there is no relation 70 | @Override 71 | public Result delete(int id) { 72 | Result result = BusinessRules.run(checkIsUsersExistsById(id)); 73 | if (result != null) { 74 | return result; 75 | } 76 | userDao.deleteById(id); 77 | return new SuccessResult(Messages.CUSTOMERDELETE); 78 | 79 | } 80 | 81 | // Checks is there a user with that id 82 | private Result checkIsUsersExistsById(int id) { 83 | if (!this.userDao.existsById(id)) { 84 | return new ErrorResult(Messages.USERNOTFOUND); 85 | } 86 | return new SuccessResult(); 87 | } 88 | 89 | // Checks is there a user with that id 90 | private Result checkIsUsersExistsByEmail(String email) { 91 | if (this.userDao.findByEmail(email) == null) { 92 | return new ErrorResult(Messages.USERNOTFOUND); 93 | } 94 | return new SuccessResult(); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/concretes/LanguageManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.concretes; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.btkAkademi.rentACar.business.abstracts.LanguageService; 10 | import com.btkAkademi.rentACar.business.constants.Messages; 11 | import com.btkAkademi.rentACar.business.dtos.LanguageSearchListDto; 12 | import com.btkAkademi.rentACar.business.requests.languageRequests.CreateLanguageRequest; 13 | import com.btkAkademi.rentACar.business.requests.languageRequests.DeleteLanguageRequest; 14 | import com.btkAkademi.rentACar.business.requests.languageRequests.UpdateLanguageRequest; 15 | import com.btkAkademi.rentACar.core.utilities.mapping.ModelMapperService; 16 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 17 | import com.btkAkademi.rentACar.core.utilities.results.Result; 18 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 19 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 20 | import com.btkAkademi.rentACar.dataAccess.abstracts.LanguageDao; 21 | import com.btkAkademi.rentACar.entities.concretes.Language; 22 | 23 | @Service 24 | public class LanguageManager implements LanguageService { 25 | // Dependencies 26 | private LanguageDao languageDao; 27 | private ModelMapperService modelMapperService; 28 | 29 | // Dependency Injection 30 | @Autowired 31 | public LanguageManager(LanguageDao languageDao, ModelMapperService modelMapperService) { 32 | this.languageDao = languageDao; 33 | this.modelMapperService = modelMapperService; 34 | } 35 | 36 | // Finds All Languages 37 | @Override 38 | public DataResult> getAll() { 39 | List languages = this.languageDao.findAll(); 40 | List languageSearchListDtos = languages.stream() 41 | .map(language -> modelMapperService.forDto().map(language, LanguageSearchListDto.class)) 42 | .collect(Collectors.toList()); 43 | return new SuccessDataResult>(languageSearchListDtos, Messages.LANGUAGELIST); 44 | } 45 | 46 | // Adds a new Language 47 | @Override 48 | public Result add(CreateLanguageRequest createLanguageRequest) { 49 | Language language = modelMapperService.forRequest().map(createLanguageRequest, Language.class); 50 | languageDao.save(language); 51 | return new SuccessResult(Messages.LANGUAGEADD); 52 | } 53 | 54 | // Deletes a language if there is no relation in the database 55 | @Override 56 | public Result delete(DeleteLanguageRequest deleteLanguageRequest) { 57 | Language language = modelMapperService.forRequest().map(deleteLanguageRequest, Language.class); 58 | languageDao.delete(language); 59 | return new SuccessResult(Messages.LANGUAGEDELETE); 60 | } 61 | 62 | // Deletes a language if there is no relation in the database 63 | @Override 64 | public Result update(UpdateLanguageRequest updateLanguageRequests) { 65 | Language language = modelMapperService.forRequest().map(updateLanguageRequests, Language.class); 66 | languageDao.save(language); 67 | return new SuccessResult(Messages.LANGUAGEUPDATE); 68 | } 69 | 70 | // finds language by name 71 | @Override 72 | public DataResult getByLanguageName(String languageName) { 73 | Language language = this.languageDao.getLanguagesByName(languageName); 74 | // var result=this.languageDao.getById(id); 75 | LanguageSearchListDto languageSearchListDto = modelMapperService.forDto().map(language, 76 | LanguageSearchListDto.class); 77 | return new SuccessDataResult(languageSearchListDto, Messages.LANGUAGELIST); 78 | } 79 | } -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/concretes/CityManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.concretes; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.btkAkademi.rentACar.business.abstracts.CityService; 10 | import com.btkAkademi.rentACar.business.constants.Messages; 11 | import com.btkAkademi.rentACar.business.dtos.CityListDto; 12 | import com.btkAkademi.rentACar.business.requests.cityRequests.CreateCityRequest; 13 | import com.btkAkademi.rentACar.business.requests.cityRequests.UpdateCityRequest; 14 | import com.btkAkademi.rentACar.core.utilities.business.BusinessRules; 15 | import com.btkAkademi.rentACar.core.utilities.mapping.ModelMapperService; 16 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 17 | import com.btkAkademi.rentACar.core.utilities.results.ErrorDataResult; 18 | import com.btkAkademi.rentACar.core.utilities.results.ErrorResult; 19 | import com.btkAkademi.rentACar.core.utilities.results.Result; 20 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 21 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 22 | import com.btkAkademi.rentACar.dataAccess.abstracts.CityDao; 23 | import com.btkAkademi.rentACar.entities.concretes.City; 24 | 25 | @Service 26 | public class CityManager implements CityService { 27 | // Dependencies 28 | private CityDao cityDao; 29 | private ModelMapperService modelMapperService; 30 | 31 | // Dependency Injeciton 32 | @Autowired 33 | public CityManager(CityDao cityDao, ModelMapperService modelMapperService) { 34 | super(); 35 | this.cityDao = cityDao; 36 | this.modelMapperService = modelMapperService; 37 | } 38 | 39 | // lists all cities in the database 40 | @Override 41 | public DataResult> findAll() { 42 | 43 | List cityList = this.cityDao.findAllByOrderByCityNameAsc(); 44 | List response = cityList.stream() 45 | .map(city -> modelMapperService.forDto().map(city, CityListDto.class)).collect(Collectors.toList()); 46 | 47 | return new SuccessDataResult>(response, Messages.CITYLIST); 48 | } 49 | 50 | // Finds city with that id 51 | @Override 52 | public DataResult findById(int id) { 53 | Result result = BusinessRules.run(checkIfCityIdExist(id)); 54 | if (result != null) { 55 | return new ErrorDataResult(result.getMessage()); 56 | } 57 | City city = cityDao.findById(id).get(); 58 | CityListDto response = modelMapperService.forDto().map(city, CityListDto.class); 59 | return new SuccessDataResult(response, Messages.CITYLIST); 60 | } 61 | 62 | // Creates a new city in the database 63 | @Override 64 | public Result add(CreateCityRequest createCityRequest) { 65 | Result result = BusinessRules.run(checkIfCityNameExists(createCityRequest.getCityName())); 66 | if (result != null) { 67 | return result; 68 | } 69 | City city = this.modelMapperService.forRequest().map(createCityRequest, City.class); 70 | this.cityDao.save(city); 71 | return new SuccessResult(Messages.CITYADD); 72 | } 73 | 74 | // update 75 | @Override 76 | public Result update(UpdateCityRequest updateCityRequest) { 77 | 78 | City city = this.modelMapperService.forRequest().map(updateCityRequest, City.class); 79 | this.cityDao.save(city); 80 | return new SuccessResult(Messages.CITYUPDATE); 81 | } 82 | 83 | // delete 84 | @Override 85 | public Result delete(int id) { 86 | Result result = BusinessRules.run(checkIfCityIdExist(id)); 87 | if (result != null) { 88 | return result; 89 | } 90 | 91 | cityDao.deleteById(id); // if there is a relation it will give error 92 | return new SuccessResult(Messages.CITYDELETE); 93 | 94 | } 95 | 96 | // Helpers 97 | 98 | // Checks city is added before or not 99 | private Result checkIfCityNameExists(String cityName) { 100 | if (cityDao.findByCityName(cityName) != null) { 101 | return new ErrorResult(Messages.CITYNAMEEXISTS); 102 | } 103 | return new SuccessResult(); 104 | } 105 | 106 | // controls that city exists or not 107 | private Result checkIfCityIdExist(int id) { 108 | if (!cityDao.existsById(id)) { 109 | return new ErrorResult(Messages.CITYNOTFOUND); 110 | } 111 | return new SuccessResult(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/btkAkademi/rentACar/business/concretes/SegmentManager.java: -------------------------------------------------------------------------------- 1 | package com.btkAkademi.rentACar.business.concretes; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.btkAkademi.rentACar.business.abstracts.SegmentService; 10 | import com.btkAkademi.rentACar.business.constants.Messages; 11 | import com.btkAkademi.rentACar.business.dtos.SegmentListDto; 12 | import com.btkAkademi.rentACar.business.requests.segmentRequest.CreateSegmentRequest; 13 | import com.btkAkademi.rentACar.business.requests.segmentRequest.UpdateSegmentRequest; 14 | import com.btkAkademi.rentACar.core.utilities.business.BusinessRules; 15 | import com.btkAkademi.rentACar.core.utilities.mapping.ModelMapperService; 16 | import com.btkAkademi.rentACar.core.utilities.results.DataResult; 17 | import com.btkAkademi.rentACar.core.utilities.results.ErrorDataResult; 18 | import com.btkAkademi.rentACar.core.utilities.results.ErrorResult; 19 | import com.btkAkademi.rentACar.core.utilities.results.Result; 20 | import com.btkAkademi.rentACar.core.utilities.results.SuccessDataResult; 21 | import com.btkAkademi.rentACar.core.utilities.results.SuccessResult; 22 | import com.btkAkademi.rentACar.dataAccess.abstracts.SegmentDao; 23 | import com.btkAkademi.rentACar.entities.concretes.Segment; 24 | 25 | @Service 26 | public class SegmentManager implements SegmentService { 27 | // Dependencies 28 | private ModelMapperService modelMapperService; 29 | private SegmentDao segmentDao; 30 | 31 | // Dependency Injection 32 | @Autowired 33 | public SegmentManager(ModelMapperService modelMapperService, SegmentDao segmentDao) { 34 | super(); 35 | this.modelMapperService = modelMapperService; 36 | this.segmentDao = segmentDao; 37 | } 38 | 39 | // Finds all segments 40 | @Override 41 | public DataResult> findAll() { 42 | List segmentList = this.segmentDao.findAll(); 43 | List response = segmentList.stream() 44 | .map(segment -> modelMapperService.forDto().map(segment, SegmentListDto.class)) 45 | .collect(Collectors.toList()); 46 | return new SuccessDataResult>(response, Messages.SEGMENTLIST); 47 | } 48 | 49 | // finds a segment 50 | @Override 51 | public DataResult findById(int id) { 52 | Result result = BusinessRules.run(checkIfSegmentExistsById(id)); 53 | if (result != null) { 54 | return new ErrorDataResult(result.getMessage()); 55 | } 56 | SegmentListDto response = modelMapperService.forDto().map(segmentDao.findById(id).get(), SegmentListDto.class); 57 | return new SuccessDataResult(response, Messages.SEGMENTLIST); 58 | 59 | } 60 | 61 | // create a new segment 62 | @Override 63 | public Result add(CreateSegmentRequest createSegmentRequest) { 64 | Result result = BusinessRules.run(CheckIfSegmentNameAlreadyExists(createSegmentRequest.getSegmentName())); 65 | if (result != null) { 66 | return result; 67 | } 68 | Segment segment = this.modelMapperService.forRequest().map(createSegmentRequest, Segment.class); 69 | this.segmentDao.save(segment); 70 | return new SuccessResult(Messages.SEGMENTADD); 71 | } 72 | 73 | // updates a new segment 74 | @Override 75 | public Result update(UpdateSegmentRequest updateSegmentRequest) { 76 | Segment segment = this.modelMapperService.forRequest().map(updateSegmentRequest, Segment.class); 77 | this.segmentDao.save(segment); 78 | return new SuccessResult(Messages.SEGMENTUPDATE); 79 | } 80 | 81 | // deletes a new segment 82 | @Override 83 | public Result delete(int id) { 84 | Result result = BusinessRules.run(checkIfSegmentExistsById(id)); 85 | if (result != null) { 86 | return result; 87 | } 88 | segmentDao.deleteById(id); 89 | return new SuccessResult(Messages.SEGMENTDELETE); 90 | 91 | } 92 | 93 | // controls if there is a segment with that name 94 | private Result CheckIfSegmentNameAlreadyExists(String SegmentName) { 95 | if (segmentDao.findBySegmentName(SegmentName) != null) { 96 | return new ErrorResult(Messages.SEGMENTNAMEALREADYEXISTS); 97 | } 98 | return new SuccessResult(); 99 | } 100 | 101 | // Checks is there a segment with that id 102 | private Result checkIfSegmentExistsById(int id) { 103 | if (!this.segmentDao.existsById(id)) { 104 | return new ErrorResult(Messages.SEGMENTNOTFOUND); 105 | } 106 | return new SuccessResult(); 107 | } 108 | 109 | } 110 | --------------------------------------------------------------------------------