CREATE TABLE xjr_notice (
    id bigint NOT NULL,
    title varchar(500) NOT NULL,
    TYPE bigint NOT NULL,
    type_name varchar(100),
    publisher bigint,
    publisher_type integer,
    publisher_name integer,
    CONTENT TEXT,
    attachs bigint,
    status integer,
    create_user_id bigint NOT NULL,
    create_date timestamp NOT NULL,
    modify_user_id bigint,
    modify_date timestamp,
    delete_mark integer NOT NULL DEFAULT 0,
    enabled_mark integer NOT NULL DEFAULT 1,
    dept_id bigint,
    tenant_id bigint,
    rule_user_id bigint
);

ALTER TABLE xjr_notice SET
TABLESPACE "sys_default";

COMMENT ON
TABLE xjr_notice IS '通知、手动待办';

COMMENT ON
COLUMN xjr_notice.title IS '标题';

COMMENT ON
COLUMN xjr_notice.type IS '类型，枚举id';

COMMENT ON
COLUMN xjr_notice.type_name IS '类型字面值';

COMMENT ON
COLUMN xjr_notice.publisher IS '发布主体id';

COMMENT ON
COLUMN xjr_notice.publisher_type IS '发布主体类型，0用户/1组织';

COMMENT ON
COLUMN xjr_notice.publisher_name IS '发布主体名称';

COMMENT ON
COLUMN xjr_notice.content IS '发布内容';

COMMENT ON
COLUMN xjr_notice.attachs IS '附件组id';

COMMENT ON
COLUMN xjr_notice.status IS '状态，0草稿/1已发布/2已结束';

ALTER TABLE xjr_notice ADD CONSTRAINT con_incident_dev_xjr_notice_constraint_1 PRIMARY KEY (id) ENABLE VALIDATE;



CREATE TABLE xjr_notice_user (
    id bigint NOT NULL,
    notice_id bigint NOT NULL,
    user_id bigint NOT NULL,
    is_read integer NOT NULL DEFAULT 0,
    reply varchar(1000),
    create_user_id bigint NOT NULL,
    create_date timestamp NOT NULL,
    modify_user_id bigint,
    modify_date timestamp,
    delete_mark integer NOT NULL DEFAULT 0,
    enabled_mark integer NOT NULL DEFAULT 1,
    dept_id bigint,
    tenant_id bigint
);

ALTER TABLE xjr_notice_user SET
TABLESPACE "sys_default";

COMMENT ON
TABLE xjr_notice_user IS '通知用户表';

COMMENT ON
COLUMN xjr_notice_user.notice_id IS '关联通知id';

COMMENT ON
COLUMN xjr_notice_user.is_read IS '是否已读1';

COMMENT ON
COLUMN xjr_notice_user.reply IS '回复';

ALTER TABLE xjr_notice_user ADD CONSTRAINT con_incident_dev_xjr_notice_user_constraint_1 PRIMARY KEY (id) ENABLE VALIDATE;



ALTER TABLE xjr_notice ADD COLUMN RANGE integer NOT NULL DEFAULT 1;

COMMENT ON
COLUMN xjr_notice.RANGE IS '通知范围，0公开/1指定用户';



ALTER TABLE xjr_department ADD COLUMN area_id bigint;

COMMENT ON
COLUMN xjr_department.area_id IS '所在区域id，区域表id';


ALTER TABLE xjr_notice ADD COLUMN  params_json varchar(5000);
COMMENT ON
COLUMN xjr_notice.params_json IS 'json 参数';

ALTER TABLE xjr_notice ADD COLUMN  path varchar(500);
COMMENT ON
COLUMN xjr_notice.path IS '路径';