From 4c4c5c357eecdd5032371eb2614a08780ab96aac Mon Sep 17 00:00:00 2001 From: SquidSpirit Date: Tue, 14 Oct 2025 21:56:51 +0800 Subject: [PATCH] feat: make preview_image_url nullable across post-related DTOs and database schema --- .../delivery/create_post_request_dto.rs | 4 ++-- .../delivery/post_info_response_dto.rs | 2 +- .../delivery/update_post_request_dto.rs | 4 ++-- .../adapter/gateway/post_info_db_mapper.rs | 2 +- .../post/src/domain/entity/post_info.rs | 2 +- .../db/post_info_with_label_record.rs | 2 +- .../framework/db/post_with_label_record.rs | 2 +- ...9_make_preview_image_url_nullable.down.sql | 2 ++ ...133149_make_preview_image_url_nullable.sql | 2 ++ .../adapter/gateway/creatPostRequestDto.ts | 6 ++--- .../adapter/gateway/postInfoResponseDto.ts | 13 +++++++---- .../adapter/presenter/postInfoViewModel.ts | 15 ++++++++---- .../src/lib/post/domain/entity/postInfo.ts | 4 ++-- .../post/framework/ui/PostContentPage.svelte | 23 ++++++++++--------- .../lib/post/framework/ui/PostPreview.svelte | 10 ++++---- .../post/framework/ui/StructuredData.svelte | 4 ++-- 16 files changed, 56 insertions(+), 41 deletions(-) create mode 100644 backend/migrations/20251014133149_make_preview_image_url_nullable.down.sql create mode 100644 backend/migrations/20251014133149_make_preview_image_url_nullable.sql diff --git a/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs b/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs index 874c059..3a2856b 100644 --- a/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs +++ b/backend/feature/post/src/adapter/delivery/create_post_request_dto.rs @@ -12,8 +12,8 @@ pub struct CreatePostRequestDto { pub content: String, pub label_ids: Vec, - #[schema(format = Uri)] - pub preview_image_url: String, + #[schema(required, format = Uri)] + pub preview_image_url: Option, #[schema(required, format = DateTime)] pub published_time: Option, diff --git a/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs b/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs index bb83498..7553423 100644 --- a/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs +++ b/backend/feature/post/src/adapter/delivery/post_info_response_dto.rs @@ -14,7 +14,7 @@ pub struct PostInfoResponseDto { pub labels: Vec, #[schema(format = Uri)] - pub preview_image_url: String, + pub preview_image_url: Option, #[schema(format = DateTime)] pub published_time: Option, diff --git a/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs b/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs index 5f93c5f..b5e839b 100644 --- a/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs +++ b/backend/feature/post/src/adapter/delivery/update_post_request_dto.rs @@ -12,8 +12,8 @@ pub struct UpdatePostRequestDto { pub content: String, pub label_ids: Vec, - #[schema(format = Uri)] - pub preview_image_url: String, + #[schema(required, format = Uri)] + pub preview_image_url: Option, #[schema(required, format = DateTime)] pub published_time: Option, diff --git a/backend/feature/post/src/adapter/gateway/post_info_db_mapper.rs b/backend/feature/post/src/adapter/gateway/post_info_db_mapper.rs index 6663175..9478738 100644 --- a/backend/feature/post/src/adapter/gateway/post_info_db_mapper.rs +++ b/backend/feature/post/src/adapter/gateway/post_info_db_mapper.rs @@ -7,7 +7,7 @@ pub struct PostInfoMapper { pub semantic_id: String, pub title: String, pub description: String, - pub preview_image_url: String, + pub preview_image_url: Option, pub published_time: Option, pub labels: Vec, } diff --git a/backend/feature/post/src/domain/entity/post_info.rs b/backend/feature/post/src/domain/entity/post_info.rs index 922be11..3aebd5a 100644 --- a/backend/feature/post/src/domain/entity/post_info.rs +++ b/backend/feature/post/src/domain/entity/post_info.rs @@ -10,7 +10,7 @@ pub struct PostInfo { pub semantic_id: String, pub title: String, pub description: String, - pub preview_image_url: String, + pub preview_image_url: Option, pub labels: Vec