feat: implement QuestionBank CRUD with pagination and template query

- 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
This commit is contained in:
Developer
2026-04-23 17:19:11 +08:00
commit 0a9588abb7
492 changed files with 112453 additions and 0 deletions
@@ -0,0 +1,46 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { FeishuBot } from './feishu-bot.entity';
@Entity('feishu_assessment_sessions')
export class FeishuAssessmentSession {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ name: 'bot_id' })
botId: string;
@Column({ name: 'open_id' })
openId: string;
@Column({ name: 'assessment_session_id' })
assessmentSessionId: string;
@Column({
type: 'varchar',
enum: ['active', 'completed', 'cancelled'],
default: 'active',
})
status: 'active' | 'completed' | 'cancelled';
@Column({ name: 'current_question_index', default: 0 })
currentQuestionIndex: number;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
// 关联关系
@ManyToOne(() => FeishuBot, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'bot_id' })
bot: FeishuBot;
}
@@ -0,0 +1,74 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { User } from '../../user/user.entity';
@Entity('feishu_bots')
export class FeishuBot {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ name: 'user_id' })
userId: string;
@Column({ name: 'tenant_id', nullable: true })
tenantId: string;
@ManyToOne(() => User, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'user_id' })
user: User;
@Column({ name: 'app_id', length: 64 })
appId: string;
@Column({ name: 'app_secret', length: 256 })
appSecret: string;
@Column({ name: 'tenant_access_token', nullable: true, type: 'text' })
tenantAccessToken: string;
@Column({ name: 'token_expires_at', nullable: true, type: 'datetime' })
tokenExpiresAt: Date;
@Column({ name: 'verification_token', nullable: true, length: 128 })
verificationToken: string;
@Column({ name: 'encrypt_key', nullable: true, length: 256 })
encryptKey: string;
@Column({ name: 'bot_name', nullable: true, length: 128 })
botName: string;
@Column({ default: true })
enabled: boolean;
@Column({ name: 'is_default', default: false })
isDefault: boolean;
@Column({ name: 'webhook_url', nullable: true, type: 'text' })
webhookUrl: string;
@Column({ name: 'use_web_socket', default: false })
useWebSocket: boolean;
@Column({ name: 'ws_connection_state', nullable: true, length: 32 })
wsConnectionState: string;
@Column({ name: 'knowledge_base_id', nullable: true, length: 36 })
knowledgeBaseId: string;
@Column({ name: 'knowledge_group_id', nullable: true, length: 36 })
knowledgeGroupId: string;
@CreateDateColumn({ name: 'created_at' })
createdAt: Date;
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}