sync: 同步 v1.0.4 开源代码并脱敏

This commit is contained in:
MiFaZhan
2026-10-29 14:59:32 +08:00
parent 14f4bb64e1
commit 3e5a7453b8
74 changed files with 3297 additions and 248 deletions
@@ -0,0 +1,37 @@
-- Migration guide for the shared-token template split.
-- Review rows before running against a production database. This script does
-- not move or retain Henan Lelian credentials.
SET NAMES utf8mb4;
-- 1. Inspect the archived template and its channels.
SELECT temp_key, temp_model, temp_config
FROM t_sim_channel_template
WHERE temp_key = 'sim_onelink_shared_v5';
SELECT chan_key, chan_config, chan_status
FROM t_sim_channels
WHERE temp_key = 'sim_onelink_shared_v5';
-- 2. Seed the new templates first (see seed_onelink_shared_channel.sql),
-- then migrate only Tengyu rows after reviewing their provider value.
-- The JSON functions require MySQL 5.7+ and intentionally preserve only the
-- channel credentials. Public API/provider settings live in the new template.
UPDATE t_sim_channels
SET temp_key = 'sim_onelink_tengyu_v1',
chan_config = JSON_OBJECT(
'credentials', JSON_OBJECT(
'pwdKey', JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.pwdKey')),
'channelNo', JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.channelNo'))
)
)
WHERE temp_key = 'sim_onelink_shared_v5'
AND LOWER(JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.provider'))) = 'tengyu';
-- 3. Henan Lelian rows must be disabled and manually migrated or removed.
UPDATE t_sim_channels
SET chan_status = 0
WHERE temp_key = 'sim_onelink_shared_v5'
AND LOWER(JSON_UNQUOTE(JSON_EXTRACT(chan_config, '$.auth.provider'))) = 'henan_lelian';
-- 4. After all rows are reviewed and migrated, remove the archived template.
-- DELETE FROM t_sim_channel_template WHERE temp_key = 'sim_onelink_shared_v5';
+65
View File
@@ -0,0 +1,65 @@
-- Shared OneLink template/channel examples. Token endpoint and credentials
-- belong to the shared-token template configuration.
SET NAMES utf8mb4;
INSERT INTO `t_sim_channel_template` (
`temp_key`, `temp_name`, `temp_model`, `temp_config`, `temp_status`,
`tenant_id`, `created_dept`, `created_by`, `updated_by`
) VALUES (
'sim_onelink_tengyu_v1',
'Tengyu shared OneLink token v1',
'shared_token',
'{"token":{"provider":"tengyu","baseUrl":"http://www.sdtywl.cn/","path":"/prod-api/open/api/oneLinkToken"}}',
1, '000000', 103, 1, 1
)
ON DUPLICATE KEY UPDATE
`temp_name` = VALUES(`temp_name`), `temp_model` = VALUES(`temp_model`),
`temp_config` = VALUES(`temp_config`), `temp_status` = VALUES(`temp_status`),
`updated_by` = VALUES(`updated_by`);
INSERT INTO `t_sim_channels` (
`temp_key`, `chan_key`, `chan_name`, `chan_config`, `chan_status`,
`chan_alias`, `region_code`, `app_key`, `app_secret`, `access_token`,
`refresh_token`, `tenant_id`, `created_dept`, `created_by`, `updated_by`
) VALUES (
'sim_onelink_tengyu_v1',
'OneLink_TENGYU_EXAMPLE',
'OneLink Tengyu shared-token example',
'{"credentials":{"pwdKey":"REPLACE_WITH_PWDKEY","channelNo":"REPLACE_WITH_CHANNEL_NO"}}',
1, '', '', '', '', '', '', '000000', 103, 1, 1
)
ON DUPLICATE KEY UPDATE
`temp_key` = VALUES(`temp_key`), `chan_key` = VALUES(`chan_key`),
`chan_config` = VALUES(`chan_config`), `chan_status` = VALUES(`chan_status`),
`updated_by` = VALUES(`updated_by`);
INSERT INTO `t_sim_channel_template` (
`temp_key`, `temp_name`, `temp_model`, `temp_config`, `temp_status`,
`tenant_id`, `created_dept`, `created_by`, `updated_by`
) VALUES (
'sim_onelink_xuzhou_mobile_v1',
'Xuzhou Mobile shared OneLink token v1',
'shared_token',
'{"token":{"provider":"xuzhou_mobile","baseUrl":"http://iot.yuanjianiot.com","path":"/admin/api/get/token","carrierType":1}}',
1, '000000', 103, 1, 1
)
ON DUPLICATE KEY UPDATE
`temp_name` = VALUES(`temp_name`), `temp_model` = VALUES(`temp_model`),
`temp_config` = VALUES(`temp_config`), `temp_status` = VALUES(`temp_status`),
`updated_by` = VALUES(`updated_by`);
INSERT INTO `t_sim_channels` (
`temp_key`, `chan_key`, `chan_name`, `chan_config`, `chan_status`,
`chan_alias`, `region_code`, `app_key`, `app_secret`, `access_token`,
`refresh_token`, `tenant_id`, `created_dept`, `created_by`, `updated_by`
) VALUES (
'sim_onelink_xuzhou_mobile_v1',
'OneLink_XUZHOU_MOBILE_EXAMPLE',
'OneLink Xuzhou Mobile shared-token example',
'{"credentials":{"appId":"REPLACE_WITH_APP_ID"}}',
1, '', '', '', '', '', '', '000000', 103, 1, 1
)
ON DUPLICATE KEY UPDATE
`temp_key` = VALUES(`temp_key`), `chan_name` = VALUES(`chan_name`),
`chan_config` = VALUES(`chan_config`), `chan_status` = VALUES(`chan_status`),
`updated_by` = VALUES(`updated_by`);
+100
View File
@@ -0,0 +1,100 @@
SET NAMES utf8mb4;
-- 腾宇(综合充值平台)通道初始化。
-- 字段复用约定(internal/logic/upstreamimpl/sim_recharge.go):
-- t_sim_channels.app_key = pwdkey(个人中心 > 密钥 Key)
-- t_sim_channels.app_secret = pwdiv(签名 IV,sign=md5(pwdkey+pwdiv+timestamp))
-- 执行前必须替换以下三个占位符。
SET @recharge_pwdkey = 'REPLACE_WITH_PWDKEY';
SET @recharge_pwdiv = 'REPLACE_WITH_PWDIV_OR_IV';
SET @recharge_chan_key = 'REPLACE_WITH_LOCAL_CHAN_KEY';
-- 上线前需在腾宇后台配置网关出口 IP 白名单,否则上游返回 407。
-- 上游单接口限流 60 次/分;全量同步触发 429 时由下轮重试兜底。
START TRANSACTION;
INSERT INTO `t_sim_channel_template` (
`temp_key`,
`temp_name`,
`temp_model`,
`temp_config`,
`temp_status`,
`tenant_id`,
`created_dept`,
`created_by`,
`updated_by`
) VALUES (
'sim_recharge_sdtywl_v1',
'综合充值平台 API',
'{}',
'{"baseUrl":"http://www.sdtywl.cn/"}',
0,
'000000',
100,
1,
1
)
ON DUPLICATE KEY UPDATE
`temp_name` = VALUES(`temp_name`),
`temp_model` = VALUES(`temp_model`),
`temp_config` = VALUES(`temp_config`),
`temp_status` = VALUES(`temp_status`),
`updated_by` = VALUES(`updated_by`);
INSERT INTO `t_sim_channels` (
`temp_key`,
`chan_key`,
`chan_name`,
`chan_config`,
`chan_status`,
`chan_alias`,
`region_code`,
`app_key`,
`app_secret`,
`access_token`,
`access_token_created`,
`access_token_expire`,
`refresh_token`,
`login_url`,
`tenant_id`,
`created_dept`,
`created_by`,
`updated_by`
) VALUES (
'sim_recharge_sdtywl_v1',
@recharge_chan_key,
'仟所腾宇',
'{}',
0,
'腾宇',
'',
@recharge_pwdkey,
@recharge_pwdiv,
NULL,
NULL,
NULL,
NULL,
'http://www.sdtywl.cn/',
'000000',
100,
1,
1
)
ON DUPLICATE KEY UPDATE
`temp_key` = VALUES(`temp_key`),
`chan_name` = VALUES(`chan_name`),
`chan_config` = VALUES(`chan_config`),
`chan_status` = VALUES(`chan_status`),
`chan_alias` = VALUES(`chan_alias`),
`region_code` = VALUES(`region_code`),
`app_key` = VALUES(`app_key`),
`app_secret` = VALUES(`app_secret`),
`access_token` = NULL,
`access_token_created` = NULL,
`access_token_expire` = NULL,
`refresh_token` = NULL,
`login_url` = VALUES(`login_url`),
`updated_by` = VALUES(`updated_by`);
COMMIT;
+19
View File
@@ -0,0 +1,19 @@
-- Public protocol configuration for the built-in templates.
-- Run after the corresponding template rows exist.
SET NAMES utf8mb4;
INSERT INTO t_sim_channel_template
(temp_key, temp_name, temp_model, temp_config, temp_status, tenant_id, created_dept, created_by, updated_by)
VALUES
('sim_yd_v5', 'China Mobile OneLink v5', 'direct',
'{"api":{"baseUrl":"https://api.iot.10086.cn/v5/","timeout":"10s"},"token":{"path":"/ec/get/token"}}',
1, '000000', 103, 1, 1),
('sim_yd_mock_v5', 'China Mobile OneLink mock v5', 'direct',
'{"api":{"baseUrl":"http://iotlcm.example.com/onelink-mock/v5/"}}',
1, '000000', 103, 1, 1),
('sim_dx_v1', 'China Telecom API v1', 'direct',
'{"api":{"baseUrl":"https://cmp-api.ctwing.cn:20164"}}',
1, '000000', 103, 1, 1)
ON DUPLICATE KEY UPDATE
temp_model = VALUES(temp_model), temp_config = VALUES(temp_config),
temp_status = VALUES(temp_status), updated_by = VALUES(updated_by);