create database if not exists ai_oqas;
use ai_oqas;
drop table if exists operate_log;
create table operate_log
(
    id           varchar(32) not null comment '自增主键',
    operation    varchar(128) comment '操作详情',
    clazz        varchar(128) comment '方法所属类名',
    method       varchar(128) comment '调用方法',
    params       varchar(1024) comment '方法参数',
    start        varchar(32) comment '开始执行时间',
    end          varchar(32) comment '结束执行时间',
    consume      bigint comment '耗时',
    remark       varchar(256) comment '备注信息',
    operator     varchar(32) comment '操作人',
    operator_id  varchar(32) comment '操作人id',
    operate_time varchar(32) comment '操作日期',
    operate_ip   varchar(32) comment '操作ip',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot;
create table robot
(
    id          varchar(32) not null comment '机器人id',
    group_id    varchar(32) comment '机器人所属组id',
    field_id    varchar(32) comment '机器人所属领域id',
    name        varchar(32) comment '机器人名称',
    faq_file    varchar(256) comment '机器人训练用的问答对数据集',
    tree_file   varchar(256) comment '机器人训练用的树结构数据集',
    graph_file  varchar(256) comment '机器人训练用的图结构数据集',
    config_id   varchar(32) comment '机器人配置id',
    status      varchar(32) comment '机器人状态',
    version     int comment '机器人版本号',
    remark      varchar(256) comment '备注信息',
    deleted     boolean comment '机器人是否被删除',
    can_deleted boolean comment '机器人是否可被删除',
    create_time varchar(32) comment '机器人创建时间',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot_user;
create table robot_user
(
    id       varchar(32) not null comment '主键',
    robot_id varchar(32) not null comment '机器人id',
    user_id  varchar(32) not null comment '用户id',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot_field;
create table robot_field
(
    id          varchar(32) not null comment '主键',
    parent_id   varchar(32) comment '父节点id',
    name        varchar(32) comment '领域名称',
    remark      varchar(256) comment '备注',
    deleted     boolean comment '是否被弃用',
    create_time varchar(32) comment '创建日期',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;
INSERT INTO ai_oqas.robot_field (id, parent_id, name, remark, deleted, create_time)
VALUES ('1189002586471149569', null, '教育', null, 0, '2019-10-29 10:14:41');
INSERT INTO ai_oqas.robot_field (id, parent_id, name, remark, deleted, create_time)
VALUES ('1189002587830104066', null, '物流', null, 0, '2019-10-29 10:14:42');
INSERT INTO ai_oqas.robot_field (id, parent_id, name, remark, deleted, create_time)
VALUES ('1189002587855269889', null, '医疗', null, 0, '2019-10-29 10:14:42');
INSERT INTO ai_oqas.robot_field (id, parent_id, name, remark, deleted, create_time)
VALUES ('1189002587872047106', null, '企业', null, 0, '2019-10-29 10:14:42');
INSERT INTO ai_oqas.robot_field (id, parent_id, name, remark, deleted, create_time)
VALUES ('1189002587893018626', null, '闲聊', null, 0, '2019-10-29 10:14:42');
INSERT INTO ai_oqas.robot_field (id, parent_id, name, remark, deleted, create_time)
VALUES ('1189002587909795841', null, '其他', null, 0, '2019-10-29 10:14:42');

drop table if exists config;
create table config
(
    id          varchar(32) not null comment '主键',
    name        varchar(32) comment '领域名称',
    value       varchar(128) comment '值',
    remark      varchar(256) comment '备注',
    deleted     boolean comment '是否被弃用',
    create_time varchar(32) comment '创建日期',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;
INSERT INTO ai_oqas.config (id, name, value, remark, deleted, create_time)
VALUES ('1190184043818426369', 'DEFAULT_CONFIG', '{"threshold":"0.5"}', null, 0, '2019-11-01 16:29:22');

drop table if exists config_user;
create table config_user
(
    id        varchar(32) not null comment '主键',
    config_id varchar(32) not null comment '配置id',
    user_id   varchar(32) not null comment '用户id',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot_operate;
create table robot_operate
(
    id           varchar(32) not null comment '主键',
    robot_id     varchar(32) not null comment '机器人id',
    op_type      varchar(32) comment '操作类型',
    op_code      varchar(32) comment '操作结果码',
    op_result    varchar(128) comment '操作结果',
    robot_status varchar(32) comment '机器人状态',
    create_time  varchar(32) comment '创建时间',
    update_time  varchar(32) comment '更新时间',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot_file;
create table robot_file
(
    id           varchar(32) not null comment '主键',
    robot_id     varchar(32) not null comment '机器人id',
    faq_file     varchar(128) comment 'faq文件',
    tree_file    varchar(128) comment 'tree文件',
    graph_file   varchar(128) comment 'graph文件',
    remark       varchar(256) comment '备注',
    create_time  varchar(32) comment '创建日期',
    operator     varchar(32)  DEFAULT NULL COMMENT '操作人',
    operator_id  varchar(256) DEFAULT NULL COMMENT '操作人id',
    operate_ip   varchar(256) DEFAULT NULL COMMENT '操作人ip',
    operate_time varchar(32)  DEFAULT NULL COMMENT '操作时间',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot_release;
create table robot_release
(
    robot_id    varchar(32) not null comment '主键',
    access_type varchar(32) comment '接入类型',
    platform    varchar(32) comment '平台名称',
    entry       varchar(128) comment '平台入口',
    url         varchar(128) comment '接口地址',
    wx_token    varchar(128) comment '微信公众号令牌',
    remark      varchar(256) comment '备注',
    create_time varchar(32) comment '创建日期',
    primary key (robot_id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists base_robot;
create table base_robot
(
    id             varchar(32)  not null comment '主键',
    field_id       varchar(32) comment '领域id',
    field_name     varchar(32) comment '领域名称',
    amount         bigint comment '数据集数量',
    purchase_price varchar(32) comment '价格',
    name           varchar(32)  not null comment '名称',
    exchange       varchar(128) not null comment '交换机',
    routing_key    varchar(128) not null comment '路由键',
    description    varchar(256) comment '描述',
    host           varchar(32) comment '主机',
    port           varchar(32) comment '端口号',
    username       varchar(32) comment '用户名',
    password       varchar(32) comment '密码',
    remark         varchar(256) comment '备注',
    create_time    varchar(32) comment '创建日期',
    update_time    varchar(32) comment '更新日期',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

drop table if exists robot_dataset;
create table robot_dataset
(
    id            varchar(32) not null comment '主键',
    robot_id      varchar(32) not null comment '机器人id',
    base_robot_id varchar(32) not null comment '数据集id',
    primary key (id)
)
    engine = InnoDB
    default charset = utf8;

