Files
akmon/mock_info.sql
2026-01-20 08:04:15 +08:00

190 lines
7.9 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.
-- mock_info.sql
-- 生成多语言AI资讯系统主要表的测试数据每表50条以上
-- 1. ak_languages
INSERT INTO public.ak_languages (id, code, name, native_name, ai_translation_enabled, translation_quality_threshold) VALUES
(gen_random_uuid(), 'zh-CN', '简体中文', '简体中文', true, 0.8),
(gen_random_uuid(), 'en-US', 'English', 'English', true, 0.8),
(gen_random_uuid(), 'ja-JP', '日本語', '日本語', true, 0.8),
(gen_random_uuid(), 'ko-KR', '한국어', '한국어', true, 0.8),
(gen_random_uuid(), 'fr-FR', 'Français', 'Français', true, 0.8),
(gen_random_uuid(), 'de-DE', 'Deutsch', 'Deutsch', true, 0.8),
(gen_random_uuid(), 'es-ES', 'Español', 'Español', true, 0.8);
-- 2. ak_users
INSERT INTO public.ak_users (id, username, email, created_at) VALUES
-- 生成50个用户
(gen_random_uuid(), 'user1', 'user1@example.com', now()),
(gen_random_uuid(), 'user2', 'user2@example.com', now()),
(gen_random_uuid(), 'user3', 'user3@example.com', now()),
(gen_random_uuid(), 'user4', 'user4@example.com', now()),
(gen_random_uuid(), 'user5', 'user5@example.com', now()),
(gen_random_uuid(), 'user6', 'user6@example.com', now()),
(gen_random_uuid(), 'user7', 'user7@example.com', now()),
(gen_random_uuid(), 'user8', 'user8@example.com', now()),
(gen_random_uuid(), 'user9', 'user9@example.com', now()),
(gen_random_uuid(), 'user10', 'user10@example.com', now()),
(gen_random_uuid(), 'user11', 'user11@example.com', now()),
(gen_random_uuid(), 'user12', 'user12@example.com', now()),
(gen_random_uuid(), 'user13', 'user13@example.com', now()),
(gen_random_uuid(), 'user14', 'user14@example.com', now()),
(gen_random_uuid(), 'user15', 'user15@example.com', now()),
(gen_random_uuid(), 'user16', 'user16@example.com', now()),
(gen_random_uuid(), 'user17', 'user17@example.com', now()),
(gen_random_uuid(), 'user18', 'user18@example.com', now()),
(gen_random_uuid(), 'user19', 'user19@example.com', now()),
(gen_random_uuid(), 'user20', 'user20@example.com', now()),
(gen_random_uuid(), 'user21', 'user21@example.com', now()),
(gen_random_uuid(), 'user22', 'user22@example.com', now()),
(gen_random_uuid(), 'user23', 'user23@example.com', now()),
(gen_random_uuid(), 'user24', 'user24@example.com', now()),
(gen_random_uuid(), 'user25', 'user25@example.com', now()),
(gen_random_uuid(), 'user26', 'user26@example.com', now()),
(gen_random_uuid(), 'user27', 'user27@example.com', now()),
(gen_random_uuid(), 'user28', 'user28@example.com', now()),
(gen_random_uuid(), 'user29', 'user29@example.com', now()),
(gen_random_uuid(), 'user30', 'user30@example.com', now()),
(gen_random_uuid(), 'user31', 'user31@example.com', now()),
(gen_random_uuid(), 'user32', 'user32@example.com', now()),
(gen_random_uuid(), 'user33', 'user33@example.com', now()),
(gen_random_uuid(), 'user34', 'user34@example.com', now()),
(gen_random_uuid(), 'user35', 'user35@example.com', now()),
(gen_random_uuid(), 'user36', 'user36@example.com', now()),
(gen_random_uuid(), 'user37', 'user37@example.com', now()),
(gen_random_uuid(), 'user38', 'user38@example.com', now()),
(gen_random_uuid(), 'user39', 'user39@example.com', now()),
(gen_random_uuid(), 'user40', 'user40@example.com', now()),
(gen_random_uuid(), 'user41', 'user41@example.com', now()),
(gen_random_uuid(), 'user42', 'user42@example.com', now()),
(gen_random_uuid(), 'user43', 'user43@example.com', now()),
(gen_random_uuid(), 'user44', 'user44@example.com', now()),
(gen_random_uuid(), 'user45', 'user45@example.com', now()),
(gen_random_uuid(), 'user46', 'user46@example.com', now()),
(gen_random_uuid(), 'user47', 'user47@example.com', now()),
(gen_random_uuid(), 'user48', 'user48@example.com', now()),
(gen_random_uuid(), 'user49', 'user49@example.com', now()),
(gen_random_uuid(), 'user50', 'user50@example.com', now());
-- 3. ak_content_categories
INSERT INTO public.ak_content_categories (id, name_key, level, ai_keywords, is_active, created_at) VALUES
(gen_random_uuid(), 'news.politics', 0, ARRAY['政治', '政府', '政策'], true, now()),
(gen_random_uuid(), 'news.economy', 0, ARRAY['经济', '金融', '股市'], true, now()),
(gen_random_uuid(), 'news.technology', 0, ARRAY['科技', 'AI', '互联网'], true, now()),
(gen_random_uuid(), 'news.sports', 0, ARRAY['体育', '足球', '篮球'], true, now()),
(gen_random_uuid(), 'news.entertainment', 0, ARRAY['娱乐', '明星', '电影'], true, now()),
(gen_random_uuid(), 'news.health', 0, ARRAY['健康', '医疗', '疾病'], true, now()),
(gen_random_uuid(), 'news.education', 0, ARRAY['教育', '学校', '考试'], true, now()),
(gen_random_uuid(), 'news.international', 0, ARRAY['国际', '外交', '全球'], true, now());
-- 4. ak_contents
-- 生成50条内容随机分配分类、作者、语言
DO $$
DECLARE
i INT := 1;
cat_ids uuid[] := ARRAY(SELECT id FROM public.ak_content_categories);
lang_codes TEXT[] := ARRAY['zh-CN','en-US','ja-JP','ko-KR','fr-FR','de-DE','es-ES'];
user_ids uuid[] := ARRAY(SELECT id FROM public.ak_users);
BEGIN
WHILE i <= 50 LOOP
INSERT INTO public.ak_contents (
id, title, content, summary, author, source_url, original_language, category_id, tags, keywords, quality_score, published_at, status, created_at, updated_at
) VALUES (
gen_random_uuid(),
'测试资讯标题' || i,
'这是第' || i || '条测试内容,内容丰富多样,适合测试。',
'摘要内容' || i,
'user' || ((i-1)%50+1),
'https://example.com/news/' || i,
lang_codes[(i%7)+1],
cat_ids[(i%8)+1],
ARRAY['标签A','标签B','标签C'],
ARRAY['关键词1','关键词2'],
-- 修正round函数类型问题强制类型转换为numeric再转float
CAST(round((random()*0.5+0.5)::numeric, 2) AS float),
now() - (i || ' days')::interval,
'published',
now() - (i || ' days')::interval,
now() - (i || ' days')::interval
);
i := i + 1;
END LOOP;
END$$;
-- 5. ak_topics
DO $$
DECLARE
i INT := 1;
cat_ids uuid[] := ARRAY(SELECT id FROM public.ak_content_categories);
BEGIN
WHILE i <= 50 LOOP
INSERT INTO public.ak_topics (
id, title, description, topic_type, status, cover_image_url, content_count, created_at, updated_at
) VALUES (
gen_random_uuid(),
'专题标题' || i,
'这是第' || i || '个专题的描述。',
'series',
'active',
'https://example.com/topic/cover/' || i || '.jpg',
(random()*20)::int,
now() - (i || ' days')::interval,
now() - (i || ' days')::interval
);
i := i + 1;
END LOOP;
END$$;
-- 6. ak_topic_contents
DO $$
DECLARE
i INT := 1;
topic_ids uuid[] := ARRAY(SELECT id FROM public.ak_topics);
content_ids uuid[] := ARRAY(SELECT id FROM public.ak_contents);
BEGIN
WHILE i <= 50 LOOP
INSERT INTO public.ak_topic_contents (
id, topic_id, content_id, display_order, editor_note, is_featured, added_at, created_at
) VALUES (
gen_random_uuid(),
topic_ids[(i%50)+1],
content_ids[(i%50)+1],
i,
'编辑说明' || i,
(i%2=0),
now() - (i || ' days')::interval,
now() - (i || ' days')::interval
);
i := i + 1;
END LOOP;
END$$;
-- 7. ak_comments
DO $$
DECLARE
i INT := 1;
content_ids uuid[] := ARRAY(SELECT id FROM public.ak_contents);
user_ids uuid[] := ARRAY(SELECT id FROM public.ak_users);
BEGIN
WHILE i <= 50 LOOP
INSERT INTO public.ak_comments (
id, target_type, target_id, author_id, author_name, content, status, like_count, reply_count, level, created_at, updated_at
) VALUES (
gen_random_uuid(),
'content',
content_ids[(i%50)+1],
user_ids[(i%50)+1],
'用户' || ((i-1)%50+1),
'这是第' || i || '条评论内容。',
'active',
(random()*10)::int,
(random()*5)::int,
0,
now() - (i || ' days')::interval,
now() - (i || ' days')::interval
);
i := i + 1;
END LOOP;
END$$;
-- 更多表可按需补充生成