feat(scenario): add scenario and scenario step CRUD module
- add ScenarioEntity and ScenarioStepEntity with cascade delete
- step fields: type (login|exec), sessionName (required), execCode, validateCode
- login steps create a named session; exec steps consume it by sessionName
- full CRUD controller under /scenarios and /scenarios/:id/steps
- paginated GET /scenarios with page/limit query params returning { data, total, page, limit }
- register ScenarioModule and entities in AppModule
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
UpdateDateColumn,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm';
|
||||
import { ScenarioEntity } from './scenario.entity';
|
||||
|
||||
export type StepType = 'login' | 'exec';
|
||||
|
||||
@Entity('scenario_steps')
|
||||
export class ScenarioStepEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
scenarioId: number;
|
||||
|
||||
@ManyToOne(() => ScenarioEntity, (scenario) => scenario.steps, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'scenarioId' })
|
||||
scenario: ScenarioEntity;
|
||||
|
||||
@Column({ type: 'text' })
|
||||
type: StepType;
|
||||
|
||||
@Column({ type: 'text' })
|
||||
sessionName: string;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
execCode: string | null;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
validateCode: string | null;
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
updatedAt: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user