CREATE TABLE BPM_AUTO_START_CONF (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_KEY_             VARCHAR(64)          NULL DEFAULT NULL,
   START_USER_          TEXT                 NULL DEFAULT NULL,
   FORM_DATA_           TEXT                 NULL DEFAULT NULL,
   TRIGGER_             VARCHAR(512)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_AUTO_START_CONF PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_AUTO_START_CONF IS
'流程自动发起配置表';

COMMENT ON COLUMN BPM_AUTO_START_CONF.ID_ IS
'ID';

COMMENT ON COLUMN BPM_AUTO_START_CONF.DEF_KEY_ IS
'流程定义key';

COMMENT ON COLUMN BPM_AUTO_START_CONF.START_USER_ IS
'启动用户';

COMMENT ON COLUMN BPM_AUTO_START_CONF.FORM_DATA_ IS
'表单数据';

COMMENT ON COLUMN BPM_AUTO_START_CONF.TRIGGER_ IS
'触发器';

COMMENT ON COLUMN BPM_AUTO_START_CONF.TENANT_ID_ IS
'租户id';

CREATE TABLE PORTAL_APP (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(255)         NULL DEFAULT NULL,
   CONTENT_             VARCHAR(1000)        NULL DEFAULT NULL,
   ICON_                VARCHAR(255)         NULL DEFAULT NULL,
   ICON_COLOR_          VARCHAR(10)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   ENABLE_              INT4                 NULL DEFAULT NULL,
   MODE_                INT4                 NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_APP PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_APP IS
'移动端应用';

COMMENT ON COLUMN PORTAL_APP.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_APP.NAME_ IS
'应用名称';

COMMENT ON COLUMN PORTAL_APP.CONTENT_ IS
'内容';

COMMENT ON COLUMN PORTAL_APP.ICON_ IS
'图标';

COMMENT ON COLUMN PORTAL_APP.ICON_COLOR_ IS
'图标颜色';

COMMENT ON COLUMN PORTAL_APP.TYPE_ID_ IS
'分类id';

COMMENT ON COLUMN PORTAL_APP.TYPE_NAME_ IS
'分类名称';

COMMENT ON COLUMN PORTAL_APP.ENABLE_ IS
'是否启用：0未启用，1已启用';

COMMENT ON COLUMN PORTAL_APP.MODE_ IS
'类型：1站内地址，2站外地址，3数据报表';

COMMENT ON COLUMN PORTAL_APP.SN_ IS
'排序';

COMMENT ON COLUMN PORTAL_APP.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN PORTAL_APP.CREATE_TIME_ IS
'创建时间';

COMMENT ON COLUMN PORTAL_APP.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN PORTAL_APP.UPDATE_TIME_ IS
'更新时间';

COMMENT ON COLUMN PORTAL_APP.TENANT_ID_ IS
'租户id';

CREATE TABLE PORTAL_APP_PARAM (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   ALIAS_               VARCHAR(64)          NULL DEFAULT NULL,
   CONTROL_TYPE_        VARCHAR(64)          NULL DEFAULT NULL,
   VALUE_               TEXT                 NULL,
   APP_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_APP_PARAM PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_APP_PARAM IS
'应用参数表';

COMMENT ON COLUMN PORTAL_APP_PARAM.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_APP_PARAM.NAME_ IS
'参数名称';

COMMENT ON COLUMN PORTAL_APP_PARAM.ALIAS_ IS
'参数编码';

COMMENT ON COLUMN PORTAL_APP_PARAM.CONTROL_TYPE_ IS
'控件类型';

COMMENT ON COLUMN PORTAL_APP_PARAM.VALUE_ IS
'参数值';

COMMENT ON COLUMN PORTAL_APP_PARAM.APP_ID_ IS
'应用ID';

COMMENT ON COLUMN PORTAL_APP_PARAM.CREATE_TIME_ IS
'创建时间';

COMMENT ON COLUMN PORTAL_APP_PARAM.TENANT_ID_ IS
'租户id';

CREATE TABLE PORTAL_APP_TAGS_RELATION (
   ID_                  VARCHAR(64)          NOT NULL,
   APP_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   TAG_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_APP_TAGS_RELATION PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_APP_TAGS_RELATION IS
'应用标签关系表';

COMMENT ON COLUMN PORTAL_APP_TAGS_RELATION.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_APP_TAGS_RELATION.APP_ID_ IS
'应用ID';

COMMENT ON COLUMN PORTAL_APP_TAGS_RELATION.TAG_ID_ IS
'标签ID';

COMMENT ON COLUMN PORTAL_APP_TAGS_RELATION.TENANT_ID_ IS
'租户id';

CREATE TABLE PORTAL_CALENDAR (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(255)         NOT NULL,
   MEMO_                VARCHAR(512)         NULL DEFAULT NULL,
   IS_DEFAULT_          CHAR(1)              NOT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CALENDAR PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CALENDAR IS
'工作日历';

COMMENT ON COLUMN PORTAL_CALENDAR.NAME_ IS
'日历名称';

COMMENT ON COLUMN PORTAL_CALENDAR.MEMO_ IS
'描述';

COMMENT ON COLUMN PORTAL_CALENDAR.IS_DEFAULT_ IS
'1=默认日历\r\n0=非默认';

CREATE TABLE PORTAL_CAL_ABSENCE (
   ID_                  VARCHAR(64)          NOT NULL,
   ABS_RASON_           VARCHAR(255)         NOT NULL,
   USER_ID_             VARCHAR(64)          NOT NULL,
   CAT_KEY_             VARCHAR(64)          NOT NULL,
   START_TIME_          TIMESTAMP                 NULL,
   END_TIME_            TIMESTAMP                 NULL,
   CONSTRAINT PK_PORTAL_CAL_ABSENCE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_ABSENCE IS
'工作日请假记录';

COMMENT ON COLUMN PORTAL_CAL_ABSENCE.ABS_RASON_ IS
'缺勤事由';

COMMENT ON COLUMN PORTAL_CAL_ABSENCE.USER_ID_ IS
'用户ID';

COMMENT ON COLUMN PORTAL_CAL_ABSENCE.CAT_KEY_ IS
'分类Key';

CREATE TABLE PORTAL_CAL_ASSIGN (
   ID_                  VARCHAR(64)          NOT NULL,
   CANLENDAR_ID_        VARCHAR(64)          NOT NULL,
   ASSIGN_TYPE_         VARCHAR(64)          NOT NULL,
   ASSIGN_ID_           VARCHAR(64)          NOT NULL,
   ASSIGN_USER_NAME_    VARCHAR(64)          NOT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CAL_ASSIGN PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_ASSIGN IS
'日历分配';

COMMENT ON COLUMN PORTAL_CAL_ASSIGN.CANLENDAR_ID_ IS
'日历ID';

COMMENT ON COLUMN PORTAL_CAL_ASSIGN.ASSIGN_TYPE_ IS
'分配者类型\r\n1,用户\r\n2.组织';

COMMENT ON COLUMN PORTAL_CAL_ASSIGN.ASSIGN_ID_ IS
'分配者ID';

COMMENT ON COLUMN PORTAL_CAL_ASSIGN.ASSIGN_USER_NAME_ IS
'分配者名称';

CREATE TABLE PORTAL_CAL_DATE_TYPE (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   KEY_                 VARCHAR(64)          NOT NULL,
   IS_RELATED_YEAR_     CHAR(1)              NOT NULL,
   YEAR_NUMBER_         INT4                 NOT NULL,
   DATE_TYPE_           VARCHAR(64)          NOT NULL,
   SCOPE_TYPE_          VARCHAR(64)          NOT NULL,
   WEEK_BEGIN_          INT4                 NULL DEFAULT NULL,
   WEEK_END_            INT4                 NULL DEFAULT NULL,
   YEAR_BEGIN_          TIMESTAMP                 NULL,
   YEAR_END_            TIMESTAMP                 NULL,
   SPECIFY_DATE_        TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CAL_DATE_TYPE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_DATE_TYPE IS
'节假日类型';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.NAME_ IS
'名称';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.KEY_ IS
'分类键';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.IS_RELATED_YEAR_ IS
'是否年相关';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.YEAR_NUMBER_ IS
'年份';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.DATE_TYPE_ IS
'W 工作日；PH 公休日；LH 法定假日；CH 公司特定假日\r\n';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.SCOPE_TYPE_ IS
'1 周日期范围；2 年日期范围；3 指定日期';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.WEEK_BEGIN_ IS
'周日期起始';

COMMENT ON COLUMN PORTAL_CAL_DATE_TYPE.WEEK_END_ IS
'周日期结束';

CREATE TABLE PORTAL_CAL_OVERTIME (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(255)         NOT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   START_TIME_          TIMESTAMP                 NULL,
   END_TIME_            TIMESTAMP                 NULL,
   WORK_TYPE_           VARCHAR(64)          NULL DEFAULT NULL,
   MEMO_                VARCHAR(2000)        NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CAL_OVERTIME PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_OVERTIME IS
'加班记录';

COMMENT ON COLUMN PORTAL_CAL_OVERTIME.SUBJECT_ IS
'主题';

COMMENT ON COLUMN PORTAL_CAL_OVERTIME.USER_ID_ IS
'用户ID';

COMMENT ON COLUMN PORTAL_CAL_OVERTIME.WORK_TYPE_ IS
'类型\r\n1.加班\r\n2.请假';

COMMENT ON COLUMN PORTAL_CAL_OVERTIME.MEMO_ IS
'备注';

CREATE TABLE PORTAL_CAL_SETTING (
   ID_                  VARCHAR(64)          NOT NULL,
   CALENDAR_ID_         VARCHAR(64)          NOT NULL,
   SHIFT_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   YEARS_               INT4                 NULL DEFAULT NULL,
   MONTHS_              INT4                 NULL DEFAULT NULL,
   DAYS_                INT4                 NULL DEFAULT NULL,
   DATE_TYPE_           VARCHAR(64)          NULL DEFAULT NULL,
   CAL_DAY_             VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CAL_SETTING PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_SETTING IS
'工作日历设置';

COMMENT ON COLUMN PORTAL_CAL_SETTING.CALENDAR_ID_ IS
'日历ID';

COMMENT ON COLUMN PORTAL_CAL_SETTING.SHIFT_ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_CAL_SETTING.YEARS_ IS
'年份';

COMMENT ON COLUMN PORTAL_CAL_SETTING.MONTHS_ IS
'月份';

COMMENT ON COLUMN PORTAL_CAL_SETTING.DAYS_ IS
'天数';

COMMENT ON COLUMN PORTAL_CAL_SETTING.DATE_TYPE_ IS
'日期分类';

COMMENT ON COLUMN PORTAL_CAL_SETTING.CAL_DAY_ IS
'当前日期';

CREATE TABLE PORTAL_CAL_SHIFT (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   MEMO_                VARCHAR(2000)        NULL DEFAULT NULL,
   MINUTES_             INT4                 NULL DEFAULT NULL,
   IS_DEFAULT_          CHAR(1)              NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CAL_SHIFT PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_SHIFT IS
'工作日班次';

COMMENT ON COLUMN PORTAL_CAL_SHIFT.NAME_ IS
'班次名';

COMMENT ON COLUMN PORTAL_CAL_SHIFT.MEMO_ IS
'描述';

COMMENT ON COLUMN PORTAL_CAL_SHIFT.MINUTES_ IS
'工时,精确到分钟';

CREATE TABLE PORTAL_CAL_SHIFT_PEROID (
   ID_                  VARCHAR(64)          NOT NULL,
   SHIFT_ID_            VARCHAR(64)          NOT NULL,
   START_TIME_          VARCHAR(64)          NULL DEFAULT NULL,
   END_TIME_            VARCHAR(64)          NULL DEFAULT NULL,
   MEMO_                VARCHAR(2000)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_CAL_SHIFT_PEROID PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_CAL_SHIFT_PEROID IS
'班次时间段';

COMMENT ON COLUMN PORTAL_CAL_SHIFT_PEROID.SHIFT_ID_ IS
'班次ID';

COMMENT ON COLUMN PORTAL_CAL_SHIFT_PEROID.START_TIME_ IS
'开始时间';

COMMENT ON COLUMN PORTAL_CAL_SHIFT_PEROID.END_TIME_ IS
'结束时间';

COMMENT ON COLUMN PORTAL_CAL_SHIFT_PEROID.MEMO_ IS
'备注';

CREATE TABLE PORTAL_DATA_SENSITIVE (
   ID_                  VARCHAR(64)          NOT NULL,
   DATA_SOURCE_ALIAS_   VARCHAR(255)         NULL DEFAULT NULL,
   TABLE_NAME_          VARCHAR(255)         NULL DEFAULT NULL,
   REULES_REMARK_       VARCHAR(1024)        NULL DEFAULT NULL,
   DESENSITIZATION_RULES_ TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_DATA_SENSITIVE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_DATA_SENSITIVE IS
'表字段脱敏处理';

COMMENT ON COLUMN PORTAL_DATA_SENSITIVE.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_DATA_SENSITIVE.DATA_SOURCE_ALIAS_ IS
'数据源别名';

COMMENT ON COLUMN PORTAL_DATA_SENSITIVE.TABLE_NAME_ IS
'表名';

COMMENT ON COLUMN PORTAL_DATA_SENSITIVE.REULES_REMARK_ IS
'规则说明';

COMMENT ON COLUMN PORTAL_DATA_SENSITIVE.DESENSITIZATION_RULES_ IS
'脱敏规则';

COMMENT ON COLUMN PORTAL_DATA_SENSITIVE.TENANT_ID_ IS
'租户id';

CREATE TABLE PORTAL_FLOW_UPLOAD_PROPERTIES (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   FLOW_KEY_            TEXT                 NULL,
   FLOW_NAME_           TEXT                 NULL,
   UPLOAD_TYPE_         VARCHAR(20)          NULL DEFAULT NULL,
   LOCATION_            VARCHAR(200)         NULL DEFAULT NULL,
   FTP_URL_             VARCHAR(200)         NULL DEFAULT NULL,
   FTP_PORT_            INT4                 NULL DEFAULT NULL,
   FTP_USER_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   FTP_PASSWORD_        VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(20)          NULL DEFAULT NULL,
   ENCRYPT_NAME_        INT4                 NULL DEFAULT NULL,
   DESC_                VARCHAR(600)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   ALIYUN_OSS_ENDPOINT_ VARCHAR(255)         NULL,
   ALIYUN_OSS_ACCESSKEYID_ VARCHAR(255)         NULL,
   ALIYUN_OSS_ACCESSKEYSECRET_ VARCHAR(255)         NULL,
   CONSTRAINT PK_PORTAL_FLOW_UPLOAD_PROPERTI PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_FLOW_UPLOAD_PROPERTIES IS
'流程附件上传配置';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.NAME_ IS
'名称';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.FLOW_KEY_ IS
'流程key';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.FLOW_NAME_ IS
'流程名称';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.UPLOAD_TYPE_ IS
'上传方式：可用参数值：database（保存在数据库），folder（保存在服务器文件目录）；ftp（上传到ftp）';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.LOCATION_ IS
'文件存储位置（存储方式为folder时需指定）';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.FTP_URL_ IS
'ftp上传地址';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.FTP_PORT_ IS
'FTP端口号';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.FTP_USER_NAME_ IS
'ftp认证用户名';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.FTP_PASSWORD_ IS
'FTP认证用户密码';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.STATUS_ IS
'状态：enable(生效)，disable（无效）';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.ENCRYPT_NAME_ IS
'文件名是否加密（1：加密，0：不加密）';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.DESC_ IS
'描述';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.CREATE_BY_ IS
'创建人id';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.CREATE_ORG_ID_ IS
'创建人所属部门id';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.UPDATE_BY_ IS
'更新人id';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.TENANT_ID_ IS
'租户id';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.ALIYUN_OSS_ENDPOINT_ IS
'访问域名 endpoint';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.ALIYUN_OSS_ACCESSKEYID_ IS
'访问密钥ID accessKeyId';

COMMENT ON COLUMN PORTAL_FLOW_UPLOAD_PROPERTIES.ALIYUN_OSS_ACCESSKEYSECRET_ IS
'访问密钥 accessKeySecret';

CREATE TABLE PORTAL_I18N_MESSAGE (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_                VARCHAR(30)          NOT NULL,
   KEY_                 VARCHAR(255)         NOT NULL,
   VALUE_               TEXT                 NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_I18N_MESSAGE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_I18N_MESSAGE IS
'国际化资源';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE.TYPE_ IS
'类型';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE.KEY_ IS
'资源KEY';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE.CREATE_ORG_ID_ IS
'创建人所属组织ID';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE.UPDATE_BY_ IS
'更新人ID';

CREATE TABLE PORTAL_I18N_MESSAGE_ERROR (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_                VARCHAR(64)          NOT NULL,
   KEY_                 VARCHAR(255)         NOT NULL,
   COUNT_               NUMERIC(38,30)       NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_I18N_MESSAGE_ERROR PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_I18N_MESSAGE_ERROR IS
'国际化资源异常日志';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE_ERROR.TYPE_ IS
'类型';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE_ERROR.KEY_ IS
'资源KEY';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE_ERROR.COUNT_ IS
'异常数量';

CREATE TABLE PORTAL_I18N_MESSAGE_TYPE (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_                VARCHAR(30)          NOT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_I18N_MESSAGE_TYPE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_I18N_MESSAGE_TYPE IS
'国际化资源支持的语言类型';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE_TYPE.TYPE_ IS
'类型';

COMMENT ON COLUMN PORTAL_I18N_MESSAGE_TYPE.DESC_ IS
'说明';


CREATE TABLE PORTAL_MESSAGE_LOG (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(600)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   SENDER_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   SENDER_NAME_         VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVERS_           VARCHAR(4000)        NULL DEFAULT NULL,
   IS_SUCCESS_          INT2                 NULL DEFAULT 0,
   EXCEPTION_           VARCHAR(2000)        NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CONTENT_             TEXT                 NULL,
   MSG_VO_              TEXT                 NULL,
   RETRY_COUNT_         INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_MESSAGE_LOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_MESSAGE_LOG IS
'消息日志';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.SUBJECT_ IS
'标题';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.TYPE_ IS
'消息类型';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.SENDER_ID_ IS
'发送人ID';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.SENDER_NAME_ IS
'发送人姓名';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.RECEIVERS_ IS
'消息接收人';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.IS_SUCCESS_ IS
'是否发送成功';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.EXCEPTION_ IS
'异常信息';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.CONTENT_ IS
'消息内容';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.MSG_VO_ IS
'消息VO';

COMMENT ON COLUMN PORTAL_MESSAGE_LOG.RETRY_COUNT_ IS
'重试次数';

CREATE TABLE PORTAL_MY_SCHEDULE (
   ID_                  VARCHAR(64)          NOT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   DATE_                TIMESTAMP                 NULL,
   START_TIEM_          VARCHAR(20)          NULL DEFAULT NULL,
   END_TIME_            VARCHAR(20)          NULL DEFAULT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   NOTE_                VARCHAR(500)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_MY_SCHEDULE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_MY_SCHEDULE IS
'行程管理';

COMMENT ON COLUMN PORTAL_MY_SCHEDULE.USER_ID_ IS
'用户id';

COMMENT ON COLUMN PORTAL_MY_SCHEDULE.START_TIEM_ IS
'日程开始时间';

COMMENT ON COLUMN PORTAL_MY_SCHEDULE.END_TIME_ IS
'日程结束时间';

COMMENT ON COLUMN PORTAL_MY_SCHEDULE.NAME_ IS
'日程名称';

COMMENT ON COLUMN PORTAL_MY_SCHEDULE.NOTE_ IS
'日程说明';

CREATE TABLE PORTAL_NEWS_NOTICE_ (
   ID_                  VARCHAR(64)          NOT NULL,
   CLASSIFY_ID_         VARCHAR(255)         NULL DEFAULT NULL,
   CLASSIFY_NAME_       VARCHAR(255)         NULL DEFAULT NULL,
   CLASSIFY_PATH_       VARCHAR(255)         NULL DEFAULT NULL,
   TITLE_               VARCHAR(255)         NULL DEFAULT NULL,
   IS_URL_              VARCHAR(255)         NULL DEFAULT NULL,
   URL_                 TEXT                 NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   END_TIME_            TIMESTAMP                 NULL,
   ROTATING_DISPLAY_PICTURES_ VARCHAR(255)         NULL DEFAULT NULL,
   TITLE_DESCRIPTION_   VARCHAR(255)         NULL DEFAULT NULL,
   PAGE_HEIGHT_         VARCHAR(10)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(255)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                INT4                 NULL DEFAULT NULL,
   ICON_                VARCHAR(255)         NULL DEFAULT NULL,
   FILE_                VARCHAR(255)         NULL DEFAULT NULL,
   DRAFTER_             VARCHAR(255)         NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_NEWS_NOTICE_ PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_NEWS_NOTICE_ IS
'新闻公告表';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.CLASSIFY_ID_ IS
'所属分类ID';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.CLASSIFY_NAME_ IS
'所属分类NAME';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.CLASSIFY_PATH_ IS
'所属分类路径';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.TITLE_ IS
'标题';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.IS_URL_ IS
'是否外部链接(true为是,false为不是)';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.URL_ IS
'内容URL';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.CONTENT_ IS
'内容';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.SN_ IS
'排序';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.ROTATING_DISPLAY_PICTURES_ IS
'轮播展示图片';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.TITLE_DESCRIPTION_ IS
'标题描述';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.PAGE_HEIGHT_ IS
'页面嵌套高度';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.TENANT_ID_ IS
'租户ID';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.TYPE_ IS
'所属类型(1为轮播图,2为新闻公告)';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.ICON_ IS
'图标';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.FILE_ IS
'附件';

COMMENT ON COLUMN PORTAL_NEWS_NOTICE_.DRAFTER_ IS
'拟稿人';

CREATE TABLE PORTAL_NEWS_TREE_ (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(255)         NULL DEFAULT NULL,
   PATH_                VARCHAR(255)         NULL DEFAULT NULL,
   PARENT_ID_           VARCHAR(255)         NULL DEFAULT NULL,
   RANK_                INT4                 NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   PARENT_NAME_         VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(255)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   COL_HEIGHT_          INT4                 NULL DEFAULT NULL,
   COLUMN_ID_           VARCHAR(255)         NULL DEFAULT NULL,
   INTERVAL_TIME_       INT4                 NULL DEFAULT NULL,
   MOBILE_ISSUE_        INT4                 NULL,
   CONSTRAINT PK_PORTAL_NEWS_TREE_ PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_NEWS_TREE_ IS
'新闻公告树表';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.NAME_ IS
'名称';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.PATH_ IS
'路径';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.PARENT_ID_ IS
'上级id';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.RANK_ IS
'级别(总共有3级)';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.SN_ IS
'排序';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.PARENT_NAME_ IS
'路径名称';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.TENANT_ID_ IS
'租户ID';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.COL_HEIGHT_ IS
'高度';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.COLUMN_ID_ IS
'首页栏目ID';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.INTERVAL_TIME_ IS
'轮播图间隔时间';

COMMENT ON COLUMN PORTAL_NEWS_TREE_.MOBILE_ISSUE_ IS
'手机端是否发布 0：未发布  1：发布';

CREATE TABLE PORTAL_SERVICE_PARAM (
   ID_                  VARCHAR(64)          NOT NULL,
   SET_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                VARCHAR(40)          NULL DEFAULT NULL,
   DESC_                VARCHAR(512)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SERVICE_PARAM PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SERVICE_PARAM IS
'服务调用参数表';

COMMENT ON COLUMN PORTAL_SERVICE_PARAM.SET_ID_ IS
'服务设置ID';

COMMENT ON COLUMN PORTAL_SERVICE_PARAM.NAME_ IS
'参数名称';

COMMENT ON COLUMN PORTAL_SERVICE_PARAM.TYPE_ IS
'参数类型';

COMMENT ON COLUMN PORTAL_SERVICE_PARAM.DESC_ IS
'参数说明';

CREATE TABLE PORTAL_SERVICE_SET (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(255)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(64)          NULL DEFAULT NULL,
   URL_                 VARCHAR(1024)        NULL DEFAULT NULL,
   ADDRESS_             VARCHAR(1024)        NULL DEFAULT NULL,
   METHOD_NAME_         VARCHAR(200)         NULL DEFAULT NULL,
   NAMESPACE_           VARCHAR(512)         NULL DEFAULT NULL,
   SOAP_ACTION_         CHAR(1)              NOT NULL,
   INPUT_SET_           TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SERVICE_SET PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SERVICE_SET IS
'服务调用设置表';

COMMENT ON COLUMN PORTAL_SERVICE_SET.NAME_ IS
'名称';

COMMENT ON COLUMN PORTAL_SERVICE_SET.ALIAS_ IS
'别名';

COMMENT ON COLUMN PORTAL_SERVICE_SET.URL_ IS
'wsdl地址';

COMMENT ON COLUMN PORTAL_SERVICE_SET.ADDRESS_ IS
'接口调用地址';

COMMENT ON COLUMN PORTAL_SERVICE_SET.METHOD_NAME_ IS
'调用的方法名称';

COMMENT ON COLUMN PORTAL_SERVICE_SET.NAMESPACE_ IS
'名称空间';

COMMENT ON COLUMN PORTAL_SERVICE_SET.SOAP_ACTION_ IS
'构建soap的模式';

COMMENT ON COLUMN PORTAL_SERVICE_SET.INPUT_SET_ IS
'输入参数设定';

CREATE TABLE PORTAL_SYS_APP (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   ICON_                TEXT                 NULL DEFAULT NULL,
   ICON_COLOR_          VARCHAR(10)          NULL DEFAULT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   MENU_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   IS_PUBLISH_          SMALLINT             NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   CREATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_APP PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_APP IS
'服务应用表';

COMMENT ON COLUMN PORTAL_SYS_APP.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_SYS_APP.NAME_ IS
'应用名称';

COMMENT ON COLUMN PORTAL_SYS_APP.ICON_ IS
'图标';

COMMENT ON COLUMN PORTAL_SYS_APP.ICON_COLOR_ IS
'图标颜色';

COMMENT ON COLUMN PORTAL_SYS_APP.TYPE_ IS
'类型';

COMMENT ON COLUMN PORTAL_SYS_APP.MENU_ID_ IS
'菜单id';

COMMENT ON COLUMN PORTAL_SYS_APP.IS_PUBLISH_ IS
'是否发布 1发布 0未发布';

COMMENT ON COLUMN PORTAL_SYS_APP.SN_ IS
'顺序';

COMMENT ON COLUMN PORTAL_SYS_APP.CONTENT_ IS
'内容';

COMMENT ON COLUMN PORTAL_SYS_APP.CREATE_TIME_ IS
'创建时间';

COMMENT ON COLUMN PORTAL_SYS_APP.UPDATE_TIME_ IS
'更新时间';

COMMENT ON COLUMN PORTAL_SYS_APP.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN PORTAL_SYS_APP.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN PORTAL_SYS_APP.TENANT_ID_ IS
'租户ID';

CREATE TABLE PORTAL_SYS_APP_MENU (
   ID_                  VARCHAR(64)          NOT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(255)         NULL DEFAULT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   SN_                  VARCHAR(255)         NULL DEFAULT NULL,
   APP_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_APP_MENU PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_APP_MENU IS
'应用菜单表';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.PARENT_ID_ IS
'父节点ID';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.NAME_ IS
'菜单名称';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.ALIAS_ IS
'别名';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.TYPE_ IS
'类型';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.CONTENT_ IS
'内容';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.SN_ IS
'排序';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.APP_ID_ IS
'APPID';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.CREATE_TIME_ IS
'创建时间';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.UPDATE_TIME_ IS
'更新时间';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN PORTAL_SYS_APP_MENU.TENANT_ID_ IS
'组合ID';

CREATE TABLE PORTAL_SYS_AUTH_USER (
   ID_                  VARCHAR(64)          NOT NULL,
   AUTHORIZE_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   RIGHT_TYPE_          VARCHAR(20)          NULL DEFAULT NULL,
   OBJ_TYPE_            VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_AUTH_USER PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_AUTH_USER IS
'流程授权中用户';

COMMENT ON COLUMN PORTAL_SYS_AUTH_USER.AUTHORIZE_ID_ IS
'流程授权主表ID';

COMMENT ON COLUMN PORTAL_SYS_AUTH_USER.OWNER_ID_ IS
'授权对象ID';

COMMENT ON COLUMN PORTAL_SYS_AUTH_USER.OWNER_NAME_ IS
'授权对象名称';

COMMENT ON COLUMN PORTAL_SYS_AUTH_USER.RIGHT_TYPE_ IS
'授权对象类型(角色,用户,岗位等)';

CREATE TABLE PORTAL_SYS_COLUMN (
   ID                   VARCHAR(64)          NOT NULL,
   NAME                 VARCHAR(100)         NULL DEFAULT NULL,
   ALIAS                VARCHAR(100)         NULL DEFAULT NULL,
   CATALOG              VARCHAR(64)          NULL DEFAULT NULL,
   COL_TYPE             INT2                 NULL DEFAULT NULL,
   DATA_MODE            INT2                 NULL DEFAULT NULL,
   DATA_FROM            VARCHAR(100)         NULL DEFAULT NULL,
   DS_ALIAS             VARCHAR(100)         NULL DEFAULT NULL,
   DS_NAME              VARCHAR(100)         NULL DEFAULT NULL,
   COL_HEIGHT           INT4                 NULL DEFAULT NULL,
   COL_URL              VARCHAR(100)         NULL DEFAULT NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   IS_PUBLIC            INT2                 NULL DEFAULT NULL,
   SUPPORT_REFESH       INT2                 NULL DEFAULT NULL,
   REFESH_TIME          INT4                 NULL DEFAULT NULL,
   SHOW_EFFECT          INT4                 NULL DEFAULT NULL,
   MEMO                 VARCHAR(255)         NULL DEFAULT NULL,
   DATA_PARAM           VARCHAR(2000)        NULL DEFAULT NULL,
   NEEDPAGE             INT2                 NULL DEFAULT NULL,
   ORG_ID               VARCHAR(64)          NULL DEFAULT NULL,
   CREATOR              VARCHAR(200)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   REQUEST_TYPE         VARCHAR(255)         NULL DEFAULT NULL,
   CATALOG_NAME         VARCHAR(100)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_COLUMN PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_COLUMN IS
'首页栏目';

COMMENT ON COLUMN PORTAL_SYS_COLUMN.REQUEST_TYPE IS
'如果是restful请求的话，需选择请求方式：POST或GET';

COMMENT ON COLUMN PORTAL_SYS_COLUMN.CATALOG_NAME IS
'分类名称';

CREATE TABLE PORTAL_SYS_DATASOURCE (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(64)          NOT NULL,
   DB_TYPE_             VARCHAR(64)          NULL DEFAULT NULL,
   SETTING_JSON_        TEXT                 NULL,
   INIT_ON_START_       INT2                 NULL DEFAULT NULL,
   ENABLED_             INT2                 NULL DEFAULT NULL,
   CLASS_PATH_          VARCHAR(128)         NULL DEFAULT NULL,
   INIT_METHOD_         VARCHAR(200)         NULL DEFAULT NULL,
   CLOSE_METHOD_        VARCHAR(150)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_DATASOURCE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_DATASOURCE IS
'数据源';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.NAME_ IS
'名称';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.ALIAS_ IS
'别名';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.DB_TYPE_ IS
'数据源id';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.SETTING_JSON_ IS
'Json存储配置';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.INIT_ON_START_ IS
'在启动时，启动连接池，并添加到spring容器中管理。';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.ENABLED_ IS
'是否生效';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.INIT_METHOD_ IS
'初始化方法，有些可以不填写';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE.CLOSE_METHOD_ IS
'关闭数据源的时候应该调用的方法，可不填';

CREATE TABLE PORTAL_SYS_DATASOURCE_DEF (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   CLASS_PATH_          VARCHAR(100)         NULL DEFAULT NULL,
   SETTING_JSON_        TEXT                 NULL,
   INIT_METHOD_         VARCHAR(64)          NULL DEFAULT NULL,
   IS_SYSTEM_           INT2                 NULL DEFAULT NULL,
   CLOSE_METHOD_        VARCHAR(150)         NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_DATASOURCE_DEF PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_DATASOURCE_DEF IS
'数据源配置';

COMMENT ON COLUMN PORTAL_SYS_DATASOURCE_DEF.IS_SYSTEM_ IS
'是系统默认的';

CREATE TABLE PORTAL_SYS_DIC (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   KEY_                 VARCHAR(40)          NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_DIC PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_DIC IS
'数据字典';

COMMENT ON COLUMN PORTAL_SYS_DIC.TYPE_ID_ IS
'类型ID';

COMMENT ON COLUMN PORTAL_SYS_DIC.KEY_ IS
'字典值代码,在同一个字典中值不能重复';

COMMENT ON COLUMN PORTAL_SYS_DIC.NAME_ IS
'字典值名称';

COMMENT ON COLUMN PORTAL_SYS_DIC.PARENT_ID_ IS
'父ID';

COMMENT ON COLUMN PORTAL_SYS_DIC.SN_ IS
'排序号';

CREATE TABLE PORTAL_SYS_EXTERNAL_UNITE (
   ID_                  VARCHAR(64)          NOT NULL,
   CORP_NAME_           VARCHAR(60)          NULL DEFAULT NULL,
   CORP_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   CORP_SECRET_         VARCHAR(255)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(50)          NULL DEFAULT NULL,
   BASE_URL_            VARCHAR(255)         NULL DEFAULT NULL,
   AGENT_ID_            VARCHAR(255)         NULL DEFAULT NULL,
   MENU_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   AGENT_KEY_           VARCHAR(255)         NULL DEFAULT NULL,
   AGENT_SECRET_        VARCHAR(255)         NULL DEFAULT NULL,
   MENU_URL_            VARCHAR(1000)        NULL DEFAULT NULL,
   TEMP_MSG_ID_         VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_EXTERNAL_UNITE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_EXTERNAL_UNITE IS
'外部应用';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.CORP_NAME_ IS
'企业名称';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.CORP_ID_ IS
'企业id';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.CORP_SECRET_ IS
'企业secret';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.TYPE_ IS
'集成类型';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.BASE_URL_ IS
'本系统地址';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.AGENT_ID_ IS
'应用id';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.MENU_NAME_ IS
'菜单名称';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.AGENT_KEY_ IS
'应用key';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.AGENT_SECRET_ IS
'应用secret';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.MENU_URL_ IS
'菜单url';

COMMENT ON COLUMN PORTAL_SYS_EXTERNAL_UNITE.TEMP_MSG_ID_ IS
'微信公众号模板消息ID';

CREATE TABLE PORTAL_SYS_FILE (
   ID_                  VARCHAR(64)          NOT NULL,
   XB_TYPE_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   FILE_NAME_           VARCHAR(128)         NOT NULL,
   FILE_TYPE_           VARCHAR(40)          NULL DEFAULT NULL,
   STORE_TYPE_          VARCHAR(40)          NULL DEFAULT NULL,
   FILE_PATH_           VARCHAR(255)         NULL DEFAULT NULL,
   BYTES_               BYTEA                NULL,
   BYTE_COUNT_          INT4                 NULL DEFAULT NULL,
   EXT_                 VARCHAR(20)          NULL DEFAULT NULL,
   NOTE_                VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATOR_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   IS_DEL_              CHAR(1)              NOT NULL,
   PROP1_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP2_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP3_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP4_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP5_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP6_               TEXT                 NULL,
   TYPE_                VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CONSTRAINT PK_PORTAL_SYS_FILE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_FILE IS
'附件表';

COMMENT ON COLUMN PORTAL_SYS_FILE.XB_TYPE_ID_ IS
'附件分类ID';

COMMENT ON COLUMN PORTAL_SYS_FILE.FILE_TYPE_ IS
'所属分类';

COMMENT ON COLUMN PORTAL_SYS_FILE.PROP1_ IS
'扩展属性1';

COMMENT ON COLUMN PORTAL_SYS_FILE.PROP2_ IS
'扩展属性2';

COMMENT ON COLUMN PORTAL_SYS_FILE.PROP3_ IS
'扩展属性3';

COMMENT ON COLUMN PORTAL_SYS_FILE.PROP4_ IS
'扩展属性4';

COMMENT ON COLUMN PORTAL_SYS_FILE.PROP5_ IS
'扩展属性5';

COMMENT ON COLUMN PORTAL_SYS_FILE.PROP6_ IS
'扩展属性6';

CREATE TABLE PORTAL_SYS_FILE_CLASSIFY (
   ID                   VARCHAR(255)         NOT NULL,
   NAME                 VARCHAR(255)         NULL DEFAULT NULL,
   PARENTID             VARCHAR(255)         NULL DEFAULT NULL,
   ORDERNO              NUMERIC(10,0)        NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CONSTRAINT PK_PORTAL_SYS_FILE_CLASSIFY PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_FILE_CLASSIFY IS
'附件分类信息';

CREATE TABLE PORTAL_SYS_IDENTITY (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   ALIAS_               VARCHAR(20)          NULL DEFAULT NULL,
   REGULATION_          VARCHAR(128)         NULL DEFAULT NULL,
   GEN_TYPE_            INT2                 NULL DEFAULT NULL,
   NO_LENGTH_           INT4                 NULL DEFAULT NULL,
   CUR_DATE_            VARCHAR(20)          NULL DEFAULT NULL,
   INIT_VALUE_          INT4                 NULL DEFAULT NULL,
   CUR_VALUE_           INT4                 NULL DEFAULT NULL,
   STEP_                INT2                 NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_IDENTITY PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_IDENTITY IS
'流水号定义';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.NAME_ IS
'名称';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.ALIAS_ IS
'别名';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.REGULATION_ IS
'规则';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.GEN_TYPE_ IS
'生成类型';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.NO_LENGTH_ IS
'流水号长度';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.CUR_DATE_ IS
'当前日期';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.INIT_VALUE_ IS
'初始值';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.CUR_VALUE_ IS
'当前值';

COMMENT ON COLUMN PORTAL_SYS_IDENTITY.STEP_ IS
'步长';

CREATE TABLE PORTAL_SYS_JOBLOG (
   ID_                  VARCHAR(50)          NOT NULL,
   JOB_NAME_            VARCHAR(100)         NULL DEFAULT NULL,
   TRIG_NAME_           VARCHAR(100)         NULL DEFAULT NULL,
   START_TIME_          TIMESTAMP                 NULL,
   END_TIME_            TIMESTAMP                 NULL,
   CONTENT_             TEXT                 NULL,
   STATE_               INT4                 NULL DEFAULT NULL,
   RUN_TIME_            INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_JOBLOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_JOBLOG IS
'定时器日志';

COMMENT ON COLUMN PORTAL_SYS_JOBLOG.JOB_NAME_ IS
'任务名称';

COMMENT ON COLUMN PORTAL_SYS_JOBLOG.TRIG_NAME_ IS
'计划名称';

COMMENT ON COLUMN PORTAL_SYS_JOBLOG.CONTENT_ IS
'日志内容';

COMMENT ON COLUMN PORTAL_SYS_JOBLOG.STATE_ IS
'处理状态';

COMMENT ON COLUMN PORTAL_SYS_JOBLOG.RUN_TIME_ IS
'运行时长';

CREATE TABLE PORTAL_SYS_LAYOUT (
   ID                   VARCHAR(64)          NOT NULL,
   NAME                 VARCHAR(100)         NULL DEFAULT NULL,
   MEMO                 VARCHAR(200)         NULL DEFAULT NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   SN                   INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_LAYOUT PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_LAYOUT IS
'首页布局';

CREATE TABLE PORTAL_SYS_LAYOUT_MANAGE (
   ID                   VARCHAR(64)          NOT NULL,
   NAME                 VARCHAR(100)         NULL DEFAULT NULL,
   MEMO                 VARCHAR(200)         NULL DEFAULT NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   DESIGN_HTML          TEXT                 NULL,
   IS_DEF               INT2                 NULL DEFAULT NULL,
   LAYOUT_TYPE          INT2                 NULL DEFAULT NULL,
   ORG_ID               VARCHAR(64)          NULL DEFAULT NULL,
   ORG_NAME             VARCHAR(255)         NULL DEFAULT NULL,
   ENABLE               INT2                 NULL DEFAULT NULL,
   SHARE_TO_SUB         INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_LAYOUT_MANAGE PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_LAYOUT_MANAGE IS
'布局管理';

COMMENT ON COLUMN PORTAL_SYS_LAYOUT_MANAGE.ENABLE IS
'是否启用(1=启用，0=停用)';

COMMENT ON COLUMN PORTAL_SYS_LAYOUT_MANAGE.SHARE_TO_SUB IS
'是否共享给子部门（1=是，0=否）';

CREATE TABLE PORTAL_SYS_LAYOUT_SETTING (
   ID_                  INT4                 NOT NULL,
   LAYOUT_ID_           VARCHAR(20)          NULL DEFAULT NULL,
   LOGO_                VARCHAR(200)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_LAYOUT_SETTING PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_LAYOUT_SETTING IS
'布局设置';

CREATE TABLE PORTAL_SYS_LAYOUT_TOOLS (
   ID_                  INT4                 NOT NULL,
   LAYOUT_ID_           VARCHAR(20)          NULL DEFAULT NULL,
   TOOLS_IDS            TEXT                 NULL,
   TOOLS_TYPE           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_LAYOUT_TOOLS PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_LAYOUT_TOOLS IS
'布局工具设置';

CREATE TABLE PORTAL_SYS_LOGS (
   ID_                  VARCHAR(64)          NOT NULL,
   OPE_NAME_            VARCHAR(500)         NULL DEFAULT NULL,
   EXECUTION_TIME_      TIMESTAMP                 NULL,
   EXECUTOR_            VARCHAR(128)         NULL DEFAULT NULL,
   IP_                  VARCHAR(64)          NULL DEFAULT NULL,
   LOG_TYPE_            VARCHAR(64)          NULL DEFAULT NULL,
   MODULE_TYPE_         VARCHAR(255)         NULL DEFAULT NULL,
   REQ_URL_             VARCHAR(128)         NULL DEFAULT NULL,
   OPE_CONTENT_         TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_LOGS PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_LOGS IS
'系统操作日志';

COMMENT ON COLUMN PORTAL_SYS_LOGS.OPE_NAME_ IS
'操作名称';

COMMENT ON COLUMN PORTAL_SYS_LOGS.EXECUTOR_ IS
'执行人';

COMMENT ON COLUMN PORTAL_SYS_LOGS.IP_ IS
'ip地址';

COMMENT ON COLUMN PORTAL_SYS_LOGS.LOG_TYPE_ IS
'日志类型';

COMMENT ON COLUMN PORTAL_SYS_LOGS.MODULE_TYPE_ IS
'模块';

COMMENT ON COLUMN PORTAL_SYS_LOGS.REQ_URL_ IS
'请求地址';

COMMENT ON COLUMN PORTAL_SYS_LOGS.OPE_CONTENT_ IS
'操作内容';

CREATE TABLE PORTAL_SYS_LOGS_SETTINGS (
   ID_                  VARCHAR(64)          NOT NULL,
   MODULE_TYPE_         VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(1)           NULL DEFAULT NULL,
   SAVE_DAYS_           INT4                 NULL DEFAULT NULL,
   REMARK_              VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_LOGS_SETTINGS PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_LOGS_SETTINGS IS
'日志配置';

COMMENT ON COLUMN PORTAL_SYS_LOGS_SETTINGS.MODULE_TYPE_ IS
'模块';

COMMENT ON COLUMN PORTAL_SYS_LOGS_SETTINGS.STATUS_ IS
'状态';

COMMENT ON COLUMN PORTAL_SYS_LOGS_SETTINGS.SAVE_DAYS_ IS
'保留天数';

COMMENT ON COLUMN PORTAL_SYS_LOGS_SETTINGS.REMARK_ IS
'描述';

CREATE TABLE PORTAL_SYS_MAIL (
   ID_                  VARCHAR(20)          NOT NULL,
   TITLE_               VARCHAR(512)         NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   SENDER_ADDRESSES_    VARCHAR(128)         NULL DEFAULT NULL,
   SENDER_NAME_         VARCHAR(128)         NULL DEFAULT NULL,
   RECEIVER_ADDRESSES_  VARCHAR(2000)        NULL DEFAULT NULL,
   RECEIVER_NAMES_      VARCHAR(2000)        NULL DEFAULT NULL,
   CC_ADDRESSES_        VARCHAR(2000)        NULL DEFAULT NULL,
   BCC_NAMES_           VARCHAR(2000)        NULL DEFAULT NULL,
   BCC_ADDRESSES_       VARCHAR(2000)        NULL DEFAULT NULL,
   CC_NAMES_            VARCHAR(2000)        NULL DEFAULT NULL,
   MESSAGE_ID_          VARCHAR(128)         NULL DEFAULT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   IS_REPLY_            INT2                 NULL DEFAULT NULL,
   SEND_DATE_           TIMESTAMP                 NULL,
   FILE_IDS_            VARCHAR(512)         NULL DEFAULT NULL,
   IS_READ_             INT2                 NULL DEFAULT NULL,
   SET_ID_              VARCHAR(20)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MAIL PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MAIL IS
'外部邮件';

COMMENT ON COLUMN PORTAL_SYS_MAIL.TITLE_ IS
'主题';

COMMENT ON COLUMN PORTAL_SYS_MAIL.CONTENT_ IS
'内容';

COMMENT ON COLUMN PORTAL_SYS_MAIL.SENDER_ADDRESSES_ IS
'发件人地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL.SENDER_NAME_ IS
'发件人地址别名';

COMMENT ON COLUMN PORTAL_SYS_MAIL.RECEIVER_ADDRESSES_ IS
'收件人地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL.RECEIVER_NAMES_ IS
'收件人地址别名';

COMMENT ON COLUMN PORTAL_SYS_MAIL.CC_ADDRESSES_ IS
'抄送人地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL.BCC_NAMES_ IS
'暗送人地址别名';

COMMENT ON COLUMN PORTAL_SYS_MAIL.BCC_ADDRESSES_ IS
'暗送人地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL.CC_NAMES_ IS
'抄送人地址别名';

COMMENT ON COLUMN PORTAL_SYS_MAIL.MESSAGE_ID_ IS
'邮件ID';

COMMENT ON COLUMN PORTAL_SYS_MAIL.TYPE_ IS
'邮件类型 1:收件箱;2:发件箱;3:草稿箱;4:垃圾箱';

COMMENT ON COLUMN PORTAL_SYS_MAIL.USER_ID_ IS
'用户ID';

COMMENT ON COLUMN PORTAL_SYS_MAIL.IS_REPLY_ IS
'是否回复';

COMMENT ON COLUMN PORTAL_SYS_MAIL.FILE_IDS_ IS
'附件ID';

COMMENT ON COLUMN PORTAL_SYS_MAIL.IS_READ_ IS
'是否已读';

CREATE TABLE PORTAL_SYS_MAIL_ATTACHEMENT (
   FILEID               VARCHAR(20)          NOT NULL,
   FILENAME             VARCHAR(128)         NULL DEFAULT NULL,
   FILEPATH             VARCHAR(128)         NULL DEFAULT NULL,
   MAILID               VARCHAR(20)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MAIL_ATTACHEMENT PRIMARY KEY (FILEID)
);

COMMENT ON TABLE PORTAL_SYS_MAIL_ATTACHEMENT IS
'外部邮件附件表';

COMMENT ON COLUMN PORTAL_SYS_MAIL_ATTACHEMENT.FILENAME IS
'文件名';

COMMENT ON COLUMN PORTAL_SYS_MAIL_ATTACHEMENT.FILEPATH IS
'文件存放路径';

COMMENT ON COLUMN PORTAL_SYS_MAIL_ATTACHEMENT.MAILID IS
'邮件ID';

CREATE TABLE PORTAL_SYS_MAIL_LINKMAN (
   ID                   VARCHAR(64)          NOT NULL,
   USERID               VARCHAR(64)          NULL DEFAULT NULL,
   MAILID               VARCHAR(64)          NULL DEFAULT NULL,
   SENDTIME             TIMESTAMP                 NULL,
   LINKNAME             VARCHAR(20)          NULL DEFAULT NULL,
   LINKADDRESS          VARCHAR(2000)        NULL DEFAULT NULL,
   SENDTIMES            INT4                 NULL DEFAULT NULL,
   PHONE                VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MAIL_LINKMAN PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_MAIL_LINKMAN IS
'外部邮件最近联系';

COMMENT ON COLUMN PORTAL_SYS_MAIL_LINKMAN.ID IS
'主键';

COMMENT ON COLUMN PORTAL_SYS_MAIL_LINKMAN.USERID IS
'用户ID';

COMMENT ON COLUMN PORTAL_SYS_MAIL_LINKMAN.MAILID IS
'邮件地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL_LINKMAN.LINKNAME IS
'联系人名称';

COMMENT ON COLUMN PORTAL_SYS_MAIL_LINKMAN.LINKADDRESS IS
'联系人地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL_LINKMAN.SENDTIMES IS
'发送次数';

CREATE TABLE PORTAL_SYS_MAIL_SETTING (
   ID_                  VARCHAR(20)          NOT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   SEND_HOST_           VARCHAR(128)         NULL DEFAULT NULL,
   SEND_PORT_           VARCHAR(128)         NULL DEFAULT NULL,
   RECEIVE_HOST_        VARCHAR(255)         NULL DEFAULT NULL,
   RECEIVE_PORT_        VARCHAR(255)         NULL DEFAULT NULL,
   PROTOCAL_            VARCHAR(255)         NULL DEFAULT NULL,
   USER_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   MAIL_ADDRESS_        VARCHAR(128)         NULL DEFAULT NULL,
   MAIL_PASS_           VARCHAR(128)         NULL DEFAULT NULL,
   SMTP_HOST_           VARCHAR(128)         NULL DEFAULT NULL,
   SMTP_PORT_           VARCHAR(64)          NULL DEFAULT NULL,
   POP_HOST_            VARCHAR(128)         NULL DEFAULT NULL,
   POP_PORT_            VARCHAR(64)          NULL DEFAULT NULL,
   IMAP_HOST_           VARCHAR(128)         NULL DEFAULT NULL,
   IMAP_PORT_           VARCHAR(64)          NULL DEFAULT NULL,
   IS_DEFAULT_          INT2                 NULL DEFAULT NULL,
   MAIL_TYPE_           VARCHAR(50)          NULL DEFAULT NULL,
   USE_SSL_             INT2                 NULL DEFAULT 0,
   IS_VALIDATE_         INT2                 NULL DEFAULT 1,
   IS_DELETE_REMOTE_    INT2                 NULL DEFAULT 0,
   IS_HANDLE_ATTACH_    INT2                 NULL DEFAULT 0,
   LAST_MESSAGE_ID_     VARCHAR(255)         NULL DEFAULT NULL,
   LAST_RECEIVE_TIME_   TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MAIL_SETTING PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MAIL_SETTING IS
'外部邮件用户设置';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.USER_ID_ IS
'用户ID';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.USER_NAME_ IS
'用户名称';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.MAIL_ADDRESS_ IS
'外部邮箱地址';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.MAIL_PASS_ IS
'外部邮箱密码';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.SMTP_HOST_ IS
'smt主机';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.SMTP_PORT_ IS
'smt端口';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.POP_HOST_ IS
'收邮件的主机';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.POP_PORT_ IS
'收邮件的主机端口';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.IMAP_HOST_ IS
'imap主机';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.IMAP_PORT_ IS
'imap端口';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.IS_DEFAULT_ IS
'是否默认';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.MAIL_TYPE_ IS
'接收邮件服务器类型';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.USE_SSL_ IS
'是否使用SSL认证。0：否；1：是';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.IS_VALIDATE_ IS
'是否需要身份验证。0：否；1：是';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.IS_DELETE_REMOTE_ IS
'下载时，是否删除远程邮件。0：否；1：是';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.IS_HANDLE_ATTACH_ IS
'是否下载附件。0：否；1：是';

COMMENT ON COLUMN PORTAL_SYS_MAIL_SETTING.LAST_MESSAGE_ID_ IS
'上一条消息ID';

CREATE TABLE PORTAL_SYS_MENU (
   ID_                  VARCHAR(64)          NOT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   ALIAS_               VARCHAR(128)         NULL DEFAULT NULL,
   ACTIVE_TAB_          VARCHAR(128)         NULL DEFAULT NULL,
   MENU_ICON_           VARCHAR(64)          NULL DEFAULT NULL,
   OPENED_              INT4                 NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   TABS_STYLE_          VARCHAR(64)          NULL DEFAULT NULL,
   PATH_                VARCHAR(4000)        NULL DEFAULT NULL,
   HREF_                VARCHAR(2000)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MENU PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MENU IS
'系统菜单';

COMMENT ON COLUMN PORTAL_SYS_MENU.PARENT_ID_ IS
'父id';

COMMENT ON COLUMN PORTAL_SYS_MENU.NAME_ IS
'菜单名称';

COMMENT ON COLUMN PORTAL_SYS_MENU.ALIAS_ IS
'别名用作state';

COMMENT ON COLUMN PORTAL_SYS_MENU.ACTIVE_TAB_ IS
'三级菜单激活的tab 在二级菜单中配置';

COMMENT ON COLUMN PORTAL_SYS_MENU.MENU_ICON_ IS
'图标';

COMMENT ON COLUMN PORTAL_SYS_MENU.OPENED_ IS
'默认展开    1展开 0 不展开';

COMMENT ON COLUMN PORTAL_SYS_MENU.TABS_STYLE_ IS
'标签页风格设置';

COMMENT ON COLUMN PORTAL_SYS_MENU.PATH_ IS
'菜单路径';

COMMENT ON COLUMN PORTAL_SYS_MENU.HREF_ IS
'外部Url地址';

CREATE TABLE PORTAL_SYS_METHOD (
   ID_                  VARCHAR(64)          NOT NULL,
   ALIAS_               VARCHAR(128)         NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   MENU_ALIAS_          VARCHAR(128)         NULL DEFAULT NULL,
   REQUEST_URL_         VARCHAR(256)         NULL DEFAULT NULL,
   PATH_                VARCHAR(1024)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_METHOD PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_METHOD IS
'系统请求方法的配置（用于角色权限配置）';

COMMENT ON COLUMN PORTAL_SYS_METHOD.ALIAS_ IS
'别名';

COMMENT ON COLUMN PORTAL_SYS_METHOD.NAME_ IS
'请求方法';

COMMENT ON COLUMN PORTAL_SYS_METHOD.MENU_ALIAS_ IS
'菜单资源别名';

COMMENT ON COLUMN PORTAL_SYS_METHOD.REQUEST_URL_ IS
'请求地址';

COMMENT ON COLUMN PORTAL_SYS_METHOD.PATH_ IS
'菜单路径';

CREATE TABLE PORTAL_SYS_MODULE (
   ID_                  VARCHAR(64)          NOT NULL,
   CODE_                VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(200)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(20)          NULL DEFAULT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   CLASSIFY_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   CLASSIFY_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   REL_CODE_            VARCHAR(64)          NULL DEFAULT NULL,
   REL_NAME_            VARCHAR(64)          NULL DEFAULT NULL,
   DESC_                VARCHAR(2000)        NULL DEFAULT NULL,
   MENU_                VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATOR_             VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(50)          NULL DEFAULT NULL,
   POST_CODE_           VARCHAR(64)          NULL DEFAULT NULL,
   POST_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   REPORT_NAME_         VARCHAR(255)         NULL DEFAULT NULL,
   REPORT_ALIAS         VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MODULE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MODULE IS
'系统模块';

CREATE TABLE PORTAL_SYS_MODULE_DETAIL (
   ID_                  VARCHAR(64)          NOT NULL,
   MODULE_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   COLUMN_NAME_         VARCHAR(64)          NULL DEFAULT NULL,
   CODE_                VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   VIEW_CODE_           VARCHAR(64)          NULL DEFAULT NULL,
   VIEW_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   URL_                 VARCHAR(300)         NULL DEFAULT NULL,
   CHART_TYPE_          VARCHAR(64)          NULL DEFAULT NULL,
   SHOW_TYPE_           VARCHAR(64)          NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MODULE_DETAIL PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MODULE_DETAIL IS
'系统模块详细';

COMMENT ON COLUMN PORTAL_SYS_MODULE_DETAIL.SN_ IS
'排序';

CREATE TABLE PORTAL_SYS_MSG (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(255)         NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_               VARCHAR(64)          NULL DEFAULT NULL,
   MESSAGE_TYPE_        VARCHAR(20)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CAN_REPLY_           INT2                 NULL DEFAULT NULL,
   IS_PUBLIC_           INT2                 NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   FILE_MSG_            VARCHAR(1024)        NULL DEFAULT NULL,
   RECEIVER_NAME_       TEXT                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MSG PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MSG IS
'系统信息';

COMMENT ON COLUMN PORTAL_SYS_MSG.SUBJECT_ IS
'主题';

COMMENT ON COLUMN PORTAL_SYS_MSG.OWNER_ID_ IS
'发帖人ID';

COMMENT ON COLUMN PORTAL_SYS_MSG.OWNER_ IS
'发帖人';

COMMENT ON COLUMN PORTAL_SYS_MSG.MESSAGE_TYPE_ IS
'消息类型';

COMMENT ON COLUMN PORTAL_SYS_MSG.CAN_REPLY_ IS
'是否可以回复';

COMMENT ON COLUMN PORTAL_SYS_MSG.IS_PUBLIC_ IS
'是否公告';

COMMENT ON COLUMN PORTAL_SYS_MSG.CONTENT_ IS
'内容';

COMMENT ON COLUMN PORTAL_SYS_MSG.FILE_MSG_ IS
'附件信息';

COMMENT ON COLUMN PORTAL_SYS_MSG.RECEIVER_NAME_ IS
'接收者名称';

CREATE TABLE PORTAL_SYS_MSG_READ (
   ID_                  VARCHAR(64)          NOT NULL,
   MSG_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_            VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_TIME_       TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MSG_READ PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MSG_READ IS
'系统消息查看';

COMMENT ON COLUMN PORTAL_SYS_MSG_READ.MSG_ID_ IS
'消息ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_READ.RECEIVER_ID_ IS
'消息接收人ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_READ.RECEIVER_ IS
'消息接收人';

CREATE TABLE PORTAL_SYS_MSG_RECEIVER (
   ID_                  VARCHAR(64)          NOT NULL,
   MSG_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_TYPE_       VARCHAR(20)          NULL DEFAULT NULL,
   RECEIVER_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_            VARCHAR(128)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MSG_RECEIVER PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MSG_RECEIVER IS
'系统消息接收';

COMMENT ON COLUMN PORTAL_SYS_MSG_RECEIVER.MSG_ID_ IS
'消息ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_RECEIVER.RECEIVER_TYPE_ IS
'接收者类型';

COMMENT ON COLUMN PORTAL_SYS_MSG_RECEIVER.RECEIVER_ID_ IS
'接收者ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_RECEIVER.RECEIVER_ IS
'接收者';

CREATE TABLE PORTAL_SYS_MSG_TPL (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(255)         NOT NULL,
   KEY_                 VARCHAR(64)          NOT NULL,
   TYPE_KEY_            VARCHAR(40)          NOT NULL,
   IS_DEFAULT_          NUMERIC(1,0)         NOT NULL,
   SUBJECT_             VARCHAR(128)         NULL DEFAULT NULL,
   PLAIN_               VARCHAR(1024)        NULL DEFAULT NULL,
   HTML_                TEXT                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   SMS_TEMPLATE_NO_     VARCHAR(40)          NULL DEFAULT NULL,
   VOICE_TEMPLATE_NO_   VARCHAR(40)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MSG_TPL PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_MSG_TPL IS
'消息模版';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.NAME_ IS
'模版名称';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.KEY_ IS
'模版业务键';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.TYPE_KEY_ IS
'模板分类。可以按任务操作类型分类，也可以按其它方式分类。';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.IS_DEFAULT_ IS
'是否默认模板。对于同一组（模板分类+二级分类）下的多个模板其中默认的一个。如果该模板分类下没有二级分类，则查询时是 同一模板分类下的默认模板。';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.SUBJECT_ IS
'标题';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.PLAIN_ IS
'纯文本';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.HTML_ IS
'模版体HTML';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.SMS_TEMPLATE_NO_ IS
'短信模板ID';

COMMENT ON COLUMN PORTAL_SYS_MSG_TPL.VOICE_TEMPLATE_NO_ IS
'电话语音模板id';

CREATE TABLE PORTAL_SYS_MY_LAYOUT (
   ID                   VARCHAR(20)          NOT NULL,
   USER_ID              VARCHAR(64)          NULL DEFAULT NULL,
   TEMPLATE_HTML        TEXT                 NULL,
   DESIGN_HTML          TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(255)         NULL DEFAULT NULL,
   VALID_               INT4                 NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_MY_LAYOUT PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_MY_LAYOUT IS
'个人首页布局';

COMMENT ON COLUMN PORTAL_SYS_MY_LAYOUT.VALID_ IS
'是否有效(1有效)';

CREATE TABLE PORTAL_SYS_NEWS_COLUMN (
   ID_                  VARCHAR(64)          NOT NULL,
   PORTAL_NEWS_ID_      VARCHAR(64)          NULL,
   NAME_                VARCHAR(255)         NULL,
   TYPE_                VARCHAR(10)          NULL,
   TENANT_ID_           VARCHAR(64)          NULL,
   CONSTRAINT PK_PORTAL_SYS_NEWS_COLUMN PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_NEWS_COLUMN IS
'新闻公告发布到手机端';

COMMENT ON COLUMN PORTAL_SYS_NEWS_COLUMN.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_SYS_NEWS_COLUMN.PORTAL_NEWS_ID_ IS
'公告ID';

COMMENT ON COLUMN PORTAL_SYS_NEWS_COLUMN.NAME_ IS
'公告名称';

COMMENT ON COLUMN PORTAL_SYS_NEWS_COLUMN.TYPE_ IS
'类型';

COMMENT ON COLUMN PORTAL_SYS_NEWS_COLUMN.TENANT_ID_ IS
'租户Id';

CREATE TABLE PORTAL_SYS_PROPERTIES (
   ID                   VARCHAR(64)          NOT NULL,
   NAME                 VARCHAR(64)          NULL DEFAULT NULL,
   ALIAS                VARCHAR(64)          NULL DEFAULT NULL,
   GROUP_               VARCHAR(64)          NULL DEFAULT NULL,
   VALUE                TEXT                 NULL,
   ENCRYPT              INT4                 NULL DEFAULT NULL,
   DESCRIPTION          VARCHAR(300)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_PROPERTIES PRIMARY KEY (ID)
);

COMMENT ON TABLE PORTAL_SYS_PROPERTIES IS
'系统配置属性';

COMMENT ON COLUMN PORTAL_SYS_PROPERTIES.ID IS
'主键';

COMMENT ON COLUMN PORTAL_SYS_PROPERTIES.NAME IS
'名称';

COMMENT ON COLUMN PORTAL_SYS_PROPERTIES.ALIAS IS
'别名';

COMMENT ON COLUMN PORTAL_SYS_PROPERTIES.GROUP_ IS
'分组';

COMMENT ON COLUMN PORTAL_SYS_PROPERTIES.ENCRYPT IS
'是否加密';

COMMENT ON COLUMN PORTAL_SYS_PROPERTIES.DESCRIPTION IS
'描述';

CREATE TABLE PORTAL_SYS_ROLE_AUTH (
   ID_                  VARCHAR(64)          NOT NULL,
   ROLE_ALIAS_          VARCHAR(128)         NULL DEFAULT NULL,
   MENU_ALIAS_          VARCHAR(128)         NULL DEFAULT NULL,
   METHOD_ALIAS_        VARCHAR(128)         NULL DEFAULT NULL,
   DATA_PERMISSION_     TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_ROLE_AUTH PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_ROLE_AUTH IS
'角色权限配置';

COMMENT ON COLUMN PORTAL_SYS_ROLE_AUTH.ROLE_ALIAS_ IS
'角色别名';

COMMENT ON COLUMN PORTAL_SYS_ROLE_AUTH.MENU_ALIAS_ IS
'菜单别名';

COMMENT ON COLUMN PORTAL_SYS_ROLE_AUTH.METHOD_ALIAS_ IS
'请求方法别名';

COMMENT ON COLUMN PORTAL_SYS_ROLE_AUTH.DATA_PERMISSION_ IS
'数据权限设置';

CREATE TABLE PORTAL_SYS_TAG (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   KEY_                 VARCHAR(40)          NULL DEFAULT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_TAG PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_TAG IS
'标签表';

COMMENT ON COLUMN PORTAL_SYS_TAG.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_SYS_TAG.TYPE_ID_ IS
'分类ID';

COMMENT ON COLUMN PORTAL_SYS_TAG.KEY_ IS
'标签KEY';

COMMENT ON COLUMN PORTAL_SYS_TAG.NAME_ IS
'标签名称';

COMMENT ON COLUMN PORTAL_SYS_TAG.SN_ IS
'排序';

COMMENT ON COLUMN PORTAL_SYS_TAG.TENANT_ID_ IS
'租户ID';

CREATE TABLE PORTAL_SYS_TOOLS (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(50)          NULL DEFAULT NULL,
   ICON_                VARCHAR(200)         NULL DEFAULT NULL,
   URL_                 VARCHAR(200)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(20)          NULL DEFAULT NULL,
   COUNT_MODE           INT2                 NULL DEFAULT NULL,
   COUNTING             VARCHAR(100)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   COUNT_PARAM          VARCHAR(200)         NULL DEFAULT NULL,
   FONT_STYLE           VARCHAR(200)         NULL DEFAULT NULL,
   NUMBER_STYLE         VARCHAR(200)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_TOOLS PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_TOOLS IS
'首页工具';

CREATE TABLE PORTAL_SYS_TYPE (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_GROUP_KEY_      VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NOT NULL,
   TYPE_KEY_            VARCHAR(64)          NOT NULL,
   STRU_TYPE_           VARCHAR(40)          NOT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   DEPTH_               INT4                 NULL DEFAULT NULL,
   PATH_                VARCHAR(255)         NULL DEFAULT NULL,
   IS_LEAF_             CHAR(1)              NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   SN_                  INT4                 NOT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   ICON_                VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SYS_TYPE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_TYPE IS
'总分类表。用于显示平级或树层次结构的分类，可以允许任何层次结构。';

COMMENT ON COLUMN PORTAL_SYS_TYPE.TYPE_GROUP_KEY_ IS
'所属分类组业务主键';

COMMENT ON COLUMN PORTAL_SYS_TYPE.NAME_ IS
'分类名称';

COMMENT ON COLUMN PORTAL_SYS_TYPE.TYPE_KEY_ IS
'节点的分类Key';

COMMENT ON COLUMN PORTAL_SYS_TYPE.STRU_TYPE_ IS
'flat 平行；tree 树形';

COMMENT ON COLUMN PORTAL_SYS_TYPE.PARENT_ID_ IS
'父节点';

COMMENT ON COLUMN PORTAL_SYS_TYPE.DEPTH_ IS
'层次';

COMMENT ON COLUMN PORTAL_SYS_TYPE.PATH_ IS
'路径';

COMMENT ON COLUMN PORTAL_SYS_TYPE.IS_LEAF_ IS
'是否叶子节点。Y=是；N=否';

COMMENT ON COLUMN PORTAL_SYS_TYPE.SN_ IS
'序号';

COMMENT ON COLUMN PORTAL_SYS_TYPE.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN PORTAL_SYS_TYPE.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN PORTAL_SYS_TYPE.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN PORTAL_SYS_TYPE.ICON_ IS
'图标';

CREATE TABLE PORTAL_SYS_TYPE_GROUP (
   ID_                  VARCHAR(64)          NOT NULL,
   GROUP_KEY_           VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NOT NULL,
   FLAG_                INT4                 NULL DEFAULT NULL,
   SN_                  INT4                 NULL DEFAULT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   CONSTRAINT PK_PORTAL_SYS_TYPE_GROUP PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SYS_TYPE_GROUP IS
'系统分类组值表';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.GROUP_KEY_ IS
'分类组业务主键';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.NAME_ IS
'分类名';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.FLAG_ IS
'标识';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.SN_ IS
'序号';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.TYPE_ IS
'类别。0=平铺结构；1=树型结构';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN PORTAL_SYS_TYPE_GROUP.UPDATE_BY_ IS
'更新人ID';

