251125:1200 6B
This commit is contained in:
436
docs/T0-T6.2.md
Normal file
436
docs/T0-T6.2.md
Normal file
@@ -0,0 +1,436 @@
|
||||
# โครงสร้างโฟลเดอร์และไฟล์ทั้งหมดสำหรับ **Backend (NestJS)** ตามแผนงาน **LCBP3-DMS v1.4.3** ตั้งแต่ Phase 0 ถึง Phase 6 (T0-T6.2) ที่ได้ดำเนินการไปแล้ว
|
||||
|
||||
โครงสร้างนี้ออกแบบตามหลัก **Domain-Driven Design** และ **Modular Architecture** ที่ระบุไว้ในแผนพัฒนา
|
||||
|
||||
---
|
||||
|
||||
## 📂 **backend/** (Backend Application)
|
||||
|
||||
* [x] `.env` (สำหรับ Local Dev เท่านั้น ห้าม commit)
|
||||
* [x] `.gitignore`
|
||||
* [x] `docker-compose.yml` (Configuration หลักสำหรับ Deploy)
|
||||
* [x] `docker-compose.override.yml` (สำหรับ Inject Secrets ตอน Dev)
|
||||
* [x] `package.json`
|
||||
* [x] `pnpm-lock.yaml`
|
||||
* [x] `tsconfig.json`
|
||||
* [x] `nest-cli.json`
|
||||
* [x] `README.md`
|
||||
|
||||
---
|
||||
|
||||
## 📂 **backend/src/** (Source Code)
|
||||
|
||||
### **📄 Entry Points**
|
||||
|
||||
* [x] `main.ts` (Application Bootstrap, Swagger, Global Pipes)
|
||||
* [x] `app.module.ts` (Root Module ที่รวมทุก Modules เข้าด้วยกัน)
|
||||
|
||||
### **📁 src/common/** (Shared Resources)
|
||||
|
||||
* [x] **common.module.ts**
|
||||
* **auth/**
|
||||
* **dto/**
|
||||
* [x] **login.dto.ts**
|
||||
* [x] **register.dto.ts**
|
||||
* [x] **auth.controller.spec.ts**
|
||||
* [x] **auth.controller.ts**
|
||||
* [x] **auth.module.ts**
|
||||
* [x] **auth.service.spec.ts**
|
||||
* [x] **auth.service.ts**
|
||||
* **config/** (Configuration Service)
|
||||
* [x] **env.validation.ts**
|
||||
* **decorators/**
|
||||
* [x] **audit.decorator.ts**
|
||||
* [x] `current-user.decorator.ts`
|
||||
* [x] `require-permission.decorator.ts`
|
||||
* **entities/**
|
||||
* [x] **audit-log.entity.ts**
|
||||
* [x] **base.entity.ts**
|
||||
* **exceptions/**
|
||||
* [x] `http-exception.filter.ts` (Global Filter)
|
||||
* **file-storage/** (Two-Phase Storage System)
|
||||
* **entities/**
|
||||
* [x] **attachment.entity.ts**
|
||||
* [x] **file-storage.controller.spec.ts**
|
||||
* [x] **file-storage.controller.ts**
|
||||
* [x] **file-storage.module.ts**
|
||||
* [x] **file-storage.service.spec.ts**
|
||||
* [x] `file-storage.service.ts` (Upload, Scan Virus, Commit)
|
||||
* [x] `guards/`
|
||||
* [x] `jwt-auth.guard.ts`
|
||||
* [x] **jwt.strategy.ts**
|
||||
* [x] `rbac.guard.ts` (ตรวจสอบสิทธิ์ 4 ระดับ)
|
||||
* **interceptors/**
|
||||
* [x] `audit-log.interceptor.ts` (เก็บ Log ลง DB)
|
||||
* [x] `transform.interceptor.ts` (Standard Response Format)
|
||||
* **resilience/** (Circuit Breaker & Retry)
|
||||
|
||||
### **📁 src/modules/** (Feature Modules)
|
||||
|
||||
1. **user/** (User Management & RBAC)
|
||||
* [x] `dto/`
|
||||
* [x] **assign-user-role.dto.ts**
|
||||
* [x] `create-user.dto.ts`
|
||||
* [x] `update-user.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `user.entity.ts`
|
||||
* [x] `role.entity.ts`
|
||||
* [x] `permission.entity.ts`
|
||||
* [x] `user-preference.entity.ts`
|
||||
* [x] **user-assignment.service.ts**
|
||||
* [x] `user.controller.ts`
|
||||
* [x] `user.module.ts`
|
||||
* [x] `user.service.ts`
|
||||
* [x] **user.service.spec.ts**
|
||||
|
||||
2. **project/** (Project Structure)
|
||||
* [x] `dto/`
|
||||
* [x] **create-project.dto.ts**
|
||||
* [x] `search-project.dto.ts`
|
||||
* [x] `update-project.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `contract-organization.entity.ts`
|
||||
* [x] `contract.entity.ts`
|
||||
* [x] `organization.entity.ts`
|
||||
* [x] `project-organization.entity.ts` (Junction)
|
||||
* [x] **project.entity.ts**
|
||||
* [x] **project.controller.spec.ts**
|
||||
* [x] `project.controller.ts`
|
||||
* [x] `project.module.ts`
|
||||
* [x] **project.service.spec.ts**
|
||||
* [x] `project.service.ts`
|
||||
|
||||
3. **correspondence/** (Core Document System)
|
||||
* [x] `dto/`
|
||||
* [x] `add-reference.dto.ts`
|
||||
* [x] `create-correspondence.dto.ts`
|
||||
* [x] `search-correspondence.dto.ts`
|
||||
* [x] **submit-correspondence.dto.ts**
|
||||
* [x] `workflow-action.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `correspondence-reference.entity.ts`
|
||||
* [x] `correspondence-revision.entity.ts`
|
||||
* [x] `correspondence-routing.entity.ts` (Unified Workflow)
|
||||
* [x] `correspondence-status.entity.ts`
|
||||
* [x] `correspondence-type.entity.ts`
|
||||
* [x] `correspondence.entity.ts`
|
||||
* [x] **routing-template-step.entity.ts**
|
||||
* [x] `routing-template.entity.ts`
|
||||
* [x] **correspondence.controller.spec.ts**
|
||||
* [x] `correspondence.controller.ts`
|
||||
* [x] `correspondence.module.ts`
|
||||
* [x] **correspondence.service.spec.ts**
|
||||
* [x] `correspondence.service.ts` (Impersonation & Workflow Logic)
|
||||
|
||||
4. **drawing/** (Contract & Shop Drawings)
|
||||
* [x] `dto/`
|
||||
* [x] `create-contract-drawing.dto.ts`
|
||||
* [x] `create-shop-drawing-revision.dto.ts`
|
||||
* [x] `create-shop-drawing.dto.ts`
|
||||
* [x] `search-contract-drawing.dto.ts`
|
||||
* [x] `search-shop-drawing.dto.ts`
|
||||
* [x] `update-contract-drawing.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `contract-drawing-sub-category.entity.ts`
|
||||
* [x] `contract-drawing-volume.entity.ts`
|
||||
* [x] `contract-drawing.entity.ts`
|
||||
* [x] `shop-drawing-main-category.entity.ts`
|
||||
* [x] `shop-drawing-revision.entity.ts`
|
||||
* [x] `shop-drawing-sub-category.entity.ts`
|
||||
* [x] `shop-drawing.entity.ts`
|
||||
* [x] `contract-drawing.controller.ts`
|
||||
* [x] `contract-drawing.service.ts`
|
||||
* [x] `drawing-master-data.controller.ts`
|
||||
* [x] `drawing-master-data.service.ts`
|
||||
* [x] `drawing.module.ts`
|
||||
* [x] `shop-drawing.controller.ts`
|
||||
* [x] `shop-drawing.service.ts`
|
||||
|
||||
4. **rfa/** (Request for Approval & Advanced Workflow)
|
||||
* [x] `dto/`
|
||||
* [x] `create-rfa.dto.ts`
|
||||
* [x] `search-rfa.dto.ts`
|
||||
* [x] `update-rfa.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `rfa-approve-code.entity.ts`
|
||||
* [x] `rfa-item.entity.ts`
|
||||
* [x] `rfa-revision.entity.ts`
|
||||
* [x] `rfa-status-code.entity.ts`
|
||||
* [x] `rfa-type.entity.ts`
|
||||
* [x] `rfa-workflow-template-step.entity.ts`
|
||||
* [x] `rfa-workflow-template.entity.ts`
|
||||
* [x] `rfa-workflow.entity.ts`
|
||||
* [x] `rfa.entity.ts`
|
||||
* [x] `rfa.controller.ts`
|
||||
* [x] `rfa.module.ts`
|
||||
* [x] `rfa.service.ts` (Unified Workflow Integration)
|
||||
|
||||
5. **circulation/** (Internal Routing)
|
||||
* [x] `dto/`
|
||||
* [x] `create-circulation.dto.ts`
|
||||
* [x] `update-circulation-routing.dto.ts`
|
||||
* [x] `search-circulation.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `circulation-routing.entity.ts`
|
||||
* [x] `circulation-status-code.entity.ts`
|
||||
* [x] `circulation.entity.ts`
|
||||
* [x] `circulation.controller.ts`
|
||||
* [x] `circulation.module.ts`
|
||||
* [x] `circulation.service.ts`
|
||||
|
||||
6. **transmittal/** (Document Forwarding)
|
||||
* [x] `dto/`
|
||||
* [x] `create-transmittal.dto.ts`
|
||||
* [x] `search-transmittal.dto.ts`
|
||||
* [x] **update-transmittal.dto.ts**
|
||||
* [x] `entities/`
|
||||
* [x] `transmittal-item.entity.ts`
|
||||
* [x] `transmittal.entity.ts`
|
||||
* [x] `transmittal.controller.ts`
|
||||
* [x] `transmittal.module.ts`
|
||||
* [x] `transmittal.service.ts`
|
||||
|
||||
7. **notification/** (System Alerts)
|
||||
* [x] `dto/`
|
||||
* [x] `create-notification.dto.ts`
|
||||
* [x] `search-notification.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `notification.entity.ts`
|
||||
* [x] `notification-cleanup.service.ts` (Cron Job)
|
||||
* [x] `notification.controller.ts`
|
||||
* [x] `notification.gateway.ts`
|
||||
* [x] `notification.module.ts` (Real-time WebSocket)
|
||||
* [x] `notification.processor.ts` (Consumer/Worker for Email & Line)
|
||||
* [x] `notification.service.ts` (Producer)
|
||||
|
||||
8. **search/** (Elasticsearch)
|
||||
* [x] `dto/search-query.dto.ts`
|
||||
* [x] `search.controller.ts`
|
||||
* [x] `search.module.ts`
|
||||
* [x] `search.service.ts` (Indexing & Searching)
|
||||
|
||||
9. **document-numbering/** (Internal Service)
|
||||
* [x] `entities/`
|
||||
* [x] `document-number-format.entity.ts`
|
||||
* [x] `document-number-counter.entity.ts`
|
||||
* [x] `document-numbering.module.ts`
|
||||
* [x] **document-numbering.service.spec.ts**
|
||||
* [x] `document-numbering.service.ts` (Double-Lock Mechanism)
|
||||
|
||||
10. **workflow-engine/** (Unified Logic)
|
||||
* [x] `interfaces/workflow.interface.ts`
|
||||
* [x] `workflow-engine.module.ts`
|
||||
* [x] **workflow-engine.service.spec.ts**
|
||||
* [x] `workflow-engine.service.ts` (State Machine Logic)
|
||||
|
||||
11. **json-schema/** (Validation)
|
||||
* [x] `dto/`
|
||||
* [x] `create-json-schema.dto.ts`+
|
||||
* [x] `search-json-schema.dto.ts`
|
||||
* [x] `update-json-schema.dto.ts`
|
||||
* [x] `entities/`
|
||||
* [x] `json-schema.entity.ts`
|
||||
* [x] **json-schema.controller.spec.ts**
|
||||
* [x] **json-schema.controller.ts**
|
||||
* [x] `json-schema.module.ts`
|
||||
* [x] **json-schema.service.spec.ts**
|
||||
* [x] `json-schema.service.ts`
|
||||
|
||||
---
|
||||
|
||||
นี่คือโครงสร้าง **Folder Structure** ของโปรเจกต์ Backend (NestJS) ฉบับสมบูรณ์ ที่รวบรวมจาก **Requirements**, **FullStackJS Guidelines**, **Data Dictionary** และสิ่งที่เราได้ **Implement ไปแล้วตั้งแต่ Phase 0 ถึง Phase 6.2** ครับ
|
||||
|
||||
โครงสร้างนี้เป็นแบบ **Domain-Driven Modular Architecture** ครับ
|
||||
|
||||
```text
|
||||
lcbp3-backend/
|
||||
├── .env # Environment variables (Local Dev)
|
||||
├── .gitignore
|
||||
├── docker-compose.yml # Main config for services (DB, Redis, ES, App)
|
||||
├── docker-compose.override.yml # Secrets injection for Dev
|
||||
├── nest-cli.json
|
||||
├── package.json
|
||||
├── pnpm-lock.yaml
|
||||
├── README.md
|
||||
├── tsconfig.json
|
||||
│
|
||||
└── src/
|
||||
├── main.ts # Entry point (Swagger, Helmet, Global Pipes)
|
||||
├── app.module.ts # Root Module
|
||||
│
|
||||
├── common/ # 🛠️ Shared Resources
|
||||
│ ├── auth/
|
||||
│ │ ├── guards/
|
||||
│ │ │ ├── jwt-auth.guard.ts
|
||||
│ │ │ └── rbac.guard.ts
|
||||
│ │ └── strategies/
|
||||
│ │ └── jwt.strategy.ts
|
||||
│ ├── config/ # Config Service
|
||||
│ ├── decorators/
|
||||
│ │ ├── current-user.decorator.ts
|
||||
│ │ └── require-permission.decorator.ts
|
||||
│ ├── exceptions/
|
||||
│ │ └── http-exception.filter.ts
|
||||
│ ├── file-storage/ # 📂 Two-Phase Storage System
|
||||
│ │ ├── dto/
|
||||
│ │ ├── entities/
|
||||
│ │ │ └── attachment.entity.ts
|
||||
│ │ ├── file-storage.module.ts
|
||||
│ │ └── file-storage.service.ts
|
||||
│ ├── interceptors/
|
||||
│ │ ├── audit-log.interceptor.ts
|
||||
│ │ └── transform.interceptor.ts
|
||||
│ └── resilience/ # Circuit Breaker & Retry logic
|
||||
│
|
||||
└── modules/ # 📦 Feature Modules
|
||||
│
|
||||
├── user/ # 👤 User & RBAC
|
||||
│ ├── dto/
|
||||
│ │ ├── create-user.dto.ts
|
||||
│ │ └── update-user.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── permission.entity.ts
|
||||
│ │ ├── role.entity.ts
|
||||
│ │ ├── user-preference.entity.ts
|
||||
│ │ └── user.entity.ts
|
||||
│ ├── user.controller.ts
|
||||
│ ├── user.module.ts
|
||||
│ └── user.service.ts
|
||||
│
|
||||
├── project/ # 🏢 Projects & Organizations
|
||||
│ ├── dto/
|
||||
│ │ ├── create-project.dto.ts
|
||||
│ │ ├── search-project.dto.ts
|
||||
│ │ └── update-project.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── contract-organization.entity.ts
|
||||
│ │ ├── contract.entity.ts
|
||||
│ │ ├── organization.entity.ts
|
||||
│ │ ├── project-organization.entity.ts
|
||||
│ │ └── project.entity.ts
|
||||
│ ├── project.controller.ts
|
||||
│ ├── project.module.ts
|
||||
│ └── project.service.ts
|
||||
│
|
||||
├── correspondence/ # ✉️ Core Document
|
||||
│ ├── dto/
|
||||
│ │ ├── add-reference.dto.ts
|
||||
│ │ ├── create-correspondence.dto.ts
|
||||
│ │ ├── search-correspondence.dto.ts
|
||||
│ │ └── workflow-action.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── correspondence-reference.entity.ts
|
||||
│ │ ├── correspondence-revision.entity.ts
|
||||
│ │ ├── correspondence-routing.entity.ts
|
||||
│ │ ├── correspondence-status.entity.ts
|
||||
│ │ ├── correspondence-type.entity.ts
|
||||
│ │ ├── correspondence.entity.ts
|
||||
│ │ └── routing-template.entity.ts
|
||||
│ ├── correspondence.controller.ts
|
||||
│ ├── correspondence.module.ts
|
||||
│ └── correspondence.service.ts
|
||||
│
|
||||
├── drawing/ # 📐 Shop & Contract Drawings
|
||||
│ ├── dto/
|
||||
│ │ ├── create-contract-drawing.dto.ts
|
||||
│ │ ├── create-shop-drawing-revision.dto.ts
|
||||
│ │ ├── create-shop-drawing.dto.ts
|
||||
│ │ ├── search-contract-drawing.dto.ts
|
||||
│ │ ├── search-shop-drawing.dto.ts
|
||||
│ │ └── update-contract-drawing.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── contract-drawing-sub-category.entity.ts
|
||||
│ │ ├── contract-drawing-volume.entity.ts
|
||||
│ │ ├── contract-drawing.entity.ts
|
||||
│ │ ├── shop-drawing-main-category.entity.ts
|
||||
│ │ ├── shop-drawing-revision.entity.ts
|
||||
│ │ ├── shop-drawing-sub-category.entity.ts
|
||||
│ │ └── shop-drawing.entity.ts
|
||||
│ ├── contract-drawing.controller.ts
|
||||
│ ├── contract-drawing.service.ts
|
||||
│ ├── drawing-master-data.controller.ts
|
||||
│ ├── drawing-master-data.service.ts
|
||||
│ ├── drawing.module.ts
|
||||
│ ├── shop-drawing.controller.ts
|
||||
│ └── shop-drawing.service.ts
|
||||
│
|
||||
├── rfa/ # ✅ Request for Approval
|
||||
│ ├── dto/
|
||||
│ │ ├── create-rfa.dto.ts
|
||||
│ │ ├── search-rfa.dto.ts
|
||||
│ │ └── update-rfa.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── rfa-approve-code.entity.ts
|
||||
│ │ ├── rfa-item.entity.ts
|
||||
│ │ ├── rfa-revision.entity.ts
|
||||
│ │ ├── rfa-status-code.entity.ts
|
||||
│ │ ├── rfa-type.entity.ts
|
||||
│ │ ├── rfa-workflow-template-step.entity.ts
|
||||
│ │ ├── rfa-workflow-template.entity.ts
|
||||
│ │ ├── rfa-workflow.entity.ts
|
||||
│ │ └── rfa.entity.ts
|
||||
│ ├── rfa.controller.ts
|
||||
│ ├── rfa.module.ts
|
||||
│ └── rfa.service.ts
|
||||
│
|
||||
├── circulation/ # 🔄 Internal Routing
|
||||
│ ├── dto/
|
||||
│ │ ├── create-circulation.dto.ts
|
||||
│ │ ├── search-circulation.dto.ts
|
||||
│ │ └── update-circulation-routing.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── circulation-routing.entity.ts
|
||||
│ │ ├── circulation-status-code.entity.ts
|
||||
│ │ └── circulation.entity.ts
|
||||
│ ├── circulation.controller.ts
|
||||
│ ├── circulation.module.ts
|
||||
│ └── circulation.service.ts
|
||||
│
|
||||
├── transmittal/ # 📤 Outgoing Documents
|
||||
│ ├── dto/
|
||||
│ │ ├── create-transmittal.dto.ts
|
||||
│ │ └── search-transmittal.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ ├── transmittal-item.entity.ts
|
||||
│ │ └── transmittal.entity.ts
|
||||
│ ├── transmittal.controller.ts
|
||||
│ ├── transmittal.module.ts
|
||||
│ └── transmittal.service.ts
|
||||
│
|
||||
├── notification/ # 🔔 Real-time & Queue
|
||||
│ ├── dto/
|
||||
│ │ ├── create-notification.dto.ts
|
||||
│ │ └── search-notification.dto.ts
|
||||
│ ├── entities/
|
||||
│ │ └── notification.entity.ts
|
||||
│ ├── notification-cleanup.service.ts
|
||||
│ ├── notification.controller.ts
|
||||
│ ├── notification.gateway.ts
|
||||
│ ├── notification.module.ts
|
||||
│ ├── notification.processor.ts
|
||||
│ └── notification.service.ts
|
||||
│
|
||||
├── search/ # 🔍 Elasticsearch
|
||||
│ ├── dto/
|
||||
│ │ └── search-query.dto.ts
|
||||
│ ├── search.controller.ts
|
||||
│ ├── search.module.ts
|
||||
│ └── search.service.ts
|
||||
│
|
||||
├── document-numbering/ # 🔢 Internal Numbering Service
|
||||
│ ├── entities/
|
||||
│ │ ├── document-number-counter.entity.ts
|
||||
│ │ └── document-number-format.entity.ts
|
||||
│ ├── document-numbering.module.ts
|
||||
│ └── document-numbering.service.ts
|
||||
│
|
||||
├── workflow-engine/ # ⚙️ Unified Logic
|
||||
│ ├── interfaces/
|
||||
│ │ └── workflow.interface.ts
|
||||
│ ├── workflow-engine.module.ts
|
||||
│ └── workflow-engine.service.ts
|
||||
│
|
||||
└── json-schema/ # 📋 Validation Logic
|
||||
├── json-schema.module.ts
|
||||
└── json-schema.service.ts
|
||||
```
|
||||
BIN
docs/extensions_list.txt
Normal file
BIN
docs/extensions_list.txt
Normal file
Binary file not shown.
226
docs/prompt.md
Normal file
226
docs/prompt.md
Normal file
@@ -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) สามารถแจ้งได้เลยครับ
|
||||
59
docs/temp.md
Normal file
59
docs/temp.md
Normal file
@@ -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 |
|
||||
Reference in New Issue
Block a user