-- HTTP审计模块配置表（除 enabled/datasource 外）
CREATE TABLE IF NOT EXISTS `sys_http_audit_config` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `config_key` varchar(100) NOT NULL COMMENT '配置键',
  `config_val` text COMMENT '配置值',
  `enabled` tinyint(4) NOT NULL DEFAULT '1' COMMENT '1启用 0停用',
  `deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '逻辑删除',
  `sort_order` int(11) NOT NULL DEFAULT '0' COMMENT '排序',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_config_key` (`config_key`),
  KEY `idx_enabled_deleted` (`enabled`,`deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='HTTP审计配置';

INSERT INTO `sys_http_audit_config` (`config_key`, `config_val`, `enabled`, `deleted`, `sort_order`, `remark`)
VALUES
('whitelist-only', 'true', 1, 0, 10, '白名单模式'),
('exclude-audit-self-paths', 'false', 1, 0, 20, '是否排除审计自身接口'),
('rule-cache-refresh-ms', '60000', 1, 0, 30, '规则缓存刷新间隔'),
('query-response-max-chars', '500', 1, 0, 40, '查询类响应最大字符'),
('max-response-store-chars', '65535', 1, 0, 50, '响应体最大字符'),
('default-request-store-chars', '65535', 1, 0, 60, '请求体默认最大字符'),
('cleanup-enabled', 'true', 1, 0, 70, '清理开关'),
('cleanup-retention-days', '180', 1, 0, 80, '保留天数'),
('path-descriptions', '{"/erp/order":"云仓-订单查询","/erp/order/add":"云仓-单据下发","/erp/order/addAll":"云仓-批量单据下发","/erp/order/cancel":"云仓-取消单据"}', 1, 0, 90, '路径说明JSON')
ON DUPLICATE KEY UPDATE
`config_val`=VALUES(`config_val`),
`enabled`=VALUES(`enabled`),
`deleted`=VALUES(`deleted`),
`sort_order`=VALUES(`sort_order`),
`remark`=VALUES(`remark`);

