mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
bugfix
This commit is contained in:
@@ -57,16 +57,10 @@ public class ResourceEntity extends CommonEntity {
|
||||
private Boolean visible;
|
||||
|
||||
|
||||
|
||||
@Comment("其他数据")
|
||||
private String metadata;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void addChildren(ResourceEntity newRs) {
|
||||
|
||||
// log.info("addChildren1 {} {}", this.getUrl(), newRs.getUrl());
|
||||
@@ -81,7 +75,7 @@ public class ResourceEntity extends CommonEntity {
|
||||
|
||||
for (ResourceEntity child : this.children) {
|
||||
|
||||
if (newRs.getUrl().startsWith(child.getUrl())) {
|
||||
if (isChildren(newRs, child)) {
|
||||
|
||||
|
||||
child.addChildren(newRs);
|
||||
@@ -119,11 +113,39 @@ public class ResourceEntity extends CommonEntity {
|
||||
|
||||
}
|
||||
|
||||
private boolean isChildren(ResourceEntity c, ResourceEntity p) {
|
||||
if (!isSamePath(c.getUrl(), p.getUrl())) {
|
||||
// 判断list是否有相同前缀
|
||||
|
||||
String[] pl = StringUtils.split(p.getUrl(), "/");
|
||||
String[] cl = StringUtils.split(c.getUrl(), "/");
|
||||
|
||||
for (int i = 0; i < pl.length; i++) {
|
||||
if (i >= cl.length) {
|
||||
return false;
|
||||
}
|
||||
if (!pl[i].equalsIgnoreCase(cl[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean isSamePath(String a, String b) {
|
||||
return a.equalsIgnoreCase(b) || (a + "/").equalsIgnoreCase(b);
|
||||
}
|
||||
|
||||
private static String getParent(String path) {
|
||||
log.info("getParent {}", path);
|
||||
|
||||
return "/" + StringUtils.join(Stream.of(StringUtils.split(path, "/")).dropRight(1), "/");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user