getleaves fix
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
parent
efcfa9c568
commit
d30a21974d
|
@ -31,7 +31,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.getLeaves = async(zoneFk, parentFk, filter) => {
|
Self.getLeaves = async(zoneFk, parentFk = null, filter) => {
|
||||||
let conn = Self.dataSource.connector;
|
let conn = Self.dataSource.connector;
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
|
|
||||||
|
@ -78,20 +78,17 @@ module.exports = Self => {
|
||||||
ON zg.lft <= ch.lft AND zg.rgt >= ch.rgt
|
ON zg.lft <= ch.lft AND zg.rgt >= ch.rgt
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
child.id,
|
zg.id,
|
||||||
child.name,
|
zg.name,
|
||||||
child.lft,
|
zg.lft,
|
||||||
child.rgt,
|
zg.rgt,
|
||||||
child.depth,
|
zg.depth,
|
||||||
child.sons,
|
zg.sons,
|
||||||
zi.isIncluded AS selected
|
zi.isIncluded AS selected
|
||||||
FROM zoneGeo parent
|
FROM zoneGeo zg
|
||||||
JOIN zoneGeo child ON child.lft > parent.lft
|
LEFT JOIN zoneIncluded zi ON zi.geoFk = zg.id
|
||||||
AND child.rgt < parent.rgt
|
|
||||||
AND child.depth = parent.depth + 1
|
|
||||||
LEFT JOIN zoneIncluded zi ON zi.geoFk = child.id
|
|
||||||
AND zi.zoneFk = ?
|
AND zi.zoneFk = ?
|
||||||
WHERE parent.id = ?) AS nst`, [zoneFk, parentFk]);
|
WHERE zg.parentFk IS NULL OR zg.parentFk = ?) AS nst`, [zoneFk, parentFk]);
|
||||||
|
|
||||||
// Get nodes from depth greather than Origin
|
// Get nodes from depth greather than Origin
|
||||||
stmt.merge(conn.makeSuffix(filter));
|
stmt.merge(conn.makeSuffix(filter));
|
||||||
|
|
Loading…
Reference in New Issue