Expose imported critical data in web app
This commit is contained in:
@@ -2,11 +2,32 @@ namespace RolemasterDb.App.Features;
|
||||
|
||||
public sealed record LookupOption(string Key, string Label);
|
||||
|
||||
public sealed record CriticalColumnReference(
|
||||
string Key,
|
||||
string Label,
|
||||
string Role,
|
||||
int SortOrder);
|
||||
|
||||
public sealed record CriticalGroupReference(
|
||||
string Key,
|
||||
string Label,
|
||||
int SortOrder);
|
||||
|
||||
public sealed record CriticalRollBandReference(
|
||||
string Label,
|
||||
int MinRoll,
|
||||
int? MaxRoll,
|
||||
int SortOrder);
|
||||
|
||||
public sealed record CriticalTableReference(
|
||||
string Key,
|
||||
string Label,
|
||||
IReadOnlyList<LookupOption> Columns,
|
||||
IReadOnlyList<LookupOption> Groups);
|
||||
string Family,
|
||||
string SourceDocument,
|
||||
string? Notes,
|
||||
IReadOnlyList<CriticalColumnReference> Columns,
|
||||
IReadOnlyList<CriticalGroupReference> Groups,
|
||||
IReadOnlyList<CriticalRollBandReference> RollBands);
|
||||
|
||||
public sealed record LookupReferenceData(
|
||||
IReadOnlyList<LookupOption> AttackTables,
|
||||
@@ -28,12 +49,23 @@ public sealed record CriticalLookupRequest(
|
||||
public sealed record CriticalLookupResponse(
|
||||
string CriticalType,
|
||||
string CriticalTableName,
|
||||
string CriticalFamily,
|
||||
string SourceDocument,
|
||||
string? TableNotes,
|
||||
string? Group,
|
||||
string? GroupLabel,
|
||||
string Column,
|
||||
string ColumnLabel,
|
||||
string ColumnRole,
|
||||
int Roll,
|
||||
string RollBand,
|
||||
int RollBandMinRoll,
|
||||
int? RollBandMaxRoll,
|
||||
string RawCellText,
|
||||
string Description,
|
||||
string? AffixText);
|
||||
string? AffixText,
|
||||
string ParseStatus,
|
||||
string ParsedJson);
|
||||
|
||||
public sealed record AttackLookupResponse(
|
||||
string AttackTable,
|
||||
|
||||
@@ -26,6 +26,7 @@ public sealed class LookupService(IDbContextFactory<RolemasterDbContext> dbConte
|
||||
.AsSplitQuery()
|
||||
.Include(item => item.Columns)
|
||||
.Include(item => item.Groups)
|
||||
.Include(item => item.RollBands)
|
||||
.OrderBy(item => item.DisplayName)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
@@ -35,8 +36,21 @@ public sealed class LookupService(IDbContextFactory<RolemasterDbContext> dbConte
|
||||
criticalTables.Select(item => new CriticalTableReference(
|
||||
item.Slug,
|
||||
item.DisplayName,
|
||||
item.Columns.OrderBy(column => column.SortOrder).Select(column => new LookupOption(column.ColumnKey, column.Label)).ToList(),
|
||||
item.Groups.OrderBy(group => group.SortOrder).Select(group => new LookupOption(group.GroupKey, group.Label)).ToList()))
|
||||
item.Family,
|
||||
item.SourceDocument,
|
||||
item.Notes,
|
||||
item.Columns
|
||||
.OrderBy(column => column.SortOrder)
|
||||
.Select(column => new CriticalColumnReference(column.ColumnKey, column.Label, column.Role, column.SortOrder))
|
||||
.ToList(),
|
||||
item.Groups
|
||||
.OrderBy(group => group.SortOrder)
|
||||
.Select(group => new CriticalGroupReference(group.GroupKey, group.Label, group.SortOrder))
|
||||
.ToList(),
|
||||
item.RollBands
|
||||
.OrderBy(rollBand => rollBand.SortOrder)
|
||||
.Select(rollBand => new CriticalRollBandReference(rollBand.Label, rollBand.MinRoll, rollBand.MaxRoll, rollBand.SortOrder))
|
||||
.ToList()))
|
||||
.ToList());
|
||||
}
|
||||
|
||||
@@ -102,12 +116,23 @@ public sealed class LookupService(IDbContextFactory<RolemasterDbContext> dbConte
|
||||
.Select(item => new CriticalLookupResponse(
|
||||
item.CriticalTable.Slug,
|
||||
item.CriticalTable.DisplayName,
|
||||
item.CriticalTable.Family,
|
||||
item.CriticalTable.SourceDocument,
|
||||
item.CriticalTable.Notes,
|
||||
item.CriticalGroup != null ? item.CriticalGroup.GroupKey : null,
|
||||
item.CriticalGroup != null ? item.CriticalGroup.Label : null,
|
||||
item.CriticalColumn.ColumnKey,
|
||||
item.CriticalColumn.Label,
|
||||
item.CriticalColumn.Role,
|
||||
request.Roll,
|
||||
item.CriticalRollBand.Label,
|
||||
item.CriticalRollBand.MinRoll,
|
||||
item.CriticalRollBand.MaxRoll,
|
||||
item.RawCellText,
|
||||
item.DescriptionText,
|
||||
item.RawAffixText))
|
||||
item.RawAffixText,
|
||||
item.ParseStatus,
|
||||
item.ParsedJson))
|
||||
.SingleOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user