comment backend events and utils

This commit is contained in:
2026-04-20 15:43:11 -06:00
parent 0f35da597f
commit 3a155b6c03
25 changed files with 175 additions and 0 deletions

View File

@@ -1,3 +1,10 @@
/*
* Main entry point for the pet shop backend application.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend;
import com.petshop.backend.config.BusinessProperties;

View File

@@ -1,3 +1,10 @@
/*
* Starts the backend with Docker and auto-reload for development.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend;
import com.petshop.backend.config.FlywayContextInitializer;

View File

@@ -1,3 +1,10 @@
/*
* Manages Docker Compose for the development database.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend;
import java.io.BufferedReader;

View File

@@ -1,3 +1,10 @@
/*
* Frees up a port by stopping whatever process is using it.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend;
import java.io.BufferedReader;

View File

@@ -1,3 +1,10 @@
/*
* Resets the development database by recreating the Docker container.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend;
public class ResetDatabaseApplication {

View File

@@ -1,3 +1,10 @@
/*
* Checks that required resources are on the classpath at startup.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend;
import java.net.URL;

View File

@@ -1,3 +1,10 @@
/*
* Event fired when an adoption is confirmed.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.event;
public record AdoptionConfirmedEvent(Long adoptionId) {}

View File

@@ -1,3 +1,10 @@
/*
* Event fired to send an adoption reminder email.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.event;
public record AdoptionReminderEvent(Long adoptionId) {}

View File

@@ -1,3 +1,10 @@
/*
* Event fired when an appointment is confirmed.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.event;
public record AppointmentConfirmedEvent(Long appointmentId) {}

View File

@@ -1,3 +1,10 @@
/*
* Event fired to send an appointment reminder email.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.event;
public record AppointmentReminderEvent(Long appointmentId) {}

View File

@@ -1,3 +1,10 @@
/*
* Listens for events and sends the matching emails.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.event;
import com.petshop.backend.repository.AdoptionRepository;

View File

@@ -1,3 +1,10 @@
/*
* Event fired to send a sale receipt email.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.event;
public record SaleReceiptEvent(Long saleId) {}

View File

@@ -1,3 +1,10 @@
/*
* Writes error responses to the client in a consistent format.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.exception;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@@ -1,3 +1,10 @@
/*
* Holds the structure of an error response sent to the client.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.exception;
import java.time.LocalDateTime;

View File

@@ -1,3 +1,10 @@
/*
* Thrown when a business rule is violated.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.exception;
public class BusinessException extends RuntimeException {

View File

@@ -1,3 +1,10 @@
/*
* Thrown when a request conflicts with existing data.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.exception;
public class ConflictException extends RuntimeException {

View File

@@ -1,3 +1,10 @@
/*
* Catches all exceptions and returns proper error responses.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.exception;
import com.petshop.backend.service.PetService;

View File

@@ -1,3 +1,10 @@
/*
* Thrown when a requested resource does not exist.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.exception;
public class ResourceNotFoundException extends RuntimeException {

View File

@@ -1,3 +1,10 @@
/*
* Retrieves the currently logged-in user from the security context.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
import com.petshop.backend.entity.User;

View File

@@ -1,3 +1,10 @@
/*
* Checks user input for scripts and inappropriate language.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
import com.petshop.backend.exception.BusinessException;

View File

@@ -1,3 +1,10 @@
/*
* Validates uploaded image files for type and size.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
import com.petshop.backend.exception.BusinessException;

View File

@@ -1,3 +1,10 @@
/*
* Formats and normalizes phone numbers.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
public class PhoneUtils {

View File

@@ -1,3 +1,10 @@
/*
* Annotation that marks a field for content safety validation.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
import jakarta.validation.Constraint;

View File

@@ -1,3 +1,10 @@
/*
* Validates fields annotated with SafeContent for dangerous input.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
import jakarta.validation.ConstraintValidator;

View File

@@ -1,3 +1,10 @@
/*
* Helper methods for trimming and formatting strings.
*
* Author: Harkamal
* Date: April 2026
*/
package com.petshop.backend.util;
public final class StringUtils {