대시보드 목록/상세 조회 권한을 company_code 기반으로 변경
This commit is contained in:
parent
1462700c83
commit
53eab6ac9c
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue