SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

--D--ROP TABLE IF EXISTS `sys_http_audit_log`;
CREATE TABLE `sys_http_audit_log`  (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`service_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '应用 spring.application.name',
`scope_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'EXTERNAL 外部 / INTERNAL 内部',
`uri` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '请求路径',
`io_direction` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'IN' COMMENT 'IN入站 OUT出站',
`method` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'HTTP 方法',
`function_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '功能描述',
`query_string` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'QueryString',
`request_body` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '请求体（全量）',
`response_body` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '响应体（查询类或超长会截断）',
`response_truncated` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1 响应已截断',
`http_status` int(11) NULL DEFAULT NULL COMMENT 'HTTP 状态码',
`ok_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '1 正常 0 异常',
`spend_ms` int(11) NULL DEFAULT NULL COMMENT '耗时毫秒',
`client_ip` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '客户端 IP',
`error_message` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '异常摘要',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`deleted` tinyint(4) NOT NULL DEFAULT 0 COMMENT '逻辑删除',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_create_time`(`create_time`) USING BTREE,
INDEX `idx_uri`(`uri`(191)) USING BTREE,
INDEX `idx_ok_client`(`ok_flag`, `client_ip`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3808156 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'HTTP接口审计' ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;
