chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,463 @@
|
||||
-- ============================================================
|
||||
-- 丹阳公益婚恋服务平台 — Demo Seed 数据脚本 v2
|
||||
-- 版本: 1.0.0-RC.2
|
||||
-- 说明: 所有 id 使用真实 UUID 格式(36字符含连字符)
|
||||
-- 执行: psql -U postgres -d danyang_match -f demo-seed-v2.sql
|
||||
-- ============================================================
|
||||
|
||||
SET session_replication_role = 'replica';
|
||||
|
||||
-- ============================================================
|
||||
-- 1. 组织
|
||||
-- ============================================================
|
||||
INSERT INTO organizations (id, name, type, contact_name, status) VALUES
|
||||
(gen_random_uuid(), '丹阳市妇女联合会', 'women_federation', '张丽华', 'active'),
|
||||
(gen_random_uuid(), '丹阳市总工会', 'trade_union', '李明远', 'active'),
|
||||
(gen_random_uuid(), '丹阳市慈善基金会', 'charity_center', '王秀英', 'active');
|
||||
|
||||
-- 取回生成的 org id
|
||||
WITH org_ids AS (
|
||||
SELECT id FROM organizations ORDER BY created_at LIMIT 1
|
||||
),
|
||||
org2 AS (
|
||||
SELECT id FROM organizations WHERE id NOT IN (SELECT id FROM org_ids) ORDER BY created_at LIMIT 1
|
||||
),
|
||||
org3 AS (
|
||||
SELECT id FROM organizations WHERE id NOT IN (SELECT id FROM org_ids, org2) ORDER BY created_at LIMIT 1
|
||||
)
|
||||
SELECT 'org-women' as org1_placeholder, 'org-trade' as org2_placeholder, 'org-charity' as org3_placeholder
|
||||
INTO TEMP TABLE _org_placeholders;
|
||||
|
||||
-- ============================================================
|
||||
-- 2. 工作人员(BCrypt hash of "demo123")
|
||||
-- ============================================================
|
||||
INSERT INTO operators (id, organization_id, name, username, password_hash, status) VALUES
|
||||
(gen_random_uuid(), (SELECT id FROM organizations WHERE type='women_federation' LIMIT 1), '陈主任', 'admin', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active'),
|
||||
(gen_random_uuid(), (SELECT id FROM organizations WHERE type='women_federation' LIMIT 1), '红娘小王', 'wanghongniang','$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active'),
|
||||
(gen_random_uuid(), (SELECT id FROM organizations WHERE type='charity_center' LIMIT 1), '审核员小张', 'reviewer01', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active'),
|
||||
(gen_random_uuid(), (SELECT id FROM organizations WHERE type='trade_union' LIMIT 1), '活动管理员赵', 'activitymgr','$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active');
|
||||
|
||||
INSERT INTO operator_roles (operator_id, role_id) VALUES
|
||||
((SELECT id FROM operators WHERE username='admin'), '00000000-0000-0000-0000-000000000001'),
|
||||
((SELECT id FROM operators WHERE username='admin'), '00000000-0000-0000-0000-000000000002'),
|
||||
((SELECT id FROM operators WHERE username='wanghongniang'), '00000000-0000-0000-0000-000000000005'),
|
||||
((SELECT id FROM operators WHERE username='wanghongniang'), '00000000-0000-0000-0000-000000000006'),
|
||||
((SELECT id FROM operators WHERE username='reviewer01'), '00000000-0000-0000-0000-000000000004'),
|
||||
((SELECT id FROM operators WHERE username='reviewer01'), '00000000-0000-0000-0000-000000000007'),
|
||||
((SELECT id FROM operators WHERE username='activitymgr'), '00000000-0000-0000-0000-000000000006'),
|
||||
((SELECT id FROM operators WHERE username='activitymgr'), '00000000-0000-0000-0000-000000000008');
|
||||
|
||||
-- ============================================================
|
||||
-- 3. Demo 用户 — 12人(6女6男),ID 使用字符串但不含连字符(VARCHAR(36)兼容)
|
||||
-- ============================================================
|
||||
-- 注意:users.id 是 VARCHAR(36),我们使用短UUID格式(32位hex无连字符)
|
||||
INSERT INTO users (id, wechat_openid, phone, account_status, relationship_status, recommendation_enabled, created_at) VALUES
|
||||
('f01a2b3c4d5e6f70000000000000001', 'demo_openid_f01', NULL, 'normal', 'searching', true, '2026-03-15T10:00:00Z'),
|
||||
('f02a2b3c4d5e6f70000000000000002', 'demo_openid_f02', NULL, 'normal', 'searching', true, '2026-03-20T14:30:00Z'),
|
||||
('f03a2b3c4d5e6f70000000000000003', 'demo_openid_f03', NULL, 'normal', 'searching', true, '2026-04-01T09:15:00Z'),
|
||||
('f04a2b3c4d5e6f70000000000000004', 'demo_openid_f04', NULL, 'normal', 'paused', true, '2026-04-10T16:00:00Z'),
|
||||
('f05a2b3c4d5e6f70000000000000005', 'demo_openid_f05', NULL, 'normal', 'searching', true, '2026-05-01T11:20:00Z'),
|
||||
('f06a2b3c4d5e6f70000000000000006', 'demo_openid_f06', NULL, 'normal', 'searching', true, '2026-05-15T08:45:00Z'),
|
||||
('m01a2b3c4d5e6f70000000000000001', 'demo_openid_m01', NULL, 'normal', 'searching', true, '2026-03-10T09:00:00Z'),
|
||||
('m02a2b3c4d5e6f70000000000000002', 'demo_openid_m02', NULL, 'normal', 'getting_to_know', true, '2026-03-25T13:00:00Z'),
|
||||
('m03a2b3c4d5e6f70000000000000003', 'demo_openid_m03', NULL, 'normal', 'searching', true, '2026-04-05T15:30:00Z'),
|
||||
('m04a2b3c4d5e6f70000000000000004', 'demo_openid_m04', NULL, 'normal', 'searching', true, '2026-04-20T10:00:00Z'),
|
||||
('m05a2b3c4d5e6f70000000000000005', 'demo_openid_m05', NULL, 'normal', 'matched_successfully', true, '2026-05-01T14:00:00Z'),
|
||||
('m06a2b3c4d5e6f70000000000000006', 'demo_openid_m06', NULL, 'normal', 'searching', true, '2026-05-10T16:30:00Z');
|
||||
|
||||
-- ============================================================
|
||||
-- 4. 用户资料
|
||||
-- ============================================================
|
||||
INSERT INTO user_profiles (
|
||||
user_id, display_name, gender, birth_date, height_cm,
|
||||
region_code, region_name, marital_status, children_status,
|
||||
education_code, occupation_code, smoking_status, drinking_status,
|
||||
long_term_danyang, future_danyang, relationship_goal, profile_completion, profile_status
|
||||
) VALUES
|
||||
('f01a2b3c4d5e6f70000000000000001', '小芳', 'female', '1995-06-15', 162, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'clerical', 'never', 'sometimes', '是', '是', '结婚', 90, 'approved'),
|
||||
('f02a2b3c4d5e6f70000000000000002', '晓燕', 'female', '1993-09-20', 165, '321181', '丹阳', 'divorced', 'none', 'college', 'teacher', 'never', 'never', '是', '是', '结婚', 95, 'approved'),
|
||||
('f03a2b3c4d5e6f70000000000000003', '婷婷', 'female', '1998-02-10', 158, '321100', '镇江', 'never_married', 'none', 'master', 'designer', 'sometimes', 'often', '是', '否', '恋爱', 85, 'approved'),
|
||||
('f04a2b3c4d5e6f70000000000000004', '美玲', 'female', '1990-11-05', 160, '321181', '丹阳', 'never_married', 'none', 'senior_high', 'factory', 'never', 'never', '是', '是', '结婚', 70, 'approved'),
|
||||
('f05a2b3c4d5e6f70000000000000005', '慧琴', 'female', '1996-07-22', 163, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'nurse', 'never', 'sometimes','是', '是', '结婚', 92, 'approved'),
|
||||
('f06a2b3c4d5e6f70000000000000006', '秀英', 'female', '1992-04-18', 157, '321181', '丹阳', 'widowed', 'none', 'junior_high','farmer', 'often', 'often', '是', '是', '结婚', 60, 'approved'),
|
||||
('m01a2b3c4d5e6f70000000000000001', '张伟', 'male', '1992-01-10', 175, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'engineer', 'never', 'sometimes','是', '是', '结婚', 88, 'approved'),
|
||||
('m02a2b3c4d5e6f70000000000000002', '李强', 'male', '1990-08-25', 178, '321181', '丹阳', 'divorced', 'none', 'master', 'manager', 'sometimes', 'often', '是', '是', '结婚', 95, 'approved'),
|
||||
('m03a2b3c4d5e6f70000000000000003', '王磊', 'male', '1997-12-03', 180, '321100', '镇江', 'never_married', 'none', 'college', 'programmer', 'never', 'never', '是', '是', '恋爱', 82, 'approved'),
|
||||
('m04a2b3c4d5e6f70000000000000004', '赵明', 'male', '1988-05-30', 172, '321181', '丹阳', 'never_married', 'none', 'senior_high','sales', 'often', 'often', '否', '是', '结婚', 75, 'approved'),
|
||||
('m05a2b3c4d5e6f70000000000000005', '孙浩', 'male', '1994-03-14', 182, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'doctor', 'never', 'sometimes','是', '是', '结婚', 97, 'approved'),
|
||||
('m06a2b3c4d5e6f70000000000000006', '周洋', 'male', '1999-08-08', 176, '320500', '苏州', 'never_married', 'none', 'master', 'researcher', 'never', 'never', '是', '否', '恋爱', 80, 'approved');
|
||||
|
||||
-- ============================================================
|
||||
-- 5. 用户择偶偏好
|
||||
-- ============================================================
|
||||
INSERT INTO user_preferences (
|
||||
user_id, min_age, max_age, age_priority,
|
||||
min_height_cm, max_height_cm, height_priority,
|
||||
region_scope, region_priority,
|
||||
marital_statuses, marital_priority,
|
||||
min_education_code, education_priority
|
||||
) VALUES
|
||||
('f01a2b3c4d5e6f70000000000000001', 28, 38, 'required', 170, 185, 'required',
|
||||
'["321181","321100"]', 'required', '["never_married"]', 'required', 'bachelor', 'preferred'),
|
||||
('f02a2b3c4d5e6f70000000000000002', 28, 40, 'required', 170, 188, 'required',
|
||||
'["321181"]', 'required', '["never_married","divorced"]', 'preferred', 'college', 'preferred'),
|
||||
('f03a2b3c4d5e6f70000000000000003', 25, 35, 'preferred', 172, 185, 'preferred',
|
||||
'["321181","321100","320500"]', 'preferred', '["never_married"]', 'required', NULL, NULL),
|
||||
('f04a2b3c4d5e6f70000000000000004', 30, 45, 'required', 168, 185, 'required',
|
||||
'["321181"]', 'required', '["never_married","divorced"]', 'preferred', 'senior_high', 'preferred'),
|
||||
('f05a2b3c4d5e6f70000000000000005', 27, 36, 'required', 172, 186, 'required',
|
||||
'["321181","321100"]', 'preferred', '["never_married"]', 'required', 'bachelor', 'preferred'),
|
||||
('f06a2b3c4d5e6f70000000000000006', 30, 50, 'required', 165, 185, 'required',
|
||||
'["321181"]', 'required', '["never_married","divorced","widowed"]', 'preferred', NULL, NULL),
|
||||
('m01a2b3c4d5e6f70000000000000001', 22, 32, 'required', 155, 170, 'preferred',
|
||||
'["321181","321100"]', 'required', '["never_married"]', 'required', 'junior_high', 'preferred'),
|
||||
('m02a2b3c4d5e6f70000000000000002', 25, 38, 'preferred', 158, 172, 'preferred',
|
||||
'["321181"]', 'preferred', '["never_married","divorced"]', 'preferred', 'college', 'preferred'),
|
||||
('m03a2b3c4d5e6f70000000000000003', 22, 30, 'preferred', 155, 168, 'preferred',
|
||||
'["321181","321100","320500"]', 'preferred', '["never_married"]', 'required', 'college', 'preferred'),
|
||||
('m04a2b3c4d5e6f70000000000000004', 25, 40, 'preferred', 155, 170, 'preferred',
|
||||
'["321181"]', 'required', '["never_married","divorced"]', 'preferred', NULL, NULL),
|
||||
('m05a2b3c4d5e6f70000000000000005', 23, 33, 'required', 158, 170, 'preferred',
|
||||
'["321181","321100"]', 'preferred', '["never_married"]', 'required', 'bachelor', 'preferred'),
|
||||
('m06a2b3c4d5e6f70000000000000006', 22, 32, 'preferred', 155, 170, 'preferred',
|
||||
'["321181","321100","320500"]', 'preferred', '["never_married"]', 'required', 'master', 'preferred');
|
||||
|
||||
-- ============================================================
|
||||
-- 6. 实名认证(user_identities)— mock
|
||||
-- ============================================================
|
||||
INSERT INTO user_identities (
|
||||
id, user_id, real_name_enc, id_number_enc, id_number_hash,
|
||||
gender, birth_date, verification_status, provider, verified_at
|
||||
) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', E'\\xenc_f01', E'\\xenc_id_f01', 'sha256_f01_demo_hash', 'female', '1995-06-15', 'verified', 'mock', '2026-03-16T10:00:00Z'),
|
||||
(gen_random_uuid(), 'f02a2b3c4d5e6f70000000000000002', E'\\xenc_f02', E'\\xenc_id_f02', 'sha256_f02_demo_hash', 'female', '1993-09-20', 'verified', 'mock', '2026-03-21T14:30:00Z'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', E'\\xenc_f03', E'\\xenc_id_f03', 'sha256_f03_demo_hash', 'female', '1998-02-10', 'verified', 'mock', '2026-04-02T09:15:00Z'),
|
||||
(gen_random_uuid(), 'f04a2b3c4d5e6f70000000000000004', E'\\xenc_f04', E'\\xenc_id_f04', 'sha256_f04_demo_hash', 'female', '1990-11-05', 'verified', 'mock', '2026-04-11T16:00:00Z'),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', E'\\xenc_f05', E'\\xenc_id_f05', 'sha256_f05_demo_hash', 'female', '1996-07-22', 'verified', 'mock', '2026-05-02T11:20:00Z'),
|
||||
(gen_random_uuid(), 'f06a2b3c4d5e6f70000000000000006', E'\\xenc_f06', E'\\xenc_id_f06', 'sha256_f06_demo_hash', 'female', '1992-04-18', 'verified', 'mock', '2026-05-16T08:45:00Z'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', E'\\xenc_m01', E'\\xenc_id_m01', 'sha256_m01_demo_hash', 'male', '1992-01-10', 'verified', 'mock', '2026-03-11T09:00:00Z'),
|
||||
(gen_random_uuid(), 'm02a2b3c4d5e6f70000000000000002', E'\\xenc_m02', E'\\xenc_id_m02', 'sha256_m02_demo_hash', 'male', '1990-08-25', 'verified', 'mock', '2026-03-26T13:00:00Z'),
|
||||
(gen_random_uuid(), 'm03a2b3c4d5e6f70000000000000003', E'\\xenc_m03', E'\\xenc_id_m03', 'sha256_m03_demo_hash', 'male', '1997-12-03', 'verified', 'mock', '2026-04-06T15:30:00Z'),
|
||||
(gen_random_uuid(), 'm04a2b3c4d5e6f70000000000000004', E'\\xenc_m04', E'\\xenc_id_m04', 'sha256_m04_demo_hash', 'male', '1988-05-30', 'verified', 'mock', '2026-04-21T10:00:00Z'),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', E'\\xenc_m05', E'\\xenc_id_m05', 'sha256_m05_demo_hash', 'male', '1994-03-14', 'verified', 'mock', '2026-05-02T14:00:00Z'),
|
||||
(gen_random_uuid(), 'm06a2b3c4d5e6f70000000000000006', E'\\xenc_m06', E'\\xenc_id_m06', 'sha256_m06_demo_hash', 'male', '1999-08-08', 'verified', 'mock', '2026-05-11T16:30:00Z');
|
||||
|
||||
-- ============================================================
|
||||
-- 7. 兴趣标签
|
||||
-- ============================================================
|
||||
INSERT INTO user_interests (user_id, interest_code) VALUES
|
||||
('f01a2b3c4d5e6f70000000000000001', 'reading'), ('f01a2b3c4d5e6f70000000000000001', 'cooking'), ('f01a2b3c4d5e6f70000000000000001', 'travel'),
|
||||
('f02a2b3c4d5e6f70000000000000002', 'sports'), ('f02a2b3c4d5e6f70000000000000002', 'music'), ('f02a2b3c4d5e6f70000000000000002', 'outdoor'),
|
||||
('f03a2b3c4d5e6f70000000000000003', 'photography'), ('f03a2b3c4d5e6f70000000000000003', 'dance'), ('f03a2b3c4d5e6f70000000000000003', 'movie'),
|
||||
('f04a2b3c4d5e6f70000000000000004', 'pets'), ('f04a2b3c4d5e6f70000000000000004', 'cooking'),
|
||||
('f05a2b3c4d5e6f70000000000000005', 'reading'), ('f05a2b3c4d5e6f70000000000000005', 'fitness'), ('f05a2b3c4d5e6f70000000000000005', 'charity'),
|
||||
('f06a2b3c4d5e6f70000000000000006', 'gardening'), ('f06a2b3c4d5e6f70000000000000006', 'cooking'),
|
||||
('m01a2b3c4d5e6f70000000000000001', 'sports'), ('m01a2b3c4d5e6f70000000000000001', 'gaming'), ('m01a2b3c4d5e6f70000000000000001', 'travel'),
|
||||
('m02a2b3c4d5e6f70000000000000002', 'reading'), ('m02a2b3c4d5e6f70000000000000002', 'investment'), ('m02a2b3c4d5e6f70000000000000002', 'hiking'),
|
||||
('m03a2b3c4d5e6f70000000000000003', 'gaming'), ('m03a2b3c4d5e6f70000000000000003', 'music'), ('m03a2b3c4d5e6f70000000000000003', 'coding'),
|
||||
('m04a2b3c4d5e6f70000000000000004', 'cars'), ('m04a2b3c4d5e6f70000000000000004', 'cooking'),
|
||||
('m05a2b3c4d5e6f70000000000000005', 'running'), ('m05a2b3c4d5e6f70000000000000005', 'reading'), ('m05a2b3c4d5e6f70000000000000005', 'charity'),
|
||||
('m06a2b3c4d5e6f70000000000000006', 'research'), ('m06a2b3c4d5e6f70000000000000006', 'travel'), ('m06a2b3c4d5e6f70000000000000006', 'photography');
|
||||
|
||||
-- ============================================================
|
||||
-- 8. 隐私设置
|
||||
-- ============================================================
|
||||
INSERT INTO user_privacy_settings (user_id, visible_in_recommendations, visible_in_search, show_occupation, show_lifestyle_photos, receive_activity_recommendations, accept_matchmaker_recommendations) VALUES
|
||||
('f01a2b3c4d5e6f70000000000000001', true, true, true, true, true, true),
|
||||
('f02a2b3c4d5e6f70000000000000002', true, true, true, false, true, true),
|
||||
('f03a2b3c4d5e6f70000000000000003', true, false, true, true, true, false),
|
||||
('f04a2b3c4d5e6f70000000000000004', true, true, false, true, true, true),
|
||||
('f05a2b3c4d5e6f70000000000000005', true, true, true, true, false, true),
|
||||
('f06a2b3c4d5e6f70000000000000006', true, false, true, true, true, true),
|
||||
('m01a2b3c4d5e6f70000000000000001', true, true, true, true, true, true),
|
||||
('m02a2b3c4d5e6f70000000000000002', true, true, true, false, true, true),
|
||||
('m03a2b3c4d5e6f70000000000000003', true, true, true, true, true, false),
|
||||
('m04a2b3c4d5e6f70000000000000004', true, false, true, true, true, true),
|
||||
('m05a2b3c4d5e6f70000000000000005', true, true, true, true, true, true),
|
||||
('m06a2b3c4d5e6f70000000000000006', true, true, true, true, true, true);
|
||||
|
||||
-- ============================================================
|
||||
-- 9. 照片(user_photos)
|
||||
-- ============================================================
|
||||
INSERT INTO user_photos (id, user_id, file_key, photo_type, sort_order, review_status) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'photos/demo/f01/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'photos/demo/f01/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'photos/demo/f01/lifestyle2.jpg','lifestyle',2, 'approved'),
|
||||
(gen_random_uuid(), 'f02a2b3c4d5e6f70000000000000002', 'photos/demo/f02/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'f02a2b3c4d5e6f70000000000000002', 'photos/demo/f02/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'photos/demo/f03/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'photos/demo/f03/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'photos/demo/f03/lifestyle2.jpg','lifestyle',2, 'approved'),
|
||||
(gen_random_uuid(), 'f04a2b3c4d5e6f70000000000000004', 'photos/demo/f04/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', 'photos/demo/f05/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', 'photos/demo/f05/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'f06a2b3c4d5e6f70000000000000006', 'photos/demo/f06/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'photos/demo/m01/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'photos/demo/m01/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'photos/demo/m01/lifestyle2.jpg','lifestyle',2, 'approved'),
|
||||
(gen_random_uuid(), 'm02a2b3c4d5e6f70000000000000002', 'photos/demo/m02/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'm02a2b3c4d5e6f70000000000000002', 'photos/demo/m02/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'm03a2b3c4d5e6f70000000000000003', 'photos/demo/m03/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'm03a2b3c4d5e6f70000000000000003', 'photos/demo/m03/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'm04a2b3c4d5e6f70000000000000004', 'photos/demo/m04/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', 'photos/demo/m05/avatar.jpg', 'avatar', 0, 'approved'),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', 'photos/demo/m05/lifestyle1.jpg','lifestyle',1, 'approved'),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', 'photos/demo/m05/lifestyle2.jpg','lifestyle',2, 'approved'),
|
||||
(gen_random_uuid(), 'm06a2b3c4d5e6f70000000000000006', 'photos/demo/m06/avatar.jpg', 'avatar', 0, 'approved');
|
||||
|
||||
-- ============================================================
|
||||
-- 10. 审核任务
|
||||
-- ============================================================
|
||||
INSERT INTO review_tasks (id, user_id, review_type, status, assigned_operator_id, submitted_at, started_at, completed_at, final_comment, version) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-03-15T11:00:00Z', '2026-03-15T11:30:00Z', '2026-03-15T12:00:00Z', '资料完整,信息真实', 1),
|
||||
(gen_random_uuid(), 'f02a2b3c4d5e6f70000000000000002', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-03-20T15:00:00Z', '2026-03-20T15:30:00Z', '2026-03-20T16:00:00Z', '资料完整', 1),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-04-01T10:00:00Z', '2026-04-01T10:30:00Z', '2026-04-01T11:00:00Z', '资料完整', 1),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-03-10T10:00:00Z', '2026-03-10T10:30:00Z', '2026-03-10T11:00:00Z', '资料完整', 1),
|
||||
(gen_random_uuid(), 'm02a2b3c4d5e6f70000000000000002', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-03-25T14:00:00Z', '2026-03-25T14:30:00Z', '2026-03-25T15:00:00Z', '资料完整', 1),
|
||||
(gen_random_uuid(), 'm03a2b3c4d5e6f70000000000000003', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-04-05T16:00:00Z', '2026-04-05T16:30:00Z', '2026-04-05T17:00:00Z', '资料完整', 1),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', 'initial_profile', 'approved', (SELECT id FROM operators WHERE username='reviewer01'), '2026-05-01T15:00:00Z', '2026-05-01T15:30:00Z', '2026-05-01T16:00:00Z', '资料完整', 1);
|
||||
|
||||
-- ============================================================
|
||||
-- 11. 用户关系
|
||||
-- ============================================================
|
||||
INSERT INTO user_relations (id, user_id, target_user_id, relation_type, created_at) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'm01a2b3c4d5e6f70000000000000001', 'liked', '2026-06-01T10:00:00Z'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'f01a2b3c4d5e6f70000000000000001', 'liked', '2026-06-01T10:05:00Z'),
|
||||
(gen_random_uuid(), 'f02a2b3c4d5e6f70000000000000002', 'm02a2b3c4d5e6f70000000000000002', 'liked', '2026-06-02T14:00:00Z'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'm03a2b3c4d5e6f70000000000000003', 'liked', '2026-06-03T09:00:00Z'),
|
||||
(gen_random_uuid(), 'm03a2b3c4d5e6f70000000000000003', 'f03a2b3c4d5e6f70000000000000003', 'liked', '2026-06-03T09:30:00Z'),
|
||||
(gen_random_uuid(), 'm04a2b3c4d5e6f70000000000000004', 'f02a2b3c4d5e6f70000000000000002', 'liked', '2026-06-04T11:00:00Z'),
|
||||
(gen_random_uuid(), 'f04a2b3c4d5e6f70000000000000004', 'm04a2b3c4d5e6f70000000000000004', 'passed', '2026-06-04T12:00:00Z'),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', 'm05a2b3c4d5e6f70000000000000005', 'liked', '2026-06-05T10:00:00Z'),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', 'f05a2b3c4d5e6f70000000000000005', 'liked', '2026-06-05T10:05:00Z'),
|
||||
(gen_random_uuid(), 'm06a2b3c4d5e6f70000000000000006', 'f01a2b3c4d5e6f70000000000000001', 'liked', '2026-06-06T14:00:00Z'),
|
||||
(gen_random_uuid(), 'f04a2b3c4d5e6f70000000000000004', 'm06a2b3c4d5e6f70000000000000006', 'passed', '2026-06-06T15:00:00Z'),
|
||||
(gen_random_uuid(), 'f06a2b3c4d5e6f70000000000000006', 'm04a2b3c4d5e6f70000000000000004', 'blocked', '2026-06-07T09:00:00Z'),
|
||||
(gen_random_uuid(), 'm02a2b3c4d5e6f70000000000000002', 'f03a2b3c4d5e6f70000000000000003', 'passed', '2026-06-07T10:00:00Z');
|
||||
|
||||
-- ============================================================
|
||||
-- 12. Match
|
||||
-- ============================================================
|
||||
INSERT INTO matches (id, user_a_id, user_b_id, status, source, matched_at) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'm01a2b3c4d5e6f70000000000000001', 'active', 'user_like', '2026-06-01T10:05:00Z'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'm03a2b3c4d5e6f70000000000000003', 'active', 'user_like', '2026-06-03T09:30:00Z'),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', 'm05a2b3c4d5e6f70000000000000005', 'successful', 'user_like', '2026-06-05T10:05:00Z');
|
||||
|
||||
-- ============================================================
|
||||
-- 13. 成功牵手请求
|
||||
-- ============================================================
|
||||
INSERT INTO relationship_success_requests (id, match_id, initiated_by, status, confirmed_by, created_at, resolved_at) VALUES
|
||||
(gen_random_uuid(), (SELECT id FROM matches WHERE user_a_id='f05a2b3c4d5e6f70000000000000005'), 'f05a2b3c4d5e6f70000000000000005', 'confirmed', 'm05a2b3c4d5e6f70000000000000005', '2026-07-01T10:00:00Z', '2026-07-01T10:30:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM matches WHERE user_a_id='f01a2b3c4d5e6f70000000000000001'), 'f01a2b3c4d5e6f70000000000000001', 'pending', NULL, '2026-07-15T14:00:00Z', NULL);
|
||||
|
||||
-- ============================================================
|
||||
-- 14. Conversations & Messages
|
||||
-- ============================================================
|
||||
INSERT INTO conversations (id, match_id, status, last_message_id, last_message_at) VALUES
|
||||
(gen_random_uuid(), (SELECT id FROM matches WHERE user_a_id='f01a2b3c4d5e6f70000000000000001'), 'active', NULL, '2026-07-10T16:00:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM matches WHERE user_a_id='f03a2b3c4d5e6f70000000000000003'), 'active', NULL, '2026-07-08T20:00:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM matches WHERE user_a_id='f05a2b3c4d5e6f70000000000000005'), 'active', NULL, '2026-07-01T18:00:00Z');
|
||||
|
||||
-- 取回 conversation ids
|
||||
WITH conv_ids AS (
|
||||
SELECT id, match_id FROM conversations ORDER BY created_at
|
||||
)
|
||||
INSERT INTO conversation_members (conversation_id, user_id, last_read_message_id, unread_count, can_send, joined_at)
|
||||
SELECT c.id, CASE WHEN m.user_a_id='f01a2b3c4d5e6f70000000000000001' OR m.user_a_id='f03a2b3c4d5e6f70000000000000003' OR m.user_a_id='f05a2b3c4d5e6f70000000000000005' THEN u else NULL end, NULL, 0, true, NOW()
|
||||
FROM conv_ids c
|
||||
JOIN matches m ON m.id = c.match_id
|
||||
JOIN LATERAL (SELECT 'f01a2b3c4d5e6f70000000000000001' as uid UNION ALL SELECT 'm01a2b3c4d5e6f70000000000000001' UNION ALL SELECT 'f03a2b3c4d5e6f70000000000000003' UNION ALL SELECT 'm03a2b3c4d5e6f70000000000000003' UNION ALL SELECT 'f05a2b3c4d5e6f70000000000000005' UNION ALL SELECT 'm05a2b3c4d5e6f70000000000000005') u ON TRUE
|
||||
WHERE (m.user_a_id='f01a2b3c4d5e6f70000000000000001' AND u.uid IN ('f01a2b3c4d5e6f70000000000000001','m01a2b3c4d5e6f70000000000000001'))
|
||||
OR (m.user_a_id='f03a2b3c4d5e6f70000000000000003' AND u.uid IN ('f03a2b3c4d5e6f70000000000000003','m03a2b3c4d5e6f70000000000000003'))
|
||||
OR (m.user_a_id='f05a2b3c4d5e6f70000000000000005' AND u.uid IN ('f05a2b3c4d5e6f70000000000000005','m05a2b3c4d5e6f70000000000000005'));
|
||||
|
||||
-- 简化的 conversation_members 插入
|
||||
DELETE FROM conversation_members;
|
||||
WITH conv AS (
|
||||
SELECT id, match_id FROM conversations
|
||||
), match_users AS (
|
||||
SELECT c.id as conv_id, m.user_a_id, m.user_b_id
|
||||
FROM conv c JOIN matches m ON m.id = c.match_id
|
||||
)
|
||||
INSERT INTO conversation_members (conversation_id, user_id, last_read_message_id, unread_count, can_send, joined_at)
|
||||
SELECT mu.conv_id, mu.user_a_id, NULL, 0, true, NOW() FROM match_users mu
|
||||
UNION ALL
|
||||
SELECT mu.conv_id, mu.user_b_id, NULL, 0, true, NOW() FROM match_users mu;
|
||||
|
||||
INSERT INTO messages (id, conversation_id, sender_id, message_type, content, status, risk_level, created_at) VALUES
|
||||
(gen_random_uuid(), (SELECT id FROM conversations ORDER BY created_at LIMIT 1), 'f01a2b3c4d5e6f70000000000000001', 'text', '你好!看到你的资料觉得挺合适的~', 'sent', 'normal', '2026-06-15T14:00:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM conversations ORDER BY created_at LIMIT 1), 'm01a2b3c4d5e6f70000000000000001', 'text', '你好!谢谢你的喜欢,我也觉得挺有缘的', 'sent', 'normal', '2026-06-15T14:05:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM conversations ORDER BY created_at LIMIT 1), 'f01a2b3c4d5e6f70000000000000001', 'text', '你也在丹阳工作吗?平时喜欢做些什么?', 'sent', 'normal', '2026-06-15T14:10:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM conversations ORDER BY created_at OFFSET 1 LIMIT 1), 'm03a2b3c4d5e6f70000000000000003', 'text', '嗨,你好!很高兴认识你', 'sent', 'normal', '2026-07-05T19:30:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM conversations ORDER BY created_at OFFSET 1 LIMIT 1), 'f03a2b3c4d5e6f70000000000000003', 'text', '你好呀!我平时喜欢拍照和跳舞,你呢?', 'sent', 'normal', '2026-07-05T19:35:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM conversations ORDER BY created_at OFFSET 2 LIMIT 1), 'm05a2b3c4d5e6f70000000000000005', 'text', '你好,很高兴认识你!', 'sent', 'normal', '2026-06-10T10:00:00Z');
|
||||
|
||||
-- 更新 conversations.last_message_id
|
||||
UPDATE conversations SET last_message_id = (SELECT id FROM messages WHERE conversation_id = conversations.id ORDER BY created_at DESC LIMIT 1);
|
||||
|
||||
-- ============================================================
|
||||
-- 15. 推荐记录
|
||||
-- ============================================================
|
||||
INSERT INTO recommendation_records (id, user_id, target_user_id, source, score, level, shown_at, action, action_at, rule_version) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'm01a2b3c4d5e6f70000000000000001', 'daily', 82.50, 'high', '2026-05-28T10:00:00Z', 'liked', '2026-06-01T10:00:00Z', 1),
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'm03a2b3c4d5e6f70000000000000003', 'daily', 70.00, 'medium', '2026-05-28T10:00:00Z', 'passed','2026-05-28T10:01:00Z', 1),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'f01a2b3c4d5e6f70000000000000001', 'daily', 85.00, 'high', '2026-05-28T11:00:00Z', 'liked', '2026-06-01T10:05:00Z', 1),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'm03a2b3c4d5e6f70000000000000003', 'daily', 78.00, 'high', '2026-06-01T09:00:00Z', 'liked', '2026-06-03T09:30:00Z', 1),
|
||||
(gen_random_uuid(), 'm03a2b3c4d5e6f70000000000000003', 'f03a2b3c4d5e6f70000000000000003', 'daily', 75.00, 'high', '2026-06-01T09:30:00Z', 'liked', '2026-06-03T09:30:00Z', 1),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', 'm05a2b3c4d5e6f70000000000000005', 'daily', 88.00, 'high', '2026-06-01T10:00:00Z', 'liked', '2026-06-05T10:00:00Z', 1),
|
||||
(gen_random_uuid(), 'm05a2b3c4d5e6f70000000000000005', 'f05a2b3c4d5e6f70000000000000005', 'daily', 86.00, 'high', '2026-06-01T10:30:00Z', 'liked', '2026-06-05T10:05:00Z', 1),
|
||||
(gen_random_uuid(), 'm06a2b3c4d5e6f70000000000000006', 'f01a2b3c4d5e6f70000000000000001', 'daily', 62.00, 'medium','2026-06-06T14:00:00Z', 'liked', '2026-06-06T14:00:00Z', 1);
|
||||
|
||||
-- ============================================================
|
||||
-- 16. 相亲活动
|
||||
-- ============================================================
|
||||
WITH act_org AS (
|
||||
SELECT id FROM organizations WHERE type='women_federation' LIMIT 1
|
||||
), act_mgr AS (
|
||||
SELECT id FROM operators WHERE username='activitymgr' LIMIT 1
|
||||
)
|
||||
INSERT INTO activities (id, title, description, organizer_org_id, coorganizer_text,
|
||||
start_at, end_at, location_name, location_address,
|
||||
male_limit, female_limit, total_limit, min_age, max_age,
|
||||
registration_start_at, registration_end_at, need_review, status, created_by)
|
||||
VALUES
|
||||
((SELECT id FROM act_org),
|
||||
'丹阳公益单身联谊会(夏季场)',
|
||||
'面向丹阳市区及周边乡镇的单身青年,由妇联、工会联合主办,提供安全、真实的交友平台。现场设有互动游戏、自由交流环节,红娘全程辅助。',
|
||||
(SELECT id FROM act_org),
|
||||
'丹阳市总工会、丹阳市慈善基金会',
|
||||
'2026-08-15T14:00:00Z', '2026-08-15T17:30:00Z',
|
||||
'丹阳市文化馆多功能厅', '丹阳市丹北路168号',
|
||||
15, 15, 30, 22, 40,
|
||||
'2026-07-01T00:00:00Z', '2026-08-10T23:59:59Z',
|
||||
true, 'registration_open', (SELECT id FROM act_mgr)),
|
||||
|
||||
((SELECT id FROM organizations WHERE type='trade_union' LIMIT 1),
|
||||
'七夕特别活动·丹阳缘来是你',
|
||||
'七夕节特别策划,浪漫主题相亲活动。适合寻找认真关系的单身人士。',
|
||||
(SELECT id FROM organizations WHERE type='trade_union' LIMIT 1),
|
||||
'丹阳市新时代文明实践中心',
|
||||
'2026-08-29T15:00:00Z', '2026-08-29T18:00:00Z',
|
||||
'丹阳大剧院报告厅', '丹阳市书院路28号',
|
||||
20, 20, 40, 25, 45,
|
||||
'2026-08-01T00:00:00Z', '2026-08-25T23:59:59Z',
|
||||
true, 'draft', (SELECT id FROM operators WHERE username='activitymgr' LIMIT 1));
|
||||
|
||||
-- ============================================================
|
||||
-- 17. 活动报名
|
||||
-- ============================================================
|
||||
WITH act1 AS (SELECT id FROM activities WHERE title LIKE '夏季%' LIMIT 1),
|
||||
mgr AS (SELECT id FROM operators WHERE username='activitymgr' LIMIT 1)
|
||||
INSERT INTO activity_registrations (id, activity_id, user_id, status, registered_at, reviewed_by, reviewed_at, checkin_status) VALUES
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'f01a2b3c4d5e6f70000000000000001', 'approved', '2026-07-05T10:00:00Z', (SELECT id FROM mgr), '2026-07-05T10:30:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'f03a2b3c4d5e6f70000000000000003', 'approved', '2026-07-06T14:00:00Z', (SELECT id FROM mgr), '2026-07-06T14:15:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'f05a2b3c4d5e6f70000000000000005', 'approved', '2026-07-07T09:00:00Z', (SELECT id FROM mgr), '2026-07-07T09:20:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'm01a2b3c4d5e6f70000000000000001', 'approved', '2026-07-08T11:00:00Z', (SELECT id FROM mgr), '2026-07-08T11:10:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'm03a2b3c4d5e6f70000000000000003', 'approved', '2026-07-09T15:00:00Z', (SELECT id FROM mgr), '2026-07-09T15:20:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'm05a2b3c4d5e6f70000000000000005', 'approved', '2026-07-10T08:30:00Z', (SELECT id FROM mgr), '2026-07-10T08:45:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'f02a2b3c4d5e6f70000000000000002', 'pending', '2026-07-12T10:00:00Z', NULL, NULL, 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'm02a2b3c4d5e6f70000000000000002', 'approved', '2026-07-11T16:00:00Z', (SELECT id FROM mgr), '2026-07-11T16:30:00Z', 'not_checked_in'),
|
||||
(gen_random_uuid(), (SELECT id FROM act1), 'f04a2b3c4d5e6f70000000000000004', 'rejected', '2026-07-13T09:00:00Z', (SELECT id FROM mgr), '2026-07-13T09:15:00Z', 'not_checked_in');
|
||||
|
||||
-- ============================================================
|
||||
-- 18. 活动互选意向
|
||||
-- ============================================================
|
||||
WITH act1 AS (SELECT id FROM activities WHERE title LIKE '夏季%' LIMIT 1)
|
||||
INSERT INTO activity_interests (id, source_user_id, target_user_id, activity_id, status, confirmed_at, created_at) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'm01a2b3c4d5e6f70000000000000001', (SELECT id FROM act1), 'mutual', '2026-08-15T17:00:00Z', '2026-08-15T17:00:00Z'),
|
||||
(gen_random_uuid(), 'f03a2b3c4d5e6f70000000000000003', 'm03a2b3c4d5e6f70000000000000003', (SELECT id FROM act1), 'mutual', '2026-08-15T17:05:00Z', '2026-08-15T17:05:00Z'),
|
||||
(gen_random_uuid(), 'f05a2b3c4d5e6f70000000000000005', 'm05a2b3c4d5e6f70000000000000005', (SELECT id FROM act1), 'expressed','2026-08-15T17:10:00Z', '2026-08-15T17:10:00Z');
|
||||
|
||||
-- ============================================================
|
||||
-- 19. 红娘服务
|
||||
-- ============================================================
|
||||
WITH mh_op AS (SELECT id FROM operators WHERE username='wanghongniang' LIMIT 1),
|
||||
women_org AS (SELECT id FROM organizations WHERE type='women_federation' LIMIT 1),
|
||||
charity_org AS (SELECT id FROM organizations WHERE type='charity_center' LIMIT 1)
|
||||
INSERT INTO matchmaker_services (id, user_id, service_type, description, status, organization_id, assigned_operator_id, assigned_at, completed_at) VALUES
|
||||
(gen_random_uuid(), 'f02a2b3c4d5e6f70000000000000002', 'recommend_partner', '离异用户希望找到合适的伴侣,需要红娘协助筛选',
|
||||
'in_service', (SELECT id FROM women_org), (SELECT id FROM mh_op), '2026-06-20T10:00:00Z', NULL),
|
||||
(gen_random_uuid(), 'f06a2b3c4d5e6f70000000000000006', 'no_match_help', '丧偶用户希望重新融入社交,找到新伴侣',
|
||||
'waiting_user', (SELECT id FROM charity_org), (SELECT id FROM mh_op), '2026-06-25T14:00:00Z', NULL),
|
||||
(gen_random_uuid(), 'f04a2b3c4d5e6f70000000000000004', 'review_preference', '用户希望调整择偶条件,请红娘帮助评估',
|
||||
'completed', (SELECT id FROM women_org), (SELECT id FROM mh_op), '2026-06-15T09:00:00Z', '2026-06-20T11:00:00Z');
|
||||
|
||||
-- 红娘推荐
|
||||
WITH ms_f02 AS (SELECT id FROM matchmaker_services WHERE user_id='f02a2b3c4d5e6f70000000000000002' LIMIT 1),
|
||||
mh_op2 AS (SELECT id FROM operators WHERE username='wanghongniang' LIMIT 1)
|
||||
INSERT INTO matchmaker_recommendations (id, service_id, user_id, target_user_id, operator_id, reason, status, created_at, viewed_at, responded_at)
|
||||
VALUES (gen_random_uuid(), (SELECT id FROM ms_f02), 'f02a2b3c4d5e6f70000000000000002', 'm02a2b3c4d5e6f70000000000000002', (SELECT id FROM mh_op2),
|
||||
'两人同在丹阳工作,年龄相仿,都离过婚有共同语言', 'viewed', '2026-06-21T10:00:00Z', '2026-06-22T09:00:00Z', NULL);
|
||||
|
||||
-- 红娘跟进
|
||||
WITH ms_f02_2 AS (SELECT id FROM matchmaker_services WHERE user_id='f02a2b3c4d5e6f70000000000000002' LIMIT 1),
|
||||
ms_f04 AS (SELECT id FROM matchmaker_services WHERE user_id='f04a2b3c4d5e6f70000000000000004' LIMIT 1),
|
||||
mh_op3 AS (SELECT id FROM operators WHERE username='wanghongniang' LIMIT 1)
|
||||
INSERT INTO matchmaker_followups (id, service_id, operator_id, followup_type, content, result_code, next_followup_at, created_at) VALUES
|
||||
(gen_random_uuid(), (SELECT id FROM ms_f02_2), (SELECT id FROM mh_op3), 'phone_call', '电话沟通用户情况,了解离异原因及择偶期望', '正常', '2026-07-01T10:00:00Z', '2026-06-22T10:00:00Z'),
|
||||
(gen_random_uuid(), (SELECT id FROM ms_f04), (SELECT id FROM mh_op3), 'face_to_face', '面对面交流,帮助用户调整身高要求从170改为168', '已调整', NULL, '2026-06-18T15:00:00Z');
|
||||
|
||||
-- ============================================================
|
||||
-- 20. 系统通知
|
||||
-- ============================================================
|
||||
WITH notif_users AS (
|
||||
SELECT 'f01a2b3c4d5e6f70000000000000001' as uid, 'f03a2b3c4d5e6f70000000000000003' as u2, 'f05a2b3c4d5e6f70000000000000005' as u3,
|
||||
'm01a2b3c4d5e6f70000000000000001' as mu1, 'm03a2b3c4d5e6f70000000000000003' as mu2, 'm05a2b3c4d5e6f70000000000000005' as mu3,
|
||||
'f02a2b3c4d5e6f70000000000000002' as mf2
|
||||
)
|
||||
INSERT INTO notifications (id, user_id, type, title, content, business_type, business_id, read_status, created_at)
|
||||
SELECT gen_random_uuid(), uid, type, title, content, business_type, NULL::uuid, read_status, created_at FROM (
|
||||
VALUES
|
||||
('match','f01a2b3c4d5e6f70000000000000001','match','你们互相喜欢!','张伟也喜欢了你,可以开始聊天啦~','match','read','2026-06-01T10:05:00Z'),
|
||||
('match','m01a2b3c4d5e6f70000000000000001','match','你们互相喜欢!','小芳也喜欢了你,可以开始聊天啦~','match','read','2026-06-01T10:05:00Z'),
|
||||
('match','f03a2b3c4d5e6f70000000000000003','match','你们互相喜欢!','王磊也喜欢了你,可以开始聊天啦~','match','read','2026-06-03T09:30:00Z'),
|
||||
('match','m03a2b3c4d5e6f70000000000000003','match','你们互相喜欢!','婷婷也喜欢了你,可以开始聊天啦~','match','unread','2026-06-03T09:30:00Z'),
|
||||
('match','f05a2b3c4d5e6f70000000000000005','match','你们互相喜欢!','孙浩也喜欢了你,可以开始聊天啦~','match','read','2026-06-05T10:05:00Z'),
|
||||
('match','m05a2b3c4d5e6f70000000000000005','match','你们互相喜欢!','慧琴也喜欢了你,可以开始聊天啦~','match','read','2026-06-05T10:05:00Z'),
|
||||
('system','f05a2b3c4d5e6f70000000000000005','system','恭喜牵手成功!','您与孙浩已成功牵手,祝你们幸福!','match','read','2026-07-01T10:30:00Z'),
|
||||
('system','m05a2b3c4d5e6f70000000000000005','system','恭喜牵手成功!','您与慧琴已成功牵手,祝你们幸福!','match','read','2026-07-01T10:30:00Z'),
|
||||
('activity','f01a2b3c4d5e6f70000000000000001','activity','活动报名已确认','您已成功报名「丹阳公益单身联谊会」','activity','read','2026-07-05T10:30:00Z'),
|
||||
('activity','f05a2b3c4d5e6f70000000000000005','activity','活动报名已确认','您已成功报名「丹阳公益单身联谊会」','activity','unread','2026-07-07T09:20:00Z'),
|
||||
('matchmaker','f02a2b3c4d5e6f70000000000000002','matchmaker','红娘已为您服务','您的红娘服务申请已被分配,红娘小王将在24小时内与您联系','matchmaker','read','2026-06-20T10:30:00Z')
|
||||
) AS t(type, user_id, ntype, title, content, business_type, read_status, created_at);
|
||||
|
||||
-- ============================================================
|
||||
-- 21. 同意记录
|
||||
-- ============================================================
|
||||
INSERT INTO consent_records (id, user_id, type, version, agreed_at, ip_address, user_agent) VALUES
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'terms_of_service', '1.0', '2026-03-15T10:00:00Z', '127.0.0.1', 'WeChat/8.0'),
|
||||
(gen_random_uuid(), 'f01a2b3c4d5e6f70000000000000001', 'privacy_policy', '1.0', '2026-03-15T10:00:00Z', '127.0.0.1', 'WeChat/8.0'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'terms_of_service', '1.0', '2026-03-10T09:00:00Z', '127.0.0.1', 'WeChat/8.0'),
|
||||
(gen_random_uuid(), 'm01a2b3c4d5e6f70000000000000001', 'privacy_policy', '1.0', '2026-03-10T09:00:00Z', '127.0.0.1', 'WeChat/8.0');
|
||||
|
||||
-- ============================================================
|
||||
-- 22. 审核原因字典
|
||||
-- ============================================================
|
||||
INSERT INTO review_reasons (code, name, category, enabled, sort_order) VALUES
|
||||
('profile_incomplete', '资料不完整', 'quality', true, 1),
|
||||
('photo_unclear', '照片不清晰', 'quality', true, 2),
|
||||
('fake_info', '信息疑似虚假', 'trust', true, 3),
|
||||
('inappropriate_photo', '照片内容不当', 'safety', true, 4),
|
||||
('duplicate_identity', '重复注册', 'duplicate', true, 5),
|
||||
('suspicious_behavior', '行为异常', 'risk', true, 6),
|
||||
('manual_review_needed', '需人工复核', 'quality', true, 7);
|
||||
|
||||
SET session_replication_role = 'origin';
|
||||
|
||||
-- ============================================================
|
||||
-- 验证数据量
|
||||
-- ============================================================
|
||||
DO $$
|
||||
DECLARE
|
||||
u_cnt INTEGER; op_cnt INTEGER; m_cnt INTEGER; a_cnt INTEGER; r_cnt INTEGER; n_cnt INTEGER;
|
||||
BEGIN
|
||||
SELECT COUNT(*) INTO u_cnt FROM users WHERE deleted_at IS NULL;
|
||||
SELECT COUNT(*) INTO op_cnt FROM operators;
|
||||
SELECT COUNT(*) INTO m_cnt FROM matches;
|
||||
SELECT COUNT(*) INTO a_cnt FROM activities WHERE deleted_at IS NULL;
|
||||
SELECT COUNT(*) INTO r_cnt FROM user_relations;
|
||||
SELECT COUNT(*) INTO n_cnt FROM notifications;
|
||||
RAISE NOTICE '✅ Demo 数据填充完成:';
|
||||
RAISE NOTICE ' 用户: %人 | 操作员: %人 | Match: %对', u_cnt, op_cnt, m_cnt;
|
||||
RAISE NOTICE ' 关系: %条 | 活动: %个 | 通知: %条', r_cnt, a_cnt, n_cnt;
|
||||
END $$;
|
||||
Reference in New Issue
Block a user