49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { Expose } from 'class-transformer';
|
|
import {
|
|
Column,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
} from 'typeorm';
|
|
import { ContentAssetType } from '../../enums/content-asset-type.enum';
|
|
import { ContentRevisionEntity } from './content-revision.entity';
|
|
import { ContentEntity } from './content.entity';
|
|
import { AssetSource } from '../../enums/asset-source.enum';
|
|
|
|
@Entity('content_asset')
|
|
@Expose()
|
|
export class ContentAssetEntity {
|
|
@PrimaryGeneratedColumn()
|
|
id: number;
|
|
|
|
@Column({ name: 'content_id' })
|
|
contentId: number;
|
|
|
|
@Column({ name: 'revision_id' })
|
|
revisionId: number;
|
|
|
|
@Column({ name: 'asset_id', type: 'uuid' })
|
|
assetId: string;
|
|
|
|
@Column({ type: String, enum: ContentAssetType })
|
|
type: ContentAssetType;
|
|
|
|
@Column({ name: 'type_name', nullable: true })
|
|
typeName?: string;
|
|
|
|
@Column({ type: 'enum', enum: AssetSource, default: AssetSource.USER })
|
|
source: AssetSource;
|
|
|
|
@Column({ default: 0 })
|
|
index: number;
|
|
|
|
@ManyToOne(() => ContentEntity, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'content_id' })
|
|
content: ContentEntity;
|
|
|
|
@ManyToOne(() => ContentRevisionEntity, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'revision_id' })
|
|
revision: ContentRevisionEntity;
|
|
}
|