完善续期通知与前端界面
This commit is contained in:
1 parent
25419c027f
commit
45f895d0c4
64 files changed
+2948
-487
No files matched your search
@@ -4,41 +4,41 @@ ALTER TABLE cookies ADD COLUMN last_refresh_at BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE cookie_status ADD COLUMN disable_reason TEXT;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS cookie_refresh_schedules (
|
||||
cookie_id VARCHAR(191) PRIMARY KEY,
|
||||
cookie_id VARCHAR(255) PRIMARY KEY,
|
||||
expire_at BIGINT NOT NULL DEFAULT 0,
|
||||
disabled TINYINT(1) NOT NULL DEFAULT 0,
|
||||
consecutive_failures INT NOT NULL DEFAULT 0,
|
||||
last_error TEXT NOT NULL,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_cookie_refresh_schedules_cookie FOREIGN KEY (cookie_id) REFERENCES cookies(id) ON DELETE CASCADE
|
||||
);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS scheduled_cookies_refresh_log (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
cookie_id VARCHAR(191) NOT NULL,
|
||||
cookie_id VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
updated_cookie_names TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS scheduled_login_renew_log (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
cookie_id VARCHAR(191) NOT NULL,
|
||||
cookie_id VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
updated_cookie_names TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS scheduled_api_cookie_renew_log (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
cookie_id VARCHAR(191) NOT NULL,
|
||||
cookie_id VARCHAR(255) NOT NULL,
|
||||
status VARCHAR(32) NOT NULL,
|
||||
message TEXT NOT NULL,
|
||||
updated_cookie_names TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS scheduled_api_cookie_renew_log;
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
-- +goose Up
|
||||
DROP PROCEDURE IF EXISTS add_xianyu_column_if_missing;
|
||||
-- +goose StatementBegin
|
||||
CREATE PROCEDURE add_xianyu_column_if_missing(
|
||||
IN p_table_name VARCHAR(64),
|
||||
IN p_column_name VARCHAR(64),
|
||||
IN p_column_definition TEXT
|
||||
)
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = p_table_name
|
||||
AND COLUMN_NAME = p_column_name
|
||||
) THEN
|
||||
SET @ddl = CONCAT('ALTER TABLE `', p_table_name, '` ADD COLUMN ', p_column_definition);
|
||||
PREPARE stmt FROM @ddl;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
END IF;
|
||||
END;
|
||||
-- +goose StatementEnd
|
||||
|
||||
CALL add_xianyu_column_if_missing('notification_channels', 'event_types', CONCAT('`event_types` VARCHAR(512) NOT NULL DEFAULT ', QUOTE('')));
|
||||
CALL add_xianyu_column_if_missing('message_notifications', 'event_types', CONCAT('`event_types` VARCHAR(512) NOT NULL DEFAULT ', QUOTE('')));
|
||||
|
||||
CALL add_xianyu_column_if_missing('scheduled_cookies_refresh_log', 'step_details', '`step_details` TEXT');
|
||||
CALL add_xianyu_column_if_missing('scheduled_cookies_refresh_log', 'renew_method', CONCAT('`renew_method` VARCHAR(64) NOT NULL DEFAULT ', QUOTE('')));
|
||||
CALL add_xianyu_column_if_missing('scheduled_cookies_refresh_log', 'duration_ms', '`duration_ms` BIGINT NOT NULL DEFAULT 0');
|
||||
CALL add_xianyu_column_if_missing('scheduled_cookies_refresh_log', 'request_count', '`request_count` INT NOT NULL DEFAULT 0');
|
||||
CALL add_xianyu_column_if_missing('scheduled_cookies_refresh_log', 'response_content', '`response_content` MEDIUMTEXT');
|
||||
|
||||
CALL add_xianyu_column_if_missing('scheduled_login_renew_log', 'step_details', '`step_details` TEXT');
|
||||
CALL add_xianyu_column_if_missing('scheduled_login_renew_log', 'renew_method', CONCAT('`renew_method` VARCHAR(64) NOT NULL DEFAULT ', QUOTE('')));
|
||||
CALL add_xianyu_column_if_missing('scheduled_login_renew_log', 'duration_ms', '`duration_ms` BIGINT NOT NULL DEFAULT 0');
|
||||
CALL add_xianyu_column_if_missing('scheduled_login_renew_log', 'request_count', '`request_count` INT NOT NULL DEFAULT 0');
|
||||
CALL add_xianyu_column_if_missing('scheduled_login_renew_log', 'response_content', '`response_content` MEDIUMTEXT');
|
||||
CALL add_xianyu_column_if_missing('scheduled_login_renew_log', 'updated_cookie_count', '`updated_cookie_count` INT NOT NULL DEFAULT 0');
|
||||
|
||||
CALL add_xianyu_column_if_missing('scheduled_api_cookie_renew_log', 'step_details', '`step_details` TEXT');
|
||||
CALL add_xianyu_column_if_missing('scheduled_api_cookie_renew_log', 'renew_method', CONCAT('`renew_method` VARCHAR(64) NOT NULL DEFAULT ', QUOTE('')));
|
||||
CALL add_xianyu_column_if_missing('scheduled_api_cookie_renew_log', 'duration_ms', '`duration_ms` BIGINT NOT NULL DEFAULT 0');
|
||||
CALL add_xianyu_column_if_missing('scheduled_api_cookie_renew_log', 'request_count', '`request_count` INT NOT NULL DEFAULT 0');
|
||||
|
||||
DROP PROCEDURE IF EXISTS add_xianyu_column_if_missing;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS risk_control_logs (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT,
|
||||
cookie_id VARCHAR(255) NOT NULL,
|
||||
event_type VARCHAR(64) NOT NULL DEFAULT 'slider_captcha',
|
||||
event_description TEXT,
|
||||
processing_result TEXT,
|
||||
processing_status VARCHAR(32) NOT NULL DEFAULT 'processing',
|
||||
captcha_engine VARCHAR(32) NOT NULL DEFAULT '',
|
||||
error_message TEXT,
|
||||
duration_ms BIGINT NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
CONSTRAINT fk_risk_control_logs_cookie FOREIGN KEY (cookie_id) REFERENCES cookies(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
INSERT IGNORE INTO system_settings (`key`, value, description) VALUES
|
||||
('log_level', 'info', '日志输出等级:debug/info/warn/error'),
|
||||
('log_format', 'text', '日志输出格式:text/json'),
|
||||
('renewal_log_retention_days', '10', '续期日志保留天数');
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS risk_control_logs;
|
||||
DELETE FROM system_settings WHERE `key` IN ('log_level', 'log_format', 'renewal_log_retention_days');
|
||||
|
||||
DROP PROCEDURE IF EXISTS drop_xianyu_column_if_exists;
|
||||
-- +goose StatementBegin
|
||||
CREATE PROCEDURE drop_xianyu_column_if_exists(
|
||||
IN p_table_name VARCHAR(64),
|
||||
IN p_column_name VARCHAR(64)
|
||||
)
|
||||
BEGIN
|
||||
IF EXISTS (
|
||||
SELECT 1
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = p_table_name
|
||||
AND COLUMN_NAME = p_column_name
|
||||
) THEN
|
||||
SET @ddl = CONCAT('ALTER TABLE `', p_table_name, '` DROP COLUMN `', p_column_name, '`');
|
||||
PREPARE stmt FROM @ddl;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
END IF;
|
||||
END;
|
||||
-- +goose StatementEnd
|
||||
|
||||
CALL drop_xianyu_column_if_exists('notification_channels', 'event_types');
|
||||
CALL drop_xianyu_column_if_exists('message_notifications', 'event_types');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_cookies_refresh_log', 'step_details');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_cookies_refresh_log', 'renew_method');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_cookies_refresh_log', 'duration_ms');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_cookies_refresh_log', 'request_count');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_cookies_refresh_log', 'response_content');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_login_renew_log', 'step_details');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_login_renew_log', 'renew_method');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_login_renew_log', 'duration_ms');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_login_renew_log', 'request_count');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_login_renew_log', 'response_content');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_login_renew_log', 'updated_cookie_count');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_api_cookie_renew_log', 'step_details');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_api_cookie_renew_log', 'renew_method');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_api_cookie_renew_log', 'duration_ms');
|
||||
CALL drop_xianyu_column_if_exists('scheduled_api_cookie_renew_log', 'request_count');
|
||||
|
||||
DROP PROCEDURE IF EXISTS drop_xianyu_column_if_exists;
|
||||
@@ -0,0 +1,63 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE notification_channels ADD COLUMN IF NOT EXISTS event_types TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE message_notifications ADD COLUMN IF NOT EXISTS event_types TEXT NOT NULL DEFAULT '';
|
||||
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN IF NOT EXISTS step_details TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN IF NOT EXISTS renew_method TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN IF NOT EXISTS duration_ms BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN IF NOT EXISTS request_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN IF NOT EXISTS response_content TEXT NOT NULL DEFAULT '';
|
||||
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN IF NOT EXISTS step_details TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN IF NOT EXISTS renew_method TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN IF NOT EXISTS duration_ms BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN IF NOT EXISTS request_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN IF NOT EXISTS response_content TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN IF NOT EXISTS updated_cookie_count INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN IF NOT EXISTS step_details TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN IF NOT EXISTS renew_method TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN IF NOT EXISTS duration_ms BIGINT NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN IF NOT EXISTS request_count INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS risk_control_logs (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
cookie_id TEXT NOT NULL REFERENCES cookies(id) ON DELETE CASCADE,
|
||||
event_type TEXT NOT NULL DEFAULT 'slider_captcha',
|
||||
event_description TEXT NOT NULL DEFAULT '',
|
||||
processing_result TEXT NOT NULL DEFAULT '',
|
||||
processing_status TEXT NOT NULL DEFAULT 'processing',
|
||||
captcha_engine TEXT NOT NULL DEFAULT '',
|
||||
error_message TEXT NOT NULL DEFAULT '',
|
||||
duration_ms BIGINT NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
INSERT INTO system_settings (key, value, description) VALUES
|
||||
('log_level', 'info', '日志输出等级:debug/info/warn/error'),
|
||||
('log_format', 'text', '日志输出格式:text/json'),
|
||||
('renewal_log_retention_days', '10', '续期日志保留天数')
|
||||
ON CONFLICT (key) DO NOTHING;
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS risk_control_logs;
|
||||
DELETE FROM system_settings WHERE key IN ('log_level', 'log_format', 'renewal_log_retention_days');
|
||||
|
||||
ALTER TABLE notification_channels DROP COLUMN IF EXISTS event_types;
|
||||
ALTER TABLE message_notifications DROP COLUMN IF EXISTS event_types;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN IF EXISTS step_details;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN IF EXISTS renew_method;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN IF EXISTS duration_ms;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN IF EXISTS request_count;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN IF EXISTS response_content;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN IF EXISTS step_details;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN IF EXISTS renew_method;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN IF EXISTS duration_ms;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN IF EXISTS request_count;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN IF EXISTS response_content;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN IF EXISTS updated_cookie_count;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN IF EXISTS step_details;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN IF EXISTS renew_method;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN IF EXISTS duration_ms;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN IF EXISTS request_count;
|
||||
@@ -0,0 +1,63 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE notification_channels ADD COLUMN event_types TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE message_notifications ADD COLUMN event_types TEXT NOT NULL DEFAULT '';
|
||||
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN step_details TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN renew_method TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN duration_ms INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN request_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_cookies_refresh_log ADD COLUMN response_content TEXT NOT NULL DEFAULT '';
|
||||
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN step_details TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN renew_method TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN duration_ms INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN request_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN response_content TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_login_renew_log ADD COLUMN updated_cookie_count INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN step_details TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN renew_method TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN duration_ms INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log ADD COLUMN request_count INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS risk_control_logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
cookie_id TEXT NOT NULL,
|
||||
event_type TEXT NOT NULL DEFAULT 'slider_captcha',
|
||||
event_description TEXT NOT NULL DEFAULT '',
|
||||
processing_result TEXT NOT NULL DEFAULT '',
|
||||
processing_status TEXT NOT NULL DEFAULT 'processing',
|
||||
captcha_engine TEXT NOT NULL DEFAULT '',
|
||||
error_message TEXT NOT NULL DEFAULT '',
|
||||
duration_ms INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (cookie_id) REFERENCES cookies(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO system_settings (key, value, description) VALUES
|
||||
('log_level', 'info', '日志输出等级:debug/info/warn/error'),
|
||||
('log_format', 'text', '日志输出格式:text/json'),
|
||||
('renewal_log_retention_days', '10', '续期日志保留天数');
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE IF EXISTS risk_control_logs;
|
||||
DELETE FROM system_settings WHERE key IN ('log_level', 'log_format', 'renewal_log_retention_days');
|
||||
|
||||
ALTER TABLE notification_channels DROP COLUMN event_types;
|
||||
ALTER TABLE message_notifications DROP COLUMN event_types;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN step_details;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN renew_method;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN duration_ms;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN request_count;
|
||||
ALTER TABLE scheduled_cookies_refresh_log DROP COLUMN response_content;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN step_details;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN renew_method;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN duration_ms;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN request_count;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN response_content;
|
||||
ALTER TABLE scheduled_login_renew_log DROP COLUMN updated_cookie_count;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN step_details;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN renew_method;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN duration_ms;
|
||||
ALTER TABLE scheduled_api_cookie_renew_log DROP COLUMN request_count;
|
||||
Reference in new issue
Block a user