CREATE TABLE sys_org(
                        org_id VARCHAR2(32) NOT NULL,
                        org_code VARCHAR2(64),
                        name VARCHAR2(90),
                        parent_id VARCHAR2(32),
                        sort_no INT,
                        status INT DEFAULT  1,
                        create_user VARCHAR2(32),
                        create_date DATE DEFAULT  SYSDATE,
                        update_user VARCHAR2(32),
                        update_date DATE,
                        deleted INT DEFAULT  0,
                        PRIMARY KEY (org_id)
);

COMMENT ON TABLE sys_org IS '单位表';
COMMENT ON COLUMN sys_org.org_id IS '机构ID';
COMMENT ON COLUMN sys_org.org_code IS '机构编码';
COMMENT ON COLUMN sys_org.name IS '机构名称';
COMMENT ON COLUMN sys_org.parent_id IS '上级单位;-1为根级目录';
COMMENT ON COLUMN sys_org.sort_no IS '排序';
COMMENT ON COLUMN sys_org.status IS '状态';
COMMENT ON COLUMN sys_org.create_user IS '创建人';
COMMENT ON COLUMN sys_org.create_date IS '创建时间';
COMMENT ON COLUMN sys_org.update_user IS '更新人';
COMMENT ON COLUMN sys_org.update_date IS '更新时间';
COMMENT ON COLUMN sys_org.deleted IS '删除标志;1删除';

CREATE TABLE sys_position(
                             position_id VARCHAR2(32) NOT NULL,
                             name VARCHAR2(90),
                             org_id VARCHAR2(32),
                             dept_id VARCHAR2(32),
                             sort_num INT,
                             status INT DEFAULT  1,
                             create_user VARCHAR2(32),
                             create_date DATE DEFAULT  SYSDATE,
                             update_user VARCHAR2(32),
                             update_date DATE,
                             deleted INT DEFAULT  0,
                             PRIMARY KEY (position_id)
);

COMMENT ON TABLE sys_position IS '岗位表';
COMMENT ON COLUMN sys_position.position_id IS '岗位ID';
COMMENT ON COLUMN sys_position.name IS '岗位名称';
COMMENT ON COLUMN sys_position.org_id IS '所属单位';
COMMENT ON COLUMN sys_position.dept_id IS '所属部门';
COMMENT ON COLUMN sys_position.sort_num IS '排序';
COMMENT ON COLUMN sys_position.status IS '状态';
COMMENT ON COLUMN sys_position.create_user IS '创建人';
COMMENT ON COLUMN sys_position.create_date IS '创建时间';
COMMENT ON COLUMN sys_position.update_user IS '更新人';
COMMENT ON COLUMN sys_position.update_date IS '更新时间';
COMMENT ON COLUMN sys_position.deleted IS '删除标志;1删除';

CREATE TABLE sys_user(
                         user_id VARCHAR2(32) NOT NULL,
                         name VARCHAR2(90),
                         avatar VARCHAR2(900),
                         phone VARCHAR2(20),
                         hx_id VARCHAR2(128),
                         position_id VARCHAR2(32),
                         org_id VARCHAR2(32),
                         org_name VARCHAR2(90),
                         status INT DEFAULT  1,
                         create_user VARCHAR2(32),
                         create_date DATE DEFAULT  SYSDATE,
                         update_user VARCHAR2(32),
                         update_date DATE,
                         deleted INT DEFAULT  0,
                         PRIMARY KEY (user_id)
);

COMMENT ON TABLE sys_user IS '用户表';
COMMENT ON COLUMN sys_user.user_id IS '用户ID';
COMMENT ON COLUMN sys_user.name IS '用户名称';
COMMENT ON COLUMN sys_user.avatar IS '头像';
COMMENT ON COLUMN sys_user.phone IS '手机';
COMMENT ON COLUMN sys_user.hx_id IS '行信ID';
COMMENT ON COLUMN sys_user.position_id IS '岗位ID';
COMMENT ON COLUMN sys_user.org_id IS '机构ID';
COMMENT ON COLUMN sys_user.org_name IS '机构名称';
COMMENT ON COLUMN sys_user.status IS '状态';
COMMENT ON COLUMN sys_user.create_user IS '创建人';
COMMENT ON COLUMN sys_user.create_date IS '创建时间';
COMMENT ON COLUMN sys_user.update_user IS '更新人';
COMMENT ON COLUMN sys_user.update_date IS '更新时间';
COMMENT ON COLUMN sys_user.deleted IS '删除标志;1删除';

CREATE TABLE sys_role(
                         role_id VARCHAR2(32) NOT NULL,
                         name VARCHAR2(90),
                         status INT DEFAULT  1,
                         create_user VARCHAR2(32),
                         create_date DATE DEFAULT  SYSDATE,
                         update_user VARCHAR2(32),
                         update_date DATE,
                         deleted INT DEFAULT  0,
                         PRIMARY KEY (role_id)
);

COMMENT ON TABLE sys_role IS '系统角色';
COMMENT ON COLUMN sys_role.role_id IS '角色ID';
COMMENT ON COLUMN sys_role.name IS '角色名称';
COMMENT ON COLUMN sys_role.status IS '状态';
COMMENT ON COLUMN sys_role.create_user IS '创建人';
COMMENT ON COLUMN sys_role.create_date IS '创建时间';
COMMENT ON COLUMN sys_role.update_user IS '更新人';
COMMENT ON COLUMN sys_role.update_date IS '更新时间';
COMMENT ON COLUMN sys_role.deleted IS '删除标志;1删除';

CREATE TABLE sys_user_role(
                              id VARCHAR2(32) NOT NULL,
                              role_id VARCHAR2(32),
                              user_id VARCHAR2(32),
                              PRIMARY KEY (id)
);

COMMENT ON TABLE sys_user_role IS '角色授权';
COMMENT ON COLUMN sys_user_role.id IS 'id';
COMMENT ON COLUMN sys_user_role.role_id IS '角色ID';
COMMENT ON COLUMN sys_user_role.user_id IS '用户ID';

CREATE TABLE sys_tenant(
                           tenant_id VARCHAR2(32) NOT NULL,
                           name VARCHAR2(90),
                           sort_no INT DEFAULT  1,
                           status INT DEFAULT  1,
                           create_user VARCHAR2(32),
                           create_date DATE DEFAULT  SYSDATE,
                           update_user VARCHAR2(32),
                           update_date DATE,
                           deleted INT DEFAULT  0,
                           PRIMARY KEY (tenant_id)
);

COMMENT ON TABLE sys_tenant IS '租户表';
COMMENT ON COLUMN sys_tenant.tenant_id IS '租户ID';
COMMENT ON COLUMN sys_tenant.name IS '租户名称';
COMMENT ON COLUMN sys_tenant.sort_no IS '排序';
COMMENT ON COLUMN sys_tenant.status IS '状态';
COMMENT ON COLUMN sys_tenant.create_user IS '创建人';
COMMENT ON COLUMN sys_tenant.create_date IS '创建时间';
COMMENT ON COLUMN sys_tenant.update_user IS '更新人';
COMMENT ON COLUMN sys_tenant.update_date IS '更新时间';
COMMENT ON COLUMN sys_tenant.deleted IS '删除标志;1删除';

CREATE TABLE ta_user_tenant(
                               id VARCHAR2(32) NOT NULL,
                               user_id VARCHAR2(32),
                               tenant_id VARCHAR2(32),
                               update_user VARCHAR2(32),
                               update_date DATE,
                               deleted INT DEFAULT  0,
                               PRIMARY KEY (id)
);

COMMENT ON TABLE ta_user_tenant IS '用户分组';
COMMENT ON COLUMN ta_user_tenant.id IS 'ID';
COMMENT ON COLUMN ta_user_tenant.user_id IS '用户ID';
COMMENT ON COLUMN ta_user_tenant.tenant_id IS '租户ID';
COMMENT ON COLUMN ta_user_tenant.update_user IS '更新人';
COMMENT ON COLUMN ta_user_tenant.update_date IS '更新时间';
COMMENT ON COLUMN ta_user_tenant.deleted IS '删除标志;1删除';

CREATE TABLE ta_project(
                           project_id VARCHAR2(32) NOT NULL,
                           name VARCHAR2(128),
                           icon VARCHAR2(255),
                           description VARCHAR2(255),
                           status INT DEFAULT  1,
                           tenant_id VARCHAR2(32),
                           deleted INT DEFAULT  0,
                           create_user VARCHAR2(32),
                           create_date DATE DEFAULT  SYSDATE,
                           update_user VARCHAR2(32),
                           update_date DATE,
                           PRIMARY KEY (project_id)
);

COMMENT ON TABLE ta_project IS '项目表';
COMMENT ON COLUMN ta_project.project_id IS '项目ID';
COMMENT ON COLUMN ta_project.name IS '项目名称';
COMMENT ON COLUMN ta_project.icon IS '项目图标';
COMMENT ON COLUMN ta_project.description IS '描述';
COMMENT ON COLUMN ta_project.status IS '状态';
COMMENT ON COLUMN ta_project.tenant_id IS '租户号';
COMMENT ON COLUMN ta_project.deleted IS '删除标志';
COMMENT ON COLUMN ta_project.create_user IS '创建人';
COMMENT ON COLUMN ta_project.create_date IS '创建时间';
COMMENT ON COLUMN ta_project.update_user IS '更新人';
COMMENT ON COLUMN ta_project.update_date IS '更新时间';

CREATE TABLE ta_project_org(
                               id VARCHAR2(32) NOT NULL,
                               project_id VARCHAR2(32),
                               org_id VARCHAR2(32),
                               PRIMARY KEY (id)
);

COMMENT ON TABLE ta_project_org IS '项目参与部门';
COMMENT ON COLUMN ta_project_org.id IS 'ID';
COMMENT ON COLUMN ta_project_org.project_id IS '项目ID';
COMMENT ON COLUMN ta_project_org.org_id IS '部门ID';

CREATE TABLE ta_project_item(
                                item_id VARCHAR2(32) NOT NULL,
                                name VARCHAR2(255),
                                icon VARCHAR2(255),
                                project_id VARCHAR2(32),
                                score DECIMAL(6,2) DEFAULT  0.0,
                                sort INT DEFAULT  0,
                                status INT DEFAULT  1,
                                tenant_id VARCHAR2(32),
                                deleted INT DEFAULT  0,
                                create_user VARCHAR2(32),
                                create_date DATE DEFAULT  SYSDATE,
                                update_user VARCHAR2(32),
                                update_date DATE,
                                PRIMARY KEY (item_id)
);

COMMENT ON TABLE ta_project_item IS '项目内容';
COMMENT ON COLUMN ta_project_item.item_id IS '内容ID';
COMMENT ON COLUMN ta_project_item.name IS '内容名称';
COMMENT ON COLUMN ta_project_item.icon IS '内容图标';
COMMENT ON COLUMN ta_project_item.project_id IS '项目ID';
COMMENT ON COLUMN ta_project_item.score IS '积分';
COMMENT ON COLUMN ta_project_item.sort IS '序号';
COMMENT ON COLUMN ta_project_item.status IS '状态';
COMMENT ON COLUMN ta_project_item.tenant_id IS '租户号';
COMMENT ON COLUMN ta_project_item.deleted IS '删除标志';
COMMENT ON COLUMN ta_project_item.create_user IS '创建人';
COMMENT ON COLUMN ta_project_item.create_date IS '创建时间';
COMMENT ON COLUMN ta_project_item.update_user IS '更新人';
COMMENT ON COLUMN ta_project_item.update_date IS '更新时间';

CREATE TABLE ta_project_report(
                                  data_id VARCHAR2(32) NOT NULL,
                                  project_id VARCHAR2(32),
                                  project_name VARCHAR2(255),
                                  project_icon VARCHAR2(255),
                                  item_id VARCHAR2(32),
                                  item_name VARCHAR2(255),
                                  item_icon VARCHAR2(255),
                                  item_sort INT DEFAULT  0,
                                  score_value DECIMAL(6,2) DEFAULT  0.0,
                                  status INT DEFAULT  1,
                                  org_id VARCHAR2(32),
                                  org_name VARCHAR2(255),
                                  tenant_id VARCHAR2(32),
                                  deleted INT DEFAULT  0,
                                  create_user VARCHAR2(32),
                                  create_date DATE DEFAULT  SYSDATE,
                                  update_user VARCHAR2(32),
                                  update_date DATE,
                                  PRIMARY KEY (data_id)
);

COMMENT ON TABLE ta_project_report IS '项目填报';
COMMENT ON COLUMN ta_project_report.data_id IS '数据ID';
COMMENT ON COLUMN ta_project_report.project_id IS '项目ID';
COMMENT ON COLUMN ta_project_report.project_name IS '项目名称';
COMMENT ON COLUMN ta_project_report.project_icon IS '项目图标';
COMMENT ON COLUMN ta_project_report.item_id IS '内容ID';
COMMENT ON COLUMN ta_project_report.item_name IS '内容名称';
COMMENT ON COLUMN ta_project_report.item_icon IS '内容图标';
COMMENT ON COLUMN ta_project_report.item_sort IS '内容序号';
COMMENT ON COLUMN ta_project_report.score_value IS '填报值';
COMMENT ON COLUMN ta_project_report.status IS '状态';
COMMENT ON COLUMN ta_project_report.org_id IS '所属部门';
COMMENT ON COLUMN ta_project_report.org_name IS '部门名称';
COMMENT ON COLUMN ta_project_report.tenant_id IS '租户号';
COMMENT ON COLUMN ta_project_report.deleted IS '删除标志';
COMMENT ON COLUMN ta_project_report.create_user IS '创建人';
COMMENT ON COLUMN ta_project_report.create_date IS '创建时间';
COMMENT ON COLUMN ta_project_report.update_user IS '更新人';
COMMENT ON COLUMN ta_project_report.update_date IS '更新时间';

CREATE TABLE sys_log(
                        log_id VARCHAR2(32) NOT NULL,
                        login_id VARCHAR2(255),
                        user_name VARCHAR2(255),
                        module_name VARCHAR2(255),
                        action VARCHAR2(900),
                        client_type VARCHAR2(128),
                        uri VARCHAR2(900),
                        description VARCHAR2(900),
                        ip VARCHAR2(255),
                        ua VARCHAR2(2000),
                        create_date DATE DEFAULT  SYSDATE,
                        PRIMARY KEY (log_id)
);

COMMENT ON TABLE sys_log IS '系统日志';
COMMENT ON COLUMN sys_log.log_id IS '日志ID';
COMMENT ON COLUMN sys_log.login_id IS '登录ID';
COMMENT ON COLUMN sys_log.user_name IS '用户名';
COMMENT ON COLUMN sys_log.module_name IS '模块名称';
COMMENT ON COLUMN sys_log.action IS '操作内容';
COMMENT ON COLUMN sys_log.client_type IS '客户端';
COMMENT ON COLUMN sys_log.uri IS '访问地址';
COMMENT ON COLUMN sys_log.description IS '具体操作';
COMMENT ON COLUMN sys_log.ip IS '用户ID';
COMMENT ON COLUMN sys_log.ua IS 'User Agent';
COMMENT ON COLUMN sys_log.create_date IS '操作时间';

CREATE TABLE sys_menu(
                         menu_id VARCHAR2(32) NOT NULL,
                         name VARCHAR2(90),
                         menu_code VARCHAR2(32),
                         parent_id VARCHAR2(32),
                         sort_no INT,
                         status INT DEFAULT  1,
                         create_user VARCHAR2(32),
                         create_date DATE DEFAULT  SYSDATE,
                         PRIMARY KEY (menu_id)
);

COMMENT ON TABLE sys_menu IS '菜单表';
COMMENT ON COLUMN sys_menu.menu_id IS '菜单ID';
COMMENT ON COLUMN sys_menu.name IS '菜单名称';
COMMENT ON COLUMN sys_menu.menu_code IS '菜单编码';
COMMENT ON COLUMN sys_menu.parent_id IS '上级ID';
COMMENT ON COLUMN sys_menu.sort_no IS '排序';
COMMENT ON COLUMN sys_menu.status IS '状态';
COMMENT ON COLUMN sys_menu.create_user IS '创建人';
COMMENT ON COLUMN sys_menu.create_date IS '创建时间';

CREATE TABLE sys_role_resource(
                                  id VARCHAR2(32) NOT NULL,
                                  role_id VARCHAR2(32),
                                  resource_id VARCHAR2(32),
                                  resource_type VARCHAR2(32),
                                  PRIMARY KEY (id)
);

COMMENT ON TABLE sys_role_resource IS '角色资源';
COMMENT ON COLUMN sys_role_resource.id IS 'id';
COMMENT ON COLUMN sys_role_resource.role_id IS '角色ID';
COMMENT ON COLUMN sys_role_resource.resource_id IS '资源ID';
COMMENT ON COLUMN sys_role_resource.resource_type IS '资源类型';

