fix(makecode): 树查询 showself 仅在 showall 时生效
避免 parent_id 懒加载把节点自身混入子级导致无限嵌套,并补充 department 回归用例与文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -83,6 +83,26 @@ func createMySQLTables(db *HoTimeDB, prefix string) {
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4")
|
||||
}
|
||||
|
||||
// department 部门表(树形结构,供通用 CRUD 树查询测试使用;
|
||||
// 不叫 org 是因为 config/admin.json 遗留 flow 会给 org 注入 admin_id 过滤)
|
||||
// 注意:MakeCode 路由在 Init 时按库中已有表生成,
|
||||
// 全新空库首次运行建表晚于 Init,/admin/department/search 需第二次运行才可用
|
||||
tbl = prefix + "department"
|
||||
if !mysqlTableExists(db, tbl) {
|
||||
fmt.Println("[MySQL Setup] 创建表:", tbl)
|
||||
db.Exec("CREATE TABLE `" + tbl + "` (" +
|
||||
"`id` int(11) unsigned NOT NULL AUTO_INCREMENT," +
|
||||
"`name` varchar(100) DEFAULT NULL COMMENT '部门名称'," +
|
||||
"`parent_id` int(11) DEFAULT NULL COMMENT '父级ID'," +
|
||||
"`parent_ids` varchar(255) DEFAULT NULL COMMENT '层级路径'," +
|
||||
"`state` int(2) DEFAULT '0'," +
|
||||
"`create_time` datetime DEFAULT NULL," +
|
||||
"`modify_time` datetime DEFAULT NULL," +
|
||||
"PRIMARY KEY (`id`)," +
|
||||
"KEY `idx_parent_id` (`parent_id`)" +
|
||||
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='部门表'")
|
||||
}
|
||||
|
||||
// test_batch 测试批量表
|
||||
tbl = prefix + "test_batch"
|
||||
if !mysqlTableExists(db, tbl) {
|
||||
|
||||
Reference in New Issue
Block a user