chore: cringed very hard
This commit is contained in:
@@ -11,7 +11,9 @@ namespace LctMonolith.Database.Data;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<Guid>, Guid>
|
public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<Guid>, Guid>
|
||||||
{
|
{
|
||||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) {
|
||||||
|
Database.EnsureCreated();
|
||||||
|
}
|
||||||
|
|
||||||
// Rank related entities
|
// Rank related entities
|
||||||
public DbSet<Rank> Ranks => Set<Rank>();
|
public DbSet<Rank> Ranks => Set<Rank>();
|
||||||
@@ -92,7 +94,7 @@ public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<Guid>, Guid>
|
|||||||
.WithMany(m => m.ChildMissions)
|
.WithMany(m => m.ChildMissions)
|
||||||
.HasForeignKey(m => m.ParentMissionId)
|
.HasForeignKey(m => m.ParentMissionId)
|
||||||
.IsRequired(false);
|
.IsRequired(false);
|
||||||
// Dialogue relationship for Mission
|
// Dialogue relationship for Mission (optional dialogue for a mission)
|
||||||
b.Entity<Mission>()
|
b.Entity<Mission>()
|
||||||
.HasOne(m => m.Dialogue)
|
.HasOne(m => m.Dialogue)
|
||||||
.WithOne(d => d.Mission)
|
.WithOne(d => d.Mission)
|
||||||
@@ -171,31 +173,28 @@ public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<Guid>, Guid>
|
|||||||
.WithMany(m => m.PlayerMissions)
|
.WithMany(m => m.PlayerMissions)
|
||||||
.HasForeignKey(pm => pm.MissionId);
|
.HasForeignKey(pm => pm.MissionId);
|
||||||
|
|
||||||
// Dialogue configurations
|
// Dialogue configurations (Mission required for Dialogue)
|
||||||
b.Entity<Dialogue>()
|
b.Entity<Dialogue>()
|
||||||
.HasOne(d => d.Mission)
|
.HasOne(d => d.Mission)
|
||||||
.WithOne(m => m.Dialogue)
|
.WithOne(m => m.Dialogue)
|
||||||
.HasForeignKey<Dialogue>(d => d.MissionId)
|
.HasForeignKey<Dialogue>(d => d.MissionId)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
// DialogueMessage configurations
|
// Dialogue -> DialogueMessage relationships (three distinct message slots)
|
||||||
b.Entity<DialogueMessage>()
|
b.Entity<Dialogue>()
|
||||||
.HasOne(dm => dm.InitialDialogue)
|
.HasOne(d => d.InitialDialogueMessage)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(dm => dm.InitialDialogueId)
|
.HasForeignKey(d => d.InitialDialogueMessageId)
|
||||||
.IsRequired(false)
|
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
b.Entity<DialogueMessage>()
|
b.Entity<Dialogue>()
|
||||||
.HasOne(dm => dm.InterimDialogue)
|
.HasOne(d => d.InterimDialogueMessage)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(dm => dm.InterimDialogueId)
|
.HasForeignKey(d => d.InterimDialogueMessageId)
|
||||||
.IsRequired(false)
|
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
b.Entity<DialogueMessage>()
|
b.Entity<Dialogue>()
|
||||||
.HasOne(dm => dm.EndDialogue)
|
.HasOne(d => d.EndDialogueMessage)
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(dm => dm.EndDialogueId)
|
.HasForeignKey(d => d.EndDialogueMessageId)
|
||||||
.IsRequired(false)
|
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
// DialogueMessageResponseOption configurations
|
// DialogueMessageResponseOption configurations
|
||||||
@@ -211,6 +210,18 @@ public class AppDbContext : IdentityDbContext<AppUser, IdentityRole<Guid>, Guid>
|
|||||||
.IsRequired(false)
|
.IsRequired(false)
|
||||||
.OnDelete(DeleteBehavior.Restrict);
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
// UserInventoryItem composite key & relationships
|
||||||
|
b.Entity<UserInventoryItem>()
|
||||||
|
.HasKey(ui => new { ui.UserId, ui.StoreItemId });
|
||||||
|
b.Entity<UserInventoryItem>()
|
||||||
|
.HasOne(ui => ui.User)
|
||||||
|
.WithMany(u => u.Inventory)
|
||||||
|
.HasForeignKey(ui => ui.UserId);
|
||||||
|
b.Entity<UserInventoryItem>()
|
||||||
|
.HasOne(ui => ui.StoreItem)
|
||||||
|
.WithMany(si => si.UserInventory)
|
||||||
|
.HasForeignKey(ui => ui.StoreItemId);
|
||||||
|
|
||||||
// Refresh token index unique
|
// Refresh token index unique
|
||||||
b.Entity<RefreshToken>().HasIndex(x => x.Token).IsUnique();
|
b.Entity<RefreshToken>().HasIndex(x => x.Token).IsUnique();
|
||||||
|
|
||||||
|
|||||||
@@ -12,36 +12,36 @@ public static class DbSeeder
|
|||||||
{
|
{
|
||||||
public static async Task SeedAsync(AppDbContext db, CancellationToken ct = default)
|
public static async Task SeedAsync(AppDbContext db, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
await db.Database.EnsureCreatedAsync(ct);
|
// await db.Database.EnsureCreatedAsync(ct);
|
||||||
|
//
|
||||||
if (!await db.Ranks.AnyAsync(ct))
|
// if (!await db.Ranks.AnyAsync(ct))
|
||||||
{
|
// {
|
||||||
var ranks = new List<Rank>
|
// var ranks = new List<Rank>
|
||||||
{
|
// {
|
||||||
new() { Title = "Искатель", ExpNeeded = 0 },
|
// new() { Title = "Искатель", ExpNeeded = 0 },
|
||||||
new() { Title = "Пилот-кандидат", ExpNeeded = 500 },
|
// new() { Title = "Пилот-кандидат", ExpNeeded = 500 },
|
||||||
new() { Title = "Принятый в экипаж", ExpNeeded = 1500 }
|
// new() { Title = "Принятый в экипаж", ExpNeeded = 1500 }
|
||||||
};
|
// };
|
||||||
db.Ranks.AddRange(ranks);
|
// db.Ranks.AddRange(ranks);
|
||||||
Log.Information("Seeded {Count} ranks", ranks.Count);
|
// Log.Information("Seeded {Count} ranks", ranks.Count);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!await db.Skills.AnyAsync(ct))
|
// if (!await db.Skills.AnyAsync(ct))
|
||||||
{
|
// {
|
||||||
var comps = new[]
|
// var comps = new[]
|
||||||
{
|
// {
|
||||||
"Вера в дело","Стремление к большему","Общение","Аналитика","Командование","Юриспруденция","Трёхмерное мышление","Базовая экономика","Основы аэронавигации"
|
// "Вера в дело","Стремление к большему","Общение","Аналитика","Командование","Юриспруденция","Трёхмерное мышление","Базовая экономика","Основы аэронавигации"
|
||||||
}.Select(n => new Skill { Title = n });
|
// }.Select(n => new Skill { Title = n });
|
||||||
db.Skills.AddRange(comps);
|
// db.Skills.AddRange(comps);
|
||||||
Log.Information("Seeded competencies");
|
// Log.Information("Seeded competencies");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (!await db.StoreItems.AnyAsync(ct))
|
// if (!await db.StoreItems.AnyAsync(ct))
|
||||||
{
|
// {
|
||||||
db.StoreItems.AddRange(new StoreItem { Name = "Футболка Алабуга", Price = 100 }, new StoreItem { Name = "Брелок Буран", Price = 50 });
|
// db.StoreItems.AddRange(new StoreItem { Name = "Футболка Алабуга", Price = 100 }, new StoreItem { Name = "Брелок Буран", Price = 50 });
|
||||||
Log.Information("Seeded store items");
|
// Log.Information("Seeded store items");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
await db.SaveChangesAsync(ct);
|
// await db.SaveChangesAsync(ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
|
||||||
USER $APP_UID
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 8081
|
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARG BUILD_CONFIGURATION=Release
|
ENV ASPNETCORE_URLS=http://+:8080
|
||||||
|
|
||||||
COPY ["LctMonolith/LctMonolith.csproj", "LctMonolith/"]
|
|
||||||
RUN dotnet restore "LctMonolith/LctMonolith.csproj"
|
|
||||||
USER app
|
USER app
|
||||||
WORKDIR "/src/LctMonolith"
|
|
||||||
RUN dotnet build "./LctMonolith.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
|
||||||
ARG configuration=Release
|
ARG configuration=Release
|
||||||
ARG BUILD_CONFIGURATION=Release
|
|
||||||
RUN dotnet publish "./LctMonolith.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
WORKDIR /src
|
||||||
|
|
||||||
COPY ["LctMonolith.csproj", "./"]
|
COPY ["LctMonolith.csproj", "./"]
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ public class Dialogue
|
|||||||
public required Mission Mission { get; set; }
|
public required Mission Mission { get; set; }
|
||||||
|
|
||||||
public Guid InitialDialogueMessageId { get; set; }
|
public Guid InitialDialogueMessageId { get; set; }
|
||||||
public Dialogue? InitialDialogueMessage { get; set; }
|
public DialogueMessage? InitialDialogueMessage { get; set; }
|
||||||
public Guid InterimDialogueMessageId { get; set; }
|
public Guid InterimDialogueMessageId { get; set; }
|
||||||
public Dialogue? InterimDialogueMessage { get; set; }
|
public DialogueMessage? InterimDialogueMessage { get; set; }
|
||||||
public Guid EndDialogueMessageId { get; set; }
|
public Guid EndDialogueMessageId { get; set; }
|
||||||
public Dialogue? EndDialogueMessage { get; set; }
|
public DialogueMessage? EndDialogueMessage { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,12 +16,5 @@ public class DialogueMessage
|
|||||||
public bool AllowMessageAi { get; set; }
|
public bool AllowMessageAi { get; set; }
|
||||||
public string MessageAiButtonText { get; set; } = string.Empty;
|
public string MessageAiButtonText { get; set; } = string.Empty;
|
||||||
|
|
||||||
public Guid InitialDialogueId { get; set; }
|
|
||||||
public Dialogue? InitialDialogue { get; set; }
|
|
||||||
public Guid InterimDialogueId { get; set; }
|
|
||||||
public Dialogue? InterimDialogue { get; set; }
|
|
||||||
public Guid EndDialogueId { get; set; }
|
|
||||||
public Dialogue? EndDialogue { get; set; }
|
|
||||||
|
|
||||||
public ICollection<DialogueMessageResponseOption> DialogueMessageResponseOptions = new List<DialogueMessageResponseOption>();
|
public ICollection<DialogueMessageResponseOption> DialogueMessageResponseOptions = new List<DialogueMessageResponseOption>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Host=localhost;Port=5432;Database=lct2025_dev;Username=postgres;Password=postgres"
|
"Default": "Host=postgres;Port=5432;Database=lct2025_dev;Username=postgres;Password=postgres"
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Key": "Dev_Insecure_Key_Change_Me",
|
"Key": "Dev_Insecure_Key_Change_Me",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"Default": "Host=localhost;Port=5432;Database=lct2025;Username=postgres;Password=postgres"
|
"Default": "Host=postgres;Port=5432;Database=lct2025;Username=postgres;Password=postgres"
|
||||||
},
|
},
|
||||||
"Jwt": {
|
"Jwt": {
|
||||||
"Key": "Dev_Insecure_Key_Change_Me",
|
"Key": "Dev_Insecure_Key_Change_Me",
|
||||||
|
|||||||
Reference in New Issue
Block a user