CREATE TABLE IF NOT EXISTS `biz_api_call_log` (
  `id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  `user_id` BIGINT UNSIGNED NOT NULL COMMENT '业务用户ID',
  `token_id` BIGINT UNSIGNED NOT NULL COMMENT '使用的Token ID',
  `api_path` VARCHAR(200) NOT NULL COMMENT '接口路径',
  `http_method` VARCHAR(10) NOT NULL DEFAULT 'POST',
  `status_code` INT NOT NULL DEFAULT 0 COMMENT '上游返回的HTTP状态码',
  `response_time` INT NOT NULL DEFAULT 0 COMMENT '上游响应耗时ms',
  `call_date` DATE NOT NULL COMMENT '调用日期',
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  INDEX `idx_user_date` (`user_id`, `call_date`),
  INDEX `idx_api_date` (`api_path`, `call_date`),
  INDEX `idx_user_api` (`user_id`, `api_path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='API调用日志';
