Files
danyang-match/backend/src/main/resources/db/demo-seed.sql
T

420 lines
32 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ============================================================
-- 丹阳公益婚恋服务平台 — Demo Seed 数据脚本
-- 版本: 1.0.0-RC.2
-- 说明: 生成演示用数据,含组织、工作人员、用户、活动、聊天等
-- 执行方式: psql -d danyang_match -f backend/src/main/resources/db/demo-seed.sql
-- ============================================================
-- 禁用外键检查,允许乱序插入
SET session_replication_role = 'replica';
-- ============================================================
-- 1. 组织(organizations)
-- ============================================================
INSERT INTO organizations (id, name, type, contact_name, status) VALUES
('org-danyang-women', '丹阳市妇女联合会', 'women_federation', '张丽华', 'active'),
('org-danyang-trade', '丹阳市总工会', 'trade_union', '李明远', 'active'),
('org-danyang-charity', '丹阳市慈善基金会', 'charity_center', '王秀英', 'active');
-- ============================================================
-- 2. 工作人员(operators)— 密码均为 BCrypt hash of "demo123"
-- ============================================================
INSERT INTO operators (id, organization_id, name, username, password_hash, status) VALUES
('op-admin-001', 'org-danyang-women', '陈主任', 'admin', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active'),
('op-mh001', 'org-danyang-women', '红娘小王', 'wanghongniang', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active'),
('op-rv001', 'org-danyang-charity', '审核员小张', 'reviewer01', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active'),
('op-act01', 'org-danyang-trade', '活动管理员赵', 'activitymgr', '$2a$10$N.zmdr9k7uOCQb376NoUnuTJ8iAt6Z5EHdBfKYuPIiCTB6MJJDEaK', 'active');
-- 操作员角色绑定
INSERT INTO operator_roles (operator_id, role_id) VALUES
('op-admin-001', '00000000-0000-0000-0000-000000000001'),
('op-admin-001', '00000000-0000-0000-0000-000000000002'),
('op-mh001', '00000000-0000-0000-0000-000000000005'),
('op-mh001', '00000000-0000-0000-0000-000000000006'),
('op-rv001', '00000000-0000-0000-0000-000000000004'),
('op-rv001', '00000000-0000-0000-0000-000000000007'),
('op-act01', '00000000-0000-0000-0000-000000000006'),
('op-act01', '00000000-0000-0000-0000-000000000008');
-- ============================================================
-- 3. Demo 用户 — 12人(6男6女)
-- ============================================================
INSERT INTO users (id, wechat_openid, phone, account_status, relationship_status, recommendation_enabled, created_at) VALUES
('user-f01', 'demo_openid_f01', NULL, 'normal', 'searching', true, '2026-03-15T10:00:00Z'),
('user-f02', 'demo_openid_f02', NULL, 'normal', 'searching', true, '2026-03-20T14:30:00Z'),
('user-f03', 'demo_openid_f03', NULL, 'normal', 'searching', true, '2026-04-01T09:15:00Z'),
('user-f04', 'demo_openid_f04', NULL, 'normal', 'paused', true, '2026-04-10T16:00:00Z'),
('user-f05', 'demo_openid_f05', NULL, 'normal', 'searching', true, '2026-05-01T11:20:00Z'),
('user-f06', 'demo_openid_f06', NULL, 'normal', 'searching', true, '2026-05-15T08:45:00Z'),
('user-m01', 'demo_openid_m01', NULL, 'normal', 'searching', true, '2026-03-10T09:00:00Z'),
('user-m02', 'demo_openid_m02', NULL, 'normal', 'getting_to_know', true, '2026-03-25T13:00:00Z'),
('user-m03', 'demo_openid_m03', NULL, 'normal', 'searching', true, '2026-04-05T15:30:00Z'),
('user-m04', 'demo_openid_m04', NULL, 'normal', 'searching', true, '2026-04-20T10:00:00Z'),
('user-m05', 'demo_openid_m05', NULL, 'normal', 'matched_successfully', true, '2026-05-01T14:00:00Z'),
('user-m06', 'demo_openid_m06', NULL, 'normal', 'searching', true, '2026-05-10T16:30:00Z');
-- ============================================================
-- 4. 用户资料(user_profiles)
-- ============================================================
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
('user-f01', '小芳', 'female', '1995-06-15', 162, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'clerical', 'never', 'sometimes', '是', '是', '结婚', 90, 'approved'),
('user-f02', '晓燕', 'female', '1993-09-20', 165, '321181', '丹阳', 'divorced', 'none', 'college', 'teacher', 'never', 'never', '是', '是', '结婚', 95, 'approved'),
('user-f03', '婷婷', 'female', '1998-02-10', 158, '321100', '镇江', 'never_married', 'none', 'master', 'designer', 'sometimes', 'often', '是', '否', '恋爱', 85, 'approved'),
('user-f04', '美玲', 'female', '1990-11-05', 160, '321181', '丹阳', 'never_married', 'none', 'senior_high', 'factory', 'never', 'never', '是', '是', '结婚', 70, 'approved'),
('user-f05', '慧琴', 'female', '1996-07-22', 163, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'nurse', 'never', 'sometimes','是', '是', '结婚', 92, 'approved'),
('user-f06', '秀英', 'female', '1992-04-18', 157, '321181', '丹阳', 'widowed', 'none', 'junior_high','farmer', 'often', 'often', '是', '是', '结婚', 60, 'approved'),
('user-m01', '张伟', 'male', '1992-01-10', 175, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'engineer', 'never', 'sometimes','是', '是', '结婚', 88, 'approved'),
('user-m02', '李强', 'male', '1990-08-25', 178, '321181', '丹阳', 'divorced', 'none', 'master', 'manager', 'sometimes', 'often', '是', '是', '结婚', 95, 'approved'),
('user-m03', '王磊', 'male', '1997-12-03', 180, '321100', '镇江', 'never_married', 'none', 'college', 'programmer', 'never', 'never', '是', '是', '恋爱', 82, 'approved'),
('user-m04', '赵明', 'male', '1988-05-30', 172, '321181', '丹阳', 'never_married', 'none', 'senior_high','sales', 'often', 'often', '否', '是', '结婚', 75, 'approved'),
('user-m05', '孙浩', 'male', '1994-03-14', 182, '321181', '丹阳', 'never_married', 'none', 'bachelor', 'doctor', 'never', 'sometimes','是', '是', '结婚', 97, 'approved'),
('user-m06', '周洋', 'male', '1999-08-08', 176, '320500', '苏州', 'never_married', 'none', 'master', 'researcher', 'never', 'never', '是', '否', '恋爱', 80, 'approved');
-- ============================================================
-- 5. 用户择偶偏好(user_preferences)
-- ============================================================
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
('user-f01', 28, 38, 'required', 170, 185, 'required',
'["321181","321100"]', 'required', '["never_married"]', 'required', 'bachelor', 'preferred'),
('user-f02', 28, 40, 'required', 170, 188, 'required',
'["321181"]', 'required', '["never_married","divorced"]', 'preferred', 'college', 'preferred'),
('user-f03', 25, 35, 'preferred', 172, 185, 'preferred',
'["321181","321100","320500"]', 'preferred', '["never_married"]', 'required', NULL, NULL),
('user-f04', 30, 45, 'required', 168, 185, 'required',
'["321181"]', 'required', '["never_married","divorced"]', 'preferred', 'senior_high', 'preferred'),
('user-f05', 27, 36, 'required', 172, 186, 'required',
'["321181","321100"]', 'preferred', '["never_married"]', 'required', 'bachelor', 'preferred'),
('user-f06', 30, 50, 'required', 165, 185, 'required',
'["321181"]', 'required', '["never_married","divorced","widowed"]', 'preferred', NULL, NULL),
('user-m01', 22, 32, 'required', 155, 170, 'preferred',
'["321181","321100"]', 'required', '["never_married"]', 'required', 'junior_high', 'preferred'),
('user-m02', 25, 38, 'preferred', 158, 172, 'preferred',
'["321181"]', 'preferred', '["never_married","divorced"]', 'preferred', 'college', 'preferred'),
('user-m03', 22, 30, 'preferred', 155, 168, 'preferred',
'["321181","321100","320500"]', 'preferred', '["never_married"]', 'required', 'college', 'preferred'),
('user-m04', 25, 40, 'preferred', 155, 170, 'preferred',
'["321181"]', 'required', '["never_married","divorced"]', 'preferred', NULL, NULL),
('user-m05', 23, 33, 'required', 158, 170, 'preferred',
'["321181","321100"]', 'preferred', '["never_married"]', 'required', 'bachelor', 'preferred'),
('user-m06', 22, 32, 'preferred', 155, 170, 'preferred',
'["321181","321100","320500"]', 'preferred', '["never_married"]', 'required', 'master', 'preferred');
-- ============================================================
-- 6. 实名认证(user_identities)— mock
-- ============================================================
INSERT INTO user_identities (
user_id, real_name_enc, id_number_enc, id_number_hash,
gender, birth_date, verification_status, provider, verified_at
) VALUES
('user-f01', E'\\xencrypted_f01', E'\\xencrypted_f01_id', 'sha256_f01', 'female', '1995-06-15', 'verified', 'mock', '2026-03-16T10:00:00Z'),
('user-f02', E'\\xencrypted_f02', E'\\xencrypted_f02_id', 'sha256_f02', 'female', '1993-09-20', 'verified', 'mock', '2026-03-21T14:30:00Z'),
('user-f03', E'\\xencrypted_f03', E'\\xencrypted_f03_id', 'sha256_f03', 'female', '1998-02-10', 'verified', 'mock', '2026-04-02T09:15:00Z'),
('user-f04', E'\\xencrypted_f04', E'\\xencrypted_f04_id', 'sha256_f04', 'female', '1990-11-05', 'verified', 'mock', '2026-04-11T16:00:00Z'),
('user-f05', E'\\xencrypted_f05', E'\\xencrypted_f05_id', 'sha256_f05', 'female', '1996-07-22', 'verified', 'mock', '2026-05-02T11:20:00Z'),
('user-f06', E'\\xencrypted_f06', E'\\xencrypted_f06_id', 'sha256_f06', 'female', '1992-04-18', 'verified', 'mock', '2026-05-16T08:45:00Z'),
('user-m01', E'\\xencrypted_m01', E'\\xencrypted_m01_id', 'sha256_m01', 'male', '1992-01-10', 'verified', 'mock', '2026-03-11T09:00:00Z'),
('user-m02', E'\\xencrypted_m02', E'\\xencrypted_m02_id', 'sha256_m02', 'male', '1990-08-25', 'verified', 'mock', '2026-03-26T13:00:00Z'),
('user-m03', E'\\xencrypted_m03', E'\\xencrypted_m03_id', 'sha256_m03', 'male', '1997-12-03', 'verified', 'mock', '2026-04-06T15:30:00Z'),
('user-m04', E'\\xencrypted_m04', E'\\xencrypted_m04_id', 'sha256_m04', 'male', '1988-05-30', 'verified', 'mock', '2026-04-21T10:00:00Z'),
('user-m05', E'\\xencrypted_m05', E'\\xencrypted_m05_id', 'sha256_m05', 'male', '1994-03-14', 'verified', 'mock', '2026-05-02T14:00:00Z'),
('user-m06', E'\\xencrypted_m06', E'\\xencrypted_m06_id', 'sha256_m06', 'male', '1999-08-08', 'verified', 'mock', '2026-05-11T16:30:00Z');
-- ============================================================
-- 7. 兴趣标签(user_interests)
-- ============================================================
INSERT INTO user_interests (user_id, interest_code) VALUES
('user-f01', 'reading'), ('user-f01', 'cooking'), ('user-f01', 'travel'),
('user-f02', 'sports'), ('user-f02', 'music'), ('user-f02', 'outdoor'),
('user-f03', 'photography'), ('user-f03', 'dance'), ('user-f03', 'movie'),
('user-f04', 'pets'), ('user-f04', 'cooking'),
('user-f05', 'reading'), ('user-f05', 'fitness'), ('user-f05', 'charity'),
('user-f06', 'gardening'), ('user-f06', 'cooking'),
('user-m01', 'sports'), ('user-m01', 'gaming'), ('user-m01', 'travel'),
('user-m02', 'reading'), ('user-m02', 'investment'), ('user-m02', 'hiking'),
('user-m03', 'gaming'), ('user-m03', 'music'), ('user-m03', 'coding'),
('user-m04', 'cars'), ('user-m04', 'cooking'),
('user-m05', 'running'), ('user-m05', 'reading'), ('user-m05', 'charity'),
('user-m06', 'research'), ('user-m06', 'travel'), ('user-m06', 'photography');
-- ============================================================
-- 8. 隐私设置(user_privacy_settings)
-- ============================================================
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
('user-f01', true, true, true, true, true, true),
('user-f02', true, true, true, false, true, true),
('user-f03', true, false, true, true, true, false),
('user-f04', true, true, false, true, true, true),
('user-f05', true, true, true, true, false,true),
('user-f06', true, false, true, true, true, true),
('user-m01', true, true, true, true, true, true),
('user-m02', true, true, true, false, true, true),
('user-m03', true, true, true, true, true, false),
('user-m04', true, false, true, true, true, true),
('user-m05', true, true, true, true, true, true),
('user-m06', 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
('photo-f01-a', 'user-f01', 'photos/user-f01/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-f01-l1','user-f01', 'photos/user-f01/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-f01-l2','user-f01', 'photos/user-f01/lifestyle/002.jpg','lifestyle',2, 'approved'),
('photo-f02-a', 'user-f02', 'photos/user-f02/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-f02-l1','user-f02', 'photos/user-f02/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-f03-a', 'user-f03', 'photos/user-f03/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-f03-l1','user-f03', 'photos/user-f03/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-f03-l2','user-f03', 'photos/user-f03/lifestyle/002.jpg','lifestyle',2, 'approved'),
('photo-f04-a', 'user-f04', 'photos/user-f04/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-f05-a', 'user-f05', 'photos/user-f05/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-f05-l1','user-f05', 'photos/user-f05/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-f06-a', 'user-f06', 'photos/user-f06/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-m01-a', 'user-m01', 'photos/user-m01/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-m01-l1','user-m01', 'photos/user-m01/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-m01-l2','user-m01', 'photos/user-m01/lifestyle/002.jpg','lifestyle',2, 'approved'),
('photo-m02-a', 'user-m02', 'photos/user-m02/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-m02-l1','user-m02', 'photos/user-m02/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-m03-a', 'user-m03', 'photos/user-m03/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-m03-l1','user-m03', 'photos/user-m03/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-m04-a', 'user-m04', 'photos/user-m04/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-m05-a', 'user-m05', 'photos/user-m05/avatar/001.jpg', 'avatar', 0, 'approved'),
('photo-m05-l1','user-m05', 'photos/user-m05/lifestyle/001.jpg','lifestyle',1, 'approved'),
('photo-m05-l2','user-m05', 'photos/user-m05/lifestyle/002.jpg','lifestyle',2, 'approved'),
('photo-m06-a', 'user-m06', 'photos/user-m06/avatar/001.jpg', 'avatar', 0, 'approved');
-- ============================================================
-- 10. 审核任务(review_tasks)
-- ============================================================
INSERT INTO review_tasks (id, user_id, review_type, status, assigned_operator_id, submitted_at, started_at, completed_at, final_comment, version) VALUES
('rt-f01', 'user-f01', 'initial_profile', 'approved', 'op-rv001', '2026-03-15T11:00:00Z', '2026-03-15T11:30:00Z', '2026-03-15T12:00:00Z', '资料完整,信息真实', 1),
('rt-f02', 'user-f02', 'initial_profile', 'approved', 'op-rv001', '2026-03-20T15:00:00Z', '2026-03-20T15:30:00Z', '2026-03-20T16:00:00Z', '资料完整', 1),
('rt-f03', 'user-f03', 'initial_profile', 'approved', 'op-rv001', '2026-04-01T10:00:00Z', '2026-04-01T10:30:00Z', '2026-04-01T11:00:00Z', '资料完整', 1),
('rt-m01', 'user-m01', 'initial_profile', 'approved', 'op-rv001', '2026-03-10T10:00:00Z', '2026-03-10T10:30:00Z', '2026-03-10T11:00:00Z', '资料完整', 1),
('rt-m02', 'user-m02', 'initial_profile', 'approved', 'op-rv001', '2026-03-25T14:00:00Z', '2026-03-25T14:30:00Z', '2026-03-25T15:00:00Z', '资料完整', 1),
('rt-m03', 'user-m03', 'initial_profile', 'approved', 'op-rv001', '2026-04-05T16:00:00Z', '2026-04-05T16:30:00Z', '2026-04-05T17:00:00Z', '资料完整', 1),
('rt-m05', 'user-m05', 'initial_profile', 'approved', 'op-rv001', '2026-05-01T15:00:00Z', '2026-05-01T15:30:00Z', '2026-05-01T16:00:00Z', '资料完整', 1);
-- ============================================================
-- 11. 用户关系(user_relations)
-- ============================================================
INSERT INTO user_relations (id, user_id, target_user_id, relation_type, created_at) VALUES
('rel-f01-m01-a', 'user-f01', 'user-m01', 'liked', '2026-06-01T10:00:00Z'),
('rel-f01-m01-b', 'user-m01', 'user-f01', 'liked', '2026-06-01T10:05:00Z'),
('rel-f02-m02', 'user-f02', 'user-m02', 'liked', '2026-06-02T14:00:00Z'),
('rel-f03-m03', 'user-f03', 'user-m03', 'liked', '2026-06-03T09:00:00Z'),
('rel-m03-f03', 'user-m03', 'user-f03', 'liked', '2026-06-03T09:30:00Z'),
('rel-m04-f02', 'user-m04', 'user-f02', 'liked', '2026-06-04T11:00:00Z'),
('rel-f04-m04', 'user-f04', 'user-m04', 'passed', '2026-06-04T12:00:00Z'),
('rel-f05-m05', 'user-f05', 'user-m05', 'liked', '2026-06-05T10:00:00Z'),
('rel-f05-m05-b', 'user-m05', 'user-f05', 'liked', '2026-06-05T10:05:00Z'),
('rel-m06-f01', 'user-m06', 'user-f01', 'liked', '2026-06-06T14:00:00Z'),
('rel-f04-m06', 'user-f04', 'user-m06', 'passed', '2026-06-06T15:00:00Z'),
('rel-f06-m04', 'user-f06', 'user-m04', 'blocked', '2026-06-07T09:00:00Z'),
('rel-m02-f03', 'user-m02', 'user-f03', 'passed', '2026-06-07T10:00:00Z');
-- ============================================================
-- 12. Match(双向匹配)
-- ============================================================
INSERT INTO matches (id, user_a_id, user_b_id, status, source, matched_at) VALUES
('match-f01-m01', 'user-f01', 'user-m01', 'active', 'user_like', '2026-06-01T10:05:00Z'),
('match-f03-m03', 'user-f03', 'user-m03', 'active', 'user_like', '2026-06-03T09:30:00Z'),
('match-f05-m05', 'user-f05', 'user-m05', 'successful', 'user_like', '2026-06-05T10:05:00Z');
-- ============================================================
-- 13. 成功牵手请求(relationship_success_requests)
-- ============================================================
INSERT INTO relationship_success_requests (id, match_id, initiated_by, status, confirmed_by, created_at, resolved_at) VALUES
('rsr-f05-m05', 'match-f05-m05', 'user-f05', 'confirmed', 'user-m05', '2026-07-01T10:00:00Z', '2026-07-01T10:30:00Z'),
('rsr-f01-m01', 'match-f01-m01', 'user-f01', '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
('conv-f01-m01', 'match-f01-m01', 'active', 'msg-f01-m01-3', '2026-07-10T16:00:00Z'),
('conv-f03-m03', 'match-f03-m03', 'active', 'msg-f03-m03-2', '2026-07-08T20:00:00Z'),
('conv-f05-m05', 'match-f05-m05', 'active', 'msg-f05-m05-1', '2026-07-01T18:00:00Z');
INSERT INTO conversation_members (conversation_id, user_id, last_read_message_id, unread_count, can_send, joined_at) VALUES
('conv-f01-m01', 'user-f01', 'msg-f01-m01-3', 0, true, '2026-06-01T10:05:00Z'),
('conv-f01-m01', 'user-m01', 'msg-f01-m01-3', 0, true, '2026-06-01T10:05:00Z'),
('conv-f03-m03', 'user-f03', 'msg-f03-m03-2', 1, true, '2026-06-03T09:30:00Z'),
('conv-f03-m03', 'user-m03', 'msg-f03-m03-2', 0, true, '2026-06-03T09:30:00Z'),
('conv-f05-m05', 'user-f05', 'msg-f05-m05-1', 0, true, '2026-06-05T10:05:00Z'),
('conv-f05-m05', 'user-m05', 'msg-f05-m05-1', 0, true, '2026-06-05T10:05:00Z');
INSERT INTO messages (id, conversation_id, sender_id, message_type, content, status, risk_level, created_at) VALUES
('msg-f01-m01-1', 'conv-f01-m01', 'user-f01', 'text', '你好!看到你的资料觉得挺合适的~', 'sent', 'normal', '2026-06-15T14:00:00Z'),
('msg-f01-m01-2', 'conv-f01-m01', 'user-m01', 'text', '你好!谢谢你的喜欢,我也觉得挺有缘的', 'sent', 'normal', '2026-06-15T14:05:00Z'),
('msg-f01-m01-3', 'conv-f01-m01', 'user-f01', 'text', '你也在丹阳工作吗?平时喜欢做些什么?', 'sent', 'normal', '2026-06-15T14:10:00Z'),
('msg-f03-m03-1', 'conv-f03-m03', 'user-m03', 'text', '嗨,你好!很高兴认识你', 'sent', 'normal', '2026-07-05T19:30:00Z'),
('msg-f03-m03-2', 'conv-f03-m03', 'user-f03', 'text', '你好呀!我平时喜欢拍照和跳舞,你呢?', 'sent', 'normal', '2026-07-05T19:35:00Z'),
('msg-f05-m05-1', 'conv-f05-m05', 'user-m05', 'text', '你好,很高兴认识你!', 'sent', 'normal', '2026-06-10T10:00:00Z');
-- ============================================================
-- 15. 推荐记录(recommendation_records)
-- ============================================================
INSERT INTO recommendation_records (id, user_id, target_user_id, source, score, level, shown_at, action, action_at, rule_version) VALUES
('rec-f01-m01', 'user-f01', 'user-m01', 'daily', 82.50, 'high', '2026-05-28T10:00:00Z', 'liked', '2026-06-01T10:00:00Z', 1),
('rec-f01-m03', 'user-f01', 'user-m03', 'daily', 70.00, 'medium', '2026-05-28T10:00:00Z', 'passed','2026-05-28T10:01:00Z', 1),
('rec-f01-m02', 'user-f01', 'user-m02', 'daily', 65.00, 'medium', '2026-05-28T10:00:00Z', 'passed','2026-05-28T10:02:00Z', 1),
('rec-m01-f01', 'user-m01', 'user-f01', 'daily', 85.00, 'high', '2026-05-28T11:00:00Z', 'liked', '2026-06-01T10:05:00Z', 1),
('rec-m01-f03', 'user-m01', 'user-f03', 'daily', 60.00, 'normal','2026-05-28T11:00:00Z', 'passed','2026-05-28T11:01:00Z', 1),
('rec-f03-m03', 'user-f03', 'user-m03', 'daily', 78.00, 'high', '2026-06-01T09:00:00Z', 'liked', '2026-06-03T09:30:00Z', 1),
('rec-m03-f03', 'user-m03', 'user-f03', 'daily', 75.00, 'high', '2026-06-01T09:30:00Z', 'liked', '2026-06-03T09:30:00Z', 1),
('rec-f05-m05', 'user-f05', 'user-m05', 'daily', 88.00, 'high', '2026-06-01T10:00:00Z', 'liked', '2026-06-05T10:00:00Z', 1),
('rec-m05-f05', 'user-m05', 'user-f05', 'daily', 86.00, 'high', '2026-06-01T10:30:00Z', 'liked', '2026-06-05T10:05:00Z', 1),
('rec-m06-f01', 'user-m06', 'user-f01', 'daily', 62.00, 'medium','2026-06-06T14:00:00Z', 'liked', '2026-06-06T14:00:00Z', 1);
-- ============================================================
-- 16. 相亲活动(activities)
-- ============================================================
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
('act-001',
'丹阳公益单身联谊会(夏季场)',
'面向丹阳市区及周边乡镇的单身青年,由妇联、工会联合主办,提供安全、真实的交友平台。现场设有互动游戏、自由交流环节,红娘全程辅助。',
'org-danyang-women',
'丹阳市总工会、丹阳市慈善基金会',
'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', 'op-admin-001'),
('act-002',
'七夕特别活动·丹阳缘来是你',
'七夕节特别策划,浪漫主题相亲活动。适合寻找认真关系的单身人士。',
'org-danyang-trade',
'丹阳市新时代文明实践中心',
'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', 'op-act01');
-- ============================================================
-- 17. 活动报名(activity_registrations)
-- ============================================================
INSERT INTO activity_registrations (id, activity_id, user_id, status, registered_at, reviewed_by, reviewed_at, checkin_status) VALUES
('reg-001-f01', 'act-001', 'user-f01', 'approved', '2026-07-05T10:00:00Z', 'op-act01', '2026-07-05T10:30:00Z', 'not_checked_in'),
('reg-001-f03', 'act-001', 'user-f03', 'approved', '2026-07-06T14:00:00Z', 'op-act01', '2026-07-06T14:15:00Z', 'not_checked_in'),
('reg-001-f05', 'act-001', 'user-f05', 'approved', '2026-07-07T09:00:00Z', 'op-act01', '2026-07-07T09:20:00Z', 'not_checked_in'),
('reg-001-m01', 'act-001', 'user-m01', 'approved', '2026-07-08T11:00:00Z', 'op-act01', '2026-07-08T11:10:00Z', 'not_checked_in'),
('reg-001-m03', 'act-001', 'user-m03', 'approved', '2026-07-09T15:00:00Z', 'op-act01', '2026-07-09T15:20:00Z', 'not_checked_in'),
('reg-001-m05', 'act-001', 'user-m05', 'approved', '2026-07-10T08:30:00Z', 'op-act01', '2026-07-10T08:45:00Z', 'not_checked_in'),
('reg-001-f02', 'act-001', 'user-f02', 'pending', '2026-07-12T10:00:00Z', NULL, NULL, 'not_checked_in'),
('reg-001-m02', 'act-001', 'user-m02', 'approved', '2026-07-11T16:00:00Z', 'op-act01', '2026-07-11T16:30:00Z', 'not_checked_in'),
('reg-001-f04', 'act-001', 'user-f04', 'rejected', '2026-07-13T09:00:00Z', 'op-act01', '2026-07-13T09:15:00Z', 'not_checked_in');
-- ============================================================
-- 18. 活动互选意向(activity_interests)
-- ============================================================
INSERT INTO activity_interests (id, source_user_id, target_user_id, activity_id, status, confirmed_at, created_at) VALUES
('ai-f01-m01', 'user-f01', 'user-m01', 'act-001', 'mutual', '2026-08-15T17:00:00Z', '2026-08-15T17:00:00Z'),
('ai-f03-m03', 'user-f03', 'user-m03', 'act-001', 'mutual', '2026-08-15T17:05:00Z', '2026-08-15T17:05:00Z'),
('ai-f05-m05', 'user-f05', 'user-m05', 'act-001', 'expressed','2026-08-15T17:10:00Z', '2026-08-15T17:10:00Z');
-- ============================================================
-- 19. 红娘服务(matchmaker_services)
-- ============================================================
INSERT INTO matchmaker_services (id, user_id, service_type, description, status, organization_id, assigned_operator_id, assigned_at, completed_at) VALUES
('ms-f02', 'user-f02', 'recommend_partner', '离异用户希望找到合适的伴侣,需要红娘协助筛选',
'in_service', 'org-danyang-women', 'op-mh001', '2026-06-20T10:00:00Z', NULL),
('ms-f06', 'user-f06', 'no_match_help', '丧偶用户希望重新融入社交,找到新伴侣',
'waiting_user', 'org-danyang-charity', 'op-mh001', '2026-06-25T14:00:00Z', NULL),
('ms-f04', 'user-f04', 'review_preference', '用户希望调整择偶条件,请红娘帮助评估',
'completed', 'org-danyang-women', 'op-mh001', '2026-06-15T09:00:00Z', '2026-06-20T11:00:00Z');
-- 红娘推荐记录
INSERT INTO matchmaker_recommendations (id, service_id, user_id, target_user_id, operator_id, reason, status, created_at, viewed_at, responded_at) VALUES
('mr-f02-m02', 'ms-f02', 'user-f02', 'user-m02', 'op-mh001',
'两人同在丹阳工作,年龄相仿,都离过婚有共同语言',
'viewed', '2026-06-21T10:00:00Z', '2026-06-22T09:00:00Z', NULL);
-- 红娘跟进记录
INSERT INTO matchmaker_followups (id, service_id, operator_id, followup_type, content, result_code, next_followup_at, created_at) VALUES
('mf-f02-1', 'ms-f02', 'op-mh001', 'phone_call', '电话沟通用户情况,了解离异原因及择偶期望', '正常', '2026-07-01T10:00:00Z', '2026-06-22T10:00:00Z'),
('mf-f04-1', 'ms-f04', 'op-mh001', 'face_to_face', '面对面交流,帮助用户调整身高要求从170改为168', '已调整', NULL, '2026-06-18T15:00:00Z');
-- ============================================================
-- 20. 系统通知(notifications)
-- ============================================================
INSERT INTO notifications (id, user_id, type, title, content, business_type, business_id, read_status, created_at) VALUES
('notif-match-f01', 'user-f01', 'match', '你们互相喜欢!', '张伟也喜欢了你,可以开始聊天啦~', 'match', 'match-f01-m01', 'read', '2026-06-01T10:05:00Z'),
('notif-match-m01', 'user-m01', 'match', '你们互相喜欢!', '小芳也喜欢了你,可以开始聊天啦~', 'match', 'match-f01-m01', 'read', '2026-06-01T10:05:00Z'),
('notif-match-f03', 'user-f03', 'match', '你们互相喜欢!', '王磊也喜欢了你,可以开始聊天啦~', 'match', 'match-f03-m03', 'read', '2026-06-03T09:30:00Z'),
('notif-match-m03', 'user-m03', 'match', '你们互相喜欢!', '婷婷也喜欢了你,可以开始聊天啦~', 'match', 'match-f03-m03', 'unread','2026-06-03T09:30:00Z'),
('notif-match-f05', 'user-f05', 'match', '你们互相喜欢!', '孙浩也喜欢了你,可以开始聊天啦~', 'match', 'match-f05-m05', 'read', '2026-06-05T10:05:00Z'),
('notif-match-m05', 'user-m05', 'match', '你们互相喜欢!', '慧琴也喜欢了你,可以开始聊天啦~', 'match', 'match-f05-m05', 'read', '2026-06-05T10:05:00Z'),
('notif-success-f05','user-f05', 'system', '恭喜牵手成功!', '您与孙浩已成功牵手,祝你们幸福!', 'match', 'match-f05-m05', 'read', '2026-07-01T10:30:00Z'),
('notif-success-m05','user-m05', 'system', '恭喜牵手成功!', '您与慧琴已成功牵手,祝你们幸福!', 'match', 'match-f05-m05', 'read', '2026-07-01T10:30:00Z'),
('notif-act-001-f01','user-f01', 'activity', '活动报名已确认', '您已成功报名「丹阳公益单身联谊会」,活动时间:2026-08-15 14:00', 'activity', 'act-001', 'read', '2026-07-05T10:30:00Z'),
('notif-act-001-f05','user-f05', 'activity', '活动报名已确认', '您已成功报名「丹阳公益单身联谊会」,活动时间:2026-08-15 14:00', 'activity', 'act-001', 'unread','2026-07-07T09:20:00Z'),
('notif-mh-f02', 'user-f02', 'matchmaker','红娘已为您服务', '您的红娘服务申请已被分配,红娘小王将在24小时内与您联系', 'matchmaker', 'ms-f02', 'read', '2026-06-20T10:30:00Z');
-- ============================================================
-- 21. 同意记录(consent_records)
-- ============================================================
INSERT INTO consent_records (id, user_id, type, version, agreed_at, ip_address, user_agent) VALUES
('cr-f01', 'user-f01', 'terms_of_service', '1.0', '2026-03-15T10:00:00Z', '127.0.0.1', 'WeChat/8.0'),
('cr-f01', 'user-f01', 'privacy_policy', '1.0', '2026-03-15T10:00:00Z', '127.0.0.1', 'WeChat/8.0'),
('cr-m01', 'user-m01', 'terms_of_service', '1.0', '2026-03-10T09:00:00Z', '127.0.0.1', 'WeChat/8.0'),
('cr-m01', 'user-m01', 'privacy_policy', '1.0', '2026-03-10T09:00:00Z', '127.0.0.1', 'WeChat/8.0');
-- ============================================================
-- 22. 审核原因字典(review_reasons)
-- ============================================================
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);
-- 启用 replication
SET session_replication_role = 'origin';
-- ============================================================
-- 验证数据量
-- ============================================================
DO $$
DECLARE
u_cnt INTEGER; o_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 o_cnt FROM organizations;
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 ' 用户: %人 | 组织: %个 | 操作员: %人', u_cnt, o_cnt, op_cnt;
RAISE NOTICE ' Match: %对 | 关系: %条 | 活动: %个 | 通知: %条', m_cnt, r_cnt, a_cnt, n_cnt;
END $$;