feat:生文
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
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[];
|
||||
}
|
||||
Reference in New Issue
Block a user