feat: complete publish test logic
This commit is contained in:
@@ -9,6 +9,8 @@ import { AppResponse } from '@/common/responses';
|
||||
import { AppTimeoutException } from '@/common/exceptions/app-timeout.exception';
|
||||
import { UpdateTestDTO } from '../dtos/update-test.dto';
|
||||
import { AccessType } from '../enums/access-types.enum';
|
||||
import { PublishTestValidatorProvider } from './publish-test-validator.provider';
|
||||
import { TestStatus } from '../enums/test-status.enum';
|
||||
|
||||
@Injectable()
|
||||
export class TestsCommandProvider {
|
||||
@@ -23,6 +25,11 @@ export class TestsCommandProvider {
|
||||
* Inject I18n Service
|
||||
*/
|
||||
private readonly i18nService: I18nService,
|
||||
|
||||
/**
|
||||
* Inject Publish Test Validator Provider
|
||||
*/
|
||||
private readonly publishTestValidatorProvider: PublishTestValidatorProvider,
|
||||
) {}
|
||||
|
||||
public async createOne(createTestDto: CreateTestDTO) {
|
||||
@@ -76,6 +83,10 @@ export class TestsCommandProvider {
|
||||
|
||||
Object.assign(test, updateTestDto);
|
||||
|
||||
if (updateTestDto.status === TestStatus.PUBLISHED) {
|
||||
await this.publishTestValidatorProvider.validate(test.id);
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.testRepository.save(test);
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user