-- ============================================================
-- 火山引擎真人人像素材 — 模块配置 SQL
-- 执行顺序：先执行 uapi_volcengine_ark.sql，再执行本文件
-- ============================================================

-- 1. 供应商配置 (rl_vendor_config)
-- api_mapping: 内部操作名 → uapi.name
INSERT INTO rl_vendor_config (id, vendor, vendor_title, upappid, api_mapping, status, callback_url, create_time, update_time) VALUES (
    'volcengine',
    'volcengine',
    '火山引擎',
    'volcengine_ark',
    '{"create_session":"createVisualValidateSession","check_session":"getVisualValidateResult","upload_asset":"createAsset","get_asset":"getAsset","delete_asset":"deleteAsset","delete_group":"deleteAssetGroup","list_groups":"listAssetGroups","list_assets":"listAssets","get_group":"getAssetGroup","update_asset":"updateAsset","update_group":"updateAssetGroup"}',
    'active',
    'https://token.opencomputing.cn/reallife_asset/api/rl_callback.dspy',
    NOW(),
    NOW()
) ON DUPLICATE KEY UPDATE
    vendor_title=VALUES(vendor_title),
    upappid=VALUES(upappid),
    api_mapping=VALUES(api_mapping),
    callback_url=VALUES(callback_url),
    update_time=NOW();

-- 2. API密钥 (upappkey)
-- callerid = vendor = 'volcengine'，与 rl_vendor_config.vendor 对应
INSERT INTO upappkey (id, upappid, ownerid, myappid, apikey, secretkey) VALUES (
    'volcengine_ark_key',
    'volcengine_ark',
    '0',
    'volcengine',
    password_encode('AKLTZWE5YTY1MDRhMmIyNGFlN2JkMzBjN2U0NGFkMWQ5ODM'),
    password_encode('TURFMU9ESTBNamc1TW1JMk5HVmpORGczT1dNeE0yVTRabVV4TVRJeFpUWQ==')
) ON DUPLICATE KEY UPDATE
    apikey=VALUES(apikey),
    secretkey=VALUES(secretkey);

-- 3. 供应商下拉代码 (appcodes_kv)
-- rl_org_group 表的 vendor 字段引用此代码表
INSERT INTO appcodes_kv (parentid, k, v) VALUES
    ('rl_vendor', 'volcengine', '火山引擎')
ON DUPLICATE KEY UPDATE v=VALUES(v);
