feat: Phase 2.1 Stage 1 추가 조회 함수 전환 (8/46)
추가 기본 조회 함수 Raw Query 전환 ✅ 추가 전환 완료 (2개): 7. getScreens() - 전체 화면 목록 조회 (동적 WHERE) 8. getScreen() - 회사 코드 필터링 포함 조회 📊 진행률: 8/46 (17.4%) 🎯 다음: Stage 2 레이아웃 관리 전환 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -177,19 +177,26 @@ export class ScreenManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 화면 목록 조회 (간단 버전) - 활성 화면만
|
* 화면 목록 조회 (간단 버전) - 활성 화면만 (✅ Raw Query 전환 완료)
|
||||||
*/
|
*/
|
||||||
async getScreens(companyCode: string): Promise<ScreenDefinition[]> {
|
async getScreens(companyCode: string): Promise<ScreenDefinition[]> {
|
||||||
const whereClause: any = { is_active: { not: "D" } }; // 삭제된 화면 제외
|
// 동적 WHERE 절 생성
|
||||||
|
const whereConditions: string[] = ["is_active != 'D'"];
|
||||||
|
const params: any[] = [];
|
||||||
|
|
||||||
if (companyCode !== "*") {
|
if (companyCode !== "*") {
|
||||||
whereClause.company_code = companyCode;
|
whereConditions.push(`company_code = $${params.length + 1}`);
|
||||||
|
params.push(companyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
const screens = await prisma.screen_definitions.findMany({
|
const whereSQL = whereConditions.join(" AND ");
|
||||||
where: whereClause,
|
|
||||||
orderBy: { created_date: "desc" },
|
const screens = await query<any>(
|
||||||
});
|
`SELECT * FROM screen_definitions
|
||||||
|
WHERE ${whereSQL}
|
||||||
|
ORDER BY created_date DESC`,
|
||||||
|
params
|
||||||
|
);
|
||||||
|
|
||||||
return screens.map((screen) => this.mapToScreenDefinition(screen));
|
return screens.map((screen) => this.mapToScreenDefinition(screen));
|
||||||
}
|
}
|
||||||
@@ -209,27 +216,35 @@ export class ScreenManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 화면 정의 조회 (회사 코드 검증 포함, 활성 화면만)
|
* 화면 정의 조회 (회사 코드 검증 포함, 활성 화면만) (✅ Raw Query 전환 완료)
|
||||||
*/
|
*/
|
||||||
async getScreen(
|
async getScreen(
|
||||||
screenId: number,
|
screenId: number,
|
||||||
companyCode: string
|
companyCode: string
|
||||||
): Promise<ScreenDefinition | null> {
|
): Promise<ScreenDefinition | null> {
|
||||||
const whereClause: any = {
|
// 동적 WHERE 절 생성
|
||||||
screen_id: screenId,
|
const whereConditions: string[] = [
|
||||||
is_active: { not: "D" }, // 삭제된 화면 제외
|
"screen_id = $1",
|
||||||
};
|
"is_active != 'D'", // 삭제된 화면 제외
|
||||||
|
];
|
||||||
|
const params: any[] = [screenId];
|
||||||
|
|
||||||
// 회사 코드가 '*'가 아닌 경우 회사별 필터링
|
// 회사 코드가 '*'가 아닌 경우 회사별 필터링
|
||||||
if (companyCode !== "*") {
|
if (companyCode !== "*") {
|
||||||
whereClause.company_code = companyCode;
|
whereConditions.push(`company_code = $${params.length + 1}`);
|
||||||
|
params.push(companyCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
const screen = await prisma.screen_definitions.findFirst({
|
const whereSQL = whereConditions.join(" AND ");
|
||||||
where: whereClause,
|
|
||||||
});
|
|
||||||
|
|
||||||
return screen ? this.mapToScreenDefinition(screen) : null;
|
const screens = await query<any>(
|
||||||
|
`SELECT * FROM screen_definitions
|
||||||
|
WHERE ${whereSQL}
|
||||||
|
LIMIT 1`,
|
||||||
|
params
|
||||||
|
);
|
||||||
|
|
||||||
|
return screens.length > 0 ? this.mapToScreenDefinition(screens[0]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user