add content

This commit is contained in:
liuyi 2025-05-19 12:39:06 +08:00
parent 34c4ac8f86
commit 6386c3f1b3
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,11 @@
export enum PostBodyType {
HTML = 'html',
MD = 'markdown',
}
export enum PostOrder {
CREATED = 'createdAt',
UPDATED = 'updatedAt',
PUBLISHED = 'publishedAt',
CUSTOM = 'custom',
}

View File

@ -0,0 +1,38 @@
import { Expose } from 'class-transformer';
import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm';
import { PostBodyType } from '@/modules/content/constants';
@Entity('content_posts')
export class PostEntity extends BaseEntity {
@PrimaryColumn({ type: 'varchar', generated: 'uuid', length: 36 })
id: string;
@Column({ comment: '文章标题' })
title: string;
@Column({ comment: '文章内容', type: 'text' })
body: string;
@Column({ comment: '文章描述', nullable: true })
summary?: string;
@Expose()
@Column({ comment: '关键字', type: 'simple-array', nullable: true })
keywords?: [];
@Column({ comment: '文章类型', type: 'varchar', enum: PostBodyType })
type: PostBodyType;
@Column({ comment: '发布时间', type: 'varchar', nullable: true })
publishedAt?: Date | null;
@Column({ comment: '自定义文章排序', default: 0 })
customOrder: number;
@Column({ comment: '创建时间' })
createdAt?: Date;
@Column({ comment: '更新时间' })
updatedAt?: Date;
}