This commit is contained in:
AdisakKanthawilang 2024-05-29 17:49:54 +07:00
parent c9c4d86f6a
commit 5cb9bd2372

View file

@ -240,6 +240,13 @@ export class kpiLinkController extends Controller {
)
.getManyAndCount();
if (_total === 0) {
return new HttpSuccess({
data: [],
total: 0,
});
}
const [kpiLink, total] = await AppDataSource.getRepository(KpiLink)
.createQueryBuilder("kpiLink")
.leftJoinAndSelect("kpiLink.kpiGroup", "kpiGroup")
@ -253,6 +260,13 @@ export class kpiLinkController extends Controller {
.orderBy("kpiLink.createdAt", "ASC")
.getManyAndCount();
if (_total === 0) {
return new HttpSuccess({
data: [],
total: 0,
});
}
const formattedResponse = kpiLink.map((item) => ({
id: item.id,
groupName: item.kpiGroup.nameGroupKPI,