datetime etc

This commit is contained in:
john 2025-05-04 23:22:30 +02:00
parent 0d7da2ea85
commit 59d660165f
7 changed files with 23 additions and 23 deletions

View file

@ -3,4 +3,4 @@ using JetBrains.Annotations;
namespace Femto.Api.Controllers.Authors.Dto;
[PublicAPI]
public record AuthorPostDto(Guid PostId, string Content, IEnumerable<Uri> Media, DateTime CreatedAt, AuthoPostAuthorDto Author );
public record AuthorPostDto(Guid PostId, string Content, IEnumerable<Uri> Media, DateTimeOffset CreatedAt, AuthoPostAuthorDto Author );

View file

@ -8,5 +8,5 @@ public record PublicPostDto(
Guid PostId,
string Content,
IEnumerable<Uri> Media,
DateTime CreatedAt
DateTimeOffset CreatedAt
);

View file

@ -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
);

View file

@ -1,3 +1,3 @@
namespace Femto.Modules.Blog.Domain.Posts.Commands.GetPosts.Dto;
public record PostDto(Guid PostId, string Text, IList<PostMediaDto> Media, DateTime CreatedAt, PostAuthorDto Author);
public record PostDto(Guid PostId, string Text, IList<PostMediaDto> Media, DateTimeOffset CreatedAt, PostAuthorDto Author);

View file

@ -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; }
}

View file

@ -7,6 +7,6 @@ public class PostCreatedIntegrationEventHandler : INotificationHandler<PostCreat
{
public async Task Handle(PostCreatedIntegrationEvent notification, CancellationToken cancellationToken)
{
throw new NotImplementedException();
// todo
}
}

View file

@ -6,14 +6,14 @@ namespace Femto.Modules.Media.Data;
internal class SavedBlob
{
public Guid Id { get; private set; }
public DateTime CreatedOn { get; private set; }
public DateTime UploadedOn { get; private set; }
public string Type { get; private set; }
public long? Size { get; private set; }
public SavedBlob(Guid id, string type, long? size)
{
Id = id;
CreatedOn = DateTime.UtcNow;
UploadedOn = DateTime.UtcNow;
Type = type;
Size = size;
}