-- ============================================================================ -- wx_moment / wx_moment_comment test seed data -- Target: tenant DB (e.g. fs_tenant_cs1) -- Usage: select tenant DB in Navicat, then execute this script -- Idempotent: removes previous rows with client_moment_id prefix test_moment_ -- ============================================================================ DELETE c FROM wx_moment_comment c INNER JOIN wx_moment m ON c.moment_id = m.id WHERE m.client_moment_id LIKE 'test_moment_%'; DELETE FROM wx_moment WHERE client_moment_id LIKE 'test_moment_%'; SET @account_id = (SELECT id FROM company_wx_account ORDER BY id LIMIT 1); SET @company_id = (SELECT company_id FROM company_wx_account WHERE id = @account_id LIMIT 1); SET @company_user_id = (SELECT company_user_id FROM company_wx_account WHERE id = @account_id LIMIT 1); SET @author_wx_id = 'wxid_test_felicity'; SET @author_contact_id = ( SELECT id FROM wx_contact WHERE account_id = @account_id AND (user_name = @author_wx_id OR alias = @author_wx_id) LIMIT 1 ); INSERT INTO wx_moment ( account_id, company_id, company_user_id, wx_contact_id, client_moment_id, author_wx_id, author_nick_name, author_head_img_url, content, media_type, media_json, publish_time, like_count, comment_count, sync_time, create_time, update_time, remark ) VALUES ( @account_id, @company_id, @company_user_id, @author_contact_id, 'test_moment_001', @author_wx_id, 'Felicity.', NULL, 'Hide and seek😁', 2, '[{"url":"https://via.placeholder.com/400x400.png?text=dog","thumbUrl":"https://via.placeholder.com/120x120.png?text=dog"}]', DATE_SUB(NOW(), INTERVAL 3 DAY), 1, 2, NOW(), NOW(), NOW(), 'test seed' ); SET @moment_id_1 = LAST_INSERT_ID(); INSERT INTO wx_moment_comment ( moment_id, account_id, wx_contact_id, client_comment_id, comment_type, commenter_wx_id, commenter_nick_name, content, media_json, comment_time, create_time, update_time ) VALUES (@moment_id_1, @account_id, NULL, 'test_like_001', 2, 'wxid_test_shi', '逝', NULL, NULL, DATE_SUB(NOW(), INTERVAL 3 DAY), NOW(), NOW()), (@moment_id_1, @account_id, @author_contact_id, 'test_cmt_001', 1, @author_wx_id, 'Felicity.', '不行,还是有点太轻松了', '[{"thumbUrl":"https://via.placeholder.com/40x40.png?text=img"}]', DATE_SUB(NOW(), INTERVAL 3 DAY), NOW(), NOW()), (@moment_id_1, @account_id, @author_contact_id, 'test_cmt_002', 1, @author_wx_id, 'Felicity.', '只消耗了十分钟的精力 🙃', NULL, DATE_SUB(NOW(), INTERVAL 3 DAY), NOW(), NOW()); INSERT INTO wx_moment ( account_id, company_id, company_user_id, wx_contact_id, client_moment_id, author_wx_id, author_nick_name, author_head_img_url, content, media_type, media_json, publish_time, like_count, comment_count, sync_time, create_time, update_time, remark ) VALUES ( @account_id, @company_id, @company_user_id, NULL, 'test_moment_002', 'wxid_test_unknown', 'Traveler', NULL, '周末随手拍一张 ☀️', 1, NULL, DATE_SUB(NOW(), INTERVAL 1 DAY), 0, 0, NOW(), NOW(), NOW(), 'test seed no contact match' ); INSERT INTO wx_moment ( account_id, company_id, company_user_id, wx_contact_id, client_moment_id, author_wx_id, author_nick_name, author_head_img_url, content, media_type, media_json, publish_time, like_count, comment_count, sync_time, create_time, update_time, remark ) VALUES ( @account_id, @company_id, @company_user_id, NULL, 'test_moment_003', 'wxid_test_multi', 'PhotoLog', NULL, '九宫格测试', 2, '[{"url":"https://via.placeholder.com/80x80.png?text=1","thumbUrl":"https://via.placeholder.com/80x80.png?text=1"},{"url":"https://via.placeholder.com/80x80.png?text=2","thumbUrl":"https://via.placeholder.com/80x80.png?text=2"},{"url":"https://via.placeholder.com/80x80.png?text=3","thumbUrl":"https://via.placeholder.com/80x80.png?text=3"},{"url":"https://via.placeholder.com/80x80.png?text=4","thumbUrl":"https://via.placeholder.com/80x80.png?text=4"}]', DATE_SUB(NOW(), INTERVAL 5 HOUR), 0, 0, NOW(), NOW(), NOW(), 'test seed multi images' ); SELECT @account_id AS seeded_account_id, COUNT(*) AS moment_count FROM wx_moment WHERE client_moment_id LIKE 'test_moment_%';