From e482a0726f2c0e5e0015aa47087ab320d854d3f8 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Sun, 22 Sep 2024 03:10:00 -0400 Subject: [PATCH] Remove creator's about, adds title. Remove extra content properties. Change creator's colors to materials palette. --- .../Contents/Data/ContentDbContext.cs | 4 - src/Web/Features/Contents/Data/Creator.cs | 22 +- .../Contents/Handlers/ChangeColors.cs | 78 +++-- .../{ChangeAbout.cs => ChangeTitle.cs} | 17 +- .../Contents/Handlers/CreateContent.cs | 2 - .../Features/Contents/Handlers/GetContent.cs | 2 - .../Contents/Handlers/GetContentsByCreator.cs | 2 - .../Contents/Handlers/GetCreatorByAlias.cs | 2 +- .../Contents/Handlers/GetFeaturedContents.cs | 2 - .../Contents/Handlers/GetFollowedContents.cs | 2 - .../Contents/Handlers/Models/ContentModel.cs | 2 - .../Contents/Handlers/Models/CreatorModel.cs | 2 +- ...9045548_UseMeterialColorSchema.Designer.cs | 320 +++++++++++++++++ .../20240919045548_UseMeterialColorSchema.cs | 144 ++++++++ ...919051151_NoMoreOptionalColors.Designer.cs | 330 ++++++++++++++++++ .../20240919051151_NoMoreOptionalColors.cs | 258 ++++++++++++++ ...22064815_RemovesAboutAddsTitle.Designer.cs | 310 ++++++++++++++++ .../20240922064815_RemovesAboutAddsTitle.cs | 43 +++ .../ContentDbContextModelSnapshot.cs | 70 ++-- src/Web/TestDataSeeder.cs | 171 +++++---- src/Web/Web.http | 26 +- 21 files changed, 1656 insertions(+), 153 deletions(-) rename src/Web/Features/Contents/Handlers/{ChangeAbout.cs => ChangeTitle.cs} (62%) create mode 100644 src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs create mode 100644 src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.cs create mode 100644 src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs create mode 100644 src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.cs create mode 100644 src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs create mode 100644 src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.cs diff --git a/src/Web/Features/Contents/Data/ContentDbContext.cs b/src/Web/Features/Contents/Data/ContentDbContext.cs index 478c576..11edff0 100644 --- a/src/Web/Features/Contents/Data/ContentDbContext.cs +++ b/src/Web/Features/Contents/Data/ContentDbContext.cs @@ -43,10 +43,6 @@ public class ContentDbContext( .Entity() .HasKey(s => new { s.CreatedBy, s.CreatorId }); - modelBuilder - .Entity() - .OwnsOne(x => x.About); - modelBuilder .Entity() .OwnsOne(x => x.Socials) diff --git a/src/Web/Features/Contents/Data/Creator.cs b/src/Web/Features/Contents/Data/Creator.cs index 75f5c50..c916cfb 100644 --- a/src/Web/Features/Contents/Data/Creator.cs +++ b/src/Web/Features/Contents/Data/Creator.cs @@ -9,24 +9,24 @@ public class Creator public DateTimeOffset CreatedAt { get; init; } [MaxLength(255)] public string Name { get; set; } = null!; - public About About { get; set; } = new(); + [MaxLength(255)] public string? Title { get; set; } public Socials Socials { get; set; } = new(); public Colors Colors { get; set; } = new(); public Images Images { get; set; } = new(); } -public class About -{ - [MaxLength(255)] public string? Title { get; set; } - [MaxLength(2048)] public string? Description { get; set; } -} - public class Colors { - [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; } + [MaxLength(9)] public string Primary { get; set; } = null!; + [MaxLength(9)] public string Secondary { get; set; } = null!; + [MaxLength(9)] public string Background { get; set; } = null!; + [MaxLength(9)] public string Surface { get; set; } = null!; + [MaxLength(9)] public string Error { get; set; } = null!; + [MaxLength(9)] public string OnPrimary { get; set; } = null!; + [MaxLength(9)] public string OnSecondary { get; set; } = null!; + [MaxLength(9)] public string OnBackground { get; set; } = null!; + [MaxLength(9)] public string OnSurface { get; set; } = null!; + [MaxLength(9)] public string OnError { get; set; } = null!; } public class Socials diff --git a/src/Web/Features/Contents/Handlers/ChangeColors.cs b/src/Web/Features/Contents/Handlers/ChangeColors.cs index db88aa3..0aa63d3 100644 --- a/src/Web/Features/Contents/Handlers/ChangeColors.cs +++ b/src/Web/Features/Contents/Handlers/ChangeColors.cs @@ -5,10 +5,16 @@ namespace Hutopy.Web.Features.Contents.Handlers; [PublicAPI] public record ChangeColorsRequest( Guid CreatorId, - string? BannerTop, - string? BannerBottom, - string? Accent, - string? Menu); + string Primary, + string Secondary, + string Background, + string Surface, + string Error, + string OnPrimary, + string OnSecondary, + string OnBackground, + string OnSurface, + string OnError); [PublicAPI] public sealed class ChangeColorsRequestValidator @@ -16,29 +22,55 @@ public sealed class ChangeColorsRequestValidator { public ChangeColorsRequestValidator() { - RuleFor(x => x.BannerTop) + RuleFor(x => x.Primary) .MinimumLength(4).WithMessage("The minimum value should be in the format #444") .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") - .When(x => x.BannerTop is not null); + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - RuleFor(x => x.BannerBottom) + RuleFor(x => x.Secondary) .MinimumLength(4).WithMessage("The minimum value should be in the format #444") .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") - .When(x => x.BannerBottom is not null); + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - RuleFor(x => x.Accent) + RuleFor(x => x.Background) .MinimumLength(4).WithMessage("The minimum value should be in the format #444") .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") - .When(x => x.Accent is not null); + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); - RuleFor(x => x.Menu) + RuleFor(x => x.Surface) .MinimumLength(4).WithMessage("The minimum value should be in the format #444") .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") - .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #") - .When(x => x.Menu is not null); + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.Error) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.OnPrimary) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.OnSecondary) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.OnBackground) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.OnSurface) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); + + RuleFor(x => x.OnError) + .MinimumLength(4).WithMessage("The minimum value should be in the format #444") + .MaximumLength(9).WithMessage("The maximum value should be in the format #11223344") + .Must(x => x.StartsWith('#')).WithMessage("The format should be a valid html color and start with #"); } } @@ -63,10 +95,16 @@ public class ChangeColorsHandler( c => c.Id == request.CreatorId, cancellationToken: ct); - creator.Colors.BannerTop = request.BannerTop; - creator.Colors.BannerBottom = request.BannerBottom; - creator.Colors.Accent = request.Accent; - creator.Colors.Menu = request.Menu; + creator.Colors.Primary = request.Primary; + creator.Colors.Secondary = request.Secondary; + creator.Colors.Background = request.Background; + creator.Colors.Surface = request.Surface; + creator.Colors.Error = request.Error; + creator.Colors.OnPrimary = request.OnPrimary; + creator.Colors.OnSecondary = request.OnSecondary; + creator.Colors.OnBackground = request.OnBackground; + creator.Colors.OnSurface = request.OnSurface; + creator.Colors.OnError = request.OnError; await context.SaveChangesAsync(ct); diff --git a/src/Web/Features/Contents/Handlers/ChangeAbout.cs b/src/Web/Features/Contents/Handlers/ChangeTitle.cs similarity index 62% rename from src/Web/Features/Contents/Handlers/ChangeAbout.cs rename to src/Web/Features/Contents/Handlers/ChangeTitle.cs index 662b4e6..16a357a 100644 --- a/src/Web/Features/Contents/Handlers/ChangeAbout.cs +++ b/src/Web/Features/Contents/Handlers/ChangeTitle.cs @@ -3,35 +3,32 @@ namespace Hutopy.Web.Features.Contents.Handlers; [PublicAPI] -public record ChangeAboutRequest( +public record ChangeTitleRequest( Guid CreatorId, - string? Title, - string? Description); + string? Title); [PublicAPI] -public class ChangeAboutHandler( +public class ChangeTitleHandler( ContentDbContext context) - : Endpoint + : Endpoint { public override void Configure() { - Post("/api/creators/{CreatorId}/about"); + Post("/api/creators/{CreatorId}/title"); Options(o => o.WithTags("Creators")); } public override async Task HandleAsync( - ChangeAboutRequest request, + ChangeTitleRequest request, CancellationToken ct) { var creator = await context .Creators - .Include(c => c.About) .SingleAsync( c => c.Id == request.CreatorId, cancellationToken: ct); - creator.About.Title = request.Title; - creator.About.Description = request.Description; + creator.Title = request.Title; await context.SaveChangesAsync(ct); diff --git a/src/Web/Features/Contents/Handlers/CreateContent.cs b/src/Web/Features/Contents/Handlers/CreateContent.cs index 3a0dd6f..e98f7f1 100644 --- a/src/Web/Features/Contents/Handlers/CreateContent.cs +++ b/src/Web/Features/Contents/Handlers/CreateContent.cs @@ -117,8 +117,6 @@ public sealed class PostContent( CreatedByName = c.Creator!.Name, CreatedByPortraitUrl = c.Creator.Images.Logo, CreatedAt = c.CreatedAt, - ColorMenu = c.Creator.Colors.Menu, - ColorAccent = c.Creator.Colors.Accent, DeletedBy = c.DeletedBy, DeletedAt = c.DeletedAt, Title = c.Title, diff --git a/src/Web/Features/Contents/Handlers/GetContent.cs b/src/Web/Features/Contents/Handlers/GetContent.cs index fc89f32..fddba07 100644 --- a/src/Web/Features/Contents/Handlers/GetContent.cs +++ b/src/Web/Features/Contents/Handlers/GetContent.cs @@ -35,8 +35,6 @@ public class GetContent( CreatedByName = c.Creator!.Name, CreatedByPortraitUrl = c.Creator.Images.Logo, CreatedAt = c.CreatedAt, - ColorMenu = c.Creator.Colors.Menu, - ColorAccent = c.Creator.Colors.Accent, DeletedBy = c.DeletedBy, DeletedAt = c.DeletedAt, Title = c.Title, diff --git a/src/Web/Features/Contents/Handlers/GetContentsByCreator.cs b/src/Web/Features/Contents/Handlers/GetContentsByCreator.cs index 33ce7ae..9689808 100644 --- a/src/Web/Features/Contents/Handlers/GetContentsByCreator.cs +++ b/src/Web/Features/Contents/Handlers/GetContentsByCreator.cs @@ -46,8 +46,6 @@ public class GetContentsByCreatorHandler( CreatedByName = c.Creator!.Name, CreatedByPortraitUrl = c.Creator.Images.Logo, CreatedAt = c.CreatedAt, - ColorMenu = c.Creator.Colors.Menu, - ColorAccent = c.Creator.Colors.Accent, DeletedBy = c.DeletedBy, DeletedAt = c.DeletedAt, Title = c.Title, diff --git a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs index 9d7c3f3..2a2b161 100644 --- a/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs +++ b/src/Web/Features/Contents/Handlers/GetCreatorByAlias.cs @@ -59,7 +59,7 @@ public class GetCreatorByAliasHandler( creator.CreatedBy, creator.CreatedAt, creator.Name, - creator.About, + creator.Title, creator.Socials, creator.Colors, creator.Images, diff --git a/src/Web/Features/Contents/Handlers/GetFeaturedContents.cs b/src/Web/Features/Contents/Handlers/GetFeaturedContents.cs index 6df55ad..0929503 100644 --- a/src/Web/Features/Contents/Handlers/GetFeaturedContents.cs +++ b/src/Web/Features/Contents/Handlers/GetFeaturedContents.cs @@ -45,8 +45,6 @@ public class GetFeaturedContentsHandler( CreatedByName = c.Creator!.Name, CreatedByPortraitUrl = c.Creator.Images.Logo, CreatedAt = c.CreatedAt, - ColorMenu = c.Creator.Colors.Menu, - ColorAccent = c.Creator.Colors.Accent, DeletedBy = c.DeletedBy, DeletedAt = c.DeletedAt, Title = c.Title, diff --git a/src/Web/Features/Contents/Handlers/GetFollowedContents.cs b/src/Web/Features/Contents/Handlers/GetFollowedContents.cs index aa80309..39de093 100644 --- a/src/Web/Features/Contents/Handlers/GetFollowedContents.cs +++ b/src/Web/Features/Contents/Handlers/GetFollowedContents.cs @@ -55,8 +55,6 @@ public class GetFollowedContentsHandler( CreatedByName = c.Creator!.Name, CreatedByPortraitUrl = c.Creator.Images.Logo, CreatedAt = c.CreatedAt, - ColorMenu = c.Creator.Colors.Menu, - ColorAccent = c.Creator.Colors.Accent, DeletedBy = c.DeletedBy, DeletedAt = c.DeletedAt, Title = c.Title, diff --git a/src/Web/Features/Contents/Handlers/Models/ContentModel.cs b/src/Web/Features/Contents/Handlers/Models/ContentModel.cs index d317529..d91b23f 100644 --- a/src/Web/Features/Contents/Handlers/Models/ContentModel.cs +++ b/src/Web/Features/Contents/Handlers/Models/ContentModel.cs @@ -7,8 +7,6 @@ public class ContentModel public required Guid CreatedBy { get; init; } public required string CreatedByName { get; init; } public required string? CreatedByPortraitUrl { get; init; } - public required string? ColorMenu { get; init; } - public required string? ColorAccent { get; init; } public required DateTimeOffset CreatedAt { get; init; } public Guid? DeletedBy { get; init; } public DateTimeOffset? DeletedAt { get; init; } diff --git a/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs b/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs index 5502231..83b7bd6 100644 --- a/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs +++ b/src/Web/Features/Contents/Handlers/Models/CreatorModel.cs @@ -8,7 +8,7 @@ public record struct CreatorModel( Guid CreatedBy, DateTimeOffset CreatedAt, string Name, - About About, + string? Title, Socials Socials, Colors Colors, Images Images, diff --git a/src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs b/src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs new file mode 100644 index 0000000..2a6f961 --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.Designer.cs @@ -0,0 +1,320 @@ +// +using System; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + [DbContext(typeof(ContentDbContext))] + [Migration("20240919045548_UseMeterialColorSchema")] + partial class UseMeterialColorSchema + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Content") + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Urls") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Contents", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Creators", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => + { + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatorId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("CreatedBy", "CreatorId"); + + b.HasIndex("CreatorId"); + + b.ToTable("Subscriptions", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => + { + b1.Property("ContentId") + .HasColumnType("uuid"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Reaction") + .HasColumnType("integer"); + + b1.Property("UserId") + .HasColumnType("uuid"); + + b1.Property("UserName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b1.HasKey("ContentId", "Id"); + + b1.ToTable("ContentReactions", "Content"); + + b1.WithOwner() + .HasForeignKey("ContentId"); + }); + + b.Navigation("Creator"); + + b.Navigation("Reactions"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Description") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b1.Property("Title") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Background") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Error") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnBackground") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnError") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnPrimary") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSecondary") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSurface") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Primary") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Secondary") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Surface") + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Colors", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Banner") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Logo") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Images", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("FacebookUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("InstagramUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("LinkedInUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("RedditUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("TikTokUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("WebsiteUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("XUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("YoutubeUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Socials", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.Navigation("About") + .IsRequired(); + + b.Navigation("Colors") + .IsRequired(); + + b.Navigation("Images") + .IsRequired(); + + b.Navigation("Socials") + .IsRequired(); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => + { + b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.cs b/src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.cs new file mode 100644 index 0000000..400104e --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240919045548_UseMeterialColorSchema.cs @@ -0,0 +1,144 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + /// + public partial class UseMeterialColorSchema : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Menu", + schema: "Content", + table: "Colors", + newName: "Surface"); + + migrationBuilder.RenameColumn( + name: "BannerTop", + schema: "Content", + table: "Colors", + newName: "Secondary"); + + migrationBuilder.RenameColumn( + name: "BannerBottom", + schema: "Content", + table: "Colors", + newName: "Primary"); + + migrationBuilder.RenameColumn( + name: "Accent", + schema: "Content", + table: "Colors", + newName: "OnSurface"); + + migrationBuilder.AddColumn( + name: "Background", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true); + + migrationBuilder.AddColumn( + name: "Error", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true); + + migrationBuilder.AddColumn( + name: "OnBackground", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true); + + migrationBuilder.AddColumn( + name: "OnError", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true); + + migrationBuilder.AddColumn( + name: "OnPrimary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true); + + migrationBuilder.AddColumn( + name: "OnSecondary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Background", + schema: "Content", + table: "Colors"); + + migrationBuilder.DropColumn( + name: "Error", + schema: "Content", + table: "Colors"); + + migrationBuilder.DropColumn( + name: "OnBackground", + schema: "Content", + table: "Colors"); + + migrationBuilder.DropColumn( + name: "OnError", + schema: "Content", + table: "Colors"); + + migrationBuilder.DropColumn( + name: "OnPrimary", + schema: "Content", + table: "Colors"); + + migrationBuilder.DropColumn( + name: "OnSecondary", + schema: "Content", + table: "Colors"); + + migrationBuilder.RenameColumn( + name: "Surface", + schema: "Content", + table: "Colors", + newName: "Menu"); + + migrationBuilder.RenameColumn( + name: "Secondary", + schema: "Content", + table: "Colors", + newName: "BannerTop"); + + migrationBuilder.RenameColumn( + name: "Primary", + schema: "Content", + table: "Colors", + newName: "BannerBottom"); + + migrationBuilder.RenameColumn( + name: "OnSurface", + schema: "Content", + table: "Colors", + newName: "Accent"); + } + } +} diff --git a/src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs b/src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs new file mode 100644 index 0000000..5793a13 --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.Designer.cs @@ -0,0 +1,330 @@ +// +using System; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + [DbContext(typeof(ContentDbContext))] + [Migration("20240919051151_NoMoreOptionalColors")] + partial class NoMoreOptionalColors + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Content") + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Urls") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Contents", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Creators", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => + { + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatorId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("CreatedBy", "CreatorId"); + + b.HasIndex("CreatorId"); + + b.ToTable("Subscriptions", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => + { + b1.Property("ContentId") + .HasColumnType("uuid"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Reaction") + .HasColumnType("integer"); + + b1.Property("UserId") + .HasColumnType("uuid"); + + b1.Property("UserName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b1.HasKey("ContentId", "Id"); + + b1.ToTable("ContentReactions", "Content"); + + b1.WithOwner() + .HasForeignKey("ContentId"); + }); + + b.Navigation("Creator"); + + b.Navigation("Reactions"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Description") + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b1.Property("Title") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Creators", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Background") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Error") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnBackground") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnError") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnPrimary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSecondary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSurface") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Primary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Secondary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Surface") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Colors", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Banner") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Logo") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Images", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("FacebookUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("InstagramUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("LinkedInUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("RedditUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("TikTokUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("WebsiteUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("XUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("YoutubeUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Socials", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.Navigation("About") + .IsRequired(); + + b.Navigation("Colors") + .IsRequired(); + + b.Navigation("Images") + .IsRequired(); + + b.Navigation("Socials") + .IsRequired(); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => + { + b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.cs b/src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.cs new file mode 100644 index 0000000..7af839e --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240919051151_NoMoreOptionalColors.cs @@ -0,0 +1,258 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + /// + public partial class NoMoreOptionalColors : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Surface", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Secondary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Primary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OnSurface", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OnSecondary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OnPrimary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OnError", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "OnBackground", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Error", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Background", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9, + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Surface", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "Secondary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "Primary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "OnSurface", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "OnSecondary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "OnPrimary", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "OnError", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "OnBackground", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "Error", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + + migrationBuilder.AlterColumn( + name: "Background", + schema: "Content", + table: "Colors", + type: "character varying(9)", + maxLength: 9, + nullable: true, + oldClrType: typeof(string), + oldType: "character varying(9)", + oldMaxLength: 9); + } + } +} diff --git a/src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs b/src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs new file mode 100644 index 0000000..5a5cb91 --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.Designer.cs @@ -0,0 +1,310 @@ +// +using System; +using Hutopy.Web.Features.Contents.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + [DbContext(typeof(ContentDbContext))] + [Migration("20240922064815_RemovesAboutAddsTitle")] + partial class RemovesAboutAddsTitle + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("Content") + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("DeletedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DeletedBy") + .HasColumnType("uuid"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2048) + .HasColumnType("character varying(2048)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b.Property("Urls") + .HasColumnType("text[]"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.ToTable("Contents", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b.HasKey("Id"); + + b.ToTable("Creators", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => + { + b.Property("CreatedBy") + .HasColumnType("uuid"); + + b.Property("CreatorId") + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("CreatedBy", "CreatorId"); + + b.HasIndex("CreatorId"); + + b.ToTable("Subscriptions", "Content"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Content", b => + { + b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Hutopy.Web.Features.Contents.Data.ContentReaction", "Reactions", b1 => + { + b1.Property("ContentId") + .HasColumnType("uuid"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b1.Property("Id")); + + b1.Property("Reaction") + .HasColumnType("integer"); + + b1.Property("UserId") + .HasColumnType("uuid"); + + b1.Property("UserName") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("character varying(128)"); + + b1.HasKey("ContentId", "Id"); + + b1.ToTable("ContentReactions", "Content"); + + b1.WithOwner() + .HasForeignKey("ContentId"); + }); + + b.Navigation("Creator"); + + b.Navigation("Reactions"); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => + { + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Background") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Error") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnBackground") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnError") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnPrimary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSecondary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSurface") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Primary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Secondary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Surface") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Colors", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Images", "Images", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("Banner") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("Logo") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Images", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.OwnsOne("Hutopy.Web.Features.Contents.Data.Socials", "Socials", b1 => + { + b1.Property("CreatorId") + .HasColumnType("uuid"); + + b1.Property("FacebookUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("InstagramUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("LinkedInUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("RedditUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("TikTokUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("WebsiteUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("XUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.Property("YoutubeUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + + b1.HasKey("CreatorId"); + + b1.ToTable("Socials", "Content"); + + b1.WithOwner() + .HasForeignKey("CreatorId"); + }); + + b.Navigation("Colors") + .IsRequired(); + + b.Navigation("Images") + .IsRequired(); + + b.Navigation("Socials") + .IsRequired(); + }); + + modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Subscription", b => + { + b.HasOne("Hutopy.Web.Features.Contents.Data.Creator", "Creator") + .WithMany() + .HasForeignKey("CreatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Creator"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.cs b/src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.cs new file mode 100644 index 0000000..ff88fb5 --- /dev/null +++ b/src/Web/Features/Contents/Migrations/20240922064815_RemovesAboutAddsTitle.cs @@ -0,0 +1,43 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hutopy.Web.Features.Contents.Migrations +{ + /// + public partial class RemovesAboutAddsTitle : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "About_Description", + schema: "Content", + table: "Creators"); + + migrationBuilder.RenameColumn( + name: "About_Title", + schema: "Content", + table: "Creators", + newName: "Title"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Title", + schema: "Content", + table: "Creators", + newName: "About_Title"); + + migrationBuilder.AddColumn( + name: "About_Description", + schema: "Content", + table: "Creators", + type: "character varying(2048)", + maxLength: 2048, + nullable: true); + } + } +} diff --git a/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs b/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs index a3d9e3f..f67224a 100644 --- a/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs +++ b/src/Web/Features/Contents/Migrations/ContentDbContextModelSnapshot.cs @@ -80,6 +80,10 @@ namespace Hutopy.Web.Features.Contents.Migrations .HasMaxLength(255) .HasColumnType("character varying(255)"); + b.Property("Title") + .HasMaxLength(255) + .HasColumnType("character varying(255)"); + b.HasKey("Id"); b.ToTable("Creators", "Content"); @@ -148,45 +152,58 @@ namespace Hutopy.Web.Features.Contents.Migrations modelBuilder.Entity("Hutopy.Web.Features.Contents.Data.Creator", b => { - b.OwnsOne("Hutopy.Web.Features.Contents.Data.About", "About", b1 => - { - b1.Property("CreatorId") - .HasColumnType("uuid"); - - b1.Property("Description") - .HasMaxLength(2048) - .HasColumnType("character varying(2048)"); - - b1.Property("Title") - .HasMaxLength(255) - .HasColumnType("character varying(255)"); - - b1.HasKey("CreatorId"); - - b1.ToTable("Creators", "Content"); - - b1.WithOwner() - .HasForeignKey("CreatorId"); - }); - b.OwnsOne("Hutopy.Web.Features.Contents.Data.Colors", "Colors", b1 => { b1.Property("CreatorId") .HasColumnType("uuid"); - b1.Property("Accent") + b1.Property("Background") + .IsRequired() .HasMaxLength(9) .HasColumnType("character varying(9)"); - b1.Property("BannerBottom") + b1.Property("Error") + .IsRequired() .HasMaxLength(9) .HasColumnType("character varying(9)"); - b1.Property("BannerTop") + b1.Property("OnBackground") + .IsRequired() .HasMaxLength(9) .HasColumnType("character varying(9)"); - b1.Property("Menu") + b1.Property("OnError") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnPrimary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSecondary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("OnSurface") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Primary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Secondary") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("character varying(9)"); + + b1.Property("Surface") + .IsRequired() .HasMaxLength(9) .HasColumnType("character varying(9)"); @@ -264,9 +281,6 @@ namespace Hutopy.Web.Features.Contents.Migrations .HasForeignKey("CreatorId"); }); - b.Navigation("About") - .IsRequired(); - b.Navigation("Colors") .IsRequired(); diff --git a/src/Web/TestDataSeeder.cs b/src/Web/TestDataSeeder.cs index 08c7bbf..b2f624f 100644 --- a/src/Web/TestDataSeeder.cs +++ b/src/Web/TestDataSeeder.cs @@ -49,7 +49,10 @@ internal class TestDataSeeder( creator.Id = creatorUser.Id; creator.CreatedBy = creator.Id; - await contentContext.Subscriptions.AddAsync(new() { CreatedBy = userA.Id, CreatorId = creator.Id }); + await contentContext.Subscriptions.AddAsync(new Subscription + { + CreatedBy = userA.Id, CreatorId = creator.Id + }); await contentContext.Creators.AddAsync(creator); var contents = GenerateContent(creator, 10); @@ -57,7 +60,9 @@ internal class TestDataSeeder( { var messages = GenerateMessages(content, 10); - var parentMessages = messages.Where((_, index) => index % 2 == 0).ToList(); + var parentMessages = messages.Where(( + _, + index) => index % 2 == 0).ToList(); foreach (var parentMessage in parentMessages) { _ = GenerateReplies(content, parentMessage, 10); @@ -68,7 +73,9 @@ internal class TestDataSeeder( } } - private List GenerateContent(Creator creator, int contentCount) + private List GenerateContent( + Creator creator, + int contentCount) { var currentDate = DateTimeOffset.UtcNow; @@ -97,7 +104,9 @@ internal class TestDataSeeder( return contents; } - private List GenerateMessages(Content content, int messageCount) + private List GenerateMessages( + Content content, + int messageCount) { var currentDate = content.CreatedAt; var messages = new List(); @@ -126,7 +135,10 @@ internal class TestDataSeeder( return messages; } - private List GenerateReplies(Content content, Message parent, int replyCount) + private List GenerateReplies( + Content content, + Message parent, + int replyCount) { var currentDate = parent.CreatedAt; var replies = new List(); @@ -157,7 +169,10 @@ internal class TestDataSeeder( return replies; } - private async Task CreateUserAsync(string name, string? portraitUrl, params string[] roles) + private async Task CreateUserAsync( + string name, + string? portraitUrl, + params string[] roles) { var user = new ApplicationUser { @@ -184,23 +199,28 @@ internal class TestDataSeeder( private readonly static Creator HutopyCreator = new() { Name = "hutopy", - About = new() + Title = "Page officielle", + Colors = new Colors { - Title = "Page officielle", - Description = "Site officiel pour Hutopy. Venez-nous-y retrouver avec tous vos fans!", - }, - Colors = new() - { - BannerTop = "#A30E79", BannerBottom = "#6B0065", Accent = "#23393B", Menu = "#53B93B", + Primary = "#A30E79", + Secondary = "#6B0065", + Background = "#53B93B", + Surface = "#23393B", + Error = "#B00020", + OnPrimary = "#ffffff", + OnSecondary = "#000000", + OnBackground = "#000000", + OnSurface = "#000000", + OnError = "#ffffff", }, Socials = - new() + new Socials { XUrl = "https://twitter.com/Hutopyinc", FacebookUrl = "https://www.facebook.com/Hutopy", InstagramUrl = "https://www.instagram.com/hutopy.inc/" }, - Images = new() + Images = new Images { Banner = "/images/usersmedia/HutopyProfile/banners/banner01.png", Logo = "/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png" @@ -210,15 +230,21 @@ internal class TestDataSeeder( private readonly static Creator ArpsCreator = new() { Name = "arps", - About = - new() - { - Title = "Page officielle", - Description = "Site officiel pour Arps. Venez-nous-y retrouver avec tous vos fans!", - }, - Colors = - new() { BannerTop = "#231F20", BannerBottom = "#231F20", Accent = "#272526", Menu = "#FFFFFF" }, - Socials = new() + Title = "Créateur de contenu", + Colors = new Colors + { + Primary = "#A30E79", + Secondary = "#6B0065", + Background = "#53B93B", + Surface = "#23393B", + Error = "#B00020", + OnPrimary = "#ffffff", + OnSecondary = "#000000", + OnBackground = "#000000", + OnSurface = "#000000", + OnError = "#ffffff", + }, + Socials = new Socials { FacebookUrl = "https://www.facebook.com/arps.company", InstagramUrl = "https://www.instagram.com/arps.co/", @@ -227,7 +253,7 @@ internal class TestDataSeeder( LinkedInUrl = "https://www.linkedin.com/in/mickael-simard-96079a90/", WebsiteUrl = "https://www.arps.ca/" }, - Images = new() + Images = new Images { Banner = "/images/usersmedia/ARPS/banners/bannerARPS01.png", Logo = "/images/usersmedia/ARPS/profilepictures/profileARPS.png" @@ -237,22 +263,27 @@ internal class TestDataSeeder( private readonly static Creator ChloeBeaugrandCreator = new() { Name = "chloebeaugrand", - About = new() + Title = "Page officielle", + Colors = new Colors { - Title = "Page officielle", - Description = "𝐿𝑎 𝑐𝑟𝑒́𝑎𝑡𝑖𝑣𝑖𝑡𝑒́ 𝑐’𝑒𝑠𝑡 𝑙’𝑖𝑛𝑡𝑒𝑙𝑙𝑖𝑔𝑒𝑛𝑐𝑒 𝑞𝑢𝑖 𝑠’𝑎𝑚𝑢𝑠𝑒!", - }, - Colors = new() - { - BannerTop = "#231F20", BannerBottom = "#272526", Accent = "#231F20", Menu = "#231F20", + Primary = "#A30E79", + Secondary = "#6B0065", + Background = "#53B93B", + Surface = "#23393B", + Error = "#B00020", + OnPrimary = "#ffffff", + OnSecondary = "#000000", + OnBackground = "#000000", + OnSurface = "#000000", + OnError = "#ffffff", }, Socials = - new() + new Socials { FacebookUrl = "https://www.facebook.com/chloegestionmedias", InstagramUrl = "https://www.instagram.com/chloe.photo_gms", }, - Images = new() + Images = new Images { Banner = "/images/usersmedia/chloebeaugrand/banners/bannerChloeBeaugrand01.png", Logo = "/images/usersmedia/chloebeaugrand/profilepictures/profileChloeBeaugrand01.png" @@ -262,24 +293,28 @@ internal class TestDataSeeder( private readonly static Creator GuillaumeMCreator = new() { Name = "guillaumem", - About = new() + Title = "Page officielle", + Colors = new Colors { - Title = "Page officielle", - Description = - "Mettre en lumière le côté humain des entrepreneurs. Chaque service, chaque produit est porteur d’une histoire, d’une passion, d’une vision unique. Mon objectif est de faire rayonner cette unicité, de créer des connexions authentiques entre ces entrepreneurs et leurs clients potentiels. Parce que derrière chaque entreprise, il y a des personnes inspirantes qui méritent d’être entendues et comprises. Et toi, quel est ton objectif pour cette année?", - }, - Colors = new() - { - BannerTop = "#0BAAB2", BannerBottom = "#006D77", Accent = "#CC6F91", Menu = "#CC6F91", + Primary = "#A30E79", + Secondary = "#6B0065", + Background = "#53B93B", + Surface = "#23393B", + Error = "#B00020", + OnPrimary = "#ffffff", + OnSecondary = "#000000", + OnBackground = "#000000", + OnSurface = "#000000", + OnError = "#ffffff", }, Socials = - new() + new Socials { FacebookUrl = "https://www.facebook.com/GuillaumeMousseau222", InstagramUrl = "https://www.instagram.com/guillaumeaime/", TikTokUrl = "https://www.tiktok.com/@guillaumeaime" }, - Images = new() + Images = new Images { Banner = "/images/usersmedia/guillaumeMousseau/banners/bannerGuillaumeMousseau01.png", Logo = @@ -290,24 +325,28 @@ internal class TestDataSeeder( private readonly static Creator LeffetCreator = new() { Name = "leffet", - About = new() + Title = "Page officielle", + Colors = new Colors { - Title = "Page officielle", - Description = - "Mettre en lumière le côté humain des entrepreneurs. Chaque service, chaque produit est porteur d’une histoire, d’une passion, d’une vision unique. Mon objectif est de faire rayonner cette unicité, de créer des connexions authentiques entre ces entrepreneurs et leurs clients potentiels. Parce que derrière chaque entreprise, il y a des personnes inspirantes qui méritent d’être entendues et comprises. Et toi, quel est ton objectif pour cette année?", - }, - Colors = new() - { - BannerTop = "#CC6F91", BannerBottom = "#FBC702", Accent = "#FBC702", Menu = "#FBC702", + Primary = "#A30E79", + Secondary = "#6B0065", + Background = "#53B93B", + Surface = "#23393B", + Error = "#B00020", + OnPrimary = "#ffffff", + OnSecondary = "#000000", + OnBackground = "#000000", + OnSurface = "#000000", + OnError = "#ffffff", }, Socials = - new() + new Socials { FacebookUrl = "https://www.facebook.com/Hutopy", InstagramUrl = "https://www.instagram.com/guillaumeaime/", WebsiteUrl = "https://fondationleffet.ca/" }, - Images = new() + Images = new Images { Banner = "/images/usersmedia/leffet/banners/banner02.png", Logo = "/images/usersmedia/leffet/profilepictures/leffetProfile01.png" @@ -317,23 +356,27 @@ internal class TestDataSeeder( private readonly static Creator MathieuCaron = new() { Name = "mathieucaron", - About = new() + Title = "Page officielle", + Colors = new Colors { - Title = "Page officielle", - Description = - "Mettre en lumière le côté humain des entrepreneurs. Chaque service, chaque produit est porteur d’une histoire, d’une passion, d’une vision unique. Mon objectif est de faire rayonner cette unicité, de créer des connexions authentiques entre ces entrepreneurs et leurs clients potentiels. Parce que derrière chaque entreprise, il y a des personnes inspirantes qui méritent d’être entendues et comprises. Et toi, quel est ton objectif pour cette année?", - }, - Colors = new() - { - BannerTop = "#101B49", BannerBottom = "#698FE7", Accent = "#1D1D1B", Menu = "#1D1D1B", + Primary = "#A30E79", + Secondary = "#6B0065", + Background = "#53B93B", + Surface = "#23393B", + Error = "#B00020", + OnPrimary = "#ffffff", + OnSecondary = "#000000", + OnBackground = "#000000", + OnSurface = "#000000", + OnError = "#ffffff", }, Socials = - new() + new Socials { FacebookUrl = "https://www.facebook.com/MathieuCaronPro/", YoutubeUrl = "https://www.youtube.com/@lesinterviewsatypiquesdema4692", }, - Images = new() + Images = new Images { Banner = "/images/usersmedia/mathieuCaron/banners/bannerMathieuCaron01.png", Logo = "/images/usersmedia/mathieuCaron/profilepictures/profileMathieuCaron01.png" diff --git a/src/Web/Web.http b/src/Web/Web.http index 9f24562..acbc0c9 100644 --- a/src/Web/Web.http +++ b/src/Web/Web.http @@ -1,5 +1,5 @@ # For more info on HTTP files go to https://aka.ms/vs/httpfile -@Email=userA@test +@Email=hutopy@test @Password=Test123# @auth_token= @@ -23,7 +23,9 @@ Content-Type: application/json "password": "{{Password}}" } -> {% client.global.set("auth_token", response.body.accessToken); %} +> {% + client.global.set("auth_token", response.body.accessToken); +%} ### @@ -64,3 +66,23 @@ Authorization: Bearer {{auth_token}} ### # GET /api/contents/creator/{CreatorId} GET {{base_url}}/api/contents/creator/8590ba59-58a7-4466-bb50-08dcb5e47c6d/ + + +### +# GET /api/creators/{CreatorId}/colors +POST {{base_url}}/api/creators/8590ba59-58a7-4466-bb50-08dcb5e47c6d/colors/ +Authorization: Bearer {{auth_token}} +Content-Type: application/json + +{ + "Primary" : "#fffff0", + "Secondary" : "#fffff0", + "Background" : "#fffff0", + "Surface" : "#fffff0", + "Error" : "#fffff0", + "OnPrimary" : "#fffff0", + "OnSecondary" : "#fffff0", + "OnBackground" : "#fffff0", + "OnSurface" : "#fffff0", + "OnError" : "#fffff0" +} \ No newline at end of file