| | |
| | | package com.qianwen.smartman.modules.dnc.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldStrategy; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import java.io.Serializable; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.stream.Collectors; |
| | | import lombok.NonNull; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldStrategy; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.qianwen.core.mp.base.BaseEntity; |
| | | import com.qianwen.smartman.modules.dnc.enums.FileType; |
| | | |
| | | import lombok.NonNull; |
| | | |
| | | /** |
| | | * dnc文件(包括目录) |
| | | */ |
| | | @TableName(File.TABLE_NAME) |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/dnc/entity/File.class */ |
| | | public class File extends BaseEntity implements Serializable { |
| | | public static final String TABLE_NAME = "blade_dnc_craft_file"; |
| | | private static final long serialVersionUID = 1; |
| | |
| | | if (startFile == null) { |
| | | throw new NullPointerException("startFile is marked non-null but is null"); |
| | | } |
| | | List<String> targetFilePath = (List) Optional.ofNullable(targetFile).map((v0) -> { |
| | | List<String> targetFilePath = Optional.ofNullable(targetFile).map((v0) -> { |
| | | return v0.pathList(); |
| | | }).orElse(new ArrayList()); |
| | | }).orElse(new ArrayList<>()); |
| | | String startPath = startFile.getId().toString(); |
| | | List<String> thisPath = pathList(); |
| | | int startIndex = thisPath.indexOf(startPath); |
| | | Collection<? extends String> otherPath = (List) thisPath.stream().skip(startIndex == -1 ? 0L : startIndex).collect(Collectors.toList()); |
| | | Collection<? extends String> otherPath = thisPath.stream().skip(startIndex == -1 ? 0L : startIndex).collect(Collectors.toList()); |
| | | List<String> newList = new ArrayList<>(); |
| | | newList.addAll(targetFilePath); |
| | | newList.addAll(targetFilePath.size(), otherPath); |
| | |
| | | |
| | | public List<String> pathList() { |
| | | Optional<String> path = Optional.ofNullable(this.allPath); |
| | | return (List) path.map(c -> { |
| | | return path.map(c -> { |
| | | return Arrays.asList(c.split("\\/")); |
| | | }).orElse(new ArrayList()); |
| | | }).orElse(new ArrayList<>()); |
| | | } |
| | | |
| | | public void joinPath(List<String> pathList, String startPath) { |
| | | List<String> originPath = pathList(); |
| | | int startIndex = originPath.indexOf(startPath); |
| | | Collection<? extends String> list = (List) originPath.stream().skip(startIndex).collect(Collectors.toList()); |
| | | Collection<? extends String> list = originPath.stream().skip(startIndex).collect(Collectors.toList()); |
| | | List<String> newList = new ArrayList<>(); |
| | | newList.addAll(pathList); |
| | | newList.addAll(pathList.size(), list); |
| | |
| | | changeParent(defaultValue); |
| | | return; |
| | | } |
| | | String key = (String) Optional.ofNullable(this.parentId).map((v0) -> { |
| | | return v0.toString(); |
| | | }).orElse(""); |
| | | String pid = (String) keyMap.getOrDefault(key, Optional.ofNullable(defaultValue).map((v0) -> { |
| | | return v0.toString(); |
| | | }).orElse(null)); |
| | | |
| | | String key = Optional.<Long>ofNullable(this.parentId).map(Object::toString).orElse(""); |
| | | String pid = keyMap.getOrDefault(key, Optional.<Long>ofNullable(defaultValue).map(Object::toString).orElse(null)); |
| | | |
| | | changeParent(pid, defaultValue); |
| | | } |
| | | |
| | | public void changeChildPath(Map<String, String> keyMap) { |
| | | List<String> originPath = pathList(); |
| | | List<String> newList1 = (List) originPath.stream().map(c -> { |
| | | return (String) keyMap.getOrDefault(c, c); |
| | | List<String> newList1 = originPath.stream().map(c -> { |
| | | return keyMap.getOrDefault(c, c); |
| | | }).collect(Collectors.toList()); |
| | | this.allPath = String.join("/", newList1); |
| | | } |