feat: add user submission functionality

This commit is contained in:
2026-07-05 21:45:45 +03:30
parent afb5045cf0
commit 7b44542ce7
48 changed files with 1459 additions and 55 deletions
@@ -1,6 +1,6 @@
import { HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { FindOneOptions, Repository } from 'typeorm';
import { PaginatedResponse } from '@/common/responses';
import { AppTimeoutException } from '@/common/exceptions/app-timeout.exception';
import { FindTestsDTO } from '../dtos/find-tests.dto';
@@ -64,12 +64,27 @@ export class TestsQueryProvider {
}
}
public async findOneForAdmin(id: number) {
public async findOneForAdmin(id: number, options?: FindOneOptions<Test>) {
let test: Test | null = null;
try {
return await this.testRepository.findOneBy({ id });
test = await this.testRepository.findOne({
where: { id },
...options,
});
} catch (err) {
throw new AppTimeoutException(err);
}
if (!test) {
throw new AppException(
'common.errors.entityNotFound',
HttpStatus.NOT_FOUND,
{ entity: '$t(tests.fields.test)' },
);
}
return test;
}
public async findOneForUser(id: number) {