-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xiaofeng
committed
Dec 14, 2021
1 parent
edf5d28
commit 894e8d8
Showing
13 changed files
with
227 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
case-server/src/main/java/com/xiaoju/framework/entity/request/dir/DirMoveReq.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.xiaoju.framework.entity.request.dir; | ||
|
||
import com.xiaoju.framework.constants.BizConstant; | ||
import com.xiaoju.framework.entity.request.ParamValidate; | ||
import lombok.Data; | ||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* 目录下用例全部迁移的请求体 | ||
* Created by didi on 2021/12/14. | ||
*/ | ||
@Data | ||
public class DirMoveReq implements ParamValidate { | ||
private Integer channel; | ||
|
||
private Long productLineId; | ||
|
||
/** | ||
* 被选中文件夹的id | ||
*/ | ||
private String fromId; | ||
|
||
/** | ||
* 如果想移到同级,设置为选中文件夹的parentId | ||
* 如果想要移到自己,设为选中文件夹的Id | ||
*/ | ||
private String toId; | ||
|
||
@Override | ||
public void validate() { | ||
if (productLineId == null || productLineId <= 0) { | ||
throw new IllegalArgumentException("业务线id为空或者非法"); | ||
} | ||
if (StringUtils.isEmpty(fromId) || StringUtils.isEmpty(toId)) { | ||
throw new IllegalArgumentException("来源或迁移文件夹id不能为空"); | ||
} | ||
if (BizConstant.ROOT_BIZ_ID.equals(fromId)) { | ||
throw new IllegalArgumentException("根文件夹暂不支持迁移"); | ||
} | ||
if (fromId.equals(toId)) { | ||
throw new IllegalArgumentException("相同的文件夹不需要迁移"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
case-server/src/main/java/com/xiaoju/framework/service/impl/DirMoveDFS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.xiaoju.framework.service.impl; | ||
|
||
import com.xiaoju.framework.constants.enums.StatusCode; | ||
import com.xiaoju.framework.entity.dto.DirNodeDto; | ||
import com.xiaoju.framework.entity.exception.CaseServerException; | ||
import lombok.Data; | ||
import org.apache.commons.compress.utils.Sets; | ||
|
||
import java.util.HashSet; | ||
|
||
/** | ||
* Created by didi on 2021/12/14. | ||
*/ | ||
@Data | ||
public class DirMoveDFS { | ||
private String fromId; | ||
|
||
private String toId; | ||
|
||
private DirNodeDto fromObj; | ||
|
||
private DirNodeDto toObj; | ||
|
||
private DirNodeDto parent; | ||
|
||
/** | ||
* 用于记录找到set的id集合,用来判断是不是从父文件夹移到了子文件夹,这样的操作不允许 | ||
*/ | ||
private HashSet<String> toSet; | ||
|
||
public DirMoveDFS(String fromId, String toId) { | ||
this.fromId = fromId; | ||
this.toId = toId; | ||
this.fromObj = null; | ||
this.toObj = null; | ||
this.parent = null; | ||
this.toSet = new HashSet<>(); | ||
} | ||
|
||
public void findNodeAndDelete(DirNodeDto node) { | ||
findNode(node, Sets.newHashSet(node.getId())); | ||
if (parent == null) { | ||
throw new CaseServerException("要去的文件夹不正确", StatusCode.INTERNAL_ERROR); | ||
} | ||
if (toSet.contains(fromObj.getId())) { | ||
throw new CaseServerException("不能从父文件夹移到子文件夹", StatusCode.INTERNAL_ERROR); | ||
} | ||
|
||
parent.getChildren().remove(fromObj); | ||
} | ||
|
||
private void findNode(DirNodeDto node, HashSet<String> set) { | ||
if (node == null) { | ||
return ; | ||
} | ||
if(toId.equals(node.getId())){ | ||
toObj = node; | ||
} | ||
for (DirNodeDto child : node.getChildren()) { | ||
set.add(node.getId()); | ||
if (fromId.equals(child.getId())) { | ||
// 找到了需要移动的文件夹,并且记录其父节点和当前节点 | ||
fromObj = child; | ||
parent = node; | ||
} | ||
if (toId.equals(child.getId())) { | ||
// 找到了要移过去的文件夹,就记录是哪个节点,并且留存经过的id路径 | ||
toObj = child; | ||
toSet = new HashSet<>(set); | ||
} | ||
findNode(child, set); | ||
set.remove(node.getId()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dist/p__casepage__index.8e90d502.async.js → ...dist/p__casepage__index.36ea6809.async.js
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Binary file added
BIN
+36.8 KB
case-server/src/main/resources/web/dist/static/testcase-template.c225ef33.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
...c/main/resources/web/dist/umi.06ec6461.js → ...c/main/resources/web/dist/umi.a34a5352.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+36.8 KB
case-server/src/main/resources/web/src/components/case/caselist/testcase-template.xlsx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters