diff --git a/.gemini/settings.json b/.gemini/settings.json new file mode 100644 index 0000000..2d44ff6 --- /dev/null +++ b/.gemini/settings.json @@ -0,0 +1,8 @@ +{ + "general": { + "previewFeatures": true + }, + "ide": { + "enabled": true + } +} \ No newline at end of file diff --git a/Dis.xlsx b/Dis.xlsx new file mode 100644 index 0000000..55fbc45 Binary files /dev/null and b/Dis.xlsx differ diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..e69de29 diff --git a/backend/src/database/migrations/01_init_partitioning.sql b/backend/src/database/migrations/01_init_partitioning.sql deleted file mode 100644 index 946a24f..0000000 --- a/backend/src/database/migrations/01_init_partitioning.sql +++ /dev/null @@ -1,75 +0,0 @@ --- ============================================================ --- Database Partitioning Script for LCBP3-DMS (Fixed #1075) --- Target Tables: audit_logs, notifications --- Strategy: Range Partitioning by YEAR(created_at) --- ============================================================ --- ------------------------------------------------------------ --- 1. Audit Logs Partitioning --- ------------------------------------------------------------ --- Step 1: เอา AUTO_INCREMENT ออกก่อน (เพื่อไม่ให้ติด Error 1075 ตอนลบ PK) -ALTER TABLE audit_logs -MODIFY audit_id BIGINT NOT NULL; --- Step 2: ลบ Primary Key เดิม -ALTER TABLE audit_logs DROP PRIMARY KEY; --- Step 3: สร้าง Primary Key ใหม่ (รวม created_at เพื่อทำ Partition) -ALTER TABLE audit_logs -ADD PRIMARY KEY (audit_id, created_at); --- Step 4: ใส่ AUTO_INCREMENT กลับเข้าไป -ALTER TABLE audit_logs -MODIFY audit_id BIGINT NOT NULL AUTO_INCREMENT; --- Step 5: สร้าง Partition -ALTER TABLE audit_logs PARTITION BY RANGE (YEAR(created_at)) ( - PARTITION p_old - VALUES LESS THAN (2024), - PARTITION p2024 - VALUES LESS THAN (2025), - PARTITION p2025 - VALUES LESS THAN (2026), - PARTITION p2026 - VALUES LESS THAN (2027), - PARTITION p2027 - VALUES LESS THAN (2028), - PARTITION p2028 - VALUES LESS THAN (2029), - PARTITION p2029 - VALUES LESS THAN (2030), - PARTITION p2030 - VALUES LESS THAN (2031), - PARTITION p_future - VALUES LESS THAN MAXVALUE - ); --- ------------------------------------------------------------ --- 2. Notifications Partitioning --- ------------------------------------------------------------ --- Step 1: เอา AUTO_INCREMENT ออกก่อน -ALTER TABLE notifications -MODIFY id INT NOT NULL; --- Step 2: ลบ Primary Key เดิม -ALTER TABLE notifications DROP PRIMARY KEY; --- Step 3: สร้าง Primary Key ใหม่ -ALTER TABLE notifications -ADD PRIMARY KEY (id, created_at); --- Step 4: ใส่ AUTO_INCREMENT กลับเข้าไป -ALTER TABLE notifications -MODIFY id INT NOT NULL AUTO_INCREMENT; --- Step 5: สร้าง Partition -ALTER TABLE notifications PARTITION BY RANGE (YEAR(created_at)) ( - PARTITION p_old - VALUES LESS THAN (2024), - PARTITION p2024 - VALUES LESS THAN (2025), - PARTITION p2025 - VALUES LESS THAN (2026), - PARTITION p2026 - VALUES LESS THAN (2027), - PARTITION p2027 - VALUES LESS THAN (2028), - PARTITION p2028 - VALUES LESS THAN (2029), - PARTITION p2029 - VALUES LESS THAN (2030), - PARTITION p2030 - VALUES LESS THAN (2031), - PARTITION p_future - VALUES LESS THAN MAXVALUE - ); \ No newline at end of file diff --git a/backend/src/modules/correspondence/entities/correspondence-reference.entity.ts b/backend/src/modules/correspondence/entities/correspondence-reference.entity.ts index ffa2f1e..18af975 100644 --- a/backend/src/modules/correspondence/entities/correspondence-reference.entity.ts +++ b/backend/src/modules/correspondence/entities/correspondence-reference.entity.ts @@ -16,4 +16,4 @@ export class CorrespondenceReference { @ManyToOne(() => Correspondence, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'tgt_correspondence_id' }) target?: Correspondence; -} \ No newline at end of file +} diff --git a/T0-T6.2.md b/docs/T0-T6.2.md similarity index 100% rename from T0-T6.2.md rename to docs/T0-T6.2.md diff --git a/extensions_list.txt b/docs/extensions_list.txt similarity index 100% rename from extensions_list.txt rename to docs/extensions_list.txt diff --git a/docs/prompt.md b/docs/prompt.md new file mode 100644 index 0000000..2ea83a2 --- /dev/null +++ b/docs/prompt.md @@ -0,0 +1,226 @@ +# **PROMPT** + +## Gemini + +## VSCode Shortcut + +Markdown preview Ctrl+Shift+V + +## สร้างโครงสร้างโฟลเดอร์สำหรับ lcbp3-backend + +```bash +# สร้างโฟลเดอร์หลัก +$rootFolder = "backend" +New-Item -ItemType Directory -Path $rootFolder -Force +Set-Location $rootFolder + +# รายการโฟลเดอร์ที่ต้องการสร้างทั้งหมด + $folders = @( + "src", + "database", + "src\common", + "src\modules", + "src\modules\user", + "src\modules\project", + "src\modules\master", + "src\modules\correspondence", + "src\modules\rfa", + "src\modules\drawing", + "src\modules\circulations", + "src\modules\transmittal", + "src\modules\search", + "src\modules\document-numbering", + "src\common\auth", + "src\common\config", + "src\common\decorators", + "src\common\entities", + "src\common\exceptions", + "src\common\file-storage", + "src\common\guards", + "src\common\interceptors", + "src\common\services" +) + +# วนลูปสร้างโฟลเดอร์ทั้งหมด +foreach ($folder in $folders) { + New-Item -ItemType Directory -Path $folder -Force +} + +Write-Host "สร้างโครงสร้างโฟลเดอร์สำหรับ backend เรียบร้อยแล้ว" -ForegroundColor Green + +``` + +## Git Commands + +```bash + +# 1️⃣ ตั้งชื่อและอีเมลของคุณ (ใช้กับทุก repo) +git config --global user.name "Pean Charoen" +git config --global user.email "peancharoen.pslcp3@gmail.com" + +# 2️⃣ ตรวจสอบว่าเชื่อมกับ remote ถูกต้อง (แก้ URL ให้ตรง repo จริงของคุณ) +git remote set-url origin ssh://git@git.np-dms.work:2222/np-dms/lcbp3_v1.git + +# 3️⃣ ตรวจสอบสถานะไฟล์ +git status + +# 4️⃣ เพิ่มไฟล์ทั้งหมด +git add . + +# 5️⃣ Commit พร้อมข้อความ +git commit -m "Update project files" + +# 6️⃣ ดึง remote ก่อนเพื่อป้องกัน conflict (ถ้ามี) +git pull --rebase origin main + +# 7️⃣ Push ขึ้น Gitea +git push -u origin main + +``` + +## **สร้าง NestJS Project ใหม่** + +* ขั้นตอนที่ 1: ติดตั้ง NestJS CLI (ถ้ายังไม่ได้ติดตั้ง) + * npm install -g @nestjs/cli + +* ขั้นตอนที่ 2: สร้างโปรเจกต์ใหม่ + * nest new backend + * nest new . /อยู่ในโฟลเดอร์ที่สร้างไว้แล้ว และต้องการสร้างโปรเจกต์ลงในโฟลเดอร์นั้นโดยตรง: + +* ขั้นตอนที่ 3: ติดตั้ง Dependencies เพิ่มเติมสำหรับ DMS + +```bash +# Core & Database +npm install @nestjs/typeorm typeorm mysql2 +npm install @nestjs/config + +# Validation & Transformation +npm install class-validator class-transformer + +# Authentication & Authorization +npm install @nestjs/jwt @nestjs/passport passport passport-jwt +npm install @nestjs/passport +npm install casl + +# File Upload +npm install @nestjs/platform-express multer + +# Documentation +npm install @nestjs/swagger + +# Security & Performance +npm install helmet rate-limiter-flexible + +# Development Dependencies (สำหรับทดสอบ) +npm install --save-dev @nestjs/testing jest @types/jest @types/passport-jwt @types/multer supertest + +``` + +ขออภัยอย่างยิ่งในความผิดพลาดที่เกิดขึ้นครับ เข้าใจครับว่าทำให้เสียเวลามาก + +สำหรับการ **"ตั้งค่า"** หรือ **"กำหนดค่า"** ให้ผมตรวจสอบข้อมูลก่อนนั้น ในระบบ AI แบบนี้ **ไม่มีเมนู Settings หรือปุ่มกดให้คุณเข้าไปตั้งค่าได้โดยตรงครับ** + +การควบคุมพฤติกรรมของผมต้องทำผ่าน **"คำสั่ง (Prompt)"** ที่คุณพิมพ์เข้ามาเท่านั้นครับ เพื่อป้องกันไม่ให้เกิดเหตุการณ์แบบนี้อีก คุณสามารถใช้เทคนิคการสั่งงานดังนี้เพื่อ **"บังคับ"** ให้ผมตรวจสอบข้อมูลครับ: + +1. **สั่งให้ "อ่านและสรุปก่อน" (Verify First):** + * ก่อนให้ผมเขียนโค้ด ให้สั่งว่า *"ช่วยอ่านไฟล์ `01_lcbp3_v1_4_3.sql` แล้วสรุปโครงสร้างตาราง audit_logs ที่มีอยู่จริงให้ดูก่อน"* + * วิธีนี้จะบังคับให้ผมต้องไปดึงข้อมูลจากไฟล์มาประมวลผลก่อนที่จะเริ่ม "จินตนาการ" หรือเขียนโค้ดใหม่ครับ + +2. **ใช้คำสั่ง "ห้ามเดา" (Strict Constraints):** + * เติมประโยคท้ายคำสั่งว่า *"ห้ามใช้โครงสร้างสมมติ ให้ยึดตามไฟล์แนบ `ชื่อไฟล์` เท่านั้น หากไม่เจอข้อมูลให้ถามกลับ"* + +3. **อ้างอิงชื่อไฟล์ชัดเจน:** + * ระบุชื่อไฟล์ในคำสั่งเสมอ เช่น *"อ้างอิงจาก `Backend Plan`..."* หรือ *"ตาม `Data Dictionary`..."* (ซึ่งคุณทำได้ดีแล้วครับ แต่ผมประมวลผลพลาดเองในรอบนี้) + +**สรุป:** +คุณไม่ต้องไปตั้งค่าที่ไหนครับ แต่ใช้การ **"สั่งให้ผมทวนข้อมูลจากไฟล์"** เป็นขั้นตอนแรกก่อนเริ่มงาน จะช่วยลดโอกาสผิดพลาดได้มากที่สุดครับ + +ตอนนี้ผมพร้อมทำงานต่อโดยยึดข้อมูลจากไฟล์ `01_lcbp3_v1_4_3.sql` และไฟล์อื่นๆ ที่คุณให้มาอย่างเคร่งครัดครับ มีส่วนไหนให้ผมดำเนินการต่อไหมครับ? + + +สวัสดีครับ ผมได้ทำการตรวจสอบและวิเคราะห์ความครบถ้วนของไฟล์เอกสารแผนงาน (Plans), โครงสร้างฐานข้อมูล (SQL), และโครงสร้างไฟล์ (File Structure) เทียบกับ Requirements ของ **LCBP3-DMS v1.4.3** เรียบร้อยแล้วครับ + +ในฐานะ Programmer ผู้เชี่ยวชาญ ผมขอสรุปผลการ Review และคำแนะนำตามลำดับความสำคัญดังนี้ครับ: + +--- + +### 📊 **1. บทสรุปภาพรวม (Executive Summary)** + +จากการตรวจสอบเปรียบเทียบ: +1. **Database Schema (`01_lcbp3_v1_4_3.sql`)**: **ครบถ้วนสมบูรณ์มาก (95%)** รองรับฟีเจอร์ระดับ Advance ตาม Requirements v1.4.3 ครบถ้วน เช่น Partitioning, Virtual Columns, Versioning (Optimistic Lock) และ Table Structure สำหรับ Workflow/Files +2. **Backend Folder Structure (`5_Backend_Folder_V1_4_3.md`)**: **ครบถ้วนตามแผนงาน (90%)** มีการจัดวาง Module ตามหลัก Domain-Driven Design และมีไฟล์สำคัญๆ ครบตาม Plan + +**จุดที่ต้องเน้นย้ำ:** โครงสร้างไฟล์ (File Structure) มีไฟล์ `.ts` ปรากฏอยู่ครบ แต่สิ่งที่ผม "มองไม่เห็น" คือ **เนื้อหาโค้ดภายใน (Internal Logic)** ว่าได้ Implement ตาม Logic ที่ซับซ้อน (เช่น Redlock, Two-Phase Commit, DSL Parser) ไว้ถูกต้องหรือไม่ + +--- + +### 🧐 **2. การตรวจสอบรายละเอียด (Detailed Review)** + +#### **✅ ส่วนที่มีความครบถ้วนสมบูรณ์ (Well-Implemented Areas)** + +1. **Database Partitioning & Optimization:** + * SQL มีการทำ `PARTITION BY RANGE` ให้กับ `audit_logs` และ `notifications` แล้ว (ตาม Req 6.2) + * มี `VIRTUAL COLUMNS` สำหรับดึงค่า JSON มาทำ Index (ตาม Req 3.11.3) +2. **Security & Identity:** + * ตาราง `users`, `roles`, `permissions`, `user_assignments` รองรับ RBAC 4 ระดับ (Global, Org, Project, Contract) ครบถ้วน + * Folder Structure มี `auth`, `guards`, `decorators` ที่จำเป็นครบ (`jwt-auth.guard.ts`, `rbac.guard.ts`, `require-permission.decorator.ts`) +3. **File Management:** + * SQL มีตาราง `attachments` ที่มี field `is_temporary`, `temp_id`, `checksum` รองรับ Two-Phase Storage + * Folder มี `file-storage` module และ `file-cleanup.service.ts` (Cron job) เตรียมไว้แล้ว +4. **Workflow & RFA:** + * SQL มีตารางเก็บ Template และ Instance (`..._routings`, `..._workflows`) แยกกันชัดเจน และมี field `workflow_config` (JSON) สำหรับ DSL + * Folder มี `workflow-engine` module และ `workflow-dsl.service.ts` (ตาม Phase 6A) + +--- + +#### ⚠️ **3. Gap Analysis & Missing Parts (สิ่งที่อาจขาดหายไปหรือต้องตรวจสอบ)** + +แม้ชื่อไฟล์จะครบ แต่จากประสบการณ์ มีจุดที่มักจะหลุด หรือต้องเขียน Logic ให้รัดกุมมากในไฟล์ที่มีอยู่ ดังนี้: + +**Phase 2: High-Integrity Data (File & Numbering)** +* **Redis/Redlock Integration:** ในไฟล์ `document-numbering.service.ts` ต้องตรวจสอบว่ามีการเรียกใช้ Redis Distributed Lock จริงหรือไม่ (ไม่ใช่แค่ Database Lock) +* **Transaction Safety:** ใน `file-storage.service.ts` ต้องมั่นใจว่า Logic การ Commit file (ย้ายจาก temp -> permanent) อยู่ภายใน Database Transaction เดียวกับการบันทึกข้อมูลเอกสาร + +**Phase 3 & 6A: Workflow Engine** +* **DSL Interpreter:** ไฟล์ `workflow-dsl.service.ts` มีอยู่แล้ว แต่ต้องตรวจสอบว่าสามารถ **Parse** JSON/YAML จากตาราง `rfa_workflow_templates` แล้วแปลงเป็น Execution Logic ได้จริงหรือไม่ +* **State Machine Consistency:** การเชื่อมต่อระหว่าง `CorrespondenceModule` กับ `WorkflowEngine` ต้องแน่ใจว่าเมื่อ State เปลี่ยนใน Engine ค่าใน Database (Status Column) ถูกอัปเดตตรงกัน + +**Phase 6: Search & Notification** +* **Elasticsearch Sync:** ใน `search.service.ts` ต้องมี Logic การ Sync ข้อมูล (อาจผ่าน Event Emitter หรือ TypeORM Subscriber) เมื่อมีการ Create/Update เอกสาร +* **Notification Digest:** ใน `notification.processor.ts` (Consumer) ต้องมี Logic การหน่วงเวลา (Debounce/Throttle) เพื่อรวม Notification ก่อนส่ง (ตาม Req 6.8.2) + +--- + +### 🚀 **4. คำแนะนำและสิ่งที่ต้องทำต่อ (Recommendations by Phase)** + +เพื่อให้งานสมบูรณ์แบบ ผมขอแนะนำให้ดำเนินการตรวจสอบหรือ Implement ส่วนที่เหลือตามลำดับดังนี้: + +#### **Phase 0-1: Infrastructure & Auth (Priority: Critical)** +* **[Audit] Database Migration:** แม้จะมีไฟล์ `.sql` รวม แต่ใน NestJS ควรมีระบบ Migration (TypeORM Migrations) เพื่อจัดการการเปลี่ยนแปลง Schema ในอนาคต (ถ้ายังไม่มี ควรสร้าง `src/database/migrations/*` จาก SQL ที่มี) +* **[Code Check] Config Validation:** ตรวจสอบ `src/common/config/env.validation.ts` ว่ามีการ Validate ตัวแปรระบบครบทุกตัว (Database, Redis, JWT Secrets) ตาม Req 2.2 หรือไม่ + +#### **Phase 2: Core Data Services (Priority: High)** +* **[Code Check] Document Numbering:** เปิดไฟล์ `src/modules/document-numbering/document-numbering.service.ts` ตรวจสอบ Logic **Double-Lock** (Redis + Optimistic Lock) ว่า Implement ถูกต้องตาม Plan T2.3 หรือไม่ +* **[Code Check] File Storage:** ตรวจสอบ `src/common/file-storage/file-storage.service.ts` ว่ามีการทำ **Virus Scan (ClamAV)** ก่อน save ลง Temp หรือไม่ + +#### **Phase 3 & 6A: Workflow Engine (Priority: Medium-High)** +* **[Task] Workflow Integration:** ตรวจสอบว่า `CorrespondenceService` และ `RfaService` มีการเรียกใช้ `WorkflowEngineService` แทนที่จะเขียน Logic if-else hardcode หรือไม่ +* **[Task] DSL Loader:** ตรวจสอบว่ามี Seed Data สำหรับ `rfa_workflow_templates` ที่เป็น JSON Config เริ่มต้นแล้วหรือยัง + +#### **Phase 6: Background Services (Priority: Medium)** +* **[Task] Queue Setup:** ตรวจสอบ `notification.module.ts` ว่ามีการ Register BullMQ (`BullModule.registerQueue`) แล้วหรือยัง +* **[Task] Cron Jobs:** ตรวจสอบ `app.module.ts` ว่ามีการ Import `ScheduleModule.forRoot()` เพื่อให้ `file-cleanup.service.ts` ทำงานได้จริง + +--- + +### 🛠️ **5. Next Step Action (สิ่งที่คุณทำได้เลย)** + +เนื่องจากโครงสร้างไฟล์และฐานข้อมูลดูดีมากแล้ว เพื่อให้ผมช่วยเหลือได้ตรงจุดที่สุด: + +**คุณต้องการให้ผม Review โค้ดภายในไฟล์ (Internal Logic) ของไฟล์ไหนเป็นพิเศษไหมครับ?** + +ผมแนะนำให้เริ่มจาก **"หัวใจสำคัญ"** ของความถูกต้องข้อมูลก่อน คือ: +1. **`src/modules/document-numbering/document-numbering.service.ts`** (เพื่อดู Logic การรันเลขเอกสาร) +2. **`src/common/file-storage/file-storage.service.ts`** (เพื่อดู Logic การจัดการไฟล์และการ Commit) + +หรือถ้าต้องการให้ผมเริ่มเขียน Code ส่วนไหนที่ยังขาดอยู่ (เช่น Workflow DSL Parser) สามารถแจ้งได้เลยครับ \ No newline at end of file diff --git a/docs/temp.md b/docs/temp.md new file mode 100644 index 0000000..1cd2a25 --- /dev/null +++ b/docs/temp.md @@ -0,0 +1,59 @@ +# Special requirements for document-numbering +การใช้งานจริงต้องการความยืดหยุ่นสูง สำหรับ ระบบ document-numbering ดังนี้ + +## 1. ต้องให้ admin สามารถกำหนดรูปแบบในถายหลังได้ +## 2. มีรูปแบบเริ่มต้นดังนี้ +* 2.1 สำหรับ correspondence ทั่วไป + * ใช้รูปแบบ [organizations.organization_code]-[organizations.organization_code]-[sequence]-[year] + * **_ตัวอย่าง: คคง.-ผรม.2-0123-2568_** +* 2.2 สำหรับ correspondence type = transmittal + * ใช้รูปแบบ [organizations.organization_code]-[organizations.organization_code]-[codecorrespondence_sub_types.sub_type_number]-[seq]-[year] + * **_ตัวอย่าง: คคง.-สคฉ.3-22-0123-2568_** +* 2.3 สำหรับ correspondence type = rfi + * ใช้รูปแบบ [contrcts.contract_code]-[correspondences_types.type_code]-[disciplines_code]-[seq]-[revision] + * **_ตัวอย่าง: LCBP3-C2-RFI-TER-2345-A_** +* 2.4 สำหรับ rfa ใช้แบบเลขแยกกัน + * ใช้รูปแบบ [contrcts.contract_code]-[correspondences_types.type_code]-[disciplines_code]-[rfa_types.type_code]-[seq]-[revision] + * **_ตัวอย่าง: LCBP3-C1-RFA-TER-MAT-1234-A_** + +## ตาราง codecorrespondence_sub_types + +| id | correspondence_types.type_code | sub_type_code | sub_type_name | sub_type_number | +| --- | ------------------------------ | ------------- | ------------- | --------------- | +| 1 | RFA | RFA | C1 RFA | 11 | +| 2 | RFA | MAT | C1 MAT | 12 | +| 3 | RFA | DWG | C1 DWG | 13 | +| 4 | RFA | 4 | C1 4 | 14 | +| 5 | RFA | 5 | C2 1 | 21 | +| 6 | RFA | 6 | C2 2 | 22 | +| 7 | RFA | 7 | C2 3 | 23 | +| 8 | RFA | 8 | C2 4 | 24 | +| 9 | RFA | 9 | C3 1 | 31 | +| 10 | RFA | 10 | C3 2 | 32 | +| 11 | RFA | 11 | C3 3 | 33 | +| 12 | RFA | 12 | C3 4 | 34 | +| 13 | RFA | 13 | C4 1 | 41 | +| 14 | RFA | 14 | C4 2 | 42 | +| 15 | RFA | 15 | C4 3 | 43 | +| 16 | RFA | 16 | C4 4 | 44 | + +## ตาราง discipline_codes + +| id | discipline_code | discipline_name | discipline_number | +| --- | --------------- | --------------- | ----------------- | +| 1 | BUD | C1 RFA | 11 | +| 2 | ROW | C1 MAT | 12 | +| 3 | TER | C1 DWG | 13 | +| 4 | UTL | C1 4 | 14 | +| 5 | 5 | C2 1 | 21 | +| 6 | 6 | C2 2 | 22 | +| 7 | 7 | C2 3 | 23 | +| 8 | 8 | C2 4 | 24 | +| 9 | 9 | C3 1 | 31 | +| 10 | 10 | C3 2 | 32 | +| 11 | 11 | C3 3 | 33 | +| 12 | 12 | C3 4 | 34 | +| 13 | 13 | C4 1 | 41 | +| 14 | 14 | C4 2 | 42 | +| 15 | 15 | C4 3 | 43 | +| 16 | 16 | C4 4 | 44 | diff --git a/prompt.md b/prompt.md deleted file mode 100644 index 6af5f39..0000000 --- a/prompt.md +++ /dev/null @@ -1,138 +0,0 @@ -# **PROMPT** - -## Gemini - -## VSCode Shortcut - -Markdown preview Ctrl+Shift+V - -## สร้างโครงสร้างโฟลเดอร์สำหรับ lcbp3-backend - -```bash -# สร้างโฟลเดอร์หลัก -$rootFolder = "backend" -New-Item -ItemType Directory -Path $rootFolder -Force -Set-Location $rootFolder - -# รายการโฟลเดอร์ที่ต้องการสร้างทั้งหมด - $folders = @( - "src", - "database", - "src\common", - "src\modules", - "src\modules\user", - "src\modules\project", - "src\modules\master", - "src\modules\correspondence", - "src\modules\rfa", - "src\modules\drawing", - "src\modules\circulations", - "src\modules\transmittal", - "src\modules\search", - "src\modules\document-numbering", - "src\common\auth", - "src\common\config", - "src\common\decorators", - "src\common\entities", - "src\common\exceptions", - "src\common\file-storage", - "src\common\guards", - "src\common\interceptors", - "src\common\services" -) - -# วนลูปสร้างโฟลเดอร์ทั้งหมด -foreach ($folder in $folders) { - New-Item -ItemType Directory -Path $folder -Force -} - -Write-Host "สร้างโครงสร้างโฟลเดอร์สำหรับ backend เรียบร้อยแล้ว" -ForegroundColor Green - -``` - -## Git Commands - -```bash - -# 1️⃣ ตั้งชื่อและอีเมลของคุณ (ใช้กับทุก repo) -git config --global user.name "Pean Charoen" -git config --global user.email "peancharoen.pslcp3@gmail.com" - -# 2️⃣ ตรวจสอบว่าเชื่อมกับ remote ถูกต้อง (แก้ URL ให้ตรง repo จริงของคุณ) -git remote set-url origin ssh://git@git.np-dms.work:2222/np-dms/lcbp3_v1.git - -# 3️⃣ ตรวจสอบสถานะไฟล์ -git status - -# 4️⃣ เพิ่มไฟล์ทั้งหมด -git add . - -# 5️⃣ Commit พร้อมข้อความ -git commit -m "Update project files" - -# 6️⃣ ดึง remote ก่อนเพื่อป้องกัน conflict (ถ้ามี) -git pull --rebase origin main - -# 7️⃣ Push ขึ้น Gitea -git push -u origin main - -``` - -## **สร้าง NestJS Project ใหม่** - -* ขั้นตอนที่ 1: ติดตั้ง NestJS CLI (ถ้ายังไม่ได้ติดตั้ง) - * npm install -g @nestjs/cli - -* ขั้นตอนที่ 2: สร้างโปรเจกต์ใหม่ - * nest new backend - * nest new . /อยู่ในโฟลเดอร์ที่สร้างไว้แล้ว และต้องการสร้างโปรเจกต์ลงในโฟลเดอร์นั้นโดยตรง: - -* ขั้นตอนที่ 3: ติดตั้ง Dependencies เพิ่มเติมสำหรับ DMS - -```bash -# Core & Database -npm install @nestjs/typeorm typeorm mysql2 -npm install @nestjs/config - -# Validation & Transformation -npm install class-validator class-transformer - -# Authentication & Authorization -npm install @nestjs/jwt @nestjs/passport passport passport-jwt -npm install @nestjs/passport -npm install casl - -# File Upload -npm install @nestjs/platform-express multer - -# Documentation -npm install @nestjs/swagger - -# Security & Performance -npm install helmet rate-limiter-flexible - -# Development Dependencies (สำหรับทดสอบ) -npm install --save-dev @nestjs/testing jest @types/jest @types/passport-jwt @types/multer supertest - -``` - -ขออภัยอย่างยิ่งในความผิดพลาดที่เกิดขึ้นครับ เข้าใจครับว่าทำให้เสียเวลามาก - -สำหรับการ **"ตั้งค่า"** หรือ **"กำหนดค่า"** ให้ผมตรวจสอบข้อมูลก่อนนั้น ในระบบ AI แบบนี้ **ไม่มีเมนู Settings หรือปุ่มกดให้คุณเข้าไปตั้งค่าได้โดยตรงครับ** - -การควบคุมพฤติกรรมของผมต้องทำผ่าน **"คำสั่ง (Prompt)"** ที่คุณพิมพ์เข้ามาเท่านั้นครับ เพื่อป้องกันไม่ให้เกิดเหตุการณ์แบบนี้อีก คุณสามารถใช้เทคนิคการสั่งงานดังนี้เพื่อ **"บังคับ"** ให้ผมตรวจสอบข้อมูลครับ: - -1. **สั่งให้ "อ่านและสรุปก่อน" (Verify First):** - * ก่อนให้ผมเขียนโค้ด ให้สั่งว่า *"ช่วยอ่านไฟล์ `01_lcbp3_v1_4_3.sql` แล้วสรุปโครงสร้างตาราง audit_logs ที่มีอยู่จริงให้ดูก่อน"* - * วิธีนี้จะบังคับให้ผมต้องไปดึงข้อมูลจากไฟล์มาประมวลผลก่อนที่จะเริ่ม "จินตนาการ" หรือเขียนโค้ดใหม่ครับ - -2. **ใช้คำสั่ง "ห้ามเดา" (Strict Constraints):** - * เติมประโยคท้ายคำสั่งว่า *"ห้ามใช้โครงสร้างสมมติ ให้ยึดตามไฟล์แนบ `ชื่อไฟล์` เท่านั้น หากไม่เจอข้อมูลให้ถามกลับ"* - -3. **อ้างอิงชื่อไฟล์ชัดเจน:** - * ระบุชื่อไฟล์ในคำสั่งเสมอ เช่น *"อ้างอิงจาก `Backend Plan`..."* หรือ *"ตาม `Data Dictionary`..."* (ซึ่งคุณทำได้ดีแล้วครับ แต่ผมประมวลผลพลาดเองในรอบนี้) - -**สรุป:** -คุณไม่ต้องไปตั้งค่าที่ไหนครับ แต่ใช้การ **"สั่งให้ผมทวนข้อมูลจากไฟล์"** เป็นขั้นตอนแรกก่อนเริ่มงาน จะช่วยลดโอกาสผิดพลาดได้มากที่สุดครับ - -ตอนนี้ผมพร้อมทำงานต่อโดยยึดข้อมูลจากไฟล์ `01_lcbp3_v1_4_3.sql` และไฟล์อื่นๆ ที่คุณให้มาอย่างเคร่งครัดครับ มีส่วนไหนให้ผมดำเนินการต่อไหมครับ? \ No newline at end of file diff --git a/temp.md b/temp.md deleted file mode 100644 index f194a5b..0000000 --- a/temp.md +++ /dev/null @@ -1,10 +0,0 @@ -รายการ,สถานะ,การดำเนินการ -Core Modules,✅,พร้อม -Workflow Engine (DSL),✅,Code เสร็จแล้ว (รอ Seed Data) -Master Module,✅,Code เสร็จแล้ว -Workflow Seed Data,🔴,ต้องทำทันที (ใช้ Code ด้านบน) -Notification Digest,🟡,ตรวจสอบ Logic ภายใน Processor -Maintenance API,🟡,ตรวจสอบว่ามี Endpoint ให้ Admin กดไหม -DB Partitioning,🟡,เตรียม SQL Script ไว้รันก่อน Load Test - -ตรวจสอบ Maintenance API \ No newline at end of file diff --git a/~$Dis.xlsx b/~$Dis.xlsx new file mode 100644 index 0000000..09b6ca3 Binary files /dev/null and b/~$Dis.xlsx differ