feat: 新增平台
This commit is contained in:
35
database/api_key_tables.sql
Normal file
35
database/api_key_tables.sql
Normal file
@@ -0,0 +1,35 @@
|
||||
-- API Key 相关表结构
|
||||
-- 执行方式: mysql -u root -p video_parser < database/api_key_tables.sql
|
||||
|
||||
-- 用户 API Key 表
|
||||
CREATE TABLE IF NOT EXISTS `user_api_keys` (
|
||||
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INT NOT NULL,
|
||||
`name` VARCHAR(100) NOT NULL COMMENT 'Key名称',
|
||||
`api_key` VARCHAR(64) NOT NULL UNIQUE COMMENT 'API Key',
|
||||
`is_active` TINYINT(1) DEFAULT 1 COMMENT '是否启用',
|
||||
`daily_limit` INT DEFAULT 100 COMMENT '每日调用限制',
|
||||
`total_calls` INT DEFAULT 0 COMMENT '总调用次数',
|
||||
`last_used_at` DATETIME COMMENT '最后使用时间',
|
||||
`last_used_ip` VARCHAR(45) COMMENT '最后使用IP',
|
||||
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
|
||||
INDEX `idx_api_key` (`api_key`),
|
||||
INDEX `idx_user_id` (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='用户API Key表';
|
||||
|
||||
-- API Key 每日统计表
|
||||
CREATE TABLE IF NOT EXISTS `api_key_daily_stats` (
|
||||
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||
`api_key_id` INT NOT NULL,
|
||||
`date` DATE NOT NULL,
|
||||
`call_count` INT DEFAULT 0 COMMENT '调用次数',
|
||||
`success_count` INT DEFAULT 0 COMMENT '成功次数',
|
||||
`fail_count` INT DEFAULT 0 COMMENT '失败次数',
|
||||
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`api_key_id`) REFERENCES `user_api_keys`(`id`) ON DELETE CASCADE,
|
||||
UNIQUE KEY `uk_api_key_date` (`api_key_id`, `date`),
|
||||
INDEX `idx_date` (`date`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='API Key每日统计表';
|
||||
23
database/new_platforms.sql
Normal file
23
database/new_platforms.sql
Normal file
@@ -0,0 +1,23 @@
|
||||
-- 新平台解析接口初始化数据
|
||||
-- 执行方式: mysql -u root -p video_parser < database/new_platforms.sql
|
||||
|
||||
-- 快手解析接口
|
||||
INSERT INTO `parser_apis` (`name`, `platform`, `api_url`, `api_key`, `weight`, `is_enabled`, `health_status`) VALUES
|
||||
('BugPK快手API', 'kuaishou', 'https://api.bugpk.com', '', 1, 1, 1),
|
||||
('优创快手API', 'kuaishou', 'http://apis.uctb.cn', '', 1, 1, 1);
|
||||
|
||||
-- 皮皮虾解析接口
|
||||
INSERT INTO `parser_apis` (`name`, `platform`, `api_url`, `api_key`, `weight`, `is_enabled`, `health_status`) VALUES
|
||||
('BugPK皮皮虾API', 'pipixia', 'https://api.bugpk.com', '', 1, 1, 1),
|
||||
('优创皮皮虾API', 'pipixia', 'http://apis.uctb.cn', '', 1, 1, 1);
|
||||
|
||||
-- 微博解析接口
|
||||
INSERT INTO `parser_apis` (`name`, `platform`, `api_url`, `api_key`, `weight`, `is_enabled`, `health_status`) VALUES
|
||||
('优创微博API', 'weibo', 'http://apis.uctb.cn', '', 1, 1, 1),
|
||||
('妖狐微博API', 'weibo', 'https://api.yaohud.cn', 'SM227DLC0ZgJ6DXJhAx', 1, 1, 1);
|
||||
|
||||
-- 健康检查配置
|
||||
INSERT INTO `health_check_config` (`platform`, `test_url`, `check_interval`, `is_enabled`) VALUES
|
||||
('kuaishou', 'https://www.kuaishou.com/f/X-1ZPlLXEI6SP1mx', 300, 1),
|
||||
('pipixia', 'https://h5.pipix.com/s/kLUS2a4iJ_M/', 300, 1),
|
||||
('weibo', 'https://video.weibo.com/show?fid=1034:5233299304415254', 300, 1);
|
||||
37
database/redeem_codes.sql
Normal file
37
database/redeem_codes.sql
Normal file
@@ -0,0 +1,37 @@
|
||||
-- 兑换码功能数据库表
|
||||
-- 执行方式: mysql -u root -p video_parser < database/redeem_codes.sql
|
||||
|
||||
-- 兑换码表
|
||||
CREATE TABLE IF NOT EXISTS `redeem_codes` (
|
||||
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||
`code` VARCHAR(32) NOT NULL UNIQUE COMMENT '兑换码',
|
||||
`batch_id` VARCHAR(32) COMMENT '批次ID',
|
||||
`target_group_id` INT NOT NULL COMMENT '目标用户组ID',
|
||||
`duration_days` INT DEFAULT 30 COMMENT '有效期天数',
|
||||
`is_used` TINYINT(1) DEFAULT 0 COMMENT '是否已使用',
|
||||
`used_by` INT COMMENT '使用者用户ID',
|
||||
`used_at` DATETIME COMMENT '使用时间',
|
||||
`expires_at` DATETIME COMMENT '兑换码过期时间',
|
||||
`remark` VARCHAR(255) COMMENT '备注',
|
||||
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`target_group_id`) REFERENCES `user_groups`(`id`),
|
||||
FOREIGN KEY (`used_by`) REFERENCES `users`(`id`),
|
||||
INDEX `idx_code` (`code`),
|
||||
INDEX `idx_batch_id` (`batch_id`),
|
||||
INDEX `idx_is_used` (`is_used`),
|
||||
INDEX `idx_expires_at` (`expires_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='兑换码表';
|
||||
|
||||
-- 用户组到期时间表
|
||||
CREATE TABLE IF NOT EXISTS `user_group_expiry` (
|
||||
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||
`user_id` INT NOT NULL UNIQUE COMMENT '用户ID',
|
||||
`group_id` INT NOT NULL COMMENT '用户组ID',
|
||||
`expires_at` DATETIME NOT NULL COMMENT '到期时间',
|
||||
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`),
|
||||
FOREIGN KEY (`group_id`) REFERENCES `user_groups`(`id`),
|
||||
INDEX `idx_user_id` (`user_id`),
|
||||
INDEX `idx_expires_at` (`expires_at`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户组到期时间表';
|
||||
Reference in New Issue
Block a user