Repository Interface

The repository interface will extend MongoRepository and will allow CRUD operations on the Pet collection.

PetRepo.java:

Java
package com.pet.clinic.app;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PetRepo extends MongoRepository<Pet, String> {
    // Additional query methods can be defined here if needed
}


Pet Clinic Application using Spring Boot

The Pet Clinic application plays an important role in the real world in saving pets from different situations. Mostly, online Pet Clinic applications are developed with the required business logic. Here, we’ve created a simple Spring Boot Application for the Pet Clinic Application. This application provides basic functionalities for understanding the Pet Clinic Application, which is used to book an appointment, search for appointment information, get information about available appointments, and other features.

For this application, we use the Spring MVC pattern with the Thymeleaf Java library. Here, we use Thymeleaf to create a Java library which is used in this application to handle the rendering of dynamic data using the Spring MVC pattern. We’ve also created a Book domain class for handling database relations with the help of Repository.

In real-time, there are several services available in the market to save pets from different situations like health issues, cleaning, and others. In this application, we use different information to track the appointment like:

  • slot id: This is automatically generated and assigned to every new appointment, This ID is generated by the Java Script
  • date time: Data and Time of Booking Appointment
  • duration:
    • 30 Minutes
    • 45 Minutes
    • 60 Minutes
    • 2 Hour
    • 3 Hour
    • 4 Hour
    • 5 Hour
  • service type:
    • General Check-up
    • Vaccination
    • Surgery
    • Grooming
  • staff: Staff to Pet to look after
  • status: It gives Booking Status like Available
  • client id: This is automatically generated and assigned to every new client, This Id is generated by the Java-Script
  • client name: Customer Name
  • phone: Customer phone number
  • email: Customer email address
  • pet id: This is automatically generated and assigned to every new pet, This Id is generated by the Java-Script
  • pet name: It is used for gather pet name
  • pet-age: It is used for gather pet age
  • medical history: It is used for gather pet previous medical information
  • microchip: It is used know the pet Micro chip Id
  • payment method: It is used for know the payment method
    • UPI
    • Net Banking
    • Credit Card
    • Debit Card
  • reason: To know the reason to visit the Service.

Prerequisites:

  • Spring Boot Framework: For building the backend services.
  • Thymeleaf: For server-side rendering of HTML.
  • MongoDB: As the NoSQL database to store pet clinic data.
  • Spring MVC Pattern: For handling web requests and responses.
  • Bootstrap Framework: For responsive and styled HTML pages.
  • Project Type is Gradle
  • Spring Tool Suite IDE (STS)

Gradle Dependencies:

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Spring Initializr:

Using Spring Initializr, we will create the Project .

  • Here we select Project type which is Gradle.
  • We then filled in the Metadata of the Project consisting of: Group Id, Artifact Id, Name, Description, Java version.
  • Also, we added all the important Gradle dependencies that can be found in the build.gradle file here.




Project Structure:

After creating the project, the structure will be like below.

Similar Reads

Model Layer

Here we created a POJO class to handle database operations with a repository interface. The POJO class is called PET and we used a dependency of lombok in Spring Boot. Used for Parameterized and non-Parameterized constructors using @Data, @AllArgsConstructor, @NoArgsConstructor, @Document....

View Layer

In this layer we display the entire application in the form HTML pages with integration Thymeleaf. The Thymeleaf is used for rendering the data dynamically when controller layer responds. We created these HTML files in the Template which is located in the resource folder of Project. Here we create...

Repository Interface

The repository interface will extend MongoRepository and will allow CRUD operations on the Pet collection....

Control Layer

In Pet Clinic application, we have created one Controller class with name PetController by using @Controller Spring Annotations....

Contact Us