From 2842ef423f4a6dc251c519b2c43459206ac2fd91 Mon Sep 17 00:00:00 2001 From: ngqile Date: Tue, 1 Dec 2026 11:53:48 +0800 Subject: [PATCH] feat(db): registration links, event lead source and consent, company privacy notices Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- local/seed/03-colite.sql | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/local/seed/03-colite.sql b/local/seed/03-colite.sql index 9bcabb6..b1d4eb1 100644 --- a/local/seed/03-colite.sql +++ b/local/seed/03-colite.sql @@ -253,3 +253,49 @@ USE `service-system`; INSERT INTO `module` (`id`, `name`, `desc`, `area`, `type`, `parent`, `url`, `icon_name`) VALUES (40050000, 'BO_DASHBOARD', 'Dashboard', 'BO', 'M', 40000000, '/', 'LayoutDashboard'); + +-- add-qr-self-registration/sql/01-registration-link.sql +USE `service-counter`; + +CREATE TABLE IF NOT EXISTS `registration_link` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `company_id` bigint NOT NULL, + `event_uuid` bigint NOT NULL, + `salesperson_user_id` bigint NULL, + `token` varchar(32) NOT NULL, + `enabled` bit(1) NOT NULL DEFAULT b'1', + `created_by` varchar(255) NULL, + `created_at` datetime NULL DEFAULT CURRENT_TIMESTAMP, + `updated_by` varchar(255) NULL, + `updated_at` datetime NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uk_registration_link_token` (`token`), + KEY `idx_registration_link_event` (`event_uuid`, `salesperson_user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +ALTER TABLE `event_lead` + ADD COLUMN `source` varchar(8) NOT NULL DEFAULT 'STAFF' AFTER `lead_type`, + ADD COLUMN `consent_at` datetime NULL AFTER `notes`, + ADD COLUMN `consent_notice_id` bigint NULL AFTER `consent_at`; + +-- add-qr-self-registration/sql/02-company-privacy-notice.sql +USE `service-system`; + +CREATE TABLE IF NOT EXISTS `company_privacy_notice` ( + `id` bigint NOT NULL AUTO_INCREMENT, + `company_id` bigint NOT NULL, + `text_en` text NOT NULL, + `text_ms` text NOT NULL, + `created_by` varchar(255) NULL, + `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `idx_company_privacy_notice_company` (`company_id`, `id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +INSERT INTO `company_privacy_notice` (`company_id`, `text_en`, `text_ms`, `created_by`) +SELECT c.`id`, + REPLACE('{company} collects the details you enter on this form (your name, mobile number, email, company, job title and interests) to contact you about our products, services and events, including by phone, SMS, WhatsApp and email. Your details are used only by {company} and the service providers who run this system for us, and are not sold to anyone. We keep them for as long as you remain a contact of ours or until you ask us to delete them. You may ask to see or correct your details, or withdraw this consent, at any time by contacting {company}. Giving your details is voluntary, but without them we cannot follow up with you.', '{company}', c.`name`), + REPLACE('{company} mengumpul butiran yang anda masukkan dalam borang ini (nama, nombor telefon bimbit, e-mel, syarikat, jawatan dan minat anda) untuk menghubungi anda mengenai produk, perkhidmatan dan acara kami, termasuk melalui telefon, SMS, WhatsApp dan e-mel. Butiran anda hanya digunakan oleh {company} dan pembekal perkhidmatan yang mengendalikan sistem ini bagi pihak kami, dan tidak dijual kepada sesiapa. Kami menyimpannya selagi anda kekal sebagai kenalan kami atau sehingga anda meminta kami memadamnya. Anda boleh meminta untuk melihat atau membetulkan butiran anda, atau menarik balik persetujuan ini, pada bila-bila masa dengan menghubungi {company}. Pemberian butiran adalah secara sukarela, tetapi tanpanya kami tidak dapat menghubungi anda.', '{company}', c.`name`), + 'default' +FROM `company` c +WHERE NOT EXISTS (SELECT 1 FROM `company_privacy_notice` n WHERE n.`company_id` = c.`id`);