feat: add choices entity admin crud

This commit is contained in:
2026-06-17 11:11:26 +03:30
parent 0eea63fec1
commit 1e8036abca
31 changed files with 805 additions and 201 deletions
@@ -1,9 +1,4 @@
import {
BadRequestException,
HttpStatus,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { BadRequestException, HttpStatus, Injectable } from '@nestjs/common';
import { CreateTestDTO } from '../dtos/create-test.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { Test } from '../entities/test.entity';
@@ -49,7 +44,9 @@ export class TestsCommandProvider {
await this.testRepository.save(newTest);
return new AppResponse(
newTest,
this.i18nService.translate('tests.messages.createSuccess'),
this.i18nService.translate('common.messages.createSuccess', {
args: { entity: '$t(tests.fields.test)' },
}),
);
} catch (err) {
throw new AppTimeoutException(err);
@@ -60,7 +57,11 @@ export class TestsCommandProvider {
const test = await this.testRepository.findOneBy({ id });
if (!test) {
throw new NotFoundException('tests.errors.testNotFound');
throw new AppException(
'common.errors.entityNotFound',
HttpStatus.NOT_FOUND,
{ entity: '$t(tests.fields.test)' },
);
}
const accessType = updateTestDto.accessType ?? test.accessType;
@@ -91,7 +92,12 @@ export class TestsCommandProvider {
throw new AppTimeoutException(err);
}
if (!test) throw new NotFoundException('tests.errors.testNotFound');
if (!test)
throw new AppException(
'common.errors.entityNotFound',
HttpStatus.NOT_FOUND,
{ entity: '$t(tests.fields.test)' },
);
try {
await this.testRepository.delete(test.id);