Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>com.github.Podzilla</groupId>
<artifactId>podzilla-utils-lib</artifactId>
<version>v1.1.6</version>
<version>v1.1.12</version>
</dependency>

<!-- Validation API & Implementation -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public List<CustomersTopSpendersResponse> getTopSpenders(
request.getStartDate(),
request.getEndDate(),
request.getPage(),
request.getSize());
request.getSize()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.Podzilla.analytics.api.controllers;

import org.springframework.http.ResponseEntity;
// import org.springframework.web.bind.MethodArgumentNotValidException;
// import org.springframework.web.bind.MissingServletRequestParameterException;
// import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
// import org.springframework.web.method.annotation.
// MethodArgumentTypeMismatchException;

import com.Podzilla.analytics.api.dtos.fulfillment.FulfillmentPlaceToShipRequest;
import com.Podzilla.analytics.api.dtos.fulfillment.FulfillmentShipToDeliverRequest;
Expand Down Expand Up @@ -44,7 +39,8 @@ public ResponseEntity<List<FulfillmentTimeResponse>> getPlaceToShipTime(
fulfillmentAnalyticsService.getPlaceToShipTimeResponse(
req.getStartDate(),
req.getEndDate(),
req.getGroupBy());
req.getGroupBy()
);
return ResponseEntity.ok(reportData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class InventoryReportController {
+ "the total value of inventory "
+ "grouped by product categories")
@GetMapping("/value/by-category")
public List<InventoryValueByCategoryResponse> getInventoryValueByCategor() {
public List<InventoryValueByCategoryResponse>
getInventoryValueByCategory() {
return inventoryAnalyticsService.getInventoryValueByCategory();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import com.Podzilla.analytics.services.ProfitAnalyticsService;

import io.swagger.v3.oas.annotations.Operation;
// import io.swagger.v3.oas.annotations.responses.ApiResponse;
// import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
package com.Podzilla.analytics.api.controllers;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.Podzilla.analytics.messaging.AnalyticsRabbitListener;
import com.podzilla.mq.events.BaseEvent;
import com.podzilla.mq.events.ConfirmationType;
import com.podzilla.mq.events.ProductSnapshot;
import com.podzilla.mq.events.WarehouseOrderFulfillmentFailedEvent;
import com.podzilla.mq.events.CourierRegisteredEvent;
import com.podzilla.mq.events.CustomerRegisteredEvent;
import com.podzilla.mq.events.DeliveryAddress;
import com.podzilla.mq.events.InventoryUpdatedEvent;
import com.podzilla.mq.events.OrderAssignedToCourierEvent;
import com.podzilla.mq.events.OrderCancelledEvent;
import com.podzilla.mq.events.OrderDeliveredEvent;
import com.podzilla.mq.events.OrderDeliveryFailedEvent;
import com.podzilla.mq.events.OrderOutForDeliveryEvent;
import com.podzilla.mq.events.OrderPlacedEvent;
import com.podzilla.mq.events.ProductCreatedEvent;

import java.util.ArrayList;
@RestController
@RequestMapping("/rabbit-tester")
public class RabbitTesterController {

static final int QUANTITY = 5;
@Autowired
private AnalyticsRabbitListener listener;

@GetMapping("/courier-registered-event")
public void testCourierRegisteredEvent() {
BaseEvent event = new CourierRegisteredEvent(
"87f23fee-2e09-4331-bc9c-912045ef0832",
"ahmad the courier", "010");
listener.handleUserEvents(event);
}

@GetMapping("/customer-registered-event")
public void testCustomerRegisteredEvent() {
BaseEvent event = new CustomerRegisteredEvent(
"27f7f5ca-6729-461e-882a-0c5123889bec",
"7amada");
listener.handleUserEvents(event);
}

@GetMapping("/order-assigned-to-courier-event")
public void testOrderAssignedToCourierEvent(
@RequestParam final String orderId,
@RequestParam final String courierId
) {
BaseEvent event = new OrderAssignedToCourierEvent(
orderId,
courierId,
new BigDecimal("10.0"), 0.0, 0.0, "signature",
ConfirmationType.QR_CODE);
listener.handleOrderEvents(event);
}

@GetMapping("/order-cancelled-event")
public void testOrderCancelledEvent(
@RequestParam final String orderId
) {
BaseEvent event = new OrderCancelledEvent(
orderId,
"2", // customerId (not used in the event)
"rabbit reason",
new ArrayList<>()
);
listener.handleOrderEvents(event);
}

@GetMapping("/order-delivered-event")
public void testOrderDeliveredEvent(
@RequestParam final String orderId
) {
BaseEvent event = new OrderDeliveredEvent(
orderId, "2",
new BigDecimal("4.73"));
listener.handleOrderEvents(event);
}

@GetMapping("/order-delivery-failed-event")
public void testOrderDeliveryFailedEvent(
@RequestParam final String orderId
) {
BaseEvent event = new OrderDeliveryFailedEvent(
orderId, "the rabit delivery failed reason", "2");
listener.handleOrderEvents(event);
}

@GetMapping("/order-out-for-delivery-event")
public void testOrderOutForDeliveryEvent(
@RequestParam final String orderId
) {
BaseEvent event = new OrderOutForDeliveryEvent(
orderId, "2");
listener.handleOrderEvents(event);
}
@GetMapping("/order-fulfillment-failed-event")
public void testOrderFailedToFulfill(
@RequestParam final String orderId
) {
BaseEvent event = new WarehouseOrderFulfillmentFailedEvent(
orderId, "order fulfillment failed rabbit reason");
listener.handleOrderEvents(event);
}

@GetMapping("/order-placed-event")
public void testOrderPlacedEvent(
@RequestParam final String customerId,
@RequestParam final String productId1,
@RequestParam final String productId2
) {
BaseEvent event = new OrderPlacedEvent(
"a1aa7c7d-fe6a-491f-a2cc-b3b923340777",
customerId,
Arrays.asList(
new com.podzilla.mq.events.OrderItem(productId1,
QUANTITY, new BigDecimal("8.5")),
new com.podzilla.mq.events.OrderItem(productId2,
QUANTITY, new BigDecimal("12.75"))
),
new DeliveryAddress(
"rabbit street",
"rabbit city wallahy",
"some state",
"some country",
"some postal code"),
new BigDecimal("13290.0"), 0.0, 0.0, "signature",
ConfirmationType.QR_CODE);
listener.handleOrderEvents(event);
}

@GetMapping("inventory-updated-event")
public void testInventoryUpdatedEvent(
@RequestParam final String productId,
@RequestParam final Integer quantity) {
BaseEvent event = new InventoryUpdatedEvent(
List.of(new ProductSnapshot(productId, quantity)));
listener.handleInventoryEvents(event);
}

@GetMapping("product-created-event")
public void testProductCreatedEvent() {
BaseEvent event = new ProductCreatedEvent(
"f12afb47-ad23-4ca8-a162-8b12de7a5e49",
"the rabbit product",
"some category",
new BigDecimal("10.0"),
Integer.valueOf(1));
listener.handleInventoryEvents(event);
}

}
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
package com.Podzilla.analytics.api.dtos;

import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;

import com.Podzilla.analytics.validation.annotations.ValidDateRange;
import com.Podzilla.analytics.validation.annotations.ValidPagination;

import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import io.swagger.v3.oas.annotations.media.Schema;

@ValidDateRange
@ValidPagination
@Getter
@AllArgsConstructor
public class DateRangePaginationRequest {
public class DateRangePaginationRequest
implements IDateRangeRequest, IPaginationRequest {

@NotNull(message = "startDate is required")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@Schema(description = "Start date and time of the range "
+ "(inclusive)", example = "2024-01-01T00:00:00", required = true)
private LocalDateTime startDate;
@Schema(description = "Start date of the range "
+ "(inclusive)", example = "2024-01-01", required = true)
private LocalDate startDate;

@NotNull(message = "endDate is required")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
@Schema(description = "End date and time of the range "
+ "(inclusive)", example = "2024-01-31T23:59:59", required = true)
private LocalDateTime endDate;
@Schema(description = "End date of the range "
+ "(inclusive)", example = "2024-01-31", required = true)
private LocalDate endDate;

@Min(value = 0, message = "Page "
+ "number must be greater than or equal to 0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@ValidDateRange
@Getter
@AllArgsConstructor
public class DateRangeRequest {
public class DateRangeRequest implements IDateRangeRequest {

@NotNull(message = "startDate is required")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.Podzilla.analytics.api.dtos;
import java.time.LocalDate;


public interface IDateRangeRequest {
LocalDate getStartDate();
LocalDate getEndDate();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.Podzilla.analytics.api.dtos;

public interface IPaginationRequest {
int getPage();
int getSize();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
import jakarta.validation.constraints.Min;
import lombok.AllArgsConstructor;
import lombok.Getter;

import com.Podzilla.analytics.validation.annotations.ValidPagination;

import io.swagger.v3.oas.annotations.media.Schema;

@ValidPagination
@Getter
@AllArgsConstructor
public class PaginationRequest {
public class PaginationRequest implements IPaginationRequest {

@Min(value = 0, message = "Page number "
+ "must be greater than or equal to 0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,57 @@
import java.math.BigDecimal;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
// import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;

@Data
@Builder
// @Builder
@NoArgsConstructor
@AllArgsConstructor
public class CourierAverageRatingResponse {

@Schema(description = "ID of the courier", example = "101")
private Long courierId;
private UUID courierId;

@Schema(description = "Full name of the courier", example = "John Doe")
private String courierName;

@Schema(description = "Average rating of the courier", example = "4.6")
private BigDecimal averageRating;

public static Builder builder() {
return new Builder();
}
public static class Builder {
private UUID courierId;
private String courierName;
private BigDecimal averageRating;

public Builder() { }

public Builder courierId(final UUID courierId) {
this.courierId = courierId;
return this;
}

public Builder courierName(final String courierName) {
this.courierName = courierName;
return this;
}

public Builder averageRating(final BigDecimal averageRating) {
this.averageRating = averageRating;
return this;
}

public CourierAverageRatingResponse build() {
return new CourierAverageRatingResponse(
courierId,
courierName,
averageRating
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;

@Data
@Builder
Expand All @@ -13,7 +14,7 @@
public class CourierDeliveryCountResponse {

@Schema(description = "ID of the courier", example = "101")
private Long courierId;
private UUID courierId;

@Schema(description = "Full name of the courier", example = "Jane Smith")
private String courierName;
Expand Down
Loading