DROP TABLE IF EXISTS "blade_log_error";
CREATE TABLE "blade_log_error"
(
    "id"             BIGINT NOT NULL,
    "tenant_id"      VARCHAR(12)  DEFAULT '000000',
    "service_id"     VARCHAR(32),
    "server_host"    VARCHAR(255),
    "server_ip"      VARCHAR(255),
    "env"            VARCHAR(255),
    "method"         VARCHAR(10),
    "request_uri"    VARCHAR(255),
    "user_agent"     VARCHAR(1000),
    "stack_trace"    TEXT,
    "exception_name" VARCHAR(255),
    "message"        TEXT,
    "line_number"    INT,
    "remote_ip"      VARCHAR(255),
    "method_class"   VARCHAR(255),
    "file_name"      VARCHAR(1000),
    "method_name"    VARCHAR(255),
    "params"         TEXT,
    "create_by"      VARCHAR(64),
    "create_time"    TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP(),
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_log_error" IS '错误日志表';
COMMENT
ON COLUMN "blade_log_error"."create_by" IS '创建者';
COMMENT
ON COLUMN "blade_log_error"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_log_error"."env" IS '系统环境';
COMMENT
ON COLUMN "blade_log_error"."exception_name" IS '异常名';
COMMENT
ON COLUMN "blade_log_error"."file_name" IS '文件名';
COMMENT
ON COLUMN "blade_log_error"."id" IS '编号';
COMMENT
ON COLUMN "blade_log_error"."line_number" IS '错误行数';
COMMENT
ON COLUMN "blade_log_error"."message" IS '异常信息';
COMMENT
ON COLUMN "blade_log_error"."method" IS '操作方式';
COMMENT
ON COLUMN "blade_log_error"."method_class" IS '方法类';
COMMENT
ON COLUMN "blade_log_error"."method_name" IS '方法名';
COMMENT
ON COLUMN "blade_log_error"."params" IS '操作提交的数据';
COMMENT
ON COLUMN "blade_log_error"."remote_ip" IS '操作IP地址';
COMMENT
ON COLUMN "blade_log_error"."request_uri" IS '请求URI';
COMMENT
ON COLUMN "blade_log_error"."server_host" IS '服务器名';
COMMENT
ON COLUMN "blade_log_error"."server_ip" IS '服务器IP地址';
COMMENT
ON COLUMN "blade_log_error"."service_id" IS '服务ID';
COMMENT
ON COLUMN "blade_log_error"."stack_trace" IS '堆栈';
COMMENT
ON COLUMN "blade_log_error"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_log_error"."user_agent" IS '用户代理';


DROP TABLE IF EXISTS "blade_client";
CREATE TABLE "blade_client"
(
    "id"                      BIGINT       NOT NULL,
    "client_id"               VARCHAR(48)  NOT NULL,
    "client_secret"           VARCHAR(256) NOT NULL,
    "resource_ids"            VARCHAR(256),
    "scope"                   VARCHAR(256) NOT NULL,
    "authorized_grant_types"  VARCHAR(256) NOT NULL,
    "web_server_redirect_uri" VARCHAR(256),
    "authorities"             VARCHAR(256),
    "access_token_validity"   INT          NOT NULL,
    "refresh_token_validity"  INT          NOT NULL,
    "additional_information"  VARCHAR(4096),
    "autoapprove"             VARCHAR(256),
    "create_user"             BIGINT,
    "create_dept"             BIGINT,
    "create_time"             TIMESTAMP(0),
    "update_user"             BIGINT,
    "update_time"             TIMESTAMP(0),
    "status"                  INT          NOT NULL,
    "is_deleted"              INT,
    NOT                       CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_client" IS '客户端表';
COMMENT
ON COLUMN "blade_client"."access_token_validity" IS '令牌过期秒数';
COMMENT
ON COLUMN "blade_client"."additional_information" IS '附加说明';
COMMENT
ON COLUMN "blade_client"."authorities" IS '权限';
COMMENT
ON COLUMN "blade_client"."authorized_grant_types" IS '授权类型';
COMMENT
ON COLUMN "blade_client"."autoapprove" IS '自动授权';
COMMENT
ON COLUMN "blade_client"."client_id" IS '客户端id';
COMMENT
ON COLUMN "blade_client"."client_secret" IS '客户端密钥';
COMMENT
ON COLUMN "blade_client"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_client"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_client"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_client"."id" IS '主键';
COMMENT
ON COLUMN "blade_client"."refresh_token_validity" IS '刷新令牌过期秒数';
COMMENT
ON COLUMN "blade_client"."resource_ids" IS '资源集合';
COMMENT
ON COLUMN "blade_client"."scope" IS '授权范围';
COMMENT
ON COLUMN "blade_client"."status" IS '状态';
COMMENT
ON COLUMN "blade_client"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_client"."update_user" IS '修改人';
COMMENT
ON COLUMN "blade_client"."web_server_redirect_uri" IS '回调地址';


DROP TABLE IF EXISTS "blade_i18n_data";
CREATE TABLE "blade_i18n_data"
(
    "id"           BIGINT NOT NULL,
    "language_tag" VARCHAR(10),
    "code"         VARCHAR(255),
    "message"      VARCHAR(255),
    "remark"       VARCHAR(255),
    "create_user"  BIGINT,
    "update_user"  BIGINT,
    "create_time"  TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP(),
    "update_time"  TIMESTAMP(0),
    NOT            CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_i18n_data"."code" IS '唯一标识 = 业务:关键词';
COMMENT
ON COLUMN "blade_i18n_data"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_i18n_data"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_i18n_data"."id" IS '主键';
COMMENT
ON COLUMN "blade_i18n_data"."language_tag" IS '语言标签';
COMMENT
ON COLUMN "blade_i18n_data"."message" IS '文本值，可以使用 { } 加角标，作为占位符';
COMMENT
ON COLUMN "blade_i18n_data"."remark" IS '备注';
COMMENT
ON COLUMN "blade_i18n_data"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_i18n_data"."update_user" IS '修改人';


DROP TABLE IF EXISTS "blade_tenant";
CREATE TABLE "blade_tenant"
(
    "id"             BIGINT      NOT NULL,
    "tenant_id"      VARCHAR(12) DEFAULT '000000',
    "tenant_name"    VARCHAR(50) NOT NULL,
    "domain_name"    VARCHAR(255),
    "background_url" VARCHAR(1000),
    "linkman"        VARCHAR(20),
    "contact_number" VARCHAR(20),
    "address"        VARCHAR(255),
    "account_number" INT         DEFAULT (-1),
    "expire_time"    TIMESTAMP(0),
    "datasource_id"  BIGINT,
    "license_key"    VARCHAR(1000),
    "create_user"    BIGINT,
    "create_dept"    BIGINT,
    "create_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "status"         INT,
    "is_deleted"     INT,
    "blade_license"  VARCHAR(3000),
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_tenant" IS '租户表';
COMMENT
ON COLUMN "blade_tenant"."account_number" IS '账号额度';
COMMENT
ON COLUMN "blade_tenant"."address" IS '联系地址';
COMMENT
ON COLUMN "blade_tenant"."background_url" IS '系统背景';
COMMENT
ON COLUMN "blade_tenant"."contact_number" IS '联系电话';
COMMENT
ON COLUMN "blade_tenant"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_tenant"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_tenant"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_tenant"."datasource_id" IS '数据源ID';
COMMENT
ON COLUMN "blade_tenant"."domain_name" IS '域名地址';
COMMENT
ON COLUMN "blade_tenant"."expire_time" IS '过期时间';
COMMENT
ON COLUMN "blade_tenant"."id" IS '主键';
COMMENT
ON COLUMN "blade_tenant"."license_key" IS '授权码';
COMMENT
ON COLUMN "blade_tenant"."linkman" IS '联系人';
COMMENT
ON COLUMN "blade_tenant"."status" IS '状态';
COMMENT
ON COLUMN "blade_tenant"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_tenant"."tenant_name" IS '租户名称';
COMMENT
ON COLUMN "blade_tenant"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_tenant"."update_user" IS '修改人';
COMMENT
ON COLUMN "blade_tenant"."blade_license" IS '单体授权码';


DROP TABLE IF EXISTS "blade_menu";
CREATE TABLE "blade_menu"
(
    "id"                  BIGINT NOT NULL,
    "parent_id"           BIGINT       DEFAULT 0,
    "code"                VARCHAR(255),
    "name"                VARCHAR(255),
    "alias"               VARCHAR(255),
    "path"                VARCHAR(255),
    "source"              VARCHAR(255),
    "sort"                INT,
    "category"            INT,
    "action"              INT          DEFAULT 0,
    "is_open"             INT          DEFAULT 1,
    "remark"              VARCHAR(255),
    "belong_application"  VARCHAR(255) DEFAULT 'CPS',
    "keep_alive"          int          DEFAULT 1,
    "is_deleted"          INT,
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_menu" IS '菜单表';
COMMENT
ON COLUMN "blade_menu"."action" IS '操作按钮类型';
COMMENT
ON COLUMN "blade_menu"."alias" IS '菜单别名';
COMMENT
ON COLUMN "blade_menu"."category" IS '菜单类型';
COMMENT
ON COLUMN "blade_menu"."code" IS '菜单编号';
COMMENT
ON COLUMN "blade_menu"."id" IS '主键';
COMMENT
ON COLUMN "blade_menu"."is_open" IS '是否打开新页面';
COMMENT
ON COLUMN "blade_menu"."name" IS '菜单名称';
COMMENT
ON COLUMN "blade_menu"."parent_id" IS '父级菜单';
COMMENT
ON COLUMN "blade_menu"."path" IS '请求地址';
COMMENT
ON COLUMN "blade_menu"."remark" IS '备注';
COMMENT
ON COLUMN "blade_menu"."belong_application" IS '所属应用';
COMMENT
ON COLUMN "blade_menu"."keep_alive" IS '路由缓存 1启用缓冲 0 停用缓冲';
COMMENT
ON COLUMN "blade_menu"."sort" IS '排序';
COMMENT
ON COLUMN "blade_menu"."source" IS '菜单资源';



DROP TABLE IF EXISTS "blade_dept";
CREATE TABLE "blade_dept"
(
    "id"            BIGINT NOT NULL,
    "tenant_id"     VARCHAR(12) DEFAULT '000000',
    "parent_id"     BIGINT      DEFAULT 0,
    "ancestors"     VARCHAR(2000),
    "dept_category" INT,
    "dept_name"     VARCHAR(45),
    "full_name"     VARCHAR(45),
    "sort"          INT,
    "remark"        VARCHAR(255),
    "is_deleted"    INT,
    NOT             CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_dept" IS '机构表';
COMMENT
ON COLUMN "blade_dept"."ancestors" IS '祖级列表';
COMMENT
ON COLUMN "blade_dept"."dept_category" IS '部门类型';
COMMENT
ON COLUMN "blade_dept"."dept_name" IS '部门名';
COMMENT
ON COLUMN "blade_dept"."full_name" IS '部门全称';
COMMENT
ON COLUMN "blade_dept"."id" IS '主键';
COMMENT
ON COLUMN "blade_dept"."parent_id" IS '父主键';
COMMENT
ON COLUMN "blade_dept"."remark" IS '备注';
COMMENT
ON COLUMN "blade_dept"."sort" IS '排序';
COMMENT
ON COLUMN "blade_dept"."tenant_id" IS '租户ID';



DROP TABLE IF EXISTS "blade_user";
CREATE TABLE "blade_user"
(
    "id"                 BIGINT NOT NULL,
    "tenant_id"          VARCHAR(12) DEFAULT '000000',
    "code"               VARCHAR(45),
    "user_type"          INT,
    "account"            VARCHAR(45),
    "password"           VARCHAR(45),
    "name"               VARCHAR(45),
    "real_name"          VARCHAR(45),
    "avatar"             VARCHAR(500),
    "email"              VARCHAR(45),
    "phone"              VARCHAR(45),
    "birthday"           TIMESTAMP(0),
    "sex"                INT,
    "role_id"            VARCHAR(1000),
    "dept_id"            VARCHAR(1000),
    "post_id"            VARCHAR(1000),
    "create_user"        BIGINT,
    "create_dept"        BIGINT,
    "create_time"        TIMESTAMP(0),
    "update_user"        BIGINT,
    "update_time"        TIMESTAMP(0),
    "status"             INT,
    "is_deleted"         INT         DEFAULT 0,
    "pwd_security_level" TINYINT,
    "pwd_update_date"    TIMESTAMP(0),
    "pwd_update_record"  TEXT,
    NOT                  CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_user" IS '用户表';
COMMENT
ON COLUMN "blade_user"."account" IS '账号';
COMMENT
ON COLUMN "blade_user"."avatar" IS '头像';
COMMENT
ON COLUMN "blade_user"."birthday" IS '生日';
COMMENT
ON COLUMN "blade_user"."code" IS '用户编号';
COMMENT
ON COLUMN "blade_user"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_user"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_user"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_user"."dept_id" IS '部门id';
COMMENT
ON COLUMN "blade_user"."email" IS '邮箱';
COMMENT
ON COLUMN "blade_user"."id" IS '主键';
COMMENT
ON COLUMN "blade_user"."is_deleted" IS '是否已删除';
COMMENT
ON COLUMN "blade_user"."name" IS '昵称';
COMMENT
ON COLUMN "blade_user"."password" IS '密码';
COMMENT
ON COLUMN "blade_user"."phone" IS '手机';
COMMENT
ON COLUMN "blade_user"."post_id" IS '岗位id';
COMMENT
ON COLUMN "blade_user"."pwd_security_level" IS '密码安全级别（0初始  1弱 2安全 3很安全）记录当前密码存储时候等级，如果后面更改密码等级时候是否需要强制修改';
COMMENT
ON COLUMN "blade_user"."pwd_update_date" IS '密码最后更新时间';
COMMENT
ON COLUMN "blade_user"."pwd_update_record" IS '密码修改记录，每次修改时候记录原密码，以逗号分隔开，防止以后要做不允许输入以往密码';
COMMENT
ON COLUMN "blade_user"."real_name" IS '真名';
COMMENT
ON COLUMN "blade_user"."role_id" IS '角色id';
COMMENT
ON COLUMN "blade_user"."sex" IS '性别';
COMMENT
ON COLUMN "blade_user"."status" IS '状态';
COMMENT
ON COLUMN "blade_user"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_user"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_user"."update_user" IS '修改人';
COMMENT
ON COLUMN "blade_user"."user_type" IS '用户平台';


DROP TABLE IF EXISTS "blade_oss";
CREATE TABLE "blade_oss"
(
    "id"          BIGINT NOT NULL,
    "tenant_id"   VARCHAR(12) DEFAULT '000000',
    "category"    INT,
    "oss_code"    VARCHAR(32),
    "endpoint"    VARCHAR(255),
    "access_key"  VARCHAR(255),
    "secret_key"  VARCHAR(255),
    "bucket_name" VARCHAR(255),
    "app_id"      VARCHAR(255),
    "region"      VARCHAR(255),
    "remark"      VARCHAR(255),
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "status"      INT,
    "is_deleted"  INT,
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_oss" IS '对象存储表';
COMMENT
ON COLUMN "blade_oss"."access_key" IS 'accessKey';
COMMENT
ON COLUMN "blade_oss"."app_id" IS '应用ID';
COMMENT
ON COLUMN "blade_oss"."bucket_name" IS '空间名';
COMMENT
ON COLUMN "blade_oss"."category" IS '分类';
COMMENT
ON COLUMN "blade_oss"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_oss"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_oss"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_oss"."endpoint" IS '资源地址';
COMMENT
ON COLUMN "blade_oss"."id" IS '主键';
COMMENT
ON COLUMN "blade_oss"."oss_code" IS '资源编号';
COMMENT
ON COLUMN "blade_oss"."region" IS '地域简称';
COMMENT
ON COLUMN "blade_oss"."remark" IS '备注';
COMMENT
ON COLUMN "blade_oss"."secret_key" IS 'secretKey';
COMMENT
ON COLUMN "blade_oss"."status" IS '状态';
COMMENT
ON COLUMN "blade_oss"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_oss"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_oss"."update_user" IS '修改人';



DROP TABLE IF EXISTS "blade_common_group";
CREATE TABLE "blade_common_group"
(
    "id"                   BIGINT NOT NULL,
    "tenant_id"            VARCHAR(12) DEFAULT '000000',
    "parent_id"            BIGINT      DEFAULT 0,
    "extend_id"            VARCHAR(64),
    "code"                 VARCHAR(255),
    "group_type"           VARCHAR(45),
    "group_category"       TINYINT,
    "group_tag"            varchar(32),
    "name"                 VARCHAR(45),
    "full_name"            VARCHAR(45),
    "sort"                 INT,
    "remark"               VARCHAR(255),
    "production_line_type" VARCHAR(50),
    "is_deleted"           INT,
    "status"               TINYINT     DEFAULT 1,
    NOT                    CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_common_group" IS '组';
COMMENT
ON COLUMN "blade_common_group"."code" IS '拼接的虚拟路径字符串代码';
COMMENT
ON COLUMN "blade_common_group"."extend_id" IS '扩展ID，例如 DMP UUID';
COMMENT
ON COLUMN "blade_common_group"."full_name" IS '组完整名称';
COMMENT
ON COLUMN "blade_common_group"."group_category" IS '组子类，对应字典项';
COMMENT
ON COLUMN "blade_common_group"."group_tag" IS '工位组标签(fms_beltline,beltline)';
COMMENT
ON COLUMN "blade_common_group"."group_type" IS '组别, 对应字典编号';
COMMENT
ON COLUMN "blade_common_group"."id" IS '主键';
COMMENT
ON COLUMN "blade_common_group"."name" IS '组名';
COMMENT
ON COLUMN "blade_common_group"."parent_id" IS '父主键';
COMMENT
ON COLUMN "blade_common_group"."remark" IS '备注';
COMMENT
ON COLUMN "blade_common_group"."sort" IS '排序';
COMMENT
ON COLUMN "blade_common_group"."production_line_type" IS '所属应用';
COMMENT
ON COLUMN "blade_common_group"."tenant_id" IS '租户ID';
COMMENT
ON COLUMN "blade_common_group"."status" IS '业务状态 1启用 0 停用';

DROP TABLE IF EXISTS "blade_interface_config";
CREATE TABLE "blade_interface_config"
(
    "id"           BIGINT       NOT NULL,
    "status"       TINYINT DEFAULT 1,
    "is_deleted"   INT,
    "create_user"  BIGINT,
    "create_dept"  BIGINT,
    "create_time"  TIMESTAMP(0),
    "update_user"  BIGINT,
    "update_time"  TIMESTAMP(0),
    "url"          VARCHAR(255),
    "url_name"     VARCHAR(64)  NOT NULL,
    "url_type"     INT          NOT NULL,
    "owning_chart" VARCHAR(255) NOT NULL,
    NOT            CLUSTER PRIMARY KEY("id"),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_interface_config" IS '接口配置表';
COMMENT
ON COLUMN "blade_interface_config"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_interface_config"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_interface_config"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_interface_config"."is_deleted" IS '删除标记：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_interface_config"."owning_chart" IS '1图表类型 bar-柱状 line-折线图 pie-饼图 GanttChart 甘特图 table-表格';
COMMENT
ON COLUMN "blade_interface_config"."status" IS '业务状态 1启用 0 停用';
COMMENT
ON COLUMN "blade_interface_config"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_interface_config"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_interface_config"."url" IS '接口url';
COMMENT
ON COLUMN "blade_interface_config"."url_name" IS '接口中文名';
COMMENT
ON COLUMN "blade_interface_config"."url_type" IS '接口类型 0 - POST； 1 - PUT； 2 - GET';


DROP TABLE IF EXISTS "blade_interface_config_field";
CREATE TABLE "blade_interface_config_field"
(
    "id"               BIGINT            NOT NULL,
    "status"           INT     DEFAULT 1 NOT NULL,
    "is_deleted"       INT,
    "create_user"      BIGINT,
    "create_dept"      BIGINT,
    "create_time"      TIMESTAMP(0),
    "update_user"      BIGINT,
    "update_time"      TIMESTAMP(0),
    "config_id"        BIGINT            NOT NULL,
    "label"            VARCHAR(255),
    "name"             VARCHAR(255)      NOT NULL,
    "is_required"      TINYINT DEFAULT 0 NOT NULL,
    "data_type"        INT               NOT NULL,
    "data_source"      VARCHAR(255),
    "is_single_choice" TINYINT,
    "checked_parent"   TINYINT,
    "relation_field"   VARCHAR(255),
    "method"           VARCHAR(10),
    NOT                CLUSTER PRIMARY KEY("id"),
    CHECK ("is_deleted" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_interface_config_field" IS '接口字段表';
COMMENT
ON COLUMN "blade_interface_config_field"."config_id" IS '接口配置id';
COMMENT
ON COLUMN "blade_interface_config_field"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_interface_config_field"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_interface_config_field"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_interface_config_field"."data_source" IS '当数据类型是下拉，树选择的时候指定数据源的地址。用于获取这些选项的数据。';
COMMENT
ON COLUMN "blade_interface_config_field"."data_type" IS '0-文本；1-数值；2-下拉；3-日期； 4-树选择';
COMMENT
ON COLUMN "blade_interface_config_field"."is_deleted" IS '删除标记：0-未删除，1-已删除';
COMMENT
ON COLUMN "blade_interface_config_field"."is_required" IS '是否必填： 0 - 不必填；1 - 必填';
COMMENT
ON COLUMN "blade_interface_config_field"."is_single_choice" IS '当下拉选择的时候指定是否单选：- 0 多选； 1 - 单选';
COMMENT
ON COLUMN "blade_interface_config_field"."name" IS '字段名称';
COMMENT
ON COLUMN "blade_interface_config_field"."status" IS '业务状态';
COMMENT
ON COLUMN "blade_interface_config_field"."update_time" IS '更新时间';
COMMENT
ON COLUMN "blade_interface_config_field"."update_user" IS '更新人';
COMMENT
ON COLUMN "blade_interface_config_field"."label" IS '字段标题';
COMMENT
ON COLUMN "blade_interface_config_field"."checked_parent" IS '树选择的情况下是否可选择父节点';
COMMENT
ON COLUMN "blade_interface_config_field"."relation_field" IS '依赖字段';
COMMENT
ON COLUMN "blade_interface_config_field"."method" IS '请求方法';


DROP TABLE IF EXISTS "blade_visual";
CREATE TABLE "blade_visual"
(
    "id"             BIGINT NOT NULL,
    "title"          VARCHAR(255),
    "background_url" CLOB,
    "category"       INT,
    "password"       VARCHAR(255),
    "create_user"    BIGINT,
    "create_dept"    BIGINT,
    "create_time"    TIMESTAMP(0),
    "update_user"    BIGINT,
    "update_time"    TIMESTAMP(0),
    "status"         INT    NOT NULL,
    "is_deleted"     INT,
    "group_name"     VARCHAR(255),
    "group_index"    INT,
    "sliding_second" INT,
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_visual" IS '可视化表';
COMMENT
ON COLUMN "blade_visual"."background_url" IS '大屏背景';
COMMENT
ON COLUMN "blade_visual"."category" IS '大屏类型';
COMMENT
ON COLUMN "blade_visual"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_visual"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_visual"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_visual"."id" IS '主键';
COMMENT
ON COLUMN "blade_visual"."password" IS '发布密码';
COMMENT
ON COLUMN "blade_visual"."status" IS '状态';
COMMENT
ON COLUMN "blade_visual"."title" IS '大屏标题';
COMMENT
ON COLUMN "blade_visual"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_visual"."update_user" IS '修改人';
COMMENT
ON COLUMN "blade_visual"."group_name" IS '大屏分组名称';
COMMENT
ON COLUMN "blade_visual"."group_index" IS '大屏分组顺序';
COMMENT
ON COLUMN "blade_visual"."sliding_second" IS '大屏轮播间隔';

DROP TABLE IF EXISTS "blade_param";
CREATE TABLE "blade_param"
(
    "id"          BIGINT NOT NULL,
    "param_name"  VARCHAR(255),
    "param_key"   VARCHAR(255),
    "param_value" VARCHAR(255),
    "remark"      VARCHAR(500),
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "status"      INT,
    "is_deleted"  INT,
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "blade_param" IS '参数表';
COMMENT
ON COLUMN "blade_param"."create_dept" IS '创建部门';
COMMENT
ON COLUMN "blade_param"."create_time" IS '创建时间';
COMMENT
ON COLUMN "blade_param"."create_user" IS '创建人';
COMMENT
ON COLUMN "blade_param"."id" IS '主键';
COMMENT
ON COLUMN "blade_param"."param_key" IS '参数键';
COMMENT
ON COLUMN "blade_param"."param_name" IS '参数名';
COMMENT
ON COLUMN "blade_param"."param_value" IS '参数值';
COMMENT
ON COLUMN "blade_param"."remark" IS '备注';
COMMENT
ON COLUMN "blade_param"."status" IS '状态';
COMMENT
ON COLUMN "blade_param"."update_time" IS '修改时间';
COMMENT
ON COLUMN "blade_param"."update_user" IS '修改人';

-- 添加应用列表
DROP TABLE IF EXISTS "blade_application";
CREATE TABLE "blade_application"
(
    "id"             BIGINT       NOT NULL,
    "name"           VARCHAR(255) NOT NULL,
    "code"           VARCHAR(255),
    "logo"           VARCHAR(255),
    "background_url" VARCHAR(1000),
    "domain_url"     VARCHAR(255),
    "is_default"     TINYINT,
    "is_show"        TINYINT DEFAULT '2',
    "sort"           INT,
    "remark"         VARCHAR(255),
    "is_deleted"     INT,
    NOT              CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "blade_application"."background_url" IS '应用系统背景';
COMMENT
ON COLUMN "blade_application"."code" IS '应用标识';
COMMENT
ON COLUMN "blade_application"."domain_url" IS '访问域名或地址';
COMMENT
ON COLUMN "blade_application"."is_default" IS '是否默认应用';
COMMENT
ON COLUMN "blade_application"."logo" IS '应用Logo';
COMMENT
ON COLUMN "blade_application"."name" IS '应用名称';
COMMENT
ON COLUMN "blade_application"."remark" IS '备注';
COMMENT
ON COLUMN "blade_application"."sort" IS '排序';
COMMENT
ON COLUMN "blade_application"."is_show" IS '是否显示 1显示 2关闭';

-- 第三方应用配置
DROP TABLE IF EXISTS "blade_outer_app_config";
CREATE TABLE "blade_outer_app_config"
(
    "id" BIGINT NOT NULL,
    "wx_corp_id" VARCHAR(255),
    "wx_app_secret" VARCHAR(255),
    "wx_book_secret" VARCHAR(255),
    "wx_callback_token" VARCHAR(255),
    "wx_agent_id" VARCHAR(255),
    "wx_aes_key" VARCHAR(255),
    "ding_app_key" VARCHAR(255),
    "ding_app_secret" VARCHAR(255),
    "ding_aes_key" VARCHAR(255),
    "ding_callback_token" VARCHAR(255),
    "ding_corp_id" VARCHAR(255),
    "app_type" INT,
    "last_sync_time" TIMESTAMP(0),
    "domain_url" VARCHAR(255),
    "status" INT DEFAULT 1 NOT NULL,
    "create_user" BIGINT,
    "create_dept" BIGINT,
    "create_time" TIMESTAMP(0),
    "update_user" BIGINT,
    "update_time" TIMESTAMP(0),
    "remark" VARCHAR(255),
    "is_deleted" INT,
    "ding_agent_id" VARCHAR(255),
    NOT CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "appTypeUnique" UNIQUE("app_type")) STORAGE(ON "MAIN", CLUSTERBTR) ;

COMMENT ON COLUMN "blade_outer_app_config"."app_type" IS '应用类型 1企业微信 2钉钉';
COMMENT ON COLUMN "blade_outer_app_config"."create_dept" IS '创建部门';
COMMENT ON COLUMN "blade_outer_app_config"."create_time" IS '创建时间';
COMMENT ON COLUMN "blade_outer_app_config"."create_user" IS '创建人';
COMMENT ON COLUMN "blade_outer_app_config"."ding_aes_key" IS '钉钉加解密aes_key';
COMMENT ON COLUMN "blade_outer_app_config"."ding_app_key" IS '钉钉应用key';
COMMENT ON COLUMN "blade_outer_app_config"."ding_app_secret" IS '钉钉应用secret';
COMMENT ON COLUMN "blade_outer_app_config"."ding_callback_token" IS '钉钉回调token';
COMMENT ON COLUMN "blade_outer_app_config"."ding_corp_id" IS '钉钉企业corpId';
COMMENT ON COLUMN "blade_outer_app_config"."last_sync_time" IS '上次同步时间';
COMMENT ON COLUMN "blade_outer_app_config"."remark" IS '备注/说明';
COMMENT ON COLUMN "blade_outer_app_config"."domain_url" IS '第三方回调域名';
COMMENT ON COLUMN "blade_outer_app_config"."status" IS '状态';
COMMENT ON COLUMN "blade_outer_app_config"."update_time" IS '更新时间';
COMMENT ON COLUMN "blade_outer_app_config"."update_user" IS '更新人';
COMMENT ON COLUMN "blade_outer_app_config"."wx_aes_key" IS '企业微信回调配置加解密aes_key';
COMMENT ON COLUMN "blade_outer_app_config"."wx_agent_id" IS '企业微信应用的AgentId';
COMMENT ON COLUMN "blade_outer_app_config"."wx_app_secret" IS '企业微信应用secret';
COMMENT ON COLUMN "blade_outer_app_config"."wx_book_secret" IS '企业微信通讯录secret';
COMMENT ON COLUMN "blade_outer_app_config"."wx_callback_token" IS '企业微信回调配置token';
COMMENT ON COLUMN "blade_outer_app_config"."wx_corp_id" IS '企业微信企业corpId';
COMMENT ON COLUMN "blade_outer_app_config"."ding_agent_id" IS '钉钉应用AgentId';


-- 脚本
-- 初始化脚本
-- 客户端
INSERT INTO blade_client(id, client_id, client_secret, resource_ids, scope,
                         authorized_grant_types, web_server_redirect_uri, authorities,
                         access_token_validity, refresh_token_validity, additional_information,
                         autoapprove, create_user, create_dept, create_time, update_user,
                         update_time, status, is_deleted)
VALUES (1123598811738675201, 'sword', 'sword_secret', NULL, 'all',
        'refresh_token,password,authorization_code,captcha,social', 'http://localhost:8888', NULL, 3600, 604800,
        NULL, NULL, 1123598815738675201, 1123598813738675201, '2019-03-24 10:40:55', 1123598815738675201,
        '2019-03-24 10:40:59', 1, 0),
       (1123598811738675202, 'saber', 'saber_secret', NULL, 'all',
        'refresh_token,password,authorization_code,captcha,social', 'http://localhost:8080', NULL, 3600, 604800,
        NULL, NULL, 1123598815738675201, 1123598813738675201, '2019-03-24 10:42:29', 1123598815738675201,
        '2019-03-24 10:42:32', 1, 0),
        (1123598811738675203, 'h5', 'h5_secret', NULL, 'all',
        'refresh_token,password,authorization_code,captcha,social', 'http://localhost:8080', NULL, 604800, 604800,
        NULL, NULL, 1123598815738675201, 1123598813738675201, '2019-03-24 10:42:29', 1123598815738675201,
        '2019-03-24 10:42:32', 1, 0);


insert into "blade_application" ("id", "name", "code", "logo", "background_url", "domain_url", "is_default", "is_show", "sort",
                                 "remark", "is_deleted")
values (1001, 'CPS', 'CPS', '', '', '', 1, 1, 2, '离散线', 0);
insert into "blade_application" ("id", "name", "code", "logo", "background_url", "domain_url", "is_default", "is_show", "sort",
                                 "remark", "is_deleted")
values (1002, '大屏', 'VISION', '', '', '', 1, 2, 2, '可视化大屏', 0);
insert into "blade_application" ("id", "name", "code", "logo", "background_url", "domain_url", "is_default", "is_show", "sort",
                                 "remark", "is_deleted")
VALUES (1003, 'HMI', 'HMI', '', '', '', 1, 2, 3, 'HMI', 0);


DROP TABLE IF EXISTS "jimu_dict";
CREATE TABLE "jimu_dict"
(
    "id"          VARCHAR(32) NOT NULL,
    "dict_name"   VARCHAR(100),
    "dict_code"   VARCHAR(100),
    "description" VARCHAR(255),
    "del_flag"    INT,
    "create_by"   VARCHAR(32),
    "create_time" TIMESTAMP(0),
    "update_by"   VARCHAR(32),
    "update_time" TIMESTAMP(0),
    "type"        BIGINT DEFAULT 0,
    NOT           CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "UK_SD_dict_code" UNIQUE ("dict_code"),
    CHECK ("type" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "jimu_dict"."create_by" IS '创建人';
COMMENT
ON COLUMN "jimu_dict"."create_time" IS '创建时间';
COMMENT
ON COLUMN "jimu_dict"."del_flag" IS '删除状态';
COMMENT
ON COLUMN "jimu_dict"."description" IS '描述';
COMMENT
ON COLUMN "jimu_dict"."dict_code" IS '字典编码';
COMMENT
ON COLUMN "jimu_dict"."dict_name" IS '字典名称';
COMMENT
ON COLUMN "jimu_dict"."type" IS '字典类型0为string,1为number';
COMMENT
ON COLUMN "jimu_dict"."update_by" IS '更新人';
COMMENT
ON COLUMN "jimu_dict"."update_time" IS '更新时间';

DROP TABLE IF EXISTS "jimu_dict_item";
CREATE TABLE "jimu_dict_item"
(
    "id"          VARCHAR(32) NOT NULL,
    "dict_id"     VARCHAR(32),
    "item_text"   VARCHAR(100),
    "item_value"  VARCHAR(100),
    "description" VARCHAR(255),
    "sort_order"  INT,
    "status"      INT,
    "create_by"   VARCHAR(32),
    "create_time" TIMESTAMP(0),
    "update_by"   VARCHAR(32),
    "update_time" TIMESTAMP(0),
    NOT           CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "jimu_dict_item"."description" IS '描述';
COMMENT
ON COLUMN "jimu_dict_item"."dict_id" IS '字典id';
COMMENT
ON COLUMN "jimu_dict_item"."item_text" IS '字典项文本';
COMMENT
ON COLUMN "jimu_dict_item"."item_value" IS '字典项值';
COMMENT
ON COLUMN "jimu_dict_item"."sort_order" IS '排序';
COMMENT
ON COLUMN "jimu_dict_item"."status" IS '状态（1启用 0不启用）';


CREATE INDEX "IDX_SDI_ROLE_SORT_ORDER" ON "jimu_dict_item" ("sort_order" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_SDI_DICT_VAL" ON "jimu_dict_item" ("dict_id" ASC, "item_value" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_SDI_ROLE_DICT_ID" ON "jimu_dict_item" ("dict_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_SDI_STATUS" ON "jimu_dict_item" ("status" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "jimu_report";
CREATE TABLE "jimu_report"
(
    "id"          VARCHAR(32) NOT NULL,
    "code"        VARCHAR(50),
    "name"        VARCHAR(50),
    "note"        VARCHAR(255),
    "status"      VARCHAR(10),
    "type"        VARCHAR(10),
    "json_str"    CLOB,
    "api_url"     VARCHAR(255),
    "thumb"       TEXT,
    "create_by"   VARCHAR(50),
    "create_time" TIMESTAMP(0),
    "update_by"   VARCHAR(50),
    "update_time" TIMESTAMP(0),
    "del_flag"    TINYINT,
    "api_method"  VARCHAR(255),
    "api_code"    VARCHAR(255),
    "template"    TINYINT,
    "view_count"  BIGINT DEFAULT 0,
    "css_str"     TEXT,
    "js_str"      TEXT,
    NOT           CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "UNIQ_JMREPORT_CODE" UNIQUE ("code")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "jimu_report" IS '在线excel设计器';
COMMENT
ON COLUMN "jimu_report"."api_code" IS '请求编码';
COMMENT
ON COLUMN "jimu_report"."api_method" IS '请求方法0-get,1-post';
COMMENT
ON COLUMN "jimu_report"."api_url" IS '请求地址';
COMMENT
ON COLUMN "jimu_report"."code" IS '编码';
COMMENT
ON COLUMN "jimu_report"."create_by" IS '创建人';
COMMENT
ON COLUMN "jimu_report"."create_time" IS '创建时间';
COMMENT
ON COLUMN "jimu_report"."css_str" IS 'css增强';
COMMENT
ON COLUMN "jimu_report"."del_flag" IS '删除标识0-正常,1-已删除';
COMMENT
ON COLUMN "jimu_report"."id" IS '主键';
COMMENT
ON COLUMN "jimu_report"."js_str" IS 'js增强';
COMMENT
ON COLUMN "jimu_report"."json_str" IS 'json字符串';
COMMENT
ON COLUMN "jimu_report"."name" IS '名称';
COMMENT
ON COLUMN "jimu_report"."note" IS '说明';
COMMENT
ON COLUMN "jimu_report"."status" IS '状态';
COMMENT
ON COLUMN "jimu_report"."template" IS '是否是模板 0-是,1-不是';
COMMENT
ON COLUMN "jimu_report"."thumb" IS '缩略图';
COMMENT
ON COLUMN "jimu_report"."type" IS '类型';
COMMENT
ON COLUMN "jimu_report"."update_by" IS '修改人';
COMMENT
ON COLUMN "jimu_report"."update_time" IS '修改时间';
COMMENT
ON COLUMN "jimu_report"."view_count" IS '浏览次数';


CREATE INDEX "UNIQ_JMREPORT_DELFLAG" ON "jimu_report" ("del_flag" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "UNIQ_JMREPORT_CREATEBY" ON "jimu_report" ("create_by" ASC) STORAGE(ON "MAIN", CLUSTERBTR);


CREATE TABLE "jimu_report_data_source"
(
    "id"            VARCHAR(36) NOT NULL,
    "name"          VARCHAR(100),
    "report_id"     VARCHAR(100),
    "code"          VARCHAR(100),
    "remark"        VARCHAR(200),
    "db_type"       VARCHAR(10),
    "db_driver"     VARCHAR(100),
    "db_url"        VARCHAR(500),
    "db_username"   VARCHAR(100),
    "db_password"   VARCHAR(100),
    "create_by"     VARCHAR(50),
    "create_time"   TIMESTAMP(0),
    "update_by"     VARCHAR(50),
    "update_time"   TIMESTAMP(0),
    "connect_times" BIGINT DEFAULT 0,
    NOT             CLUSTER PRIMARY KEY("id"),
    CHECK ("connect_times" >= 0)
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "jimu_report_data_source"."code" IS '编码';
COMMENT
ON COLUMN "jimu_report_data_source"."connect_times" IS '连接失败次数';
COMMENT
ON COLUMN "jimu_report_data_source"."create_by" IS '创建人';
COMMENT
ON COLUMN "jimu_report_data_source"."create_time" IS '创建日期';
COMMENT
ON COLUMN "jimu_report_data_source"."db_driver" IS '驱动类';
COMMENT
ON COLUMN "jimu_report_data_source"."db_password" IS '密码';
COMMENT
ON COLUMN "jimu_report_data_source"."db_type" IS '数据库类型';
COMMENT
ON COLUMN "jimu_report_data_source"."db_url" IS '数据源地址';
COMMENT
ON COLUMN "jimu_report_data_source"."db_username" IS '用户名';
COMMENT
ON COLUMN "jimu_report_data_source"."name" IS '数据源名称';
COMMENT
ON COLUMN "jimu_report_data_source"."remark" IS '备注';
COMMENT
ON COLUMN "jimu_report_data_source"."report_id" IS '报表_id';
COMMENT
ON COLUMN "jimu_report_data_source"."update_by" IS '更新人';
COMMENT
ON COLUMN "jimu_report_data_source"."update_time" IS '更新日期';


CREATE INDEX "IDX_JMDATASOURCE_REPORT_ID" ON "jimu_report_data_source" ("report_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_JMDATASOURCE_CODE" ON "jimu_report_data_source" ("code" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "jimu_report_db";
CREATE TABLE "jimu_report_db"
(
    "id"               VARCHAR(36) NOT NULL,
    "jimu_report_id"   VARCHAR(32),
    "create_by"        VARCHAR(50),
    "update_by"        VARCHAR(50),
    "create_time"      TIMESTAMP(0),
    "update_time"      TIMESTAMP(0),
    "db_code"          VARCHAR(32),
    "db_ch_name"       VARCHAR(50),
    "db_type"          VARCHAR(32),
    "db_table_name"    VARCHAR(32),
    "db_dyn_sql"       CLOB,
    "db_key"           VARCHAR(32),
    "tb_db_key"        VARCHAR(32),
    "tb_db_table_name" VARCHAR(32),
    "java_type"        VARCHAR(32),
    "java_value"       VARCHAR(255),
    "api_url"          VARCHAR(255),
    "api_method"       VARCHAR(255),
    "is_list"          VARCHAR(10) DEFAULT '0',
    "is_page"          VARCHAR(10),
    "db_source"        VARCHAR(255),
    "db_source_type"   VARCHAR(50),
    "json_data"        TEXT,
    "api_convert"      VARCHAR(255),
    NOT                CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "jimu_report_db"."api_convert" IS 'api转换器';
COMMENT
ON COLUMN "jimu_report_db"."api_method" IS '请求方法0-get,1-post';
COMMENT
ON COLUMN "jimu_report_db"."api_url" IS '请求地址';
COMMENT
ON COLUMN "jimu_report_db"."create_by" IS '创建人登录名称';
COMMENT
ON COLUMN "jimu_report_db"."create_time" IS '创建日期';
COMMENT
ON COLUMN "jimu_report_db"."db_ch_name" IS '数据集名字';
COMMENT
ON COLUMN "jimu_report_db"."db_code" IS '数据集编码';
COMMENT
ON COLUMN "jimu_report_db"."db_dyn_sql" IS '动态查询SQL';
COMMENT
ON COLUMN "jimu_report_db"."db_key" IS '数据源KEY';
COMMENT
ON COLUMN "jimu_report_db"."db_source" IS '数据源';
COMMENT
ON COLUMN "jimu_report_db"."db_source_type" IS '数据库类型 MYSQL ORACLE SQLSERVER';
COMMENT
ON COLUMN "jimu_report_db"."db_table_name" IS '数据库表名';
COMMENT
ON COLUMN "jimu_report_db"."db_type" IS '数据源类型';
COMMENT
ON COLUMN "jimu_report_db"."id" IS 'id';
COMMENT
ON COLUMN "jimu_report_db"."is_list" IS '是否是列表0否1是 默认0';
COMMENT
ON COLUMN "jimu_report_db"."is_page" IS '是否作为分页,0:不分页，1:分页';
COMMENT
ON COLUMN "jimu_report_db"."java_type" IS 'java类数据集  类型（spring:springkey,class:java类名）';
COMMENT
ON COLUMN "jimu_report_db"."java_value" IS 'java类数据源  数值（bean key/java类名）';
COMMENT
ON COLUMN "jimu_report_db"."jimu_report_id" IS '主键字段';
COMMENT
ON COLUMN "jimu_report_db"."json_data" IS 'json数据，直接解析json内容';
COMMENT
ON COLUMN "jimu_report_db"."tb_db_key" IS '填报数据源';
COMMENT
ON COLUMN "jimu_report_db"."tb_db_table_name" IS '填报数据表';
COMMENT
ON COLUMN "jimu_report_db"."update_by" IS '更新人登录名称';
COMMENT
ON COLUMN "jimu_report_db"."update_time" IS '更新日期';


CREATE INDEX "IDX_DB_SOURCE_ID" ON "jimu_report_db" ("db_source" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_jimu_report_ID" ON "jimu_report_db" ("jimu_report_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_JMREPORTDB_DB_KEY" ON "jimu_report_db" ("db_key" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "jimu_report_db_field";
CREATE TABLE "jimu_report_db_field"
(
    "id"                VARCHAR(36) NOT NULL,
    "create_by"         VARCHAR(50),
    "create_time"       TIMESTAMP(0),
    "update_by"         VARCHAR(50),
    "update_time"       TIMESTAMP(0),
    "jimu_report_db_id" VARCHAR(32),
    "field_name"        VARCHAR(80),
    "field_text"        VARCHAR(50),
    "widget_type"       VARCHAR(50),
    "widget_width"      INT,
    "order_num"         INT,
    "search_flag"       INT DEFAULT 0,
    "search_mode"       INT,
    "dict_code"         VARCHAR(255),
    "search_value"      VARCHAR(100),
    "search_format"     VARCHAR(50),
    "ext_json"          TEXT,
    NOT                 CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "jimu_report_db_field"."create_by" IS '创建人登录名称';
COMMENT
ON COLUMN "jimu_report_db_field"."create_time" IS '创建日期';
COMMENT
ON COLUMN "jimu_report_db_field"."dict_code" IS '字典编码支持从表中取数据';
COMMENT
ON COLUMN "jimu_report_db_field"."ext_json" IS '参数配置';
COMMENT
ON COLUMN "jimu_report_db_field"."field_name" IS '字段名';
COMMENT
ON COLUMN "jimu_report_db_field"."field_text" IS '字段文本';
COMMENT
ON COLUMN "jimu_report_db_field"."id" IS 'id';
COMMENT
ON COLUMN "jimu_report_db_field"."jimu_report_db_id" IS '数据源ID';
COMMENT
ON COLUMN "jimu_report_db_field"."order_num" IS '排序';
COMMENT
ON COLUMN "jimu_report_db_field"."search_flag" IS '查询标识0否1是 默认0';
COMMENT
ON COLUMN "jimu_report_db_field"."search_format" IS '查询时间格式化表达式';
COMMENT
ON COLUMN "jimu_report_db_field"."search_mode" IS '查询模式1简单2范围';
COMMENT
ON COLUMN "jimu_report_db_field"."search_value" IS '查询默认值';
COMMENT
ON COLUMN "jimu_report_db_field"."update_by" IS '更新人登录名称';
COMMENT
ON COLUMN "jimu_report_db_field"."update_time" IS '更新日期';
COMMENT
ON COLUMN "jimu_report_db_field"."widget_type" IS '控件类型';
COMMENT
ON COLUMN "jimu_report_db_field"."widget_width" IS '控件宽度';


CREATE INDEX "IDX_JRDF_jimu_report_db_ID" ON "jimu_report_db_field" ("jimu_report_db_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);
CREATE INDEX "IDX_DBFIELD_ORDER_NUM" ON "jimu_report_db_field" ("order_num" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "jimu_report_db_param";
CREATE TABLE "jimu_report_db_param"
(
    "id"                  VARCHAR(36) NOT NULL,
    "jimu_report_head_id" VARCHAR(36) NOT NULL,
    "param_name"          VARCHAR(32) NOT NULL,
    "param_txt"           VARCHAR(32),
    "param_value"         VARCHAR(1000),
    "order_num"           INT,
    "create_by"           VARCHAR(50),
    "create_time"         TIMESTAMP(0),
    "update_by"           VARCHAR(50),
    "update_time"         TIMESTAMP(0),
    "search_flag"         INT,
    "widget_type"         VARCHAR(50),
    "search_mode"         INT,
    "dict_code"           VARCHAR(255),
    "search_format"       VARCHAR(50),
    "ext_json"            TEXT,
    NOT                   CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON COLUMN "jimu_report_db_param"."create_by" IS '创建人登录名称';
COMMENT
ON COLUMN "jimu_report_db_param"."create_time" IS '创建日期';
COMMENT
ON COLUMN "jimu_report_db_param"."dict_code" IS '字典';
COMMENT
ON COLUMN "jimu_report_db_param"."ext_json" IS '参数配置';
COMMENT
ON COLUMN "jimu_report_db_param"."jimu_report_head_id" IS '动态报表ID';
COMMENT
ON COLUMN "jimu_report_db_param"."order_num" IS '排序';
COMMENT
ON COLUMN "jimu_report_db_param"."param_name" IS '参数字段';
COMMENT
ON COLUMN "jimu_report_db_param"."param_txt" IS '参数文本';
COMMENT
ON COLUMN "jimu_report_db_param"."param_value" IS '参数默认值';
COMMENT
ON COLUMN "jimu_report_db_param"."search_flag" IS '查询标识0否1是 默认0';
COMMENT
ON COLUMN "jimu_report_db_param"."search_format" IS '查询时间格式化表达式';
COMMENT
ON COLUMN "jimu_report_db_param"."search_mode" IS '查询模式1简单2范围';
COMMENT
ON COLUMN "jimu_report_db_param"."update_by" IS '更新人登录名称';
COMMENT
ON COLUMN "jimu_report_db_param"."update_time" IS '更新日期';
COMMENT
ON COLUMN "jimu_report_db_param"."widget_type" IS '查询控件类型';


CREATE INDEX "IDX_JRDP_jimu_report_HEAD_ID" ON "jimu_report_db_param" ("jimu_report_head_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "jimu_report_link";
CREATE TABLE "jimu_report_link"
(
    "id"            VARCHAR(32) NOT NULL,
    "report_id"     VARCHAR(32),
    "parameter"     TEXT,
    "eject_type"    VARCHAR(1),
    "link_name"     VARCHAR(255),
    "api_method"    VARCHAR(1),
    "link_type"     VARCHAR(1),
    "api_url"       VARCHAR(1000),
    "link_chart_id" VARCHAR(50),
    "expression"    VARCHAR(255),
    "requirement"   VARCHAR(255),
    NOT             CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "jimu_report_link" IS '超链接配置表';
COMMENT
ON COLUMN "jimu_report_link"."api_method" IS '请求方法0-get,1-post';
COMMENT
ON COLUMN "jimu_report_link"."api_url" IS '外网api';
COMMENT
ON COLUMN "jimu_report_link"."eject_type" IS '弹出方式（0 当前页面 1 新窗口）';
COMMENT
ON COLUMN "jimu_report_link"."expression" IS '表达式';
COMMENT
ON COLUMN "jimu_report_link"."id" IS '主键id';
COMMENT
ON COLUMN "jimu_report_link"."link_chart_id" IS '联动图表的ID';
COMMENT
ON COLUMN "jimu_report_link"."link_name" IS '链接名称';
COMMENT
ON COLUMN "jimu_report_link"."link_type" IS '链接方式(0 网络报表 1 网络连接 2 图表联动)';
COMMENT
ON COLUMN "jimu_report_link"."parameter" IS '参数';
COMMENT
ON COLUMN "jimu_report_link"."report_id" IS '积木设计器id';
COMMENT
ON COLUMN "jimu_report_link"."requirement" IS '条件';


CREATE INDEX "UNIQ_LINK_REPORTID" ON "jimu_report_link" ("report_id" ASC) STORAGE(ON "MAIN", CLUSTERBTR);

DROP TABLE IF EXISTS "jimu_report_map";
CREATE TABLE "jimu_report_map"
(
    "id"           VARCHAR(64) NOT NULL,
    "label"        VARCHAR(125),
    "name"         VARCHAR(125),
    "data"         CLOB,
    "create_by"    VARCHAR(32),
    "create_time"  TIMESTAMP(0),
    "update_by"    VARCHAR(32),
    "update_time"  TIMESTAMP(0),
    "del_flag"     VARCHAR(1),
    "sys_org_code" VARCHAR(64),
    NOT            CLUSTER PRIMARY KEY("id"),
    CONSTRAINT "UNIQ_JMREPORT_MAP_NAME" UNIQUE ("name")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "jimu_report_map" IS '地图配置表';
COMMENT
ON COLUMN "jimu_report_map"."create_by" IS '创建人';
COMMENT
ON COLUMN "jimu_report_map"."create_time" IS '创建时间';
COMMENT
ON COLUMN "jimu_report_map"."data" IS '地图数据';
COMMENT
ON COLUMN "jimu_report_map"."del_flag" IS '0表示未删除,1表示删除';
COMMENT
ON COLUMN "jimu_report_map"."id" IS '主键';
COMMENT
ON COLUMN "jimu_report_map"."label" IS '地图名称';
COMMENT
ON COLUMN "jimu_report_map"."name" IS '地图编码';
COMMENT
ON COLUMN "jimu_report_map"."sys_org_code" IS '所属部门';
COMMENT
ON COLUMN "jimu_report_map"."update_by" IS '修改人';
COMMENT
ON COLUMN "jimu_report_map"."update_time" IS '修改时间';

DROP TABLE IF EXISTS "jimu_report_share";
CREATE TABLE "jimu_report_share"
(
    "id"               VARCHAR(32) NOT NULL,
    "report_id"        VARCHAR(32),
    "preview_url"      VARCHAR(1000),
    "preview_lock"     VARCHAR(4),
    "last_update_time" TIMESTAMP(0),
    "term_of_validity" VARCHAR(1),
    "status"           VARCHAR(1),
    NOT                CLUSTER PRIMARY KEY("id")
) STORAGE(ON "MAIN", CLUSTERBTR);

COMMENT
ON TABLE "jimu_report_share" IS '积木报表预览权限表';
COMMENT
ON COLUMN "jimu_report_share"."id" IS '主键';
COMMENT
ON COLUMN "jimu_report_share"."last_update_time" IS '最后更新时间';
COMMENT
ON COLUMN "jimu_report_share"."preview_lock" IS '密码锁';
COMMENT
ON COLUMN "jimu_report_share"."preview_url" IS '预览地址';
COMMENT
ON COLUMN "jimu_report_share"."report_id" IS '在线excel设计器id';
COMMENT
ON COLUMN "jimu_report_share"."status" IS '是否过期(0未过期，1已过期)';
COMMENT
ON COLUMN "jimu_report_share"."term_of_validity" IS '有效期(0:永久有效，1:1天，2:7天)';
