Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 18x 18x 18x 18x 18x 18x 1x 1x 17x 17x 18x 17x 17x 17x 17x 17x 17x 1x | import { Injectable, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { StatementThread, type Company } from '@amalia/core/models';
import { CustomObjectsService } from '@amalia/data-capture/records/core';
@Injectable()
export class StatementCommentsService {
public constructor(
@InjectRepository(StatementThread)
private readonly statementThreadRepository: Repository<StatementThread>,
private readonly customObjectService: CustomObjectsService,
) {}
/**
* Find statementThread by id
* @param company
* @param id
* @param relations
*/
public async findThreadById(company: Company, id: string, relations?: string[]): Promise<StatementThread> {
const statementThread = await this.statementThreadRepository.findOne({
where: { id, company: { id: company.id } },
relations,
});
if (!statementThread) {
throw new NotFoundException();
}
let scopeName: string | undefined;
if (statementThread.scopeDefinitionId && statementThread.scopeId) {
scopeName = (
await this.customObjectService.findByDefinitionAndExternalId(
company,
statementThread.scopeDefinitionId,
statementThread.scopeId,
false,
)
)?.name;
}
return {
...statementThread,
scopeName,
};
}
}
|