feat(leader-skin): shop catalog + 5 endpoints (/products, /buy, /buy_set, /buy_set_item, /ids)
Schema: LeaderSkinShopSeries -> Products (owned rewards) + owned SetCompletionRewards on the series; ViewerLeaderSkinSetClaim composite PK (ViewerId, SeriesId) backs the /buy_set_item idempotent-claim check. Importer mirrors SleeveShopImporter: idempotent find-or-create, owned collections rewritten wholesale on rerun. 16 series, 104 products. Controller (extends existing /set with 5 new endpoints): - /products: dict-keyed-by-series_id-string wire shape. is_completed per-viewer, rewards.status from ViewerLeaderSkinSetClaim (0=no set sale, 1=available, 2=claimed) matching client RewardStatus enum. - /buy: single skin, sales_type 1/2 dispatch, 3=>501. - /buy_set: whole series at SetPrice; requires set_sales_status != 0; grants every product's rewards (RewardGrantService idempotent on already-owned cosmetics, so partial-set buys don't double-add). - /buy_set_item: requires viewer owns every skin in series; idempotent on re-claim (returns 200 + empty reward_list, not 400) so client retries don't error. - /ids: flat owned-skin-id list for badge refresh. 496 tests pass (was 486; +10 leader-skin-shop tests). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
3627
SVSim.Database/Migrations/20260528024430_AddLeaderSkinShop.Designer.cs
generated
Normal file
3627
SVSim.Database/Migrations/20260528024430_AddLeaderSkinShop.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
155
SVSim.Database/Migrations/20260528024430_AddLeaderSkinShop.cs
Normal file
155
SVSim.Database/Migrations/20260528024430_AddLeaderSkinShop.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SVSim.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddLeaderSkinShop : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeaderSkinShopSeries",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false),
|
||||
IsNew = table.Column<bool>(type: "boolean", nullable: false),
|
||||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||
SetSalesStatus = table.Column<int>(type: "integer", nullable: false),
|
||||
SetPriceCrystal = table.Column<int>(type: "integer", nullable: true),
|
||||
SetPriceRupy = table.Column<int>(type: "integer", nullable: true),
|
||||
SetPriceTicket = table.Column<int>(type: "integer", nullable: true),
|
||||
SetPriceTicketId = table.Column<long>(type: "bigint", nullable: true),
|
||||
SetCompletionRewardStatus = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeaderSkinShopSeries", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ViewerLeaderSkinSetClaims",
|
||||
columns: table => new
|
||||
{
|
||||
ViewerId = table.Column<long>(type: "bigint", nullable: false),
|
||||
SeriesId = table.Column<int>(type: "integer", nullable: false),
|
||||
ClaimedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ViewerLeaderSkinSetClaims", x => new { x.ViewerId, x.SeriesId });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeaderSkinShopProducts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false),
|
||||
SeriesId = table.Column<int>(type: "integer", nullable: false),
|
||||
LeaderSkinId = table.Column<int>(type: "integer", nullable: false),
|
||||
ProductNameKey = table.Column<string>(type: "text", nullable: false),
|
||||
IntroductionKey = table.Column<string>(type: "text", nullable: false),
|
||||
CvNameKey = table.Column<string>(type: "text", nullable: false),
|
||||
SinglePriceCrystal = table.Column<int>(type: "integer", nullable: true),
|
||||
SinglePriceRupy = table.Column<int>(type: "integer", nullable: true),
|
||||
SinglePriceTicket = table.Column<int>(type: "integer", nullable: true),
|
||||
TicketNumber = table.Column<int>(type: "integer", nullable: true),
|
||||
TicketItemId = table.Column<long>(type: "bigint", nullable: true),
|
||||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||
DateCreated = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DateUpdated = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeaderSkinShopProducts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_LeaderSkinShopProducts_LeaderSkinShopSeries_SeriesId",
|
||||
column: x => x.SeriesId,
|
||||
principalTable: "LeaderSkinShopSeries",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeaderSkinShopSeriesRewardEntry",
|
||||
columns: table => new
|
||||
{
|
||||
LeaderSkinShopSeriesEntryId = table.Column<int>(type: "integer", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderIndex = table.Column<int>(type: "integer", nullable: false),
|
||||
RewardType = table.Column<int>(type: "integer", nullable: false),
|
||||
RewardDetailId = table.Column<long>(type: "bigint", nullable: false),
|
||||
RewardNumber = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeaderSkinShopSeriesRewardEntry", x => new { x.LeaderSkinShopSeriesEntryId, x.Id });
|
||||
table.ForeignKey(
|
||||
name: "FK_LeaderSkinShopSeriesRewardEntry_LeaderSkinShopSeries_Leader~",
|
||||
column: x => x.LeaderSkinShopSeriesEntryId,
|
||||
principalTable: "LeaderSkinShopSeries",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LeaderSkinShopProductRewardEntry",
|
||||
columns: table => new
|
||||
{
|
||||
LeaderSkinShopProductEntryId = table.Column<int>(type: "integer", nullable: false),
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
OrderIndex = table.Column<int>(type: "integer", nullable: false),
|
||||
RewardType = table.Column<int>(type: "integer", nullable: false),
|
||||
RewardDetailId = table.Column<long>(type: "bigint", nullable: false),
|
||||
RewardNumber = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LeaderSkinShopProductRewardEntry", x => new { x.LeaderSkinShopProductEntryId, x.Id });
|
||||
table.ForeignKey(
|
||||
name: "FK_LeaderSkinShopProductRewardEntry_LeaderSkinShopProducts_Lea~",
|
||||
column: x => x.LeaderSkinShopProductEntryId,
|
||||
principalTable: "LeaderSkinShopProducts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LeaderSkinShopProducts_SeriesId",
|
||||
table: "LeaderSkinShopProducts",
|
||||
column: "SeriesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ViewerLeaderSkinSetClaims_ViewerId",
|
||||
table: "ViewerLeaderSkinSetClaims",
|
||||
column: "ViewerId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeaderSkinShopProductRewardEntry");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeaderSkinShopSeriesRewardEntry");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ViewerLeaderSkinSetClaims");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeaderSkinShopProducts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LeaderSkinShopSeries");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1182,6 +1182,100 @@ namespace SVSim.Database.Migrations
|
||||
b.ToTable("LeaderSkins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopProductEntry", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("CvNameKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateUpdated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("IntroductionKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("LeaderSkinId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ProductNameKey")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("SeriesId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SinglePriceCrystal")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SinglePriceRupy")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SinglePriceTicket")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("TicketItemId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int?>("TicketNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SeriesId");
|
||||
|
||||
b.ToTable("LeaderSkinShopProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateUpdated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsNew")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("SetCompletionRewardStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SetPriceCrystal")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SetPriceRupy")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int?>("SetPriceTicket")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<long?>("SetPriceTicketId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("SetSalesStatus")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LeaderSkinShopSeries");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.LoadingExclusionCardEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@@ -2300,6 +2394,24 @@ namespace SVSim.Database.Migrations
|
||||
b.ToTable("ViewerEventCounters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerLeaderSkinSetClaim", b =>
|
||||
{
|
||||
b.Property<long>("ViewerId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("SeriesId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("ClaimedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("ViewerId", "SeriesId");
|
||||
|
||||
b.HasIndex("ViewerId");
|
||||
|
||||
b.ToTable("ViewerLeaderSkinSetClaims");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.ViewerMission", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
@@ -2714,6 +2826,86 @@ namespace SVSim.Database.Migrations
|
||||
b.Navigation("Class");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopProductEntry", b =>
|
||||
{
|
||||
b.HasOne("SVSim.Database.Models.LeaderSkinShopSeriesEntry", "Series")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("SeriesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.OwnsMany("SVSim.Database.Models.LeaderSkinShopProductRewardEntry", "Rewards", b1 =>
|
||||
{
|
||||
b1.Property<int>("LeaderSkinShopProductEntryId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property<int>("Id"));
|
||||
|
||||
b1.Property<int>("OrderIndex")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<long>("RewardDetailId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<int>("RewardNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("RewardType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.HasKey("LeaderSkinShopProductEntryId", "Id");
|
||||
|
||||
b1.ToTable("LeaderSkinShopProductRewardEntry");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("LeaderSkinShopProductEntryId");
|
||||
});
|
||||
|
||||
b.Navigation("Rewards");
|
||||
|
||||
b.Navigation("Series");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b =>
|
||||
{
|
||||
b.OwnsMany("SVSim.Database.Models.LeaderSkinShopSeriesRewardEntry", "SetCompletionRewards", b1 =>
|
||||
{
|
||||
b1.Property<int>("LeaderSkinShopSeriesEntryId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property<int>("Id"));
|
||||
|
||||
b1.Property<int>("OrderIndex")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<long>("RewardDetailId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b1.Property<int>("RewardNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.Property<int>("RewardType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b1.HasKey("LeaderSkinShopSeriesEntryId", "Id");
|
||||
|
||||
b1.ToTable("LeaderSkinShopSeriesRewardEntry");
|
||||
|
||||
b1.WithOwner()
|
||||
.HasForeignKey("LeaderSkinShopSeriesEntryId");
|
||||
});
|
||||
|
||||
b.Navigation("SetCompletionRewards");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.PackConfigEntry", b =>
|
||||
{
|
||||
b.OwnsMany("SVSim.Database.Models.PackBannerEntry", "Banners", b1 =>
|
||||
@@ -3396,6 +3588,11 @@ namespace SVSim.Database.Migrations
|
||||
b.Navigation("LeaderSkins");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.LeaderSkinShopSeriesEntry", b =>
|
||||
{
|
||||
b.Navigation("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SVSim.Database.Models.PuzzleGroupEntry", b =>
|
||||
{
|
||||
b.Navigation("Puzzles");
|
||||
|
||||
36
SVSim.Database/Models/LeaderSkinShopProductEntry.cs
Normal file
36
SVSim.Database/Models/LeaderSkinShopProductEntry.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using SVSim.Database.Common;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One purchasable leader-skin product. PK = wire product_id (small ints in captures — e.g. 31,
|
||||
/// 165, 166). FK <see cref="SeriesId"/>. <see cref="LeaderSkinId"/> points at the
|
||||
/// <see cref="LeaderSkinEntry"/> the buyer ends up owning.
|
||||
/// </summary>
|
||||
public class LeaderSkinShopProductEntry : BaseEntity<int>
|
||||
{
|
||||
public int SeriesId { get; set; }
|
||||
public int LeaderSkinId { get; set; }
|
||||
|
||||
/// <summary>SystemText keys — resolved client-side via Data.Master.GetLeaderSkinProductText.</summary>
|
||||
public string ProductNameKey { get; set; } = string.Empty;
|
||||
public string IntroductionKey { get; set; } = string.Empty;
|
||||
public string CvNameKey { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Per-product price for solo buy. Captures consistently show crystal/rupy parity for
|
||||
/// regular skins (500c / 500r single, 400 unit-price when bought as set). Nullable so
|
||||
/// promotions can offer one currency without the other.
|
||||
/// </summary>
|
||||
public int? SinglePriceCrystal { get; set; }
|
||||
public int? SinglePriceRupy { get; set; }
|
||||
public int? SinglePriceTicket { get; set; }
|
||||
public int? TicketNumber { get; set; }
|
||||
public long? TicketItemId { get; set; }
|
||||
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
public List<LeaderSkinShopProductRewardEntry> Rewards { get; set; } = new();
|
||||
|
||||
public LeaderSkinShopSeriesEntry? Series { get; set; }
|
||||
}
|
||||
17
SVSim.Database/Models/LeaderSkinShopProductRewardEntry.cs
Normal file
17
SVSim.Database/Models/LeaderSkinShopProductRewardEntry.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One per-buy reward attached to a leader-skin product. Owned by
|
||||
/// <see cref="LeaderSkinShopProductEntry"/>. Captures show each skin product bundles 3 rewards:
|
||||
/// the skin itself (type=10), the matching emblem (type=7), and the matching sleeve (type=6).
|
||||
/// </summary>
|
||||
[Owned]
|
||||
public class LeaderSkinShopProductRewardEntry
|
||||
{
|
||||
public int OrderIndex { get; set; }
|
||||
public int RewardType { get; set; } // Wizard.UserGoods.Type
|
||||
public long RewardDetailId { get; set; }
|
||||
public int RewardNumber { get; set; }
|
||||
}
|
||||
33
SVSim.Database/Models/LeaderSkinShopSeriesEntry.cs
Normal file
33
SVSim.Database/Models/LeaderSkinShopSeriesEntry.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using SVSim.Database.Common;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One leader-skin-shop series (a themed collection — e.g. "7th Anniversary Skins").
|
||||
/// PK = wire series_id. <see cref="SetSalesStatus"/> controls whether the per-series
|
||||
/// "buy whole set" UI is offered: 0=none (single-skin purchases only), non-zero=set sale active.
|
||||
/// When set-active, the set-price + set-completion-reward fields are populated.
|
||||
/// </summary>
|
||||
public class LeaderSkinShopSeriesEntry : BaseEntity<int>
|
||||
{
|
||||
public bool IsNew { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
/// <summary>SkinSeriesPurchaseInfo.eSetSalesStatus — 0=None.</summary>
|
||||
public int SetSalesStatus { get; set; }
|
||||
|
||||
public int? SetPriceCrystal { get; set; }
|
||||
public int? SetPriceRupy { get; set; }
|
||||
public int? SetPriceTicket { get; set; }
|
||||
public long? SetPriceTicketId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SkinSeriesPurchaseInfo.RewardStatus — 0=none. The per-VIEWER claim state is computed
|
||||
/// at request time from <see cref="ViewerLeaderSkinSetClaim"/>; this column is the catalog
|
||||
/// default surfaced when no viewer is in context (or when set_sales_status==0).
|
||||
/// </summary>
|
||||
public int SetCompletionRewardStatus { get; set; }
|
||||
|
||||
public List<LeaderSkinShopProductEntry> Products { get; set; } = new();
|
||||
public List<LeaderSkinShopSeriesRewardEntry> SetCompletionRewards { get; set; } = new();
|
||||
}
|
||||
18
SVSim.Database/Models/LeaderSkinShopSeriesRewardEntry.cs
Normal file
18
SVSim.Database/Models/LeaderSkinShopSeriesRewardEntry.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One set-completion bonus item attached to a leader-skin series. Owned by
|
||||
/// <see cref="LeaderSkinShopSeriesEntry"/>. Granted by /leader_skin/buy_set_item once the
|
||||
/// viewer owns every skin in the series. Wire shape: entries inside
|
||||
/// <c>rewards.items[]</c> on the per-series block of /leader_skin/products.
|
||||
/// </summary>
|
||||
[Owned]
|
||||
public class LeaderSkinShopSeriesRewardEntry
|
||||
{
|
||||
public int OrderIndex { get; set; }
|
||||
public int RewardType { get; set; }
|
||||
public long RewardDetailId { get; set; }
|
||||
public int RewardNumber { get; set; }
|
||||
}
|
||||
14
SVSim.Database/Models/ViewerLeaderSkinSetClaim.cs
Normal file
14
SVSim.Database/Models/ViewerLeaderSkinSetClaim.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One row per (viewer, leader-skin series) marking that the viewer has claimed the
|
||||
/// series-completion bonus via /leader_skin/buy_set_item. Composite PK (ViewerId, SeriesId).
|
||||
/// Standalone table (not a Viewer owned collection) to avoid the cartesian-explode pitfall
|
||||
/// when loading the viewer graph — claim state is checked per-series, not per-viewer-load.
|
||||
/// </summary>
|
||||
public class ViewerLeaderSkinSetClaim
|
||||
{
|
||||
public long ViewerId { get; set; }
|
||||
public int SeriesId { get; set; }
|
||||
public DateTime ClaimedAt { get; set; }
|
||||
}
|
||||
@@ -73,6 +73,9 @@ public class SVSimDbContext : DbContext
|
||||
public DbSet<SleeveShopSeriesEntry> SleeveShopSeries => Set<SleeveShopSeriesEntry>();
|
||||
public DbSet<SleeveShopProductEntry> SleeveShopProducts => Set<SleeveShopProductEntry>();
|
||||
public DbSet<ItemPurchaseCatalogEntry> ItemPurchaseCatalog => Set<ItemPurchaseCatalogEntry>();
|
||||
public DbSet<LeaderSkinShopSeriesEntry> LeaderSkinShopSeries => Set<LeaderSkinShopSeriesEntry>();
|
||||
public DbSet<LeaderSkinShopProductEntry> LeaderSkinShopProducts => Set<LeaderSkinShopProductEntry>();
|
||||
public DbSet<ViewerLeaderSkinSetClaim> ViewerLeaderSkinSetClaims => Set<ViewerLeaderSkinSetClaim>();
|
||||
public DbSet<MaintenanceCardEntry> MaintenanceCards => Set<MaintenanceCardEntry>();
|
||||
public DbSet<FeatureMaintenanceEntry> FeatureMaintenances => Set<FeatureMaintenanceEntry>();
|
||||
public DbSet<PreReleaseInfo> PreReleaseInfos => Set<PreReleaseInfo>();
|
||||
@@ -191,6 +194,21 @@ public class SVSimDbContext : DbContext
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<SleeveShopProductEntry>().HasIndex(p => p.SeriesId);
|
||||
|
||||
modelBuilder.Entity<LeaderSkinShopSeriesEntry>().OwnsMany(s => s.SetCompletionRewards);
|
||||
modelBuilder.Entity<LeaderSkinShopProductEntry>().OwnsMany(p => p.Rewards);
|
||||
modelBuilder.Entity<LeaderSkinShopProductEntry>()
|
||||
.HasOne(p => p.Series)
|
||||
.WithMany(s => s.Products)
|
||||
.HasForeignKey(p => p.SeriesId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
modelBuilder.Entity<LeaderSkinShopProductEntry>().HasIndex(p => p.SeriesId);
|
||||
|
||||
modelBuilder.Entity<ViewerLeaderSkinSetClaim>(b =>
|
||||
{
|
||||
b.HasKey(c => new { c.ViewerId, c.SeriesId });
|
||||
b.HasIndex(c => c.ViewerId);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CardCosmeticReward>(b =>
|
||||
{
|
||||
b.HasKey(r => new { r.CardId, r.Type, r.CosmeticId });
|
||||
|
||||
Reference in New Issue
Block a user