Home > Back-end >  Recently met a problem, relevant departments of the tree for advice!
Recently met a problem, relevant departments of the tree for advice!

Time:03-26

DROP TABLE IF the EXISTS ` hd_dept `;
The CREATE TABLE ` hd_dept ` (
` ID ` int (11), NOT NULL AUTO_INCREMENT COMMENT 'primary key',
` PARENT_ID ` int (11) NULL DEFAULT NULL COMMENT 'parent node,
` DEPT_NAME ` varchar (32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT 'department name,
` COMPANY_ID ` int (11) NULL DEFAULT NULL COMMENT 'company',
` CREATED_BY ` int (11) NULL DEFAULT NULL COMMENT 'founder,
` CREATED_TIME ` datetime (0) NULL DEFAULT NULL COMMENT 'creation time,
` UPDATED_BY ` int (11) NULL DEFAULT NULL COMMENT 'update people',
` UPDATED_TIME ` datetime (0) NULL DEFAULT NULL COMMENT 'update time,
` TENANT_ID ` int (11) NULL DEFAULT NULL COMMENT 'tenants'
PRIMARY KEY (` ID `) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=33790 CHARACTER SET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='department table ROW_FORMAT=Dynamic;

This is the department table table structure, it is a tree structure, through the parent_id associations, currently doing import departments judgment under the condition that a company cannot have a moniker department,

Recently raised a new demand:
Under the same company, for the same level, can have the same department name, edit/new name, judge whether have the same departments at the same level, if any, prompt "existing" the department;
Under the same company for different level allows the existence of the same name departments;
Then I ran into trouble, the feeling is according to the current table structure have no way to achieve this effect,
This is the template of the import, asked to use the full path matching

Please god give some advice!
  • Related