mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2026-01-20 16:51:03 -05:00
package-info and new controllers for email
This commit is contained in:
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
11
src/main/java/group/goforward/battlbuilder/package-info.java
Normal file
11
src/main/java/group/goforward/battlbuilder/package-info.java
Normal 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;
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -28,7 +28,7 @@ public class BrandServiceImpl implements BrandService {
|
||||
|
||||
@Override
|
||||
public Brand save(Brand item) {
|
||||
return null;
|
||||
return repo.save(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,4 +57,9 @@ public class EmailServiceImpl implements EmailService {
|
||||
|
||||
return emailRequestRepository.save(emailRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(Integer id) {
|
||||
deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -1,4 +1,4 @@
|
||||
package group.goforward.battlbuilder;
|
||||
package group.goforward.battlbuilder.utils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user