/*
 Cloud Database Transfer Tool

 Source Server Type    : MySQL

 Target Server Type    : DM8

 Date: 2025-08-28 14:12:23
*/


-- ----------------------------
-- Table structure for system_sync_log
-- ----------------------------
CREATE TABLE system_sync_log (
                                 id bigint NOT NULL PRIMARY KEY,
                                 bim_request_id varchar(64) DEFAULT '' NULL,
                                 service_name varchar(100)  NOT NULL,
                                 request_method varchar(16) DEFAULT 'POST' NOT NULL,
                                 request_url varchar(500)  NOT NULL,
                                 client_ip varchar(50)  NOT NULL,
                                 user_agent varchar(512) DEFAULT NULL NULL,
                                 request_time datetime  NOT NULL,
                                 response_time datetime DEFAULT NULL NULL,
                                 duration bigint DEFAULT NULL NULL,
                                 encrypted_request text  NOT NULL,
                                 decrypted_request text  NULL,
                                 status smallint DEFAULT 0 NOT NULL,
                                 error_code varchar(100) DEFAULT NULL NULL,
                                 error_message varchar(1000) DEFAULT NULL NULL,
                                 exception_stack text  NULL,
                                 response_data text  NULL,
                                 encrypted_response text  NULL,
                                 auth_user varchar(100) DEFAULT NULL NULL,
                                 decrypt_status smallint DEFAULT 0 NOT NULL,
                                 signature_verify_status smallint DEFAULT 0 NOT NULL,
                                 auth_status smallint DEFAULT 0 NOT NULL,
                                 business_result varchar(100) DEFAULT NULL NULL,
                                 extra text  NULL,
                                 creator varchar(64) DEFAULT '' NULL,
                                 create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
                                 updater varchar(64) DEFAULT '' NULL,
                                 update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
                                 deleted bit DEFAULT '0' NOT NULL
);

CREATE INDEX idx_system_sync_log_01 ON system_sync_log (bim_request_id);
CREATE INDEX idx_system_sync_log_02 ON system_sync_log (service_name);
CREATE INDEX idx_system_sync_log_03 ON system_sync_log (request_time);
CREATE INDEX idx_system_sync_log_04 ON system_sync_log (status);
CREATE INDEX idx_system_sync_log_05 ON system_sync_log (client_ip);
CREATE INDEX idx_system_sync_log_06 ON system_sync_log (auth_user);

COMMENT ON COLUMN system_sync_log.id IS '日志主键';
COMMENT ON COLUMN system_sync_log.bim_request_id IS '外部请求ID';
COMMENT ON COLUMN system_sync_log.service_name IS '接口名称/服务名称';
COMMENT ON COLUMN system_sync_log.request_method IS '请求方法';
COMMENT ON COLUMN system_sync_log.request_url IS '请求URL';
COMMENT ON COLUMN system_sync_log.client_ip IS '客户端IP地址';
COMMENT ON COLUMN system_sync_log.user_agent IS '用户代理字符串';
COMMENT ON COLUMN system_sync_log.request_time IS '请求开始时间';
COMMENT ON COLUMN system_sync_log.response_time IS '请求结束时间';
COMMENT ON COLUMN system_sync_log.duration IS '请求处理耗时（毫秒）';
COMMENT ON COLUMN system_sync_log.encrypted_request IS '原始加密请求体';
COMMENT ON COLUMN system_sync_log.decrypted_request IS '解密后的请求体';
COMMENT ON COLUMN system_sync_log.status IS '响应状态 0-成功 1-解密失败 2-签名验证失败 3-认证失败 4-业务处理失败 5-系统异常';
COMMENT ON COLUMN system_sync_log.error_code IS '错误码';
COMMENT ON COLUMN system_sync_log.error_message IS '错误信息';
COMMENT ON COLUMN system_sync_log.exception_stack IS '异常堆栈';
COMMENT ON COLUMN system_sync_log.response_data IS '响应数据（加密前）';
COMMENT ON COLUMN system_sync_log.encrypted_response IS '加密后的响应数据';
COMMENT ON COLUMN system_sync_log.auth_user IS '认证用户';
COMMENT ON COLUMN system_sync_log.decrypt_status IS '解密状态 0-成功 1-失败';
COMMENT ON COLUMN system_sync_log.signature_verify_status IS '签名验证状态 0-成功 1-失败';
COMMENT ON COLUMN system_sync_log.auth_status IS '认证状态 0-成功 1-失败';
COMMENT ON COLUMN system_sync_log.business_result IS '业务处理结果';
COMMENT ON COLUMN system_sync_log.extra IS '额外信息';
COMMENT ON COLUMN system_sync_log.creator IS '创建者';
COMMENT ON COLUMN system_sync_log.create_time IS '创建时间';
COMMENT ON COLUMN system_sync_log.updater IS '更新者';
COMMENT ON COLUMN system_sync_log.update_time IS '更新时间';
COMMENT ON COLUMN system_sync_log.deleted IS '是否删除';
COMMENT ON TABLE system_sync_log IS '同步接口调用日志表';
