Split creators out of identity
This commit is contained in:
@@ -7,17 +7,50 @@ public class ContentDbContext(
|
||||
: DbContext(options)
|
||||
{
|
||||
public const string SchemaName = "Content";
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.HasDefaultSchema("Content");
|
||||
|
||||
|
||||
modelBuilder
|
||||
.Entity<Content>()
|
||||
.Property(c => c.CreatedAt)
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasDefaultValueSql("CURRENT_TIMESTAMP");
|
||||
|
||||
modelBuilder
|
||||
.Entity<Creator>()
|
||||
.OwnsOne<About>(x => x.About);
|
||||
|
||||
modelBuilder
|
||||
.Entity<Creator>()
|
||||
.OwnsOne<SocialNetworks>(x => x.SocialNetworks);
|
||||
|
||||
modelBuilder
|
||||
.Entity<Creator>()
|
||||
.OwnsOne<ProfileColors>(x => x.ProfileColors);
|
||||
|
||||
modelBuilder
|
||||
.Entity<Creator>()
|
||||
.OwnsOne<StoredDataUrls>(x => x.StoredDataUrls);
|
||||
}
|
||||
|
||||
public DbSet<Content> Contents { get; set; }
|
||||
public DbSet<Content> Contents { get; init; } = null!;
|
||||
public DbSet<Creator> Creators { get; init; } = null!;
|
||||
|
||||
|
||||
public async Task<Creator?> FindByCreatorAliasAsync(
|
||||
string creatorAlias,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
|
||||
|
||||
var user = await Creators.SingleOrDefaultAsync(creator =>
|
||||
EF.Functions.Like(
|
||||
creatorAlias,
|
||||
creator.Name),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
48
src/Web/Features/Contents/Data/Creator.cs
Normal file
48
src/Web/Features/Contents/Data/Creator.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Data;
|
||||
|
||||
public class Creator
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid CreatedBy { get; init; }
|
||||
public DateTimeOffset CreatedAt { get; init; }
|
||||
[MaxLength(255)] public string Name { get; set; } = null!;
|
||||
|
||||
public About About { get; set; } = new();
|
||||
public SocialNetworks SocialNetworks { get; set; } = new();
|
||||
public ProfileColors ProfileColors { get; set; } = new();
|
||||
public StoredDataUrls StoredDataUrls { get; set; } = new();
|
||||
}
|
||||
|
||||
public class About
|
||||
{
|
||||
[MaxLength(255)] public string? Title { get; set; }
|
||||
[MaxLength(255)] public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public class ProfileColors
|
||||
{
|
||||
[MaxLength(9)] public string? BannerTop { get; set; }
|
||||
[MaxLength(9)] public string? BannerBottom { get; set; }
|
||||
[MaxLength(9)] public string? Accent { get; set; }
|
||||
[MaxLength(9)] public string? Menu { get; set; }
|
||||
}
|
||||
|
||||
public class SocialNetworks
|
||||
{
|
||||
[MaxLength(255)] public string? FacebookUrl { get; set; }
|
||||
[MaxLength(255)] public string? InstagramUrl { get; set; }
|
||||
[MaxLength(255)] public string? XUrl { get; set; }
|
||||
[MaxLength(255)] public string? LinkedInUrl { get; set; }
|
||||
[MaxLength(255)] public string? TikTokUrl { get; set; }
|
||||
[MaxLength(255)] public string? YoutubeUrl { get; set; }
|
||||
[MaxLength(255)] public string? RedditUrl { get; set; }
|
||||
[MaxLength(255)] public string? WebsiteUrl { get; set; }
|
||||
}
|
||||
|
||||
public class StoredDataUrls
|
||||
{
|
||||
[MaxLength(255)] public string? BannerPictureUrl { get; set; }
|
||||
[MaxLength(255)] public string? ProfilePictureUrl { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user