No description
Find a file
waruneeauy 750947f34f 1. เพิ่ม helper สำหรับ build clone rows จาก metadata ของ repository แล้ว pre-generate UUID ให้ parent และ child ล่วงหน้า
2. เปลี่ยน inner clone flow เป็น cloneEmployeeNodeBatch(...) ที่ทำงานเป็นชุด แทนการ save() parent แล้ว save() children ทีละรายการ
3. ใช้ insertInChunks(...) สำหรับ batch insert ของ parent rows และ EmployeePosition rows
4. ใช้ helper เดียวกันซ้ำทุกระดับของ tree (root, child1, child2, child3, child4) เพื่อลด code duplication และคง mapping ของ destination org ids ตาม logic เดิม
2026-05-05 16:38:54 +07:00
.forgejo/workflows fix tag version 2026-03-04 17:02:19 +07:00
.vs แก้ caption ไอดี 2024-02-28 14:00:38 +07:00
docker fix 2026-02-27 07:56:04 +07:00
docs fix performance 2026-04-30 16:35:00 +07:00
scripts Revert "fix: sync and script keycloak" 2026-02-26 23:16:43 +07:00
sql_seed update 2026-04-24 16:15:47 +07:00
src 1. เพิ่ม helper สำหรับ build clone rows จาก metadata ของ repository แล้ว pre-generate UUID ให้ parent และ child ล่วงหน้า 2026-05-05 16:38:54 +07:00
static fist commit 2024-01-24 11:39:00 +07:00
.dockerignore fist commit 2024-01-24 11:39:00 +07:00
.env.example no message 2024-12-18 10:52:40 +07:00
.gitignore fix bug ออกคำสั่งยกเลิกลาออก #2183 + api แก้ไขเปลี่ยนผู้สร้างคำสั่ง #1551 2026-03-10 18:12:58 +07:00
.onedev-buildspec.yml edit @server@ 2025-02-02 17:46:40 +00:00
.prettierignore chore: update prettierignore setting 2024-03-20 11:12:24 +07:00
.prettierrc fist commit 2024-01-24 11:39:00 +07:00
CHANGELOG.md Changed LogMemoryStore from active refresh (setInterval) to passive refresh on-access (60 min TTL) 2026-01-29 00:30:34 +07:00
cliff.toml chore: git-cliff changelog 2024-03-13 11:29:15 +07:00
jest.config.js add test, and fix script 2026-02-09 17:45:50 +07:00
nodemon.json fist commit 2024-01-24 11:39:00 +07:00
package-lock.json Implement feature X to enhance user experience and fix bug Y in module Z 2026-03-24 15:25:11 +07:00
package.json add test, and fix script 2026-02-09 17:45:50 +07:00
pnpm-lock.yaml fist commit 2024-01-24 11:39:00 +07:00
README.md add read me 2025-11-12 23:28:16 +07:00
tsconfig.json fix 2026-02-26 22:10:33 +07:00
tsoa.json updated api web service 2025-08-07 17:14:56 +07:00

hrms-api-org

ระบบ API สำหรับจัดการข้อมูลบุคลากรและโครงสร้างองค์กร (HRMS)


Features

  • RESTful API (Express)
  • ฐานข้อมูล MySQL (TypeORM)
  • Cronjob อัตโนมัติ (node-cron)
  • WebSocket สำหรับ real-time
  • RabbitMQ integration
  • Swagger UI สำหรับ API docs
  • รองรับการ import/export ข้อมูล

🗂️ โครงสร้างโปรเจกต์หลัก

Path รายละเอียด
src/controllers/ API Controllers
src/entities/ Entity สำหรับ TypeORM
src/services/ Service logic (RabbitMQ, WebSocket)
src/database/data-source.ts ตั้งค่าเชื่อมต่อฐานข้อมูล
src/migration/ ไฟล์ migration ของฐานข้อมูล
static/ ไฟล์ static และ config
scripts/clean-migration-fk-idx.js สคริปต์ลบบรรทัด FK*/idx* ใน migration

🚀 การใช้งานเบื้องต้น

  1. ติดตั้ง dependencies

    npm install
    
  2. สร้างไฟล์ .env

    • กำหนดค่าฐานข้อมูลและ API_KEY ตามต้องการ
  3. Build และ Start

    npm run build
    npm start
    
  4. ดู API docs

    • เปิดที่ http://localhost:3000/api-docs

🛠️ คำสั่งที่สำคัญ (npm scripts)

  • npm run dev : รันแบบ development (hot reload)

  • npm run build : สร้างไฟล์สำหรับ production

  • npm run migration:generate : สร้าง migration ใหม่ เช่น

    npm run migration:generate src/migration/update_table_0811202s
    
  • npm run migration:run : รัน migration

  • node scripts/clean-migration-fk-idx.js : ลบบรรทัดที่มี FK_ หรือ idx_ ใน migration อัตโนมัติ (ควรรันหลัง gen migration ทุกครั้ง)


🐳 การ Build/Deploy ด้วย act (local GitHub Actions)

หากต้องการ build และ deploy ด้วย workflow release (เช่น ทดสอบ pipeline บนเครื่อง) ให้ใช้คำสั่งนี้:

act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357

อธิบาย option ที่ใช้:

  • -W .github/workflows/release.yaml : ระบุ workflow ที่จะรัน
  • --input IMAGE_VER=latest : กำหนด tag ของ docker image (เช่น latest)
  • -s DOCKER_USER=... : กำหนด secret สำหรับ docker registry
  • -s DOCKER_PASS=... : กำหนด secret สำหรับ docker registry
  • -s SSH_PASSWORD=... : กำหนด secret สำหรับ ssh deploy

⚠️ หมายเหตุ: สำหรับ production ห้ามใช้รหัสผ่านจริงใน public repo หรือแชร์ credentials


⚠️ หมายเหตุเกี่ยวกับ Migration

  • หลังจากใช้ npm run migration:generate แล้ว ต้องลบบรรทัดที่มี FK_ หรือ idx_ ออกจากไฟล์ migration ทุกครั้ง (ทั้งในฟังก์ชัน up/down)

  • สามารถใช้สคริปต์นี้ช่วยลบอัตโนมัติ:

    node scripts/clean-migration-fk-idx.js
    
  • สคริปต์นี้จะค้นหาและแทนที่บรรทัดที่มี FK_ หรือ idx_ ด้วย comment // removed FK_/idx_ auto-cleanup ในทุกไฟล์ migration


📄 License

Distributed under the ISC License.