package-info and new controllers for email

This commit is contained in:
2025-12-11 17:07:22 -05:00
parent 7b64c35502
commit f8ff380fa8
26 changed files with 354 additions and 140 deletions

View File

@@ -0,0 +1,12 @@
/**
* Catalog classification package for the BattlBuilder application.
* <p>
* This package contains classes responsible for platform resolution,
* rule compilation, and product context classification.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.catalog.classification;

View File

@@ -1,13 +1,11 @@
/**
* Provides the classes necessary for the Spring Configurations for the Battl.Builder application.
* This package includes Configurations for Spring-Boot application
*
*
* <p>The main entry point for managing the inventory is the
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
*
* @since 1.0
* @author Don Strawsburg
* @version 1.1
*/
package group.goforward.battlbuilder.configuration;
/**
* Configuration package for the BattlBuilder application.
* <p>
* Contains Spring configuration classes for security, CORS, JPA,
* caching, and password encoding.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.configuration;

View File

@@ -0,0 +1,11 @@
/**
* Admin controllers package for the BattlBuilder application.
* <p>
* Contains REST controllers for administrative operations including
* category management, platform configuration, and merchant administration.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.controllers.admin;

View File

@@ -0,0 +1,128 @@
package group.goforward.battlbuilder.controllers.api;
import group.goforward.battlbuilder.utils.ApiResponse;
import group.goforward.battlbuilder.dto.EmailRequestDto;
import group.goforward.battlbuilder.model.EmailRequest;
import group.goforward.battlbuilder.repos.EmailRequestRepository;
import group.goforward.battlbuilder.services.utils.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/api/email")
public class EmailController {
private static final String EMAIL_STATUS_SENT = "SENT";
private final EmailService emailService;
private final EmailRequestRepository emailRequestRepository;
@Autowired
public EmailController(EmailService emailService, EmailRequestRepository emailRequestRepository) {
this.emailService = emailService;
this.emailRequestRepository = emailRequestRepository;
}
@GetMapping
public ResponseEntity<ApiResponse<List<EmailRequest>>> getAllEmailRequests() {
try {
List<EmailRequest> emailRequests = emailRequestRepository.findAll();
return ResponseEntity.ok(
ApiResponse.success(emailRequests, "Email requests retrieved successfully")
);
} catch (Exception e) {
return ResponseEntity.status(500).body(
ApiResponse.error("Error retrieving email requests: " + e.getMessage(), null)
);
}
}
@GetMapping("/allSent")
public ResponseEntity<ApiResponse<List<EmailRequest>>> getNotSentEmailRequests() {
try {
List<EmailRequest> emailRequests = emailRequestRepository.findSent();
return ResponseEntity.ok(
ApiResponse.success(emailRequests, "Not sent email requests retrieved successfully")
);
} catch (Exception e) {
return ResponseEntity.status(500).body(
ApiResponse.error("Error retrieving not sent email requests: " + e.getMessage(), null)
);
}
}
@GetMapping("/allFailed")
public ResponseEntity<ApiResponse<List<EmailRequest>>> getFailedEmailRequests() {
try {
List<EmailRequest> emailRequests = emailRequestRepository.findFailed();
return ResponseEntity.ok(
ApiResponse.success(emailRequests, "Failed email requests retrieved successfully")
);
} catch (Exception e) {
return ResponseEntity.status(500).body(
ApiResponse.error("Error retrieving failed email requests: " + e.getMessage(), null)
);
}
}
@GetMapping("/allPending")
public ResponseEntity<ApiResponse<List<EmailRequest>>> getPendingEmailRequests() {
try {
List<EmailRequest> emailRequests = emailRequestRepository.findPending();
return ResponseEntity.ok(
ApiResponse.success(emailRequests, "Pending email requests retrieved successfully")
);
} catch (Exception e) {
return ResponseEntity.status(500).body(
ApiResponse.error("Error retrieving Pending email requests: " + e.getMessage(), null)
);
}
}
@PostMapping("/send")
public ResponseEntity<ApiResponse<EmailRequest>> sendEmail(@RequestBody EmailRequestDto emailDto) {
try {
EmailRequest emailRequest = emailService.sendEmail(
emailDto.getRecipient(),
emailDto.getSubject(),
emailDto.getBody()
);
return buildEmailResponse(emailRequest);
} catch (Exception e) {
return buildErrorResponse(e.getMessage());
}
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
return brandService.findById(id)
.map(item -> {
brandService.deleteById(id);
return ResponseEntity.noContent().<Void>build();
})
.orElse(ResponseEntity.notFound().build());
}
private ResponseEntity<ApiResponse<EmailRequest>> buildEmailResponse(EmailRequest emailRequest) {
if (EMAIL_STATUS_SENT.equals(emailRequest.getStatus())) {
return ResponseEntity.ok(
ApiResponse.success(emailRequest, "Email sent successfully")
);
} else {
String errorMessage = "Failed to send email: " + emailRequest.getErrorMessage();
return ResponseEntity.status(500).body(
ApiResponse.error(errorMessage, emailRequest)
);
}
}
private ResponseEntity<ApiResponse<EmailRequest>> buildErrorResponse(String exceptionMessage) {
String errorMessage = "Error processing email request: " + exceptionMessage;
return ResponseEntity.status(500).body(
ApiResponse.error(errorMessage, null)
);
}
}

View File

@@ -1,14 +1,11 @@
/**
* Provides the classes necessary for the public api endpoints for the Battl.Builder
* application Spring Controllers.
* This package includes Controllers for Spring-Boot application
*
*
* <p>The main entry point for managing the inventory is the
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
*
* @since 1.0
* @author Don Strawsburg
* @version 1.1
*/
package group.goforward.battlbuilder.controllers.api;
/**
* API controllers package for the BattlBuilder application.
* <p>
* Contains REST API controllers for public-facing endpoints including
* brand management, state information, and user operations.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.controllers.api;

View File

@@ -1,13 +1,11 @@
/**
* Provides the classes necessary for the Spring Controllers for the Battl.Builder application.
* This package includes Controllers for Spring-Boot application
* Utility controllers package for the BattlBuilder application.
* <p>
* Contains utility REST controllers for email handling and
* health check operations.
*
*
* <p>The main entry point for managing the inventory is the
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
*
* @since 1.0
* @author Don Strawsburg
* @version 1.1
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.controllers;

View File

@@ -1,61 +0,0 @@
package group.goforward.battlbuilder.controllers.utils;
import group.goforward.battlbuilder.ApiResponse;
import group.goforward.battlbuilder.dto.EmailRequestDto;
import group.goforward.battlbuilder.model.EmailRequest;
import group.goforward.battlbuilder.services.utils.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/email")
public class EmailController {
private static final String EMAIL_STATUS_SENT = "SENT";
private final EmailService emailService;
@Autowired
public EmailController(EmailService emailService) {
this.emailService = emailService;
}
@PostMapping("/send")
public ResponseEntity<ApiResponse<EmailRequest>> sendEmail(@RequestBody EmailRequestDto emailDto) {
try {
EmailRequest emailRequest = emailService.sendEmail(
emailDto.getRecipient(),
emailDto.getSubject(),
emailDto.getBody()
);
return buildEmailResponse(emailRequest);
} catch (Exception e) {
return buildErrorResponse(e.getMessage());
}
}
private ResponseEntity<ApiResponse<EmailRequest>> buildEmailResponse(EmailRequest emailRequest) {
if (EMAIL_STATUS_SENT.equals(emailRequest.getStatus())) {
return ResponseEntity.ok(
ApiResponse.success(emailRequest, "Email sent successfully")
);
} else {
String errorMessage = "Failed to send email: " + emailRequest.getErrorMessage();
return ResponseEntity.status(500).body(
ApiResponse.error(errorMessage, emailRequest)
);
}
}
private ResponseEntity<ApiResponse<EmailRequest>> buildErrorResponse(String exceptionMessage) {
String errorMessage = "Error processing email request: " + exceptionMessage;
return ResponseEntity.status(500).body(
ApiResponse.error(errorMessage, null)
);
}
}

View File

@@ -1,14 +1,11 @@
/**
* Provides the classes necessary for the utility controllers for the Battl.Builder
* application Spring Controllers.
* This package includes Controllers for Spring-Boot application
*
*
* <p>The main entry point for managing the inventory is the
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
*
* @since 1.0
* @author Don Strawsburg
* @version 1.1
*/
package group.goforward.battlbuilder.controllers.utils;
/**
* Utility controllers package for the BattlBuilder application.
* <p>
* Contains utility REST controllers for email handling and
* health check operations.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.controllers.utils;

View File

@@ -0,0 +1,12 @@
/**
* Web admin DTOs package for the BattlBuilder application.
* <p>
* Contains Data Transfer Objects specific to administrative
* operations including user management, mappings, and platform configuration.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.dto;

View File

@@ -5,6 +5,21 @@ import java.time.LocalDateTime;
@Entity
@Table(name = "email_requests")
@NamedQuery(
name = "EmailRequest.findSent",
query = "SELECT e FROM EmailRequest e WHERE e.status = 'SENT'"
)
@NamedQuery(
name = "EmailRequest.findFailed",
query = "SELECT e FROM EmailRequest e WHERE e.status = 'FAILED'"
)
@NamedQuery(
name = "EmailRequest.findPending",
query = "SELECT e FROM EmailRequest e WHERE e.status = 'PENDING'"
)
public class EmailRequest {
@Id

View File

@@ -1 +1,11 @@
package group.goforward.battlbuilder.model;
/**
* Model package for the BattlBuilder application.
* <p>
* Contains JPA entity classes representing the domain model including
* products, merchants, categories, platforms, and user accounts.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.model;

View File

@@ -0,0 +1,11 @@
/**
* Root package for the BattlBuilder application.
* <p>
* BattlBuilder is a comprehensive platform for firearm parts catalog management,
* product classification, and merchant integration.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder;

View File

@@ -9,4 +9,10 @@ import java.util.List;
@Repository
public interface EmailRequestRepository extends JpaRepository<EmailRequest, Long> {
List<EmailRequest> findByStatus(String status);
List<EmailRequest> findFailed();
List<EmailRequest> findSent();
List<EmailRequest> findPending();
}

View File

@@ -1,13 +1,11 @@
/**
* Provides the classes necessary for the Spring Repository for the Battl.Builder application.
* This package includes Repository for Spring-Boot application
*
*
* <p>The main entry point for managing the inventory is the
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
*
* @since 1.0
* @author Sean Strawsburg
* @version 1.1
*/
package group.goforward.battlbuilder.repos;
/**
* Repositories package for the BattlBuilder application.
* <p>
* Contains Spring Data JPA repository interfaces for database
* access and persistence operations.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.repos;

View File

@@ -0,0 +1,11 @@
/**
* Admin services package for the BattlBuilder application.
* <p>
* Contains service classes for administrative business logic
* and operations.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.services.admin;

View File

@@ -28,7 +28,7 @@ public class BrandServiceImpl implements BrandService {
@Override
public Brand save(Brand item) {
return null;
return repo.save(item);
}
@Override

View File

@@ -1,13 +1,10 @@
/**
* Provides the classes necessary for the Spring Services implementations for the Battl.Builder application.
* This package includes Services implementations for Spring-Boot application
*
*
* <p>The main entry point for managing the inventory is the
* {@link group.goforward.battlbuilder.BattlBuilderApplication} class.</p>
*
* @since 1.0
* @author Don Strawsburg
* @version 1.1
*/
/**
* Service implementations package for the BattlBuilder application.
* <p>
* Contains implementation classes for service interfaces.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.services.impl;

View File

@@ -1 +1,12 @@
package group.goforward.battlbuilder.services;
/**
* Services package for the BattlBuilder application.
* <p>
* Contains business logic service classes for product management,
* category classification, mapping recommendations, and merchant operations.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.services;

View File

@@ -4,4 +4,6 @@ import group.goforward.battlbuilder.model.EmailRequest;
public interface EmailService {
EmailRequest sendEmail(String recipient, String subject, String body);
void deleteById(Integer id);
}

View File

@@ -57,4 +57,9 @@ public class EmailServiceImpl implements EmailService {
return emailRequestRepository.save(emailRequest);
}
@Override
public void deleteById(Integer id) {
deleteById(id);
}
}

View File

@@ -0,0 +1,10 @@
/**
* Utility service implementations package for the BattlBuilder application.
* <p>
* Contains implementation classes for utility service interfaces.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.services.utils.impl;

View File

@@ -1,4 +1,4 @@
package group.goforward.battlbuilder;
package group.goforward.battlbuilder.utils;
import java.time.LocalDateTime;

View File

@@ -0,0 +1,11 @@
/**
* Utilities package for the BattlBuilder application.
* <p>
* Contains utility classes and helper functions used throughout
* the application.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.utils;

View File

@@ -0,0 +1,12 @@
/**
* Web admin package for the BattlBuilder application.
* <p>
* Contains web controllers for administrative interface operations
* including user management, merchant administration, and import status.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.web.admin;

View File

@@ -0,0 +1,12 @@
/**
* Web authentication DTOs package for the BattlBuilder application.
* <p>
* Contains Data Transfer Objects for authentication operations
* including login requests, registration, and authentication responses.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.web.dto.auth;

View File

@@ -0,0 +1,11 @@
/**
* Web package for the BattlBuilder application.
* <p>
* Contains web-related classes including controllers and DTOs
* for the web layer.
*
* @author Forward Group, LLC
* @version 1.0
* @since 2025-12-10
*/
package group.goforward.battlbuilder.web;