feat: add semanticId to PostInfo, PostInfoViewModel, and PostInfoResponseDto; update PostPreview link
This commit is contained in:
parent
6232105458
commit
898ee86f91
@ -4,6 +4,7 @@ import z from 'zod';
|
|||||||
|
|
||||||
export const PostInfoResponseSchema = z.object({
|
export const PostInfoResponseSchema = z.object({
|
||||||
id: z.int32(),
|
id: z.int32(),
|
||||||
|
semantic_id: z.string(),
|
||||||
title: z.string(),
|
title: z.string(),
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
preview_image_url: z.url(),
|
preview_image_url: z.url(),
|
||||||
@ -13,6 +14,7 @@ export const PostInfoResponseSchema = z.object({
|
|||||||
|
|
||||||
export class PostInfoResponseDto {
|
export class PostInfoResponseDto {
|
||||||
readonly id: number;
|
readonly id: number;
|
||||||
|
readonly semanticId: string;
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
readonly description: string;
|
readonly description: string;
|
||||||
readonly previewImageUrl: URL;
|
readonly previewImageUrl: URL;
|
||||||
@ -21,6 +23,7 @@ export class PostInfoResponseDto {
|
|||||||
|
|
||||||
private constructor(props: {
|
private constructor(props: {
|
||||||
id: number;
|
id: number;
|
||||||
|
semanticId: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
previewImageUrl: URL;
|
previewImageUrl: URL;
|
||||||
@ -28,6 +31,7 @@ export class PostInfoResponseDto {
|
|||||||
publishedTime: Date | null;
|
publishedTime: Date | null;
|
||||||
}) {
|
}) {
|
||||||
this.id = props.id;
|
this.id = props.id;
|
||||||
|
this.semanticId = props.semanticId;
|
||||||
this.title = props.title;
|
this.title = props.title;
|
||||||
this.description = props.description;
|
this.description = props.description;
|
||||||
this.previewImageUrl = props.previewImageUrl;
|
this.previewImageUrl = props.previewImageUrl;
|
||||||
@ -45,6 +49,7 @@ export class PostInfoResponseDto {
|
|||||||
|
|
||||||
return new PostInfoResponseDto({
|
return new PostInfoResponseDto({
|
||||||
id: parsedJson.id,
|
id: parsedJson.id,
|
||||||
|
semanticId: parsedJson.semantic_id,
|
||||||
title: parsedJson.title,
|
title: parsedJson.title,
|
||||||
description: parsedJson.description,
|
description: parsedJson.description,
|
||||||
previewImageUrl: new URL(parsedJson.preview_image_url),
|
previewImageUrl: new URL(parsedJson.preview_image_url),
|
||||||
@ -56,6 +61,7 @@ export class PostInfoResponseDto {
|
|||||||
toEntity(): PostInfo {
|
toEntity(): PostInfo {
|
||||||
return new PostInfo({
|
return new PostInfo({
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
semanticId: this.semanticId,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
previewImageUrl: this.previewImageUrl,
|
previewImageUrl: this.previewImageUrl,
|
||||||
|
@ -6,6 +6,7 @@ import type { PostInfo } from '$lib/post/domain/entity/postInfo';
|
|||||||
|
|
||||||
export class PostInfoViewModel {
|
export class PostInfoViewModel {
|
||||||
readonly id: number;
|
readonly id: number;
|
||||||
|
readonly semanticId: string;
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
readonly description: string;
|
readonly description: string;
|
||||||
readonly previewImageUrl: URL;
|
readonly previewImageUrl: URL;
|
||||||
@ -14,6 +15,7 @@ export class PostInfoViewModel {
|
|||||||
|
|
||||||
private constructor(props: {
|
private constructor(props: {
|
||||||
id: number;
|
id: number;
|
||||||
|
semanticId: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
previewImageUrl: URL;
|
previewImageUrl: URL;
|
||||||
@ -21,6 +23,7 @@ export class PostInfoViewModel {
|
|||||||
publishedTime: Date | null;
|
publishedTime: Date | null;
|
||||||
}) {
|
}) {
|
||||||
this.id = props.id;
|
this.id = props.id;
|
||||||
|
this.semanticId = props.semanticId;
|
||||||
this.title = props.title;
|
this.title = props.title;
|
||||||
this.description = props.description;
|
this.description = props.description;
|
||||||
this.previewImageUrl = props.previewImageUrl;
|
this.previewImageUrl = props.previewImageUrl;
|
||||||
@ -31,6 +34,7 @@ export class PostInfoViewModel {
|
|||||||
static fromEntity(postInfo: PostInfo): PostInfoViewModel {
|
static fromEntity(postInfo: PostInfo): PostInfoViewModel {
|
||||||
return new PostInfoViewModel({
|
return new PostInfoViewModel({
|
||||||
id: postInfo.id,
|
id: postInfo.id,
|
||||||
|
semanticId: postInfo.semanticId,
|
||||||
title: postInfo.title,
|
title: postInfo.title,
|
||||||
description: postInfo.description,
|
description: postInfo.description,
|
||||||
previewImageUrl: postInfo.previewImageUrl,
|
previewImageUrl: postInfo.previewImageUrl,
|
||||||
@ -47,6 +51,7 @@ export class PostInfoViewModel {
|
|||||||
|
|
||||||
return new PostInfoViewModel({
|
return new PostInfoViewModel({
|
||||||
id: props.id,
|
id: props.id,
|
||||||
|
semanticId: props.semanticId,
|
||||||
title: props.title,
|
title: props.title,
|
||||||
description: props.description,
|
description: props.description,
|
||||||
previewImageUrl: new URL(props.previewImageUrl),
|
previewImageUrl: new URL(props.previewImageUrl),
|
||||||
@ -66,6 +71,7 @@ export class PostInfoViewModel {
|
|||||||
dehydrate(): DehydratedPostInfoProps {
|
dehydrate(): DehydratedPostInfoProps {
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
semanticId: this.semanticId,
|
||||||
title: this.title,
|
title: this.title,
|
||||||
description: this.description,
|
description: this.description,
|
||||||
previewImageUrl: this.previewImageUrl.href,
|
previewImageUrl: this.previewImageUrl.href,
|
||||||
@ -77,6 +83,7 @@ export class PostInfoViewModel {
|
|||||||
|
|
||||||
export interface DehydratedPostInfoProps {
|
export interface DehydratedPostInfoProps {
|
||||||
id: number;
|
id: number;
|
||||||
|
semanticId: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
previewImageUrl: string;
|
previewImageUrl: string;
|
||||||
|
@ -2,6 +2,7 @@ import type { Label } from '$lib/post/domain/entity/label';
|
|||||||
|
|
||||||
export class PostInfo {
|
export class PostInfo {
|
||||||
readonly id: number;
|
readonly id: number;
|
||||||
|
readonly semanticId: string;
|
||||||
readonly title: string;
|
readonly title: string;
|
||||||
readonly description: string;
|
readonly description: string;
|
||||||
readonly previewImageUrl: URL;
|
readonly previewImageUrl: URL;
|
||||||
@ -10,6 +11,7 @@ export class PostInfo {
|
|||||||
|
|
||||||
constructor(props: {
|
constructor(props: {
|
||||||
id: number;
|
id: number;
|
||||||
|
semanticId: string;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
previewImageUrl: URL;
|
previewImageUrl: URL;
|
||||||
@ -17,6 +19,7 @@ export class PostInfo {
|
|||||||
publishedTime: Date | null;
|
publishedTime: Date | null;
|
||||||
}) {
|
}) {
|
||||||
this.id = props.id;
|
this.id = props.id;
|
||||||
|
this.semanticId = props.semanticId;
|
||||||
this.title = props.title;
|
this.title = props.title;
|
||||||
this.description = props.description;
|
this.description = props.description;
|
||||||
this.previewImageUrl = props.previewImageUrl;
|
this.previewImageUrl = props.previewImageUrl;
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a class="flex cursor-pointer flex-col gap-y-6" href="/post/{postInfo.id}" title={postInfo.title}>
|
<a class="flex cursor-pointer flex-col gap-y-6" href="/post/{postInfo.semanticId}" title={postInfo.title}>
|
||||||
<div class="relative aspect-video overflow-hidden rounded-2xl bg-gray-200">
|
<div class="relative aspect-video overflow-hidden rounded-2xl bg-gray-200">
|
||||||
<img
|
<img
|
||||||
class="rounded-2xl object-cover transition-opacity duration-300
|
class="rounded-2xl object-cover transition-opacity duration-300
|
||||||
|
Loading…
x
Reference in New Issue
Block a user