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

131 lines
6.1 KiB
PL/PgSQL
Raw Permalink 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.
-- ===================================================================
-- 公司信息全局配置表初始化数据
-- 配合 comindex.uvue 页面使用
-- ===================================================================
-- 创建全局配置表(如果不存在)
CREATE TABLE IF NOT EXISTS public.ak_global_config (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
config_key VARCHAR(100) NOT NULL UNIQUE,
config_value TEXT NOT NULL,
config_type VARCHAR(50) DEFAULT 'string',
description TEXT,
is_active BOOLEAN DEFAULT true,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- 创建索引
CREATE INDEX IF NOT EXISTS idx_ak_global_config_key ON public.ak_global_config(config_key);
CREATE INDEX IF NOT EXISTS idx_ak_global_config_active ON public.ak_global_config(is_active);
CREATE INDEX IF NOT EXISTS idx_ak_global_config_type ON public.ak_global_config(config_type);
-- 插入公司基础信息(多语言支持)
INSERT INTO public.ak_global_config (config_key, config_value, config_type, description) VALUES
-- 公司名称
('company_name_zh', '创新科技有限公司', 'string', '公司名称-简体中文'),
('company_name_en', 'Innovation Technology Co., Ltd.', 'string', '公司名称-英文'),
('company_name_tw', '創新科技有限公司', 'string', '公司名称-繁体中文'),
('company_name_ja', 'イノベーション技術株式会社', 'string', '公司名称-日文'),
-- 公司标语
('company_slogan_zh', '科技创新,未来可期', 'string', '公司标语-简体中文'),
('company_slogan_en', 'Innovation for the Future', 'string', '公司标语-英文'),
('company_slogan_tw', '科技創新,未來可期', 'string', '公司标语-繁体中文'),
('company_slogan_ja', '技術革新で未来を創る', 'string', '公司标语-日文'),
-- 公司地址
('company_address_zh', '上海市浦东新区张江高科技园区创新路88号', 'string', '公司地址-简体中文'),
('company_address_en', '88 Innovation Road, Zhangjiang Hi-Tech Park, Pudong New Area, Shanghai', 'string', '公司地址-英文'),
('company_address_tw', '上海市浦東新區張江高科技園區創新路88號', 'string', '公司地址-繁体中文'),
('company_address_ja', '上海市浦東新区張江ハイテクパーク イベーション路88号', 'string', '公司地址-日文'),
-- 联系方式(无多语言差异)
('company_phone', '400-123-4567', 'string', '公司电话'),
('company_email', 'info@innovation-tech.com', 'string', '公司邮箱'),
('company_icp', '沪ICP备12345678号-1', 'string', 'ICP备案号'),
-- 公司LOGO
('company_logo_url', '/static/company-logo.png', 'string', '公司LOGO地址'),
-- 社交媒体链接
('social_wechat_url', 'https://weixin.qq.com/innovation-tech', 'string', '微信官方账号链接'),
('social_weibo_url', 'https://weibo.com/innovation-tech', 'string', '微博官方账号链接'),
('social_qq_url', 'https://qun.qq.com/innovation-tech', 'string', 'QQ群/空间链接'),
('social_linkedin_url', 'https://linkedin.com/company/innovation-tech', 'string', 'LinkedIn公司主页'),
('social_twitter_url', 'https://twitter.com/innovation_tech', 'string', 'Twitter官方账号'),
-- 热门搜索关键词(多语言支持)
-- 简体中文
('hot_search_1_zh', '人工智能', 'string', '热门搜索1-简体中文'),
('hot_search_2_zh', '大数据分析', 'string', '热门搜索2-简体中文'),
('hot_search_3_zh', '物联网', 'string', '热门搜索3-简体中文'),
('hot_search_4_zh', '云计算', 'string', '热门搜索4-简体中文'),
('hot_search_5_zh', '区块链', 'string', '热门搜索5-简体中文'),
-- 英文
('hot_search_1_en', 'Artificial Intelligence', 'string', '热门搜索1-英文'),
('hot_search_2_en', 'Big Data Analytics', 'string', '热门搜索2-英文'),
('hot_search_3_en', 'Internet of Things', 'string', '热门搜索3-英文'),
('hot_search_4_en', 'Cloud Computing', 'string', '热门搜索4-英文'),
('hot_search_5_en', 'Blockchain', 'string', '热门搜索5-英文'),
-- 繁体中文
('hot_search_1_tw', '人工智慧', 'string', '热门搜索1-繁体中文'),
('hot_search_2_tw', '大數據分析', 'string', '热门搜索2-繁体中文'),
('hot_search_3_tw', '物聯網', 'string', '热门搜索3-繁体中文'),
('hot_search_4_tw', '雲端運算', 'string', '热门搜索4-繁体中文'),
('hot_search_5_tw', '區塊鏈', 'string', '热门搜索5-繁体中文'),
-- 日文
('hot_search_1_ja', '人工知能', 'string', '热门搜索1-日文'),
('hot_search_2_ja', 'ビッグデータ解析', 'string', '热门搜索2-日文'),
('hot_search_3_ja', 'IoT', 'string', '热门搜索3-日文'),
('hot_search_4_ja', 'クラウドコンピューティング', 'string', '热门搜索4-日文'),
('hot_search_5_ja', 'ブロックチェーン', 'string', '热门搜索5-日文')
ON CONFLICT (config_key) DO UPDATE SET
config_value = EXCLUDED.config_value,
description = EXCLUDED.description,
updated_at = NOW();
-- 创建更新时间触发器
CREATE OR REPLACE FUNCTION update_updated_at_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ language 'plpgsql';
-- 为全局配置表创建更新时间触发器
DROP TRIGGER IF EXISTS update_ak_global_config_updated_at ON public.ak_global_config;
CREATE TRIGGER update_ak_global_config_updated_at
BEFORE UPDATE ON public.ak_global_config
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();
-- 创建视图,方便查询当前有效的配置
CREATE OR REPLACE VIEW public.vw_active_global_config AS
SELECT
config_key,
config_value,
config_type,
description,
created_at,
updated_at
FROM public.ak_global_config
WHERE is_active = true
ORDER BY config_key;
COMMENT ON VIEW public.vw_active_global_config IS '当前有效的全局配置视图';
-- 输出完成信息
DO $$
BEGIN
RAISE NOTICE '全局配置表初始化完成!';
RAISE NOTICE '现在可以在 comindex.uvue 页面中使用多语言公司信息了。';
RAISE NOTICE '配置项包括:公司名称、标语、地址、联系方式、社交媒体链接、热门搜索关键词等。';
END
$$;