1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
import {
vendorPQSubmissions,
vendors,
projects,
users,
vendorInvestigations
} from "@/db/schema"
import { CustomColumnMapping } from "../filter-columns"
/**
* Helper function to create custom column mapping for PQ submissions
*/
export function createPQFilterMapping(): CustomColumnMapping {
return {
// PQ 제출 관련
pqNumber: { table: vendorPQSubmissions, column: "pqNumber" },
status: { table: vendorPQSubmissions, column: "status" },
type: { table: vendorPQSubmissions, column: "type" },
createdAt: { table: vendorPQSubmissions, column: "createdAt" },
updatedAt: { table: vendorPQSubmissions, column: "updatedAt" },
submittedAt: { table: vendorPQSubmissions, column: "submittedAt" },
approvedAt: { table: vendorPQSubmissions, column: "approvedAt" },
rejectedAt: { table: vendorPQSubmissions, column: "rejectedAt" },
// 협력업체 관련
vendorName: { table: vendors, column: "vendorName" },
vendorCode: { table: vendors, column: "vendorCode" },
taxId: { table: vendors, column: "taxId" },
vendorStatus: { table: vendors, column: "status" },
// 프로젝트 관련
projectName: { table: projects, column: "name" },
projectCode: { table: projects, column: "code" },
// 요청자 관련
requesterName: { table: users, column: "name" },
requesterEmail: { table: users, column: "email" },
// 실사 관련
evaluationResult: { table: vendorInvestigations, column: "evaluationResult" },
evaluationType: { table: vendorInvestigations, column: "evaluationType" },
investigationStatus: { table: vendorInvestigations, column: "investigationStatus" },
investigationAddress: { table: vendorInvestigations, column: "investigationAddress" },
qmManagerId: { table: vendorInvestigations, column: "qmManagerId" },
}
}
/**
* PQ 관련 조인 테이블들
*/
export function getPQJoinedTables() {
return {
vendors,
projects,
users,
vendorInvestigations,
}
}
/**
* 직접 컬럼 참조 방식의 매핑 (더 타입 안전)
*/
export function createPQDirectColumnMapping(): CustomColumnMapping {
return {
// PQ 제출 관련 - 직접 컬럼 참조
pqNumber: vendorPQSubmissions.pqNumber,
status: vendorPQSubmissions.status,
type: vendorPQSubmissions.type,
createdAt: vendorPQSubmissions.createdAt,
updatedAt: vendorPQSubmissions.updatedAt,
submittedAt: vendorPQSubmissions.submittedAt,
approvedAt: vendorPQSubmissions.approvedAt,
rejectedAt: vendorPQSubmissions.rejectedAt,
// 협력업체 관련
vendorName: vendors.vendorName,
vendorCode: vendors.vendorCode,
taxId: vendors.taxId,
vendorStatus: vendors.status,
// 프로젝트 관련
projectName: projects.name,
projectCode: projects.code,
// 요청자 관련
requesterName: users.name,
requesterEmail: users.email,
// 실사 관련
evaluationResult: vendorInvestigations.evaluationResult,
evaluationType: vendorInvestigations.evaluationType,
investigationStatus: vendorInvestigations.investigationStatus,
investigationAddress: vendorInvestigations.investigationAddress,
qmManagerId: vendorInvestigations.qmManagerId,
}
}
|