mirror of
https://gitea.tendokyu.moe/Kayori/MedusaPluginChargeMachine.git
synced 2026-09-29 18:47:57 +03:00
Added Enum for ArticleType and Basic messages
This commit is contained in:
@@ -7,4 +7,15 @@ public class ChargeMachineDbContext(DbContextOptions<ChargeMachineDbContext> opt
|
||||
{
|
||||
public DbSet<ChargeHistory> ChargeHistories { get; set; }
|
||||
public DbSet<ArticleContent> ArticleContents { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
// Store ArticleType enum as its member name string (e.g. "DOCMT_0001") so the
|
||||
// value is human-readable in the DB and matches the wire protocol exactly.
|
||||
modelBuilder.Entity<ArticleContent>()
|
||||
.Property(a => a.ArticleType)
|
||||
.HasConversion<string>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,21 +41,29 @@ public class ChargeMachinePlugin : IMedusaPlugin
|
||||
if (await db.ArticleContents.AnyAsync())
|
||||
return;
|
||||
|
||||
// Order matches the enum table in gamemode.dll (0x2C160-0x2C228).
|
||||
// DOCMT_* = document text displayed on screen; URL_* = URLs/QR targets.
|
||||
// _A/_B variants = primary/secondary display; only 0001-0004 have both;
|
||||
// 0005-0008 exist only as _B (secondary).
|
||||
var defaults = new List<ArticleContent>
|
||||
{
|
||||
new() { ArticleType = "DOCMT_0000", ArticleDoc = "" },
|
||||
new() { ArticleType = "DOCMT_0001", ArticleDoc = "PASELI Charge Machine" },
|
||||
new() { ArticleType = "DOCMT_0002", ArticleDoc = "" },
|
||||
new() { ArticleType = "DOCMT_0003", ArticleDoc = "" },
|
||||
new() { ArticleType = "URL_0001_A", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0001_B", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0002_A", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0002_B", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0003_A", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0003_B", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0004_A", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "URL_0041_B", ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = "PASELIUNIT", ArticleDoc = "P" },
|
||||
new() { ArticleType = ArticleType.DOCMT_0001, ArticleDoc = "PASELI Charge Machine" },
|
||||
new() { ArticleType = ArticleType.DOCMT_0002, ArticleDoc = "Top up your PASELI balance to play." },
|
||||
new() { ArticleType = ArticleType.DOCMT_0003, ArticleDoc = "Charges are non-refundable. Ensure your card is registered before charging." },
|
||||
new() { ArticleType = ArticleType.URL_0001_A, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0001_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0002_A, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0002_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0003_A, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0003_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0004_A, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0004_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.PASELIUNIT, ArticleDoc = "P" },
|
||||
new() { ArticleType = ArticleType.DOCMT_0004, ArticleDoc = "For support, contact your arcade operator." },
|
||||
new() { ArticleType = ArticleType.URL_0005_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0006_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0007_B, ArticleDoc = "https://localhost:5173/" },
|
||||
new() { ArticleType = ArticleType.URL_0008_B, ArticleDoc = "https://localhost:5173/" },
|
||||
};
|
||||
|
||||
db.ArticleContents.AddRange(defaults);
|
||||
|
||||
@@ -5,6 +5,6 @@ namespace MedusaPluginChargeMachine.Entities;
|
||||
public class ArticleContent
|
||||
{
|
||||
[Key]
|
||||
public required string ArticleType { get; set; }
|
||||
public required ArticleType ArticleType { get; set; }
|
||||
public required string ArticleDoc { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace MedusaPluginChargeMachine.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// All article type keys used by the LA9 charge machine firmware (gamemode.dll 0x2C160).
|
||||
/// Member names are the exact strings stored in the DB and sent on the wire.
|
||||
/// DOCMT_* = on-screen document text; URL_* = URL/QR targets;
|
||||
/// 0001-0004 have both _A (primary) and _B (secondary) variants;
|
||||
/// 0005-0008 only have a _B variant.
|
||||
/// </summary>
|
||||
public enum ArticleType
|
||||
{
|
||||
DOCMT_0001,
|
||||
DOCMT_0002,
|
||||
DOCMT_0003,
|
||||
URL_0001_A,
|
||||
URL_0001_B,
|
||||
URL_0002_A,
|
||||
URL_0002_B,
|
||||
URL_0003_A,
|
||||
URL_0003_B,
|
||||
URL_0004_A,
|
||||
URL_0004_B,
|
||||
PASELIUNIT,
|
||||
DOCMT_0004,
|
||||
URL_0005_B,
|
||||
URL_0006_B,
|
||||
URL_0007_B,
|
||||
URL_0008_B,
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class GetConfigEaChargeHandler(ChargeMachineDbContext db) : Handler<Empty
|
||||
var articleList = articles
|
||||
.Select(a => new EaChargeConfigChargeArticleItem
|
||||
{
|
||||
ArticleType = new XrpcString(a.ArticleType),
|
||||
ArticleType = new XrpcString(a.ArticleType.ToString()),
|
||||
ArticleDoc = new XrpcString(a.ArticleDoc)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using MedusaPluginChargeMachine;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MedusaPluginChargeMachine.Migrations
|
||||
{
|
||||
[DbContext(typeof(ChargeMachineDbContext))]
|
||||
[Migration("20260810081653_ArticleTypeEnumConversion")]
|
||||
partial class ArticleTypeEnumConversion
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.10");
|
||||
|
||||
modelBuilder.Entity("MedusaPluginChargeMachine.Entities.ArticleContent", b =>
|
||||
{
|
||||
b.Property<string>("ArticleType")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ArticleDoc")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("ArticleType");
|
||||
|
||||
b.ToTable("ArticleContents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("MedusaPluginChargeMachine.Entities.ChargeHistory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("CardId")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("ChargeAmount")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ChargeNum")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<DateTime>("OrderDate")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ChargeHistories");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace MedusaPluginChargeMachine.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ArticleTypeEnumConversion : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user