-- Table structure for system_sync_log
-- ----------------------------
DROP TABLE IF EXISTS `system_sync_log`;
CREATE TABLE `system_sync_log` (
  `id` bigint NOT NULL COMMENT '日志主键',
  `bim_request_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '外部请求ID',
  `service_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '接口名称/服务名称',
  `request_method` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'POST' COMMENT '请求方法',
  `request_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '请求URL',
  `client_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '客户端IP地址',
  `user_agent` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '用户代理字符串',
  `request_time` datetime NOT NULL COMMENT '请求开始时间',
  `response_time` datetime NULL DEFAULT NULL COMMENT '请求结束时间',
  `duration` bigint NULL DEFAULT NULL COMMENT '请求处理耗时（毫秒）',
  `encrypted_request` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '原始加密请求体',
  `decrypted_request` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '解密后的请求体',
  `status` tinyint NOT NULL DEFAULT 0 COMMENT '响应状态 0-成功 1-解密失败 2-签名验证失败 3-认证失败 4-业务处理失败 5-系统异常',
  `error_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '错误码',
  `error_message` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '错误信息',
  `exception_stack` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '异常堆栈',
  `response_data` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '响应数据（加密前）',
  `encrypted_response` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '加密后的响应数据',
  `auth_user` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '认证用户',
  `decrypt_status` tinyint NOT NULL DEFAULT 0 COMMENT '解密状态 0-成功 1-失败',
  `signature_verify_status` tinyint NOT NULL DEFAULT 0 COMMENT '签名验证状态 0-成功 1-失败',
  `auth_status` tinyint NOT NULL DEFAULT 0 COMMENT '认证状态 0-成功 1-失败',
  `business_result` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '业务处理结果',
  `extra` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '额外信息',
  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_bim_request_id` (`bim_request_id`) USING BTREE COMMENT '外部请求ID索引',
  INDEX `idx_service_name` (`service_name`) USING BTREE COMMENT '服务名称索引',
  INDEX `idx_request_time` (`request_time`) USING BTREE COMMENT '请求时间索引',
  INDEX `idx_status` (`status`) USING BTREE COMMENT '状态索引',
  INDEX `idx_client_ip` (`client_ip`) USING BTREE COMMENT '客户端IP索引',
  INDEX `idx_auth_user` (`auth_user`) USING BTREE COMMENT '认证用户索引'
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '同步接口调用日志表';
