S9 — RLPD Web Portal — Target Schema (Phase 2)¶
TARGET DESIGN — extension ของ PORTAL เดิม
S9 มี schema PORTAL อยู่แล้ว (48 ตาราง) — เอกสารนี้ ขยายต่อ ไม่ใช่สร้างใหม่ทั้งหมด · DDL เพิ่ม/แก้ใน
schema.sql · 📋 สิ่งที่ต่างจากเดิม · ERD · Data Dictionary · 🛠️ Backend Implementation · สถานะปัจจุบัน: ../../s9_webportal/
แนวทาง: reuse > modify > new¶
PORTAL เดิมครอบคลุม WPT-002/003/005/008 ไปแล้วมาก (UserProfile+Pid, RLPDSystems, PermissionRequest,
ApiTokens/Query Builder, routing ผ่าน PetitionRequestDepartments, SystemAccessLog) · จึงเพิ่มเฉพาะส่วนที่ SRS
ต้องการจริง ๆ: SSO multi-identity, security-policy config, survey, service-center routing, dashboard stats
🔑 Requirement → Table Traceability (spine)¶
| REQ | TOR/CR | สาระสำคัญ | ตาราง (tag) |
|---|---|---|---|
| REQ-WPT-001 | 7.19.1, CR-1/2/3/6 | Integration + OpenAPI, Service Center routing, Query Builder, multi-case | EndpointRegistry 🆕 · ServiceCenterRequest 🆕 · ServiceCenterRouting 🆕 · PublishedQuery 🆕 · reuse ApiKey/ApiTokens/OpenApiExecuteLog/PetitionRequestDepartments |
| REQ-WPT-002 | 7.19.2 | ฐานข้อมูลกลาง User–Subsystem membership (ThaiD) | UserSubsystemMembership 🆕 · reuse UserProfile(Pid), RLPDSystems, UserRole |
| REQ-WPT-003 | 7.19.3 | UI Card ตามสมาชิก + Breadcrumb | SubsystemCard 🆕 (filter ด้วย UserSubsystemMembership) · reuse RLPDSystems |
| REQ-WPT-004 | 7.19.4 | SSL/TLS รวมศูนย์ | ไม่มีผลต่อ schema — API Gateway / wildcard cert / SSL termination (infra) |
| REQ-WPT-005 | 7.19.5, CR-5, O-4/O-8 | Authorization รวมศูนย์ + "ขอสิทธิ์ AD เท่านั้น" + รวม role + อนุมัติใน Portal | PermissionRequest.AdOnlyAccess ✏️ · PermissionApproval 🆕 · SubsystemOwner 🆕 · Notification 🆕 · reuse RequestedPermissions, ModuleRoles, PermissionRequestUserRole |
| REQ-WPT-006 | 7.19.6, O-2/O-3 | ThaiD/Digital ID/AD + SSO + alt credential + dynamic downstream SSO | AuthProvider 🆕 · UserIdentity 🆕 · SsoSession 🆕 · SsoDownstreamGrant 🆕 |
| REQ-WPT-007 | 7.19.7, CR-4, O-7 | Lockout/aging/inactive/no-reuse + admin toggle + back-office config | SecurityPolicy 🆕 · PasswordHistory 🆕 · LoginAttempt 🆕 · UserSecurityStatus 🆕 · reuse PasswordResetToken |
| REQ-WPT-008 | 7.19.8 | Dashboard + สถิติช่วงเวลา + User/Audit Log + Export | AuditLog 🆕 · UsageStatDaily 🆕 · reuse SystemAccessLog · Export = app layer |
| REQ-WPT-009 | CR-7 (Extra) | แบบประเมินความพึงพอใจ + รายงาน/Export | Survey 🆕 · SurveyQuestion 🆕 · SurveyResponse 🆕 · SurveyAnswer 🆕 |
Legend: 🆕 new · ✏️ modify (ALTER) · reuse = ตารางเดิมใน PORTAL ใช้ต่อไม่แก้
REQ ที่ไม่มีผลต่อ schema
- REQ-WPT-004 SSL/TLS — reverse proxy / API Gateway / wildcard certificate (infra ล้วน)
- Export Excel/CSV (WPT-008/009) — application layer อ่านจาก
AuditLog/SystemAccessLog/UsageStatDaily/survey tables - Dynamic downstream SSO logic — protocol (SAML/OIDC) ที่ app/gateway; schema เก็บแค่
SsoSession/SsoDownstreamGrant
ตารางใหม่/แก้ไข (23 ใหม่ + 1 แก้)¶
| กลุ่ม | ตาราง | tag |
|---|---|---|
| Membership | UserSubsystemMembership |
🆕 |
| Card UI | SubsystemCard |
🆕 |
| Auth/SSO | AuthProvider, UserIdentity, SsoSession, SsoDownstreamGrant |
🆕 |
| Login security | SecurityPolicy, PasswordHistory, LoginAttempt, UserSecurityStatus |
🆕 |
| Authz routing | SubsystemOwner, PermissionApproval, Notification |
🆕 |
| Integration | EndpointRegistry, ServiceCenterRequest, ServiceCenterRouting, PublishedQuery |
🆕 |
| Dashboard | AuditLog, UsageStatDaily |
🆕 |
| Survey | Survey, SurveyQuestion, SurveyResponse, SurveyAnswer |
🆕 |
| Permission form | PermissionRequest (+AdOnlyAccess) |
✏️ |
ตารางเดิมที่ใช้ต่อ (reuse — ไม่แก้)¶
UserProfile (Pid=ThaiD), RLPDSystems, UserRole, ModuleRoles, Groups/SubGroups,
PermissionRequest (+lookups: Action/Agency/UserPosition/UserRole/UserType/UserWorkingGroup),
RequestedPermissions, PermissionRequestHistory/Files/RunningNumber,
PetitionRequests + PetitionRequestDepartments/Files/History, PetitionChannel,
ApiKey, ApiTokens (Query Builder token + AllowedQuery/AllowedIpAddresses), OpenApiExecuteLog, EmailSentLog,
SystemAccessLog, EmailNotificationSettings, PasswordResetToken, TaskStatusMapping, master/geo lookups
Role Hierarchy (SRS §3.1)¶
PORTAL_ADMIN · EXECUTIVE · AUDITOR · INTERNAL_USER · EXTERNAL_USER · EXTERNAL_AGENCY · CONSULTANT_USER
→ บริหารผ่าน UserRole (JSON roles per system) + ModuleRoles เดิม · CONSULTANT_USER ใช้ UserIdentity provider=LOCAL (alt credential, O-2)
ความเชื่อมโยงสำคัญ¶
- Card filtering:
UserSubsystemMembership.CitizenId(จาก ThaiD) → กรองSubsystemCardที่ผู้ใช้เห็น (WPT-003 อิง WPT-002) - Permission approval:
PermissionRequest→ กระจายPermissionApprovalรายSystemCode; เจ้าของระบบจากSubsystemOwnerได้Notificationแล้วอนุมัติใน Portal (WPT-005) - Service Center: intake
ServiceCenterRequest→ fan-outServiceCenterRoutingราย subsystem พร้อม accept/reject (CR-1 + CR-6 ใช้โครงเดียวกัน ต่างที่Origin) - Dashboard:
SystemAccessLog/AuditLog(raw) → roll-upUsageStatDaily(เร็วสำหรับกราฟช่วงเวลา)