From 873f0b552f597bf4ee0947856f368c4f0c9d36e5 Mon Sep 17 00:00:00 2001 From: Don Strawsburg Date: Fri, 28 Nov 2025 23:13:08 -0500 Subject: [PATCH] more entities --- .../ballistic/model/AffiliateCategoryMap.java | 65 +++++++ .../goforward/ballistic/model/Brand.java | 11 ++ .../goforward/ballistic/model/FeedImport.java | 126 +++++++++++++ .../goforward/ballistic/model/Merchant.java | 93 ++++++++++ .../ballistic/model/PartCategory.java | 54 ++++++ .../ballistic/model/PriceHistory.java | 63 +++++++ .../goforward/ballistic/model/Product.java | 152 +++++++++++++++- .../ballistic/model/ProductCategory.java | 93 ++++++++++ .../ballistic/model/ProductOffer.java | 167 ++++++++++++++++++ 9 files changed, 820 insertions(+), 4 deletions(-) create mode 100644 src/main/java/group/goforward/ballistic/model/AffiliateCategoryMap.java create mode 100644 src/main/java/group/goforward/ballistic/model/FeedImport.java create mode 100644 src/main/java/group/goforward/ballistic/model/Merchant.java create mode 100644 src/main/java/group/goforward/ballistic/model/PartCategory.java create mode 100644 src/main/java/group/goforward/ballistic/model/PriceHistory.java create mode 100644 src/main/java/group/goforward/ballistic/model/ProductCategory.java create mode 100644 src/main/java/group/goforward/ballistic/model/ProductOffer.java diff --git a/src/main/java/group/goforward/ballistic/model/AffiliateCategoryMap.java b/src/main/java/group/goforward/ballistic/model/AffiliateCategoryMap.java new file mode 100644 index 0000000..3e623dc --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/AffiliateCategoryMap.java @@ -0,0 +1,65 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; + +@Entity +@Table(name = "affiliate_category_map") +public class AffiliateCategoryMap { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "feedname", nullable = false, length = 100) + private String feedname; + + @Column(name = "affiliatecategory", nullable = false) + private String affiliatecategory; + + @Column(name = "buildercategoryid", nullable = false) + private Integer buildercategoryid; + + @Column(name = "notes") + private String notes; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getFeedname() { + return feedname; + } + + public void setFeedname(String feedname) { + this.feedname = feedname; + } + + public String getAffiliatecategory() { + return affiliatecategory; + } + + public void setAffiliatecategory(String affiliatecategory) { + this.affiliatecategory = affiliatecategory; + } + + public Integer getBuildercategoryid() { + return buildercategoryid; + } + + public void setBuildercategoryid(Integer buildercategoryid) { + this.buildercategoryid = buildercategoryid; + } + + public String getNotes() { + return notes; + } + + public void setNotes(String notes) { + this.notes = notes; + } + +} \ No newline at end of file diff --git a/src/main/java/group/goforward/ballistic/model/Brand.java b/src/main/java/group/goforward/ballistic/model/Brand.java index cef5788..7a05dc9 100644 --- a/src/main/java/group/goforward/ballistic/model/Brand.java +++ b/src/main/java/group/goforward/ballistic/model/Brand.java @@ -34,6 +34,17 @@ public class Brand { @Column(name = "uuid") private UUID uuid; + @Column(name = "url", length = Integer.MAX_VALUE) + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + public Integer getId() { return id; } diff --git a/src/main/java/group/goforward/ballistic/model/FeedImport.java b/src/main/java/group/goforward/ballistic/model/FeedImport.java new file mode 100644 index 0000000..a117543 --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/FeedImport.java @@ -0,0 +1,126 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; +import org.hibernate.annotations.ColumnDefault; + +import java.time.OffsetDateTime; + +@Entity +@Table(name = "feed_imports") +public class FeedImport { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "merchant_id", nullable = false) + private Merchant merchant; + + @ColumnDefault("now()") + @Column(name = "started_at", nullable = false) + private OffsetDateTime startedAt; + + @Column(name = "finished_at") + private OffsetDateTime finishedAt; + + @Column(name = "rows_total") + private Integer rowsTotal; + + @Column(name = "rows_processed") + private Integer rowsProcessed; + + @Column(name = "rows_new") + private Integer rowsNew; + + @Column(name = "rows_updated") + private Integer rowsUpdated; + + @ColumnDefault("'running'") + @Column(name = "status", nullable = false, length = Integer.MAX_VALUE) + private String status; + + @Column(name = "error_message", length = Integer.MAX_VALUE) + private String errorMessage; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Merchant getMerchant() { + return merchant; + } + + public void setMerchant(Merchant merchant) { + this.merchant = merchant; + } + + public OffsetDateTime getStartedAt() { + return startedAt; + } + + public void setStartedAt(OffsetDateTime startedAt) { + this.startedAt = startedAt; + } + + public OffsetDateTime getFinishedAt() { + return finishedAt; + } + + public void setFinishedAt(OffsetDateTime finishedAt) { + this.finishedAt = finishedAt; + } + + public Integer getRowsTotal() { + return rowsTotal; + } + + public void setRowsTotal(Integer rowsTotal) { + this.rowsTotal = rowsTotal; + } + + public Integer getRowsProcessed() { + return rowsProcessed; + } + + public void setRowsProcessed(Integer rowsProcessed) { + this.rowsProcessed = rowsProcessed; + } + + public Integer getRowsNew() { + return rowsNew; + } + + public void setRowsNew(Integer rowsNew) { + this.rowsNew = rowsNew; + } + + public Integer getRowsUpdated() { + return rowsUpdated; + } + + public void setRowsUpdated(Integer rowsUpdated) { + this.rowsUpdated = rowsUpdated; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + +} \ No newline at end of file diff --git a/src/main/java/group/goforward/ballistic/model/Merchant.java b/src/main/java/group/goforward/ballistic/model/Merchant.java new file mode 100644 index 0000000..fe43897 --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/Merchant.java @@ -0,0 +1,93 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; +import org.hibernate.annotations.ColumnDefault; + +import java.time.OffsetDateTime; + +@Entity +@Table(name = "merchants") +public class Merchant { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "name", nullable = false, length = Integer.MAX_VALUE) + private String name; + + @Column(name = "avantlink_mid", nullable = false, length = Integer.MAX_VALUE) + private String avantlinkMid; + + @Column(name = "feed_url", nullable = false, length = Integer.MAX_VALUE) + private String feedUrl; + + @ColumnDefault("true") + @Column(name = "is_active", nullable = false) + private Boolean isActive = false; + + @ColumnDefault("now()") + @Column(name = "created_at", nullable = false) + private OffsetDateTime createdAt; + + @ColumnDefault("now()") + @Column(name = "updated_at", nullable = false) + private OffsetDateTime updatedAt; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAvantlinkMid() { + return avantlinkMid; + } + + public void setAvantlinkMid(String avantlinkMid) { + this.avantlinkMid = avantlinkMid; + } + + public String getFeedUrl() { + return feedUrl; + } + + public void setFeedUrl(String feedUrl) { + this.feedUrl = feedUrl; + } + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + +} \ No newline at end of file diff --git a/src/main/java/group/goforward/ballistic/model/PartCategory.java b/src/main/java/group/goforward/ballistic/model/PartCategory.java new file mode 100644 index 0000000..79cd38d --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/PartCategory.java @@ -0,0 +1,54 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; + +@Entity +@Table(name = "part_categories") +public class PartCategory { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "slug", nullable = false, length = Integer.MAX_VALUE) + private String slug; + + @Column(name = "name", nullable = false, length = Integer.MAX_VALUE) + private String name; + + @Column(name = "description", length = Integer.MAX_VALUE) + private String description; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getSlug() { + return slug; + } + + public void setSlug(String slug) { + this.slug = slug; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} \ No newline at end of file diff --git a/src/main/java/group/goforward/ballistic/model/PriceHistory.java b/src/main/java/group/goforward/ballistic/model/PriceHistory.java new file mode 100644 index 0000000..9f9eeb6 --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/PriceHistory.java @@ -0,0 +1,63 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; +import org.hibernate.annotations.ColumnDefault; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; + +@Entity +@Table(name = "price_history") +public class PriceHistory { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @OnDelete(action = OnDeleteAction.CASCADE) + @JoinColumn(name = "product_offer_id", nullable = false) + private ProductOffer productOffer; + + @Column(name = "price", nullable = false, precision = 10, scale = 2) + private BigDecimal price; + + @ColumnDefault("now()") + @Column(name = "recorded_at", nullable = false) + private OffsetDateTime recordedAt; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public ProductOffer getProductOffer() { + return productOffer; + } + + public void setProductOffer(ProductOffer productOffer) { + this.productOffer = productOffer; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public OffsetDateTime getRecordedAt() { + return recordedAt; + } + + public void setRecordedAt(OffsetDateTime recordedAt) { + this.recordedAt = recordedAt; + } + +} \ No newline at end of file diff --git a/src/main/java/group/goforward/ballistic/model/Product.java b/src/main/java/group/goforward/ballistic/model/Product.java index f5a2fcf..5c49905 100644 --- a/src/main/java/group/goforward/ballistic/model/Product.java +++ b/src/main/java/group/goforward/ballistic/model/Product.java @@ -1,9 +1,6 @@ package group.goforward.ballistic.model; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import jakarta.persistence.Table; +import jakarta.persistence.*; import org.hibernate.annotations.ColumnDefault; import java.math.BigDecimal; @@ -46,6 +43,153 @@ public class Product { @Column(name = "deleted_at") private Instant deletedAt; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "brand_id") + private Brand brand; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "part_category_id", nullable = false) + private PartCategory partCategory; + + @Column(name = "slug", nullable = false, length = Integer.MAX_VALUE) + private String slug; + + @Column(name = "caliber", length = Integer.MAX_VALUE) + private String caliber; + + @Column(name = "barrel_length_mm") + private Integer barrelLengthMm; + + @Column(name = "gas_system", length = Integer.MAX_VALUE) + private String gasSystem; + + @Column(name = "handguard_length_mm") + private Integer handguardLengthMm; + + @Column(name = "image_url", length = Integer.MAX_VALUE) + private String imageUrl; + + @Column(name = "spec_sheet_url", length = Integer.MAX_VALUE) + private String specSheetUrl; + + @Column(name = "msrp", precision = 10, scale = 2) + private BigDecimal msrp; + + @Column(name = "current_lowest_price", precision = 10, scale = 2) + private BigDecimal currentLowestPrice; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "current_lowest_merchant_id") + private Merchant currentLowestMerchant; + + @ColumnDefault("true") + @Column(name = "is_active", nullable = false) + private Boolean isActive = false; + + public Boolean getIsActive() { + return isActive; + } + + public void setIsActive(Boolean isActive) { + this.isActive = isActive; + } + + public Merchant getCurrentLowestMerchant() { + return currentLowestMerchant; + } + + public void setCurrentLowestMerchant(Merchant currentLowestMerchant) { + this.currentLowestMerchant = currentLowestMerchant; + } + + public BigDecimal getCurrentLowestPrice() { + return currentLowestPrice; + } + + public void setCurrentLowestPrice(BigDecimal currentLowestPrice) { + this.currentLowestPrice = currentLowestPrice; + } + + public BigDecimal getMsrp() { + return msrp; + } + + public void setMsrp(BigDecimal msrp) { + this.msrp = msrp; + } + + public String getSpecSheetUrl() { + return specSheetUrl; + } + + public void setSpecSheetUrl(String specSheetUrl) { + this.specSheetUrl = specSheetUrl; + } + + public String getImageUrl() { + return imageUrl; + } + + public void setImageUrl(String imageUrl) { + this.imageUrl = imageUrl; + } + + public Integer getHandguardLengthMm() { + return handguardLengthMm; + } + + public void setHandguardLengthMm(Integer handguardLengthMm) { + this.handguardLengthMm = handguardLengthMm; + } + + public String getGasSystem() { + return gasSystem; + } + + public void setGasSystem(String gasSystem) { + this.gasSystem = gasSystem; + } + + public Integer getBarrelLengthMm() { + return barrelLengthMm; + } + + public void setBarrelLengthMm(Integer barrelLengthMm) { + this.barrelLengthMm = barrelLengthMm; + } + + public String getCaliber() { + return caliber; + } + + public void setCaliber(String caliber) { + this.caliber = caliber; + } + + public String getSlug() { + return slug; + } + + public void setSlug(String slug) { + this.slug = slug; + } + + public PartCategory getPartCategory() { + return partCategory; + } + + public void setPartCategory(PartCategory partCategory) { + this.partCategory = partCategory; + } + + public Brand getBrand() { + return brand; + } + + public void setBrand(Brand brand) { + this.brand = brand; + } + public Integer getId() { return id; } diff --git a/src/main/java/group/goforward/ballistic/model/ProductCategory.java b/src/main/java/group/goforward/ballistic/model/ProductCategory.java new file mode 100644 index 0000000..c21d12c --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/ProductCategory.java @@ -0,0 +1,93 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; +import org.hibernate.annotations.ColumnDefault; + +import java.time.Instant; + +@Entity +@Table(name = "product_categories") +public class ProductCategory { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id", nullable = false) + private Integer id; + + @Column(name = "name", nullable = false, length = 100) + private String name; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_category_id") + private ProductCategory parentCategory; + + @Column(name = "type", length = 50) + private String type; + + @Column(name = "sort_order") + private Integer sortOrder; + + @ColumnDefault("now()") + @Column(name = "created_at") + private Instant createdAt; + + @ColumnDefault("now()") + @Column(name = "updated_at") + private Instant updatedAt; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ProductCategory getParentCategory() { + return parentCategory; + } + + public void setParentCategory(ProductCategory parentCategory) { + this.parentCategory = parentCategory; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getSortOrder() { + return sortOrder; + } + + public void setSortOrder(Integer sortOrder) { + this.sortOrder = sortOrder; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public Instant getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Instant updatedAt) { + this.updatedAt = updatedAt; + } + +} \ No newline at end of file diff --git a/src/main/java/group/goforward/ballistic/model/ProductOffer.java b/src/main/java/group/goforward/ballistic/model/ProductOffer.java new file mode 100644 index 0000000..64ec40b --- /dev/null +++ b/src/main/java/group/goforward/ballistic/model/ProductOffer.java @@ -0,0 +1,167 @@ +package group.goforward.ballistic.model; + +import jakarta.persistence.*; +import org.hibernate.annotations.ColumnDefault; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; + +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.UUID; + +@Entity +@Table(name = "product_offers") +public class ProductOffer { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", nullable = false) + private UUID id; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @OnDelete(action = OnDeleteAction.CASCADE) + @JoinColumn(name = "product_id", nullable = false) + private Product product; + + @ManyToOne(fetch = FetchType.LAZY, optional = false) + @JoinColumn(name = "merchant_id", nullable = false) + private Merchant merchant; + + @Column(name = "avantlink_product_id", nullable = false, length = Integer.MAX_VALUE) + private String avantlinkProductId; + + @Column(name = "sku", length = Integer.MAX_VALUE) + private String sku; + + @Column(name = "upc", length = Integer.MAX_VALUE) + private String upc; + + @Column(name = "buy_url", nullable = false, length = Integer.MAX_VALUE) + private String buyUrl; + + @Column(name = "price", nullable = false, precision = 10, scale = 2) + private BigDecimal price; + + @Column(name = "original_price", precision = 10, scale = 2) + private BigDecimal originalPrice; + + @ColumnDefault("'USD'") + @Column(name = "currency", nullable = false, length = Integer.MAX_VALUE) + private String currency; + + @ColumnDefault("true") + @Column(name = "in_stock", nullable = false) + private Boolean inStock = false; + + @ColumnDefault("now()") + @Column(name = "last_seen_at", nullable = false) + private OffsetDateTime lastSeenAt; + + @ColumnDefault("now()") + @Column(name = "first_seen_at", nullable = false) + private OffsetDateTime firstSeenAt; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } + + public Merchant getMerchant() { + return merchant; + } + + public void setMerchant(Merchant merchant) { + this.merchant = merchant; + } + + public String getAvantlinkProductId() { + return avantlinkProductId; + } + + public void setAvantlinkProductId(String avantlinkProductId) { + this.avantlinkProductId = avantlinkProductId; + } + + public String getSku() { + return sku; + } + + public void setSku(String sku) { + this.sku = sku; + } + + public String getUpc() { + return upc; + } + + public void setUpc(String upc) { + this.upc = upc; + } + + public String getBuyUrl() { + return buyUrl; + } + + public void setBuyUrl(String buyUrl) { + this.buyUrl = buyUrl; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public BigDecimal getOriginalPrice() { + return originalPrice; + } + + public void setOriginalPrice(BigDecimal originalPrice) { + this.originalPrice = originalPrice; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public Boolean getInStock() { + return inStock; + } + + public void setInStock(Boolean inStock) { + this.inStock = inStock; + } + + public OffsetDateTime getLastSeenAt() { + return lastSeenAt; + } + + public void setLastSeenAt(OffsetDateTime lastSeenAt) { + this.lastSeenAt = lastSeenAt; + } + + public OffsetDateTime getFirstSeenAt() { + return firstSeenAt; + } + + public void setFirstSeenAt(OffsetDateTime firstSeenAt) { + this.firstSeenAt = firstSeenAt; + } + +} \ No newline at end of file