comment backend events and utils
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Manages Docker Compose for the development database.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
|
||||
package com.petshop.backend;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Formats and normalizes phone numbers.
|
||||
*
|
||||
* Author: Harkamal
|
||||
* Date: April 2026
|
||||
*/
|
||||
|
||||
package com.petshop.backend.util;
|
||||
|
||||
public class PhoneUtils {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user