Files
platform-pipi/apps/api/src/modules/chars/sentence.entity.ts
T
2026-01-30 16:04:10 +08:00

53 lines
1.5 KiB
TypeScript

import {
Entity,
PrimaryGeneratedColumn,
Column,
OneToMany,
Index,
} from 'typeorm';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { CharacterSentence } from './character-sentence.entity';
@Entity('sentences')
export class Sentence {
@ApiProperty({ description: '句子ID', example: 1 })
@PrimaryGeneratedColumn({ type: 'bigint' })
id: number;
@ApiProperty({ description: '句子内容', example: '这是一个例句。' })
@Column({ type: 'text' })
@Index()
content: string;
@ApiPropertyOptional({
description: '翻译(英语句子需要)',
example: 'This is an example sentence.',
nullable: true,
})
@Column({ type: 'text', nullable: true })
translation: string | null;
@ApiPropertyOptional({
description: '音频文件路径',
example: '/audio/sentence1.mp3',
maxLength: 500,
nullable: true,
})
@Column({ type: 'varchar', length: 500, nullable: true, name: 'audio_path' })
audioPath: string | null;
@ApiPropertyOptional({
description: '来源(如教材名称)',
example: '人教版语文一年级上册',
maxLength: 100,
nullable: true,
})
@Column({ type: 'varchar', length: 100, nullable: true })
source: string | null;
@OneToMany(() => CharacterSentence, (characterSentence) => characterSentence.sentence, {
cascade: true,
})
characterSentences: CharacterSentence[];
}