drop table if exists hx_department; CREATE Table hx_department ( id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(128) NOT NULL COMMENT `部门名称`, status TINYINT DEFAULT 0 COMMENT `状态备用`, parent_id INTEGER NOT NULL COMMENT `上一级部门id,无上级为0`, root_node_id INTEGER NOT NULL COMMENT `所在部门树中根部门的id`, depth TINYINT not NULL COMMENT `所在部门树中的深度`, sort INTEGER DEFAULT 0 COMMENT `部门排序`, deleted_at DATETIME COMMENT `删除时间` ) COMMENT `部门、组织架构`; CREATE Table hx_department_user ( id BIGINT PRIMARY KEY AUTO_INCREMENT, user_id BIGINT NOT NULL COMMENT `用户id`, dept_id INTEGER not NULL COMMENT `部门id`, created_by BIGINT not NULL, created_at DATETIME NOT NULL, deleted_at DATETIME ) COMMENT `用户-部门关系表`;