0a9588abb7
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
45 lines
952 B
TypeScript
45 lines
952 B
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
ManyToOne,
|
|
JoinColumn,
|
|
} from 'typeorm';
|
|
import { SearchHistory } from './search-history.entity';
|
|
import { Tenant } from '../tenant/tenant.entity';
|
|
|
|
@Entity('chat_messages')
|
|
export class ChatMessage {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'search_history_id' })
|
|
searchHistoryId: string;
|
|
|
|
@Column({ name: 'tenant_id', nullable: true, type: 'text' })
|
|
tenantId: string;
|
|
|
|
@Column()
|
|
role: 'user' | 'assistant';
|
|
|
|
@Column('text')
|
|
content: string;
|
|
|
|
@Column({ nullable: true })
|
|
sources?: string; // JSON string
|
|
|
|
@CreateDateColumn({ name: 'created_at' })
|
|
createdAt: Date;
|
|
|
|
@ManyToOne(() => SearchHistory, (history) => history.messages, {
|
|
onDelete: 'CASCADE',
|
|
})
|
|
@JoinColumn({ name: 'search_history_id' })
|
|
searchHistory: SearchHistory;
|
|
|
|
@ManyToOne(() => Tenant)
|
|
@JoinColumn({ name: 'tenant_id' })
|
|
tenant: Tenant;
|
|
}
|