feat: add user submission functionality
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user