This commit is contained in:
Tour
2025-12-09 12:29:06 +01:00
parent 70dbb21c5d
commit eb4df0d60b

View File

@@ -16,13 +16,11 @@ import java.util.stream.Collectors;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.stream.Collectors;
/**
* REST API for Auction Monitor control and status.
* Provides endpoints for:
* - Status checking
* - Manual workflow triggers
* - Statistics
*/
/// REST API for Auction Monitor control and status.
/// Provides endpoints for:
/// - Status checking
/// - Manual workflow triggers
/// - Statistics
@Path("/api/monitor")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@@ -36,10 +34,8 @@ public class AuctionMonitorResource {
@Inject RateLimitedHttpClient httpClient;
@Inject LotEnrichmentService enrichmentService;
/**
* GET /api/monitor/status
* Returns current monitoring status
*/
/// GET /api/monitor/status
/// Returns current monitoring status
@GET
@Path("/status")
public Response getStatus() {
@@ -72,10 +68,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/statistics
* Returns detailed statistics
*/
/// GET /api/monitor/statistics
/// Returns detailed statistics
@GET
@Path("/statistics")
public Response getStatistics() {
@@ -165,10 +159,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/closing-soon
* Returns lots closing within the next specified hours (default: 24 hours)
*/
/// GET /api/monitor/closing-soon
/// Returns lots closing within the next specified hours (default: 24 hours)
@GET
@Path("/closing-soon")
public Response getClosingSoon(@QueryParam("hours") @DefaultValue("24") int hours) {
@@ -190,10 +182,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/lots/{lotId}/bid-history
* Returns bid history for a specific lot
*/
/// GET /api/monitor/lots/{lotId}/bid-history
/// Returns bid history for a specific lot
@GET
@Path("/lots/{lotId}/bid-history")
public Response getBidHistory(@PathParam("lotId") String lotId) {
@@ -208,10 +198,8 @@ public class AuctionMonitorResource {
}
}
/**
* POST /api/monitor/trigger/scraper-import
* Manually trigger scraper import workflow
*/
/// POST /api/monitor/trigger/scraper-import
/// Manually trigger scraper import workflow
@POST
@Path("/trigger/scraper-import")
public Response triggerScraperImport() {
@@ -226,10 +214,8 @@ public class AuctionMonitorResource {
}
}
/**
* POST /api/monitor/trigger/image-processing
* Manually trigger image processing workflow
*/
/// POST /api/monitor/trigger/image-processing
/// Manually trigger image processing workflow
@POST
@Path("/trigger/image-processing")
public Response triggerImageProcessing() {
@@ -244,10 +230,8 @@ public class AuctionMonitorResource {
}
}
/**
* POST /api/monitor/trigger/bid-monitoring
* Manually trigger bid monitoring workflow
*/
/// POST /api/monitor/trigger/bid-monitoring
/// Manually trigger bid monitoring workflow
@POST
@Path("/trigger/bid-monitoring")
public Response triggerBidMonitoring() {
@@ -262,10 +246,8 @@ public class AuctionMonitorResource {
}
}
/**
* POST /api/monitor/trigger/closing-alerts
* Manually trigger closing alerts workflow
*/
/// POST /api/monitor/trigger/closing-alerts
/// Manually trigger closing alerts workflow
@POST
@Path("/trigger/closing-alerts")
public Response triggerClosingAlerts() {
@@ -280,10 +262,8 @@ public class AuctionMonitorResource {
}
}
/**
* POST /api/monitor/trigger/graphql-enrichment
* Manually trigger GraphQL enrichment for all lots or lots closing soon
*/
/// POST /api/monitor/trigger/graphql-enrichment
/// Manually trigger GraphQL enrichment for all lots or lots closing soon
@POST
@Path("/trigger/graphql-enrichment")
public Response triggerGraphQLEnrichment(@QueryParam("hoursUntilClose") @DefaultValue("24") int hours) {
@@ -310,10 +290,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/auctions
* Returns list of all auctions
*/
/// GET /api/monitor/auctions
/// Returns list of all auctions
@GET
@Path("/auctions")
public Response getAuctions(@QueryParam("country") String country) {
@@ -331,16 +309,13 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/lots
* Returns list of active lots
*/
/// GET /api/monitor/lots
/// Returns list of active lots
@GET
@Path("/lots")
public Response getActiveLots() {
try {
var lots = db.getActiveLots();
return Response.ok(lots).build();
return Response.ok(db.getActiveLots()).build();
} catch (Exception e) {
LOG.error("Failed to get lots", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
@@ -349,10 +324,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/lots/closing-soon
* Returns lots closing within specified minutes (default 30)
*/
/// GET /api/monitor/lots/closing-soon
/// Returns lots closing within specified minutes (default 30)
@GET
@Path("/lots/closing-soon")
public Response getLotsClosingSoon(@QueryParam("minutes") @DefaultValue("30") int minutes) {
@@ -376,16 +349,13 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/lots/{lotId}/images
* Returns images for a specific lot
*/
/// GET /api/monitor/lots/{lotId}/images
/// Returns images for a specific lot
@GET
@Path("/lots/{lotId}/images")
public Response getLotImages(@PathParam("lotId") int lotId) {
try {
var images = db.getImagesForLot(lotId);
return Response.ok(images).build();
return Response.ok(db.getImagesForLot(lotId)).build();
} catch (Exception e) {
LOG.error("Failed to get lot images", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
@@ -394,10 +364,8 @@ public class AuctionMonitorResource {
}
}
/**
* POST /api/monitor/test-notification
* Send a test notification
*/
/// POST /api/monitor/test-notification
/// Send a test notification
@POST
@Path("/test-notification")
public Response sendTestNotification(Map<String, String> request) {
@@ -417,10 +385,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/rate-limit/stats
* Returns HTTP rate limiting statistics for all hosts
*/
/// GET /api/monitor/rate-limit/stats
/// Returns HTTP rate limiting statistics for all hosts
@GET
@Path("/rate-limit/stats")
public Response getRateLimitStats() {
@@ -453,10 +419,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/rate-limit/stats/{host}
* Returns HTTP rate limiting statistics for a specific host
*/
/// GET /api/monitor/rate-limit/stats/{host}
/// Returns HTTP rate limiting statistics for a specific host
@GET
@Path("/rate-limit/stats/{host}")
public Response getRateLimitStatsForHost(@PathParam("host") String host) {
@@ -487,10 +451,8 @@ public class AuctionMonitorResource {
.build();
}
}
/**
* GET /api/monitor/charts/country-distribution
* Returns dynamic country distribution for charts
*/
/// GET /api/monitor/charts/country-distribution
/// Returns dynamic country distribution for charts
@GET
@Path("/charts/country-distribution")
public Response getCountryDistribution() {
@@ -512,10 +474,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/charts/category-distribution
* Returns dynamic category distribution with intelligence for charts
*/
/// GET /api/monitor/charts/category-distribution
/// Returns dynamic category distribution with intelligence for charts
@GET
@Path("/charts/category-distribution")
public Response getCategoryDistribution() {
@@ -566,10 +526,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/charts/bidding-trend
* Returns time series data for last N hours
*/
/// GET /api/monitor/charts/bidding-trend
/// Returns time series data for last N hours
@GET
@Path("/charts/bidding-trend")
public Response getBiddingTrend(@QueryParam("hours") @DefaultValue("24") int hours) {
@@ -605,10 +563,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/charts/insights
* Returns intelligent insights
*/
/// GET /api/monitor/charts/insights
/// Returns intelligent insights
@GET
@Path("/charts/insights")
public Response getInsights() {
@@ -704,10 +660,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/intelligence/sleepers
* Returns "sleeper" lots (high watch count, low bids)
*/
/// GET /api/monitor/intelligence/sleepers
/// Returns "sleeper" lots (high watch count, low bids)
@GET
@Path("/intelligence/sleepers")
public Response getSleeperLots(@QueryParam("minFollowers") @DefaultValue("10") int minFollowers) {
@@ -731,10 +685,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/intelligence/bargains
* Returns lots priced below auction house estimates
*/
/// GET /api/monitor/intelligence/bargains
/// Returns lots priced below auction house estimates
@GET
@Path("/intelligence/bargains")
public Response getBargains() {
@@ -765,10 +717,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/intelligence/popular
* Returns lots by popularity level
*/
/// GET /api/monitor/intelligence/popular
/// Returns lots by popularity level
@GET
@Path("/intelligence/popular")
public Response getPopularLots(@QueryParam("level") @DefaultValue("HIGH") String level) {
@@ -798,10 +748,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/intelligence/price-analysis
* Returns price vs estimate analysis
*/
/// GET /api/monitor/intelligence/price-analysis
/// Returns price vs estimate analysis
@GET
@Path("/intelligence/price-analysis")
public Response getPriceAnalysis() {
@@ -838,10 +786,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/lots/{lotId}/intelligence
* Returns detailed intelligence for a specific lot
*/
/// GET /api/monitor/lots/{lotId}/intelligence
/// Returns detailed intelligence for a specific lot
@GET
@Path("/lots/{lotId}/intelligence")
public Response getLotIntelligence(@PathParam("lotId") long lotId) {
@@ -883,10 +829,8 @@ public class AuctionMonitorResource {
}
}
/**
* GET /api/monitor/charts/watch-distribution
* Returns follower/watch count distribution
*/
/// GET /api/monitor/charts/watch-distribution
/// Returns follower/watch count distribution
@GET
@Path("/charts/watch-distribution")
public Response getWatchDistribution() {