自测通了创建工程,查询工程和添加子集的接口。

This commit is contained in:
chenxudong 2024-12-18 17:30:42 +08:00
parent 1b4492e812
commit dc4a7d4337
10 changed files with 22 additions and 106 deletions

View File

@ -13,4 +13,5 @@ public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {
List<EdFileInfo> selectAllAdminFolder(String prjId); List<EdFileInfo> selectAllAdminFolder(String prjId);
} }

View File

@ -24,7 +24,7 @@ public class BaseModel {
/** /**
* 最后更新时间 * 最后更新时间
*/ */
@TableField(value = "update_time") @TableField(value = "updated_time")
private Date updateTime; private Date updateTime;
/** /**

View File

@ -103,12 +103,6 @@ public class EdFileInfo extends BaseModel {
@TableField(value = "save_status") @TableField(value = "save_status")
private Integer saveStatus; private Integer saveStatus;
/**
* 文件夹发布状态0-未发布1-已发布
*/
@TableField(value = "publish_status")
private int publishStatus;
/** /**
* 文件大小 * 文件大小
*/ */

View File

@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.pojo.resp;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
@ -12,6 +13,6 @@ public class ProjectVO {
private String parentId; private String parentId;
private int sort; private int sort;
private List<ProjectVO> children; private List<ProjectVO> children = new ArrayList<>();
} }

View File

@ -44,7 +44,9 @@ import static com.electromagnetic.industry.software.common.cons.ElectromagneticC
@Service @Service
public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo> implements EdFileInfoService { public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo> implements EdFileInfoService {
private EleLog log = new EleLog(EdFileInfoServiceImpl.class); private final EleLog log = new EleLog(EdFileInfoServiceImpl.class);
private static final String PRJ_PARENT_ID = "0";
@Resource @Resource
private Environment environment; private Environment environment;
@ -94,7 +96,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
try { try {
// 保存信息到MySQL // 保存信息到MySQL
int id = Integer.parseInt(this.baseMapper.maxPrjId()); String maxPrjId = this.baseMapper.maxPrjId();
int id = Integer.parseInt(StrUtil.isEmpty(maxPrjId) ? "100000" : maxPrjId);
Date now = new Date(); Date now = new Date();
String currentUserId = UserThreadLocal.getUserId(); String currentUserId = UserThreadLocal.getUserId();
String newPrjId = String.valueOf(id + 1); String newPrjId = String.valueOf(id + 1);
@ -104,6 +107,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.setFileId(newPrjId) .setFileId(newPrjId)
.setFileName(prjName) .setFileName(prjName)
.setFileVersion(100) .setFileVersion(100)
.setParentId(PRJ_PARENT_ID)
.setFileTime(EleCommonUtil.getNowTimeStr()) .setFileTime(EleCommonUtil.getNowTimeStr())
.setDataType(EleDataTypeEnum.FOLDER.code) .setDataType(EleDataTypeEnum.FOLDER.code)
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code) .setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
@ -117,7 +121,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.setUpdatedBy(currentUserId); .setUpdatedBy(currentUserId);
this.save(fileInfo); this.save(fileInfo);
// 保存到文件系统 // 保存到文件系统
fileSystemService.createDirectory(eleDataPath); fileSystemService.createDirectory(eleDataPath + File.separator + prjName);
} catch (Exception e) { } catch (Exception e) {
String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage()); String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage());
log.error(info, e); log.error(info, e);
@ -248,8 +252,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
.setUpdateTime(now) .setUpdateTime(now)
.setCreatedBy(currentUserId) .setCreatedBy(currentUserId)
.setUpdatedBy(currentUserId); .setUpdatedBy(currentUserId);
this.save(fileInfo);
// 保存到文件系统 // 保存到文件系统
String targetFilePath = getPath(paths) + File.separator + folderName; String targetFilePath = eleDataPath + File.separator + getPath(paths) + File.separator + folderName;
fileSystemService.createDirectory(targetFilePath); fileSystemService.createDirectory(targetFilePath);
return ElectromagneticResultUtil.success(true); return ElectromagneticResultUtil.success(true);
} catch (Exception e) { } catch (Exception e) {
@ -270,24 +275,21 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
try { try {
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class) LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
.select(EdFileInfo::getId) .select(EdFileInfo::getId)
.eq(EdFileInfo::getParentId, 0) .eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code); .eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
List<String> ids = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList()); List<String> ids = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
List<ProjectVO> projectVOS = new ArrayList<>(); List<ProjectVO> projectVOS = new ArrayList<>();
for (String id : ids) { for (String id : ids) {
LambdaQueryWrapper<EdFileInfo> queryWrapper1 = Wrappers.lambdaQuery(EdFileInfo.class) List<EdFileInfo> edFileInfos = this.baseMapper.selectAllAdminFolder(id);
.select(EdFileInfo::getId, EdFileInfo::getFileName, EdFileInfo::getParentId, EdFileInfo::getSort)
.like(EdFileInfo::getFilePath, MYSQL_FILE_PATH_SPLIT + id + MYSQL_FILE_PATH_SPLIT);
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper1);
// 转换为树 // 转换为树
TreeNodeConfig config = new TreeNodeConfig(); TreeNodeConfig config = new TreeNodeConfig();
config.setIdKey(EdFileInfo.Fields.id); config.setIdKey(EdFileInfo.Fields.id);
config.setParentIdKey(EdFileInfo.Fields.parentId); config.setParentIdKey(EdFileInfo.Fields.parentId);
config.setWeightKey(EdFileInfo.Fields.sort); config.setWeightKey(EdFileInfo.Fields.sort);
List<Tree<String>> trees = TreeUtil.build(edFileInfos, "0", config, ((obj, treeNode) -> { List<Tree<String>> trees = TreeUtil.build(edFileInfos, PRJ_PARENT_ID, config, ((obj, treeNode) -> {
treeNode.putExtra(EdFileInfo.Fields.id, obj.getId()); treeNode.putExtra(EdFileInfo.Fields.id, obj.getId());
treeNode.putExtra(EdFileInfo.Fields.parentId, obj.getParentId()); treeNode.putExtra(EdFileInfo.Fields.parentId, obj.getParentId());
treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort()); treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort());

View File

@ -4,14 +4,12 @@
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper"> <mapper namespace="com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper">
<select id="maxPrjId" resultType="java.lang.String"> <select id="maxPrjId" resultType="java.lang.String">
select max(id) from ed_file_info where length(id) = 6 and (parent_id is null or parent_id = "") select max(id) from ed_file_info where length(id) = 6
</select> </select>
<select id="selectAllAdminFolder" <select id="selectAllAdminFolder"
resultType="com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo"> resultType="com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo">
select id, file_name, parent_id, sort, file_path from ed_file_info where length(id) = 6 and effect_flag = 1 and data_type = 0 select id, file_name, parent_id, sort, file_path from ed_file_info where length(id) = 6 and effect_flag = 1 and data_type = 0 and file_path like concat(#{prjId}, '%')
</select> </select>
</mapper> </mapper>

View File

@ -5,8 +5,8 @@ import lombok.AllArgsConstructor;
@AllArgsConstructor @AllArgsConstructor
public enum EleDataTypeEnum { public enum EleDataTypeEnum {
FILE(0, "文件夹"), FOLDER(0, "文件夹"),
FOLDER(1, "普通文件"); FILE(1, "普通文件");
public int code; public int code;
public String desc; public String desc;

View File

@ -2,7 +2,7 @@ package com.electromagnetic.industry.software.common.resp;
import java.io.Serializable; import java.io.Serializable;
public class ElectromagneticResult<T> implements Serializable, Result { public class ElectromagneticResult<T> implements Serializable {
private static final long serialVersionUID = -6408526187818056594L; private static final long serialVersionUID = -6408526187818056594L;
/** /**
@ -73,11 +73,6 @@ public class ElectromagneticResult<T> implements Serializable, Result {
this.data = data; this.data = data;
} }
@Override
public Integer getStatus() {
return success ? 1 : 0;
}
/** /**
* Getter method for property <tt>errorCode</tt>. * Getter method for property <tt>errorCode</tt>.
* *
@ -113,12 +108,4 @@ public class ElectromagneticResult<T> implements Serializable, Result {
public void setErrorMessage(String errorMessage) { public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
@Override
public Message getMessage() {
Message msg = new Message(this.getErrorMessage());
//页面展示时防止出现null状况
msg.setCode("");
return msg;
}
} }

View File

@ -1,50 +0,0 @@
package com.electromagnetic.industry.software.common.resp;
public class Message {
/**
* 返回结果码
*/
private String code;
/**
* 返回结果信息
*/
private String message;
/**
* 返回错误明细
*/
private ErrorContext errorContext;
public Message(String messageStr) {
this.message = messageStr;
}
public String getCode() {
return code;
}
public Message setCode(String code) {
this.code = code;
return this;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("code = ");
builder.append(code);
builder.append(", message = ");
builder.append(message);
builder.append(", ");
builder.append("BaseResult [");
builder.append("errorContext=");
builder.append(errorContext);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,17 +0,0 @@
package com.electromagnetic.industry.software.common.resp;
public interface Result {
/**
* 返回状态
*
* @return
*/
Integer getStatus();
/**
* 返回消息
*
* @return
*/
Message getMessage();
}