-- Phase 1: lobster_api_registry 能力预置（租户库）
-- 若表结构为旧版(api_url)，请先执行租户库结构升级；本脚本面向 mapper 使用的 base_url/provider 列结构。

-- 扩展列（幂等，MySQL 8+ 可手工执行；Java LobsterApiRegistrySeedService 亦会在行业包开通时 seed）

INSERT INTO lobster_api_registry (api_key, api_name, category, provider, base_url, auth_type, auth_config, timeout, priority, is_backup, description, enabled, create_time)
SELECT 'weather', '天气查询', 'weather', 'amap', 'https://restapi.amap.com/v3/weather/weatherInfo', 'apikey', '{}', 5000, 0, 0,
       'capability:weather,trigger:conversation,node', 1, NOW()
WHERE NOT EXISTS (SELECT 1 FROM lobster_api_registry WHERE api_key = 'weather');

INSERT INTO lobster_api_registry (api_key, api_name, category, provider, base_url, auth_type, auth_config, timeout, priority, is_backup, description, enabled, create_time)
SELECT 'logistics_kdniao', '快递鸟物流查询', 'logistics', 'kdniao', 'https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx', 'none', '{}', 8000, 0, 0,
       'capability:logistics,tool:query_logistics', 1, NOW()
WHERE NOT EXISTS (SELECT 1 FROM lobster_api_registry WHERE api_key = 'logistics_kdniao');

INSERT INTO lobster_api_registry (api_key, api_name, category, provider, base_url, auth_type, auth_config, timeout, priority, is_backup, description, enabled, create_time)
SELECT 'logistics_sf', '顺丰物流查询', 'logistics', 'sf', 'https://ds-api.sf-express.com/externalapi/', 'bearer', '{}', 8000, 1, 1,
       'capability:logistics,provider:sf', 1, NOW()
WHERE NOT EXISTS (SELECT 1 FROM lobster_api_registry WHERE api_key = 'logistics_sf');

INSERT INTO lobster_api_registry (api_key, api_name, category, provider, base_url, auth_type, auth_config, timeout, priority, is_backup, description, enabled, create_time)
SELECT 'logistics_jd', '京东物流查询', 'logistics', 'jd', 'https://api.jd.com/routerjson', 'oauth2', '{}', 8000, 2, 1,
       'capability:logistics,provider:jd', 1, NOW()
WHERE NOT EXISTS (SELECT 1 FROM lobster_api_registry WHERE api_key = 'logistics_jd');

INSERT INTO lobster_api_registry (api_key, api_name, category, provider, base_url, auth_type, auth_config, timeout, priority, is_backup, description, enabled, create_time)
SELECT 'product_mall', '商城商品列表', 'product', 'internal', '', 'none', '{}', 5000, 0, 0,
       'capability:product,tool:query_product', 1, NOW()
WHERE NOT EXISTS (SELECT 1 FROM lobster_api_registry WHERE api_key = 'product_mall');
