initial data model work

This commit is contained in:
Alan Moon 2025-02-26 13:04:50 -08:00
parent 3222c63fa6
commit 54307d7582
4 changed files with 38 additions and 0 deletions

View File

@ -30,6 +30,7 @@ public class DBContext : DbContext {
public DbSet<RatingRank> RatingRanks { get; set; } = null!; public DbSet<RatingRank> RatingRanks { get; set; } = null!;
public DbSet<UserMissionData> UserMissionData { get; set; } = null!; public DbSet<UserMissionData> UserMissionData { get; set; } = null!;
public DbSet<UserBadgeCompleteData> UserBadgesCompleted { get; set; } = null!; public DbSet<UserBadgeCompleteData> UserBadgesCompleted { get; set; } = null!;
public DbSet<UserBan> Bans { get; set; } = null!;
private readonly IOptions<ApiServerConfig> config; private readonly IOptions<ApiServerConfig> config;
@ -156,6 +157,9 @@ public class DBContext : DbContext {
builder.Entity<Viking>().HasMany(v => v.UserBadgesCompleted) builder.Entity<Viking>().HasMany(v => v.UserBadgesCompleted)
.WithOne(r => r.Viking); .WithOne(r => r.Viking);
builder.Entity<Viking>().HasMany(v => v.UserBans)
.WithOne(r => r.Viking);
// Dragons // Dragons
builder.Entity<Dragon>().HasOne(d => d.Viking) builder.Entity<Dragon>().HasOne(d => d.Viking)
.WithMany(e => e.Dragons) .WithMany(e => e.Dragons)
@ -301,5 +305,10 @@ public class DBContext : DbContext {
builder.Entity<UserBadgeCompleteData>().HasOne(r => r.Viking) builder.Entity<UserBadgeCompleteData>().HasOne(r => r.Viking)
.WithMany(v => v.UserBadgesCompleted) .WithMany(v => v.UserBadgesCompleted)
.HasForeignKey(r => r.VikingId); .HasForeignKey(r => r.VikingId);
// Bans
builder.Entity<UserBan>().HasOne(r => r.Viking)
.WithMany(e => e.UserBans)
.HasForeignKey(e => e.VikingId);
} }
} }

19
src/Model/UserBan.cs Normal file
View File

@ -0,0 +1,19 @@
using System;
using System.ComponentModel.DataAnnotations;
using sodoff.Schema;
namespace sodoff.Model;
public class UserBan
{
[Key]
public int Id { get; set; }
public int VikingId { get; set; }
public UserBanType UserBanType { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime? ExpiresOn { get; set; }
public virtual Viking? Viking { get; set; }
}

View File

@ -44,6 +44,7 @@ public class Viking {
public virtual Dragon? SelectedDragon { get; set; } public virtual Dragon? SelectedDragon { get; set; }
public virtual ICollection<UserMissionData> UserMissions { get; set; } = null!; public virtual ICollection<UserMissionData> UserMissions { get; set; } = null!;
public virtual ICollection<UserBadgeCompleteData> UserBadgesCompleted { get; set; } = null!; public virtual ICollection<UserBadgeCompleteData> UserBadgesCompleted { get; set; } = null!;
public virtual ICollection<UserBan> UserBans { get; set; } = null!;
public DateTime? CreationDate { get; set; } public DateTime? CreationDate { get; set; }
public DateTime? BirthDate { get; set; } public DateTime? BirthDate { get; set; }

View File

@ -0,0 +1,9 @@
namespace sodoff.Schema;
public enum UserBanType
{
IndefiniteOpenChatBan = 1,
TemporaryOpenChatBan = 2,
IndefiniteAccountBan = 3,
TemporaryAccountBan = 4
}