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
|
import { relations } from "drizzle-orm";
import {
date,
integer,
pgTable,
serial,
text,
timestamp,
varchar,
decimal,
boolean,
} from "drizzle-orm/pg-core";
import { vendors } from "./vendors";
// 정규업체 등록 관리 테이블
export const vendorRegularRegistrations = pgTable("vendor_regular_registrations", {
id: serial("id").primaryKey(),
vendorId: integer("vendor_id").notNull().references(() => vendors.id),
status: varchar("status", { length: 50 }).notNull().default("audit_pass"), // audit_pass, approval_ready, pending_approval, registration_completed, registration_failed
potentialCode: varchar("potential_code", { length: 20 }), // 잠재코드
majorItems: text("major_items"), // 주요품목 (JSON 형태로 저장)
registrationRequestDate: date("registration_request_date"), // 등록요청일
assignedDepartment: varchar("assigned_department", { length: 100 }), // 담당부서
assignedDepartmentCode: varchar("assigned_department_code", { length: 20 }), // 담당부서코드
assignedUser: varchar("assigned_user", { length: 100 }), // 담당자
assignedUserCode: varchar("assigned_user_code", { length: 20 }), // 담당자코드
remarks: text("remarks"), // 비고
// 안전적격성 평가 관련
safetyQualificationContent: text("safety_qualification_content"), // 안전적격성 평가 내용
// GTC Skip 관련
gtcSkipped: boolean("gtc_skipped").notNull().default(false), // GTC Skip 여부
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
});
// 업무담당자 정보 테이블
export const vendorBusinessContacts = pgTable("vendor_business_contacts", {
id: serial("id").primaryKey(),
vendorId: integer("vendor_id").notNull().references(() => vendors.id),
contactType: varchar("contact_type", { length: 20 }).notNull(), // sales, design, delivery, quality, tax_invoice
contactName: varchar("contact_name", { length: 100 }).notNull(), // 담당자명
position: varchar("position", { length: 50 }).notNull(), // 직급
department: varchar("department", { length: 100 }).notNull(), // 부서
responsibility: varchar("responsibility", { length: 200 }).notNull(), // 담당업무
email: varchar("email", { length: 255 }).notNull(), // Email
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
});
// 추가정보 테이블
export const vendorAdditionalInfo = pgTable("vendor_additional_info", {
id: serial("id").primaryKey(),
vendorId: integer("vendor_id").notNull().references(() => vendors.id),
businessType: varchar("business_type", { length: 50 }), // 사업유형
industryType: varchar("industry_type", { length: 50 }), // 산업유형
companySize: varchar("company_size", { length: 20 }), // 기업규모
revenue: decimal("revenue", { precision: 15, scale: 2 }), // 매출액
factoryEstablishedDate: date("factory_established_date"), // 공장설립일
preferredContractTerms: text("preferred_contract_terms"), // 선호계약조건
createdAt: timestamp("created_at").defaultNow(),
updatedAt: timestamp("updated_at").defaultNow(),
});
// Relations
export const vendorRegularRegistrationsRelations = relations(
vendorRegularRegistrations,
({ one }) => ({
vendor: one(vendors, {
fields: [vendorRegularRegistrations.vendorId],
references: [vendors.id],
}),
})
);
export const vendorBusinessContactsRelations = relations(
vendorBusinessContacts,
({ one }) => ({
vendor: one(vendors, {
fields: [vendorBusinessContacts.vendorId],
references: [vendors.id],
}),
})
);
export const vendorAdditionalInfoRelations = relations(
vendorAdditionalInfo,
({ one }) => ({
vendor: one(vendors, {
fields: [vendorAdditionalInfo.vendorId],
references: [vendors.id],
}),
})
);
|