The course is part of this learning path
In this course, we will learn the concepts of microservice and spring framework with a focus on Spring Boot.
Learning Objectives
- Understanding Spring Boot
Intended Audience
- Beginner Java developers
- Java developers interested in learning how to Build and Deploy RESTful Web Services
- Java Developers who want to develop web applications using the Spring framework
- Java Developers who want to develop web applications with microservices
- Java Developers who wish to develop Spring Boot Microservices with Spring Cloud
Prerequisites
- Basic Java knowledge
Hello, dear friends. In this video, we will create the Add to Basket Operation. So, let's get started. Now, the add basket operation will consist of two parts, sold product operations and bill operations. First I want to define sold products services and bill services. So, first I need a sold product repository. Add a new interface and name it SoldProductRepository, extends JpaRepository. The class will be soldProduct and the ID type is Long. Of course, we need a Repository annotation. Okay, done. Let's add another repository for the bill. The class will be Bill and the type is Long. Add Repository annotation. Okay, done. Now, that I think the structure is clear, I want to find all services and service implementation methods in this and in the following videos. Add a new service and name it SoldProductService. Now, I will define our methods. First, we need to getAll sold products.
Add saveSoldProduct, getSoldProductById, deleteSoldProductById, delete all SoldProductById, This must take an ID list. deleteSoldProductWithObject. Okay, that's enough for now. Let's add a service implementation class for SoldProduct, implements SoldProductService. For service implementation classes, we need Service annotation. Now, inject soldProductRepository. Now, I will override all methods one by one.
For getAllSoldProducts we will use findAll() method of repository. For saveSoldProduct(), we need save() method. Now, let's override getSoldProductById. Now, in this, we have to check if the SoldProduct is present or not. If now we have to throw an exception. Okay, done. For deleteById(), we will use the deleteById() method. For deleteSoldProductAllById(), we will use deleteAllById() method. For deleteSoldProductByObject(), we will use delete() method again, but this time we will send SoldProduct instance as a parameter.
Okay, done. We have now finished the sold product implementations. Let's continue with Bill. Add a new interface, name it BillService. Let's define methods. First method is getAllBills(). Save, getById(). The last one is delete(). Done. Let's define service implementation. Add a new class and name it BillServiceImplementation, implements BillService. Add Service annotation, inject BillRepository. Now, override methods one by one. For getAllBills(), we will use findAll() method.
For save() method, we need save() method. For geById(), we need to check is Bill present or not again. For delete(), we will use the deleteById() method. Okay, done. We have now completed all service operations. Let's take a short break here. In the next video, we will continue with the add to basket operations. See you in the next video.
OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.