feat: add admin panel dto & validation

This commit is contained in:
2026-11-14 22:43:12 +03:30
parent 2d32e2679b
commit 8d6834f44c
18 changed files with 1832 additions and 52 deletions
@@ -69,6 +69,11 @@ export class Test extends BaseEntity {
@Column({ type: 'int', nullable: false, default: 0 })
questionsCount!: number;
// Published questionnaires have no versioned snapshots. Keep their structure
// immutable even after unpublishing, including for active guest sessions.
@Column({ type: 'boolean', default: false })
structureLocked!: boolean;
@OneToMany(() => ResultRange, (range) => range.test)
resultRanges!: Array<ResultRange>;
@@ -72,19 +72,21 @@ export class TestsCommandProvider {
}
const accessType = updateTestDto.accessType ?? test.accessType;
const price = updateTestDto.price ?? test.price;
const price =
updateTestDto.price !== undefined ? updateTestDto.price : test.price;
if (
(accessType === AccessType.PAID && !price) ||
(accessType !== AccessType.PAID && price)
(accessType === AccessType.PAID && price == null) ||
(accessType !== AccessType.PAID && price != null)
) {
throw new BadRequestException('tests.errors.priceAccessConstraint');
}
Object.assign(test, updateTestDto);
if (updateTestDto.status === TestStatus.PUBLISHED) {
if (test.status === TestStatus.PUBLISHED) {
await this.publishTestValidatorProvider.validate(test.id);
test.structureLocked = true;
}
try {