-- 云仓地址变更：192.168.10.108:8180
-- 1) 新增 HTTP 审计规则，确保云仓出站请求写入 sys_http_audit_log
-- 2) 记录一次地址变更信息到 HTTP 记录表

SET NAMES utf8mb4;

INSERT INTO `sys_http_audit_rule`
(`rule_type`, `match_mode`, `pattern`, `direction`, `request_max_chars`, `response_max_chars`, `enabled`, `record_all`, `sort_order`, `remark`, `create_time`, `update_time`, `deleted`)
SELECT
    'URI', 'CONTAINS', '192.168.10.108:8180', 'OUT', NULL, NULL, 1, 1, 210, '云仓出站地址审计', NOW(), NOW(), 0
WHERE NOT EXISTS (
    SELECT 1
    FROM `sys_http_audit_rule`
    WHERE `rule_type` = 'URI'
      AND `match_mode` = 'CONTAINS'
      AND `pattern` = '192.168.10.108:8180'
      AND `direction` = 'OUT'
      AND (`deleted` = 0 OR `deleted` IS NULL)
);

INSERT INTO `sys_http_audit_log`
(`service_name`, `scope_type`, `uri`, `io_direction`, `method`, `function_desc`, `request_body`, `response_body`, `http_status`, `ok_flag`, `spend_ms`, `client_ip`, `error_message`, `create_time`, `deleted`)
VALUES
('rsf-server', 'INTERNAL', 'http://192.168.10.108:8180', 'OUT', 'CONFIG', '云仓地址配置变更记录', '{"platform.erp.base-url":"http://192.168.10.108:8180"}', '{"msg":"cloud wms url updated"}', 200, 1, 0, '127.0.0.1', NULL, NOW(), 0);

