diff options
| author | joonhoekim <26rote@gmail.com> | 2025-06-24 01:51:59 +0000 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-06-24 01:51:59 +0000 |
| commit | 6824e097d768f724cf439b410ccfb1ab9685ac98 (patch) | |
| tree | 1f297313637878e7a4ad6c89b84d5a2c3e9eb650 /lib/techsales-rfq/repository.ts | |
| parent | f4825dd3853188de4688fb4a56c0f4e847da314b (diff) | |
| parent | 4e63d8427d26d0d1b366ddc53650e15f3481fc75 (diff) | |
(merge) 대표님/최겸 작업사항 머지
Diffstat (limited to 'lib/techsales-rfq/repository.ts')
| -rw-r--r-- | lib/techsales-rfq/repository.ts | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/techsales-rfq/repository.ts b/lib/techsales-rfq/repository.ts index e9ad3925..1aaf4b3d 100644 --- a/lib/techsales-rfq/repository.ts +++ b/lib/techsales-rfq/repository.ts @@ -117,11 +117,24 @@ export async function selectTechSalesRfqsWithJoin( projMsrm: biddingProjects.projMsrm, ptypeNm: biddingProjects.ptypeNm, - // 첨부파일 개수 + // 첨부파일 개수 (타입별로 분리) attachmentCount: sql<number>`( SELECT COUNT(*) FROM tech_sales_attachments WHERE tech_sales_attachments.tech_sales_rfq_id = ${techSalesRfqs.id} + AND tech_sales_attachments.attachment_type = 'RFQ_COMMON' + )`, + hasTbeAttachments: sql<boolean>`( + SELECT CASE WHEN COUNT(*) > 0 THEN TRUE ELSE FALSE END + FROM tech_sales_attachments + WHERE tech_sales_attachments.tech_sales_rfq_id = ${techSalesRfqs.id} + AND tech_sales_attachments.attachment_type = 'TBE_RESULT' + )`, + hasCbeAttachments: sql<boolean>`( + SELECT CASE WHEN COUNT(*) > 0 THEN TRUE ELSE FALSE END + FROM tech_sales_attachments + WHERE tech_sales_attachments.tech_sales_rfq_id = ${techSalesRfqs.id} + AND tech_sales_attachments.attachment_type = 'CBE_RESULT' )`, // 벤더 견적 개수 @@ -258,6 +271,20 @@ export async function selectTechSalesVendorQuotationsWithJoin( WHERE tech_sales_attachments.tech_sales_rfq_id = ${techSalesRfqs.id} )`, + // 견적서 첨부파일 개수 + quotationAttachmentCount: sql<number>`( + SELECT COUNT(*) + FROM tech_sales_vendor_quotation_attachments + WHERE tech_sales_vendor_quotation_attachments.quotation_id = ${techSalesVendorQuotations.id} + )`, + + // RFQ 아이템 개수 + itemCount: sql<number>`( + SELECT COUNT(*) + FROM tech_sales_rfq_items + WHERE tech_sales_rfq_items.rfq_id = ${techSalesRfqs.id} + )`, + }) .from(techSalesVendorQuotations) .leftJoin(techSalesRfqs, sql`${techSalesVendorQuotations.rfqId} = ${techSalesRfqs.id}`) |
