From 59d660165fa1a7915edb303bfc87844fe1cca3d7 Mon Sep 17 00:00:00 2001 From: john Date: Sun, 4 May 2025 23:22:30 +0200 Subject: [PATCH] datetime etc --- .../Controllers/Authors/Dto/AuthorPostDto.cs | 2 +- .../Controllers/Posts/Dto/PublicPostDto.cs | 2 +- .../Migrations/20250425121459_Init.sql | 28 +++++++++---------- .../Posts/Commands/GetPosts/Dto/PostDto.cs | 2 +- .../Commands/GetPosts/GetPostsQueryHandler.cs | 6 ++-- .../PostCreatedIntegrationEventHandler.cs | 2 +- Femto.Modules.Media/Data/SavedBlob.cs | 4 +-- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Femto.Api/Controllers/Authors/Dto/AuthorPostDto.cs b/Femto.Api/Controllers/Authors/Dto/AuthorPostDto.cs index 20837dc..7c62ede 100644 --- a/Femto.Api/Controllers/Authors/Dto/AuthorPostDto.cs +++ b/Femto.Api/Controllers/Authors/Dto/AuthorPostDto.cs @@ -3,4 +3,4 @@ using JetBrains.Annotations; namespace Femto.Api.Controllers.Authors.Dto; [PublicAPI] -public record AuthorPostDto(Guid PostId, string Content, IEnumerable Media, DateTime CreatedAt, AuthoPostAuthorDto Author ); \ No newline at end of file +public record AuthorPostDto(Guid PostId, string Content, IEnumerable Media, DateTimeOffset CreatedAt, AuthoPostAuthorDto Author ); \ No newline at end of file diff --git a/Femto.Api/Controllers/Posts/Dto/PublicPostDto.cs b/Femto.Api/Controllers/Posts/Dto/PublicPostDto.cs index 35e7dfc..8eeaecd 100644 --- a/Femto.Api/Controllers/Posts/Dto/PublicPostDto.cs +++ b/Femto.Api/Controllers/Posts/Dto/PublicPostDto.cs @@ -8,5 +8,5 @@ public record PublicPostDto( Guid PostId, string Content, IEnumerable Media, - DateTime CreatedAt + DateTimeOffset CreatedAt ); \ No newline at end of file diff --git a/Femto.Database/Migrations/20250425121459_Init.sql b/Femto.Database/Migrations/20250425121459_Init.sql index 037d76c..d89c301 100644 --- a/Femto.Database/Migrations/20250425121459_Init.sql +++ b/Femto.Database/Migrations/20250425121459_Init.sql @@ -11,10 +11,10 @@ CREATE TABLE blog.author CREATE TABLE blog.post ( - id uuid PRIMARY KEY, - content text NOT NULL, - created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - author_id uuid NOT NULL REFERENCES blog.author (id) on DELETE CASCADE + id uuid PRIMARY KEY, + content text NOT NULL, + posted_on timestamptz NOT NULL DEFAULT now(), + author_id uuid NOT NULL REFERENCES blog.author (id) on DELETE CASCADE ); CREATE TABLE blog.post_media @@ -31,23 +31,23 @@ CREATE TABLE blog.outbox ( id uuid PRIMARY KEY, - event_type text NOT NULL, - aggregate_id uuid NOT NULL, - payload jsonb NOT NULL, - created_at timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, + event_type text NOT NULL, + aggregate_id uuid NOT NULL, + payload jsonb NOT NULL, + created_at timestamp DEFAULT now() NOT NULL, processed_at timestamp, next_retry_at timestamp, - retry_count int DEFAULT 0 NOT NULL, + retry_count int DEFAULT 0 NOT NULL, last_error text, - status outbox_status DEFAULT 'pending' NOT NULL + status outbox_status DEFAULT 'pending' NOT NULL ); CREATE SCHEMA media; CREATE TABLE media.saved_blob ( - id uuid PRIMARY KEY, - created_on timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, - type varchar(64) NOT NULL, - size int + id uuid PRIMARY KEY, + uploaded_on timestamp DEFAULT now() NOT NULL, + type varchar(64) NOT NULL, + size int ); \ No newline at end of file diff --git a/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/Dto/PostDto.cs b/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/Dto/PostDto.cs index 73ec8f3..765bb76 100644 --- a/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/Dto/PostDto.cs +++ b/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/Dto/PostDto.cs @@ -1,3 +1,3 @@ namespace Femto.Modules.Blog.Domain.Posts.Commands.GetPosts.Dto; -public record PostDto(Guid PostId, string Text, IList Media, DateTime CreatedAt, PostAuthorDto Author); \ No newline at end of file +public record PostDto(Guid PostId, string Text, IList Media, DateTimeOffset CreatedAt, PostAuthorDto Author); \ No newline at end of file diff --git a/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/GetPostsQueryHandler.cs b/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/GetPostsQueryHandler.cs index 5b2eb50..896b2d1 100644 --- a/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/GetPostsQueryHandler.cs +++ b/Femto.Modules.Blog/Domain/Posts/Commands/GetPosts/GetPostsQueryHandler.cs @@ -40,7 +40,7 @@ public class GetPostsQueryHandler(IDbConnectionFactory connectionFactory) page.id as PostId, page.content as Content, blog.post_media.url as MediaUrl, - page.created_on as CreatedAt, + page.posted_on as PostedOn, page.Username, page.AuthorId from page @@ -76,7 +76,7 @@ public class GetPostsQueryHandler(IDbConnectionFactory connectionFactory) postId, post.Content, media, - post.CreatedAt, + post.PostedOn, new PostAuthorDto(post.AuthorId, post.Username) ); }) @@ -92,7 +92,7 @@ public class GetPostsQueryHandler(IDbConnectionFactory connectionFactory) public Guid PostId { get; set; } public string Content { get; set; } public string? MediaUrl { get; set; } - public DateTime CreatedAt { get; set; } + public DateTimeOffset PostedOn { get; set; } public Guid AuthorId { get; set; } public string Username { get; set; } } diff --git a/Femto.Modules.Blog/Handlers/PostCreatedIntegrationEventHandler.cs b/Femto.Modules.Blog/Handlers/PostCreatedIntegrationEventHandler.cs index 13f2ae1..cc4cb7f 100644 --- a/Femto.Modules.Blog/Handlers/PostCreatedIntegrationEventHandler.cs +++ b/Femto.Modules.Blog/Handlers/PostCreatedIntegrationEventHandler.cs @@ -7,6 +7,6 @@ public class PostCreatedIntegrationEventHandler : INotificationHandler