summaryrefslogtreecommitdiff
path: root/lib/pq/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pq/service.ts')
-rw-r--r--lib/pq/service.ts57
1 files changed, 56 insertions, 1 deletions
diff --git a/lib/pq/service.ts b/lib/pq/service.ts
index f15790eb..989f8d5c 100644
--- a/lib/pq/service.ts
+++ b/lib/pq/service.ts
@@ -2710,7 +2710,7 @@ export async function sendInvestigationResultsAction(input: {
await tx.insert(vendorRegularRegistrations).values({
vendorId: investigation.vendorId,
- status: "audit_pass", // 실사 통과 상태로 시작
+ status: "under_review", // 실사 통과 상태로 시작
majorItems: majorItemsJson,
registrationRequestDate: new Date().toISOString().split('T')[0], // date 타입으로 변환
remarks: `PQ 실사 통과로 자동 생성 (PQ번호: ${investigation.pqNumber || 'N/A'})`,
@@ -3772,6 +3772,61 @@ export async function updateInvestigationDetailsAction(input: {
}
}
+// 구매자체평가 첨부파일 조회
+export async function getInvestigationAttachments(investigationId: number) {
+ try {
+ const attachments = await db
+ .select({
+ id: vendorInvestigationAttachments.id,
+ fileName: vendorInvestigationAttachments.fileName,
+ originalFileName: vendorInvestigationAttachments.originalFileName,
+ filePath: vendorInvestigationAttachments.filePath,
+ fileSize: vendorInvestigationAttachments.fileSize,
+ mimeType: vendorInvestigationAttachments.mimeType,
+ attachmentType: vendorInvestigationAttachments.attachmentType,
+ createdAt: vendorInvestigationAttachments.createdAt,
+ })
+ .from(vendorInvestigationAttachments)
+ .where(eq(vendorInvestigationAttachments.investigationId, investigationId))
+ .orderBy(desc(vendorInvestigationAttachments.createdAt));
+
+ return {
+ success: true,
+ attachments,
+ };
+ } catch (error) {
+ console.error("첨부파일 조회 오류:", error);
+ return {
+ success: false,
+ error: "첨부파일 조회 중 오류가 발생했습니다.",
+ attachments: [],
+ };
+ }
+}
+
+// 구매자체평가 첨부파일 삭제
+export async function deleteInvestigationAttachment(attachmentId: number) {
+ try {
+ await db
+ .delete(vendorInvestigationAttachments)
+ .where(eq(vendorInvestigationAttachments.id, attachmentId));
+
+ revalidateTag("pq-submissions");
+ revalidatePath("/evcp/pq_new");
+
+ return {
+ success: true,
+ message: "첨부파일이 성공적으로 삭제되었습니다.",
+ };
+ } catch (error) {
+ console.error("첨부파일 삭제 오류:", error);
+ return {
+ success: false,
+ error: "첨부파일 삭제 중 오류가 발생했습니다.",
+ };
+ }
+}
+
export async function autoDeactivateExpiredPQLists() {
try {
const now = new Date();