Работа с подклассами
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+103
-2
@@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum;
|
||||
namespace Pf2eModel.Migrations
|
||||
{
|
||||
[DbContext(typeof(Pf2eDbContext))]
|
||||
[Migration("20250424112427_1")]
|
||||
[Migration("20250425111349_1")]
|
||||
partial class _1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -33,7 +33,7 @@ namespace Pf2eModel.Migrations
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell", "language" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "language" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" });
|
||||
@@ -1441,6 +1441,59 @@ namespace Pf2eModel.Migrations
|
||||
b.ToTable("spell_rituals", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("Additional")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("additional")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Extra")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("extra");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("group_id")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_subclasses");
|
||||
|
||||
b.HasIndex("GroupId")
|
||||
.HasDatabaseName("ix_subclasses_group_id");
|
||||
|
||||
b.ToTable("subclasses", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<int?>("ClassId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("class_id")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_subclass_groups");
|
||||
|
||||
b.HasIndex("ClassId")
|
||||
.HasDatabaseName("ix_subclass_groups_class_id");
|
||||
|
||||
b.ToTable("subclass_groups", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -2004,6 +2057,47 @@ namespace Pf2eModel.Migrations
|
||||
b.Navigation("Spell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Structure.SubclassGroup", "Group")
|
||||
.WithMany("Subclasses")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_subclasses_subclass_groups_group_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||
.WithOne()
|
||||
.HasForeignKey("Pf2eModel.Model.Structure.Subclass", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_subclasses_entities_id");
|
||||
|
||||
b.Navigation("Entity");
|
||||
|
||||
b.Navigation("Group");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Structure.Class", "Class")
|
||||
.WithMany("SubclassGroups")
|
||||
.HasForeignKey("ClassId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("fk_subclass_groups_classes_class_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||
.WithOne()
|
||||
.HasForeignKey("Pf2eModel.Model.Structure.SubclassGroup", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_subclass_groups_entities_id");
|
||||
|
||||
b.Navigation("Class");
|
||||
|
||||
b.Navigation("Entity");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||
@@ -2065,6 +2159,8 @@ namespace Pf2eModel.Migrations
|
||||
b.Navigation("ClassProgressions");
|
||||
|
||||
b.Navigation("ClassTrainings");
|
||||
|
||||
b.Navigation("SubclassGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Deity", b =>
|
||||
@@ -2093,6 +2189,11 @@ namespace Pf2eModel.Migrations
|
||||
|
||||
b.Navigation("SpellRitual");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b =>
|
||||
{
|
||||
b.Navigation("Subclasses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@ namespace Pf2eModel.Migrations
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_fonts", new[] { "none", "heal", "harm", "any" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "deity_sanctification", new[] { "holy", "unholy", "any" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_rarity", new[] { "common", "uncommon", "rare", "unique" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "condition", "deity", "feat", "heritage", "spell", "language" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "unknown", "trait", "action", "ancestry", "archetype", "background", "backpack", "campaign_feature", "class", "subclass_group", "subclass", "condition", "deity", "feat", "heritage", "spell", "language" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_action_type", new[] { "passive", "action", "reaction", "free" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "feat_category", new[] { "uncategorized", "ancestry-feature", "class-feature", "calling", "class", "skill", "general", "ancestry", "bonus", "deityboon", "curse", "pfsboon", "campaign-feature" });
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "locale_type", new[] { "english", "legacy_english", "russian", "legacy", "hobby", "other" });
|
||||
@@ -1438,6 +1438,59 @@ namespace Pf2eModel.Migrations
|
||||
b.ToTable("spell_rituals", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<string>("Additional")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("additional")
|
||||
.HasColumnOrder(3);
|
||||
|
||||
b.Property<string>("Extra")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("extra");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("group_id")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_subclasses");
|
||||
|
||||
b.HasIndex("GroupId")
|
||||
.HasDatabaseName("ix_subclasses_group_id");
|
||||
|
||||
b.ToTable("subclasses", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasColumnOrder(1);
|
||||
|
||||
b.Property<int?>("ClassId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("class_id")
|
||||
.HasColumnOrder(2);
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_subclass_groups");
|
||||
|
||||
b.HasIndex("ClassId")
|
||||
.HasDatabaseName("ix_subclass_groups_class_id");
|
||||
|
||||
b.ToTable("subclass_groups", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -2001,6 +2054,47 @@ namespace Pf2eModel.Migrations
|
||||
b.Navigation("Spell");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Subclass", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Structure.SubclassGroup", "Group")
|
||||
.WithMany("Subclasses")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_subclasses_subclass_groups_group_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||
.WithOne()
|
||||
.HasForeignKey("Pf2eModel.Model.Structure.Subclass", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_subclasses_entities_id");
|
||||
|
||||
b.Navigation("Entity");
|
||||
|
||||
b.Navigation("Group");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Structure.Class", "Class")
|
||||
.WithMany("SubclassGroups")
|
||||
.HasForeignKey("ClassId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.HasConstraintName("fk_subclass_groups_classes_class_id");
|
||||
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||
.WithOne()
|
||||
.HasForeignKey("Pf2eModel.Model.Structure.SubclassGroup", "Id")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_subclass_groups_entities_id");
|
||||
|
||||
b.Navigation("Class");
|
||||
|
||||
b.Navigation("Entity");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Trait", b =>
|
||||
{
|
||||
b.HasOne("Pf2eModel.Model.Base.Entity", "Entity")
|
||||
@@ -2062,6 +2156,8 @@ namespace Pf2eModel.Migrations
|
||||
b.Navigation("ClassProgressions");
|
||||
|
||||
b.Navigation("ClassTrainings");
|
||||
|
||||
b.Navigation("SubclassGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.Deity", b =>
|
||||
@@ -2090,6 +2186,11 @@ namespace Pf2eModel.Migrations
|
||||
|
||||
b.Navigation("SpellRitual");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Pf2eModel.Model.Structure.SubclassGroup", b =>
|
||||
{
|
||||
b.Navigation("Subclasses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,12 @@ public enum EntityType
|
||||
[PgName("class")]
|
||||
Class,
|
||||
|
||||
[PgName("subclass_group")]
|
||||
SubclassGroup,
|
||||
|
||||
[PgName("subclass")]
|
||||
Subclass,
|
||||
|
||||
[PgName("condition")]
|
||||
Condition,
|
||||
|
||||
|
||||
@@ -35,4 +35,6 @@ public partial class Class : IEntity
|
||||
public virtual ICollection<ClassProgression> ClassProgressions { get; set; } = [];
|
||||
|
||||
public virtual ICollection<ClassTraining> ClassTrainings { get; set; } = [];
|
||||
|
||||
public virtual ICollection<SubclassGroup> SubclassGroups { get; set; } = [];
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
[EntityOfType(EntityType.Subclass)]
|
||||
public class Subclass : IEntity
|
||||
{
|
||||
[Key]
|
||||
@@ -14,12 +16,12 @@ public class Subclass : IEntity
|
||||
public Entity Entity { get; set; } = null!;
|
||||
|
||||
[Column(Order = 2)]
|
||||
public int? ClassId { get; set; } = null;
|
||||
public int GroupId { get; set; }
|
||||
|
||||
public Class? Class { get; set; } = null!;
|
||||
public SubclassGroup Group { get; set; } = null!;
|
||||
|
||||
[Column(Order = 3)]
|
||||
public LocaleString Additional { get; set; } = null!;
|
||||
public LocaleString Additional { get; set; } = new();
|
||||
|
||||
public string Extra { get; set; } = null!;
|
||||
public string Extra { get; set; } = "{}";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure.ClassRelation;
|
||||
|
||||
namespace Pf2eModel.Model.Structure;
|
||||
|
||||
[EntityOfType(EntityType.SubclassGroup)]
|
||||
public class SubclassGroup : IEntity
|
||||
{
|
||||
[Key]
|
||||
[Column(Order = 1)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public Entity Entity { get; set; } = null!;
|
||||
|
||||
[Column(Order = 2)]
|
||||
public int? ClassId { get; set; } = null;
|
||||
|
||||
public Class? Class { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Subclass> Subclasses { get; set; } = [];
|
||||
}
|
||||
@@ -55,6 +55,10 @@ public partial class Pf2eDbContext : DbContext
|
||||
|
||||
public virtual DbSet<ClassTraining> ClassTrainings { get; set; }
|
||||
|
||||
public virtual DbSet<SubclassGroup> SubclassGroups { get; set; }
|
||||
|
||||
public virtual DbSet<Subclass> Subclasses { get; set; }
|
||||
|
||||
public virtual DbSet<Condition> Conditions { get; set; }
|
||||
|
||||
public virtual DbSet<Deity> Deities { get; set; }
|
||||
|
||||
@@ -309,6 +309,30 @@ public partial class Pf2eDbContext
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
});
|
||||
|
||||
// Subclass
|
||||
modelBuilder.Entity<SubclassGroup>(entity =>
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
entity
|
||||
.HasOne(g => g.Class)
|
||||
.WithMany(c => c.SubclassGroups)
|
||||
.HasForeignKey(g => g.ClassId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
modelBuilder.Entity<Subclass>(entity =>
|
||||
{
|
||||
BindEntity(entity);
|
||||
|
||||
BindLocaleString(entity, s => s.Additional);
|
||||
|
||||
entity
|
||||
.HasOne(s => s.Group)
|
||||
.WithMany(g => g.Subclasses)
|
||||
.HasForeignKey(s => s.GroupId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
// Condition
|
||||
modelBuilder.Entity<Condition>(entity =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user