Merge branch 'main' into feature/screen-management

This commit is contained in:
kjs
2025-12-24 18:38:08 +09:00
37 changed files with 6132 additions and 1159 deletions

View File

@@ -234,10 +234,23 @@ export class ReportService {
`;
const queries = await query<ReportQuery>(queriesQuery, [reportId]);
// 메뉴 매핑 조회
const menuMappingQuery = `
SELECT menu_objid
FROM report_menu_mapping
WHERE report_id = $1
ORDER BY created_at
`;
const menuMappings = await query<{ menu_objid: number }>(menuMappingQuery, [
reportId,
]);
const menuObjids = menuMappings?.map((m) => Number(m.menu_objid)) || [];
return {
report,
layout,
queries: queries || [],
menuObjids,
};
}
@@ -696,6 +709,43 @@ export class ReportService {
}
}
// 3. 메뉴 매핑 저장 (있는 경우)
if (data.menuObjids !== undefined) {
// 기존 메뉴 매핑 모두 삭제
await client.query(
`DELETE FROM report_menu_mapping WHERE report_id = $1`,
[reportId]
);
// 새 메뉴 매핑 삽입
if (data.menuObjids.length > 0) {
// 리포트의 company_code 조회
const reportResult = await client.query(
`SELECT company_code FROM report_master WHERE report_id = $1`,
[reportId]
);
const companyCode = reportResult.rows[0]?.company_code || "*";
const insertMappingSql = `
INSERT INTO report_menu_mapping (
report_id,
menu_objid,
company_code,
created_by
) VALUES ($1, $2, $3, $4)
`;
for (const menuObjid of data.menuObjids) {
await client.query(insertMappingSql, [
reportId,
menuObjid,
companyCode,
userId,
]);
}
}
}
return true;
});
}