diff --git a/backend-node/src/controllers/DashboardController.ts b/backend-node/src/controllers/DashboardController.ts index 01ac16c0..76b666f0 100644 --- a/backend-node/src/controllers/DashboardController.ts +++ b/backend-node/src/controllers/DashboardController.ts @@ -419,7 +419,7 @@ export class DashboardController { limit: Math.min(parseInt(req.query.limit as string) || 20, 100), search: req.query.search as string, category: req.query.category as string, - createdBy: userId, // 본인이 만든 대시보드만 + // createdBy 제거 - 회사 대시보드 전체 표시 }; const result = await DashboardService.getDashboards( diff --git a/backend-node/src/services/DashboardService.ts b/backend-node/src/services/DashboardService.ts index 4b13d6b8..5f3cea61 100644 --- a/backend-node/src/services/DashboardService.ts +++ b/backend-node/src/services/DashboardService.ts @@ -178,21 +178,24 @@ export class DashboardService { let params: any[] = []; let paramIndex = 1; - // 회사 코드 필터링 (최우선) + // 회사 코드 필터링 - company_code가 일치하면 해당 회사 사용자는 모두 조회 가능 if (companyCode) { - whereConditions.push(`d.company_code = $${paramIndex}`); - params.push(companyCode); - paramIndex++; - } - - // 권한 필터링 - if (userId) { + if (companyCode === '*') { + // 최고 관리자는 모든 대시보드 조회 가능 + } else { + whereConditions.push(`d.company_code = $${paramIndex}`); + params.push(companyCode); + paramIndex++; + } + } else if (userId) { + // 회사 코드 없이 userId만 있는 경우 (본인 생성 또는 공개) whereConditions.push( `(d.created_by = $${paramIndex} OR d.is_public = true)` ); params.push(userId); paramIndex++; } else { + // 비로그인 사용자는 공개 대시보드만 whereConditions.push("d.is_public = true"); }