레이아웃 저장/로드 데이터 구조 수정
This commit is contained in:
@@ -561,7 +561,7 @@ export class ReportService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 레이아웃 저장 (쿼리 포함)
|
||||
* 레이아웃 저장 (쿼리 포함) - 페이지 기반 구조
|
||||
*/
|
||||
async saveLayout(
|
||||
reportId: string,
|
||||
@@ -569,6 +569,19 @@ export class ReportService {
|
||||
userId: string
|
||||
): Promise<boolean> {
|
||||
return transaction(async (client) => {
|
||||
// 첫 번째 페이지 정보를 기본 레이아웃으로 사용
|
||||
const firstPage = data.layoutConfig.pages[0];
|
||||
const canvasWidth = firstPage?.width || 210;
|
||||
const canvasHeight = firstPage?.height || 297;
|
||||
const pageOrientation =
|
||||
canvasWidth > canvasHeight ? "landscape" : "portrait";
|
||||
const margins = firstPage?.margins || {
|
||||
top: 20,
|
||||
bottom: 20,
|
||||
left: 20,
|
||||
right: 20,
|
||||
};
|
||||
|
||||
// 1. 레이아웃 저장
|
||||
const existingQuery = `
|
||||
SELECT layout_id FROM report_layout WHERE report_id = $1
|
||||
@@ -576,7 +589,7 @@ export class ReportService {
|
||||
const existing = await client.query(existingQuery, [reportId]);
|
||||
|
||||
if (existing.rows.length > 0) {
|
||||
// 업데이트
|
||||
// 업데이트 - components 컬럼에 전체 layoutConfig 저장
|
||||
const updateQuery = `
|
||||
UPDATE report_layout
|
||||
SET
|
||||
@@ -594,14 +607,14 @@ export class ReportService {
|
||||
`;
|
||||
|
||||
await client.query(updateQuery, [
|
||||
data.canvasWidth,
|
||||
data.canvasHeight,
|
||||
data.pageOrientation,
|
||||
data.marginTop,
|
||||
data.marginBottom,
|
||||
data.marginLeft,
|
||||
data.marginRight,
|
||||
JSON.stringify(data.components),
|
||||
canvasWidth,
|
||||
canvasHeight,
|
||||
pageOrientation,
|
||||
margins.top,
|
||||
margins.bottom,
|
||||
margins.left,
|
||||
margins.right,
|
||||
JSON.stringify(data.layoutConfig), // 전체 layoutConfig 저장
|
||||
userId,
|
||||
reportId,
|
||||
]);
|
||||
@@ -627,14 +640,14 @@ export class ReportService {
|
||||
await client.query(insertQuery, [
|
||||
layoutId,
|
||||
reportId,
|
||||
data.canvasWidth,
|
||||
data.canvasHeight,
|
||||
data.pageOrientation,
|
||||
data.marginTop,
|
||||
data.marginBottom,
|
||||
data.marginLeft,
|
||||
data.marginRight,
|
||||
JSON.stringify(data.components),
|
||||
canvasWidth,
|
||||
canvasHeight,
|
||||
pageOrientation,
|
||||
margins.top,
|
||||
margins.bottom,
|
||||
margins.left,
|
||||
margins.right,
|
||||
JSON.stringify(data.layoutConfig), // 전체 layoutConfig 저장
|
||||
userId,
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user