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[]> {
|
||||
const whereClause: any = { is_active: { not: "D" } }; // 삭제된 화면 제외
|
||||
// 동적 WHERE 절 생성
|
||||
const whereConditions: string[] = ["is_active != 'D'"];
|
||||
const params: any[] = [];
|
||||
|
||||
if (companyCode !== "*") {
|
||||
whereClause.company_code = companyCode;
|
||||
whereConditions.push(`company_code = $${params.length + 1}`);
|
||||
params.push(companyCode);
|
||||
}
|
||||
|
||||
const screens = await prisma.screen_definitions.findMany({
|
||||
where: whereClause,
|
||||
orderBy: { created_date: "desc" },
|
||||
});
|
||||
const whereSQL = whereConditions.join(" AND ");
|
||||
|
||||
const screens = await query<any>(
|
||||
`SELECT * FROM screen_definitions
|
||||
WHERE ${whereSQL}
|
||||
ORDER BY created_date DESC`,
|
||||
params
|
||||
);
|
||||
|
||||
return screens.map((screen) => this.mapToScreenDefinition(screen));
|
||||
}
|
||||
@@ -209,27 +216,35 @@ export class ScreenManagementService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 화면 정의 조회 (회사 코드 검증 포함, 활성 화면만)
|
||||
* 화면 정의 조회 (회사 코드 검증 포함, 활성 화면만) (✅ Raw Query 전환 완료)
|
||||
*/
|
||||
async getScreen(
|
||||
screenId: number,
|
||||
companyCode: string
|
||||
): Promise<ScreenDefinition | null> {
|
||||
const whereClause: any = {
|
||||
screen_id: screenId,
|
||||
is_active: { not: "D" }, // 삭제된 화면 제외
|
||||
};
|
||||
// 동적 WHERE 절 생성
|
||||
const whereConditions: string[] = [
|
||||
"screen_id = $1",
|
||||
"is_active != 'D'", // 삭제된 화면 제외
|
||||
];
|
||||
const params: any[] = [screenId];
|
||||
|
||||
// 회사 코드가 '*'가 아닌 경우 회사별 필터링
|
||||
if (companyCode !== "*") {
|
||||
whereClause.company_code = companyCode;
|
||||
whereConditions.push(`company_code = $${params.length + 1}`);
|
||||
params.push(companyCode);
|
||||
}
|
||||
|
||||
const screen = await prisma.screen_definitions.findFirst({
|
||||
where: whereClause,
|
||||
});
|
||||
const whereSQL = whereConditions.join(" AND ");
|
||||
|
||||
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