自测通了创建工程,查询工程和添加子集的接口。
This commit is contained in:
parent
1b4492e812
commit
dc4a7d4337
|
|
@ -13,4 +13,5 @@ public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {
|
|||
|
||||
List<EdFileInfo> selectAllAdminFolder(String prjId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class BaseModel {
|
|||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
@TableField(value = "updated_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -103,12 +103,6 @@ public class EdFileInfo extends BaseModel {
|
|||
@TableField(value = "save_status")
|
||||
private Integer saveStatus;
|
||||
|
||||
/**
|
||||
* 文件夹发布状态,0-未发布,1-已发布
|
||||
*/
|
||||
@TableField(value = "publish_status")
|
||||
private int publishStatus;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.pojo.resp;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
|
@ -12,6 +13,6 @@ public class ProjectVO {
|
|||
private String parentId;
|
||||
private int sort;
|
||||
|
||||
private List<ProjectVO> children;
|
||||
private List<ProjectVO> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,9 @@ import static com.electromagnetic.industry.software.common.cons.ElectromagneticC
|
|||
@Service
|
||||
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
|
||||
private Environment environment;
|
||||
|
|
@ -94,7 +96,8 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
|
||||
try {
|
||||
// 保存信息到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();
|
||||
String currentUserId = UserThreadLocal.getUserId();
|
||||
String newPrjId = String.valueOf(id + 1);
|
||||
|
|
@ -104,6 +107,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setFileId(newPrjId)
|
||||
.setFileName(prjName)
|
||||
.setFileVersion(100)
|
||||
.setParentId(PRJ_PARENT_ID)
|
||||
.setFileTime(EleCommonUtil.getNowTimeStr())
|
||||
.setDataType(EleDataTypeEnum.FOLDER.code)
|
||||
.setDataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||
|
|
@ -117,7 +121,7 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setUpdatedBy(currentUserId);
|
||||
this.save(fileInfo);
|
||||
// 保存到文件系统
|
||||
fileSystemService.createDirectory(eleDataPath);
|
||||
fileSystemService.createDirectory(eleDataPath + File.separator + prjName);
|
||||
} catch (Exception e) {
|
||||
String info = StrFormatter.format("文件创建失败,具体为--->{}", e.getMessage());
|
||||
log.error(info, e);
|
||||
|
|
@ -248,8 +252,9 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
.setUpdateTime(now)
|
||||
.setCreatedBy(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);
|
||||
return ElectromagneticResultUtil.success(true);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -270,24 +275,21 @@ public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileI
|
|||
try {
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.select(EdFileInfo::getId)
|
||||
.eq(EdFileInfo::getParentId, 0)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code);
|
||||
.eq(EdFileInfo::getParentId, PRJ_PARENT_ID)
|
||||
.eq(EdFileInfo::getEffectFlag, EffectFlagEnum.EFFECT.code);
|
||||
List<String> ids = this.baseMapper.selectList(queryWrapper).stream().map(EdFileInfo::getId).collect(Collectors.toList());
|
||||
|
||||
List<ProjectVO> projectVOS = new ArrayList<>();
|
||||
|
||||
for (String id : ids) {
|
||||
LambdaQueryWrapper<EdFileInfo> queryWrapper1 = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||
.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);
|
||||
List<EdFileInfo> edFileInfos = this.baseMapper.selectAllAdminFolder(id);
|
||||
// 转换为树
|
||||
TreeNodeConfig config = new TreeNodeConfig();
|
||||
config.setIdKey(EdFileInfo.Fields.id);
|
||||
config.setParentIdKey(EdFileInfo.Fields.parentId);
|
||||
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.parentId, obj.getParentId());
|
||||
treeNode.putExtra(EdFileInfo.Fields.sort, obj.getSort());
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@
|
|||
<mapper namespace="com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper">
|
||||
|
||||
<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 id="selectAllAdminFolder"
|
||||
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>
|
||||
</mapper>
|
||||
|
|
@ -5,8 +5,8 @@ import lombok.AllArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
public enum EleDataTypeEnum {
|
||||
|
||||
FILE(0, "文件夹"),
|
||||
FOLDER(1, "普通文件");
|
||||
FOLDER(0, "文件夹"),
|
||||
FILE(1, "普通文件");
|
||||
|
||||
public int code;
|
||||
public String desc;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.electromagnetic.industry.software.common.resp;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ElectromagneticResult<T> implements Serializable, Result {
|
||||
public class ElectromagneticResult<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6408526187818056594L;
|
||||
/**
|
||||
|
|
@ -73,11 +73,6 @@ public class ElectromagneticResult<T> implements Serializable, Result {
|
|||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getStatus() {
|
||||
return success ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>errorCode</tt>.
|
||||
*
|
||||
|
|
@ -113,12 +108,4 @@ public class ElectromagneticResult<T> implements Serializable, Result {
|
|||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Message getMessage() {
|
||||
Message msg = new Message(this.getErrorMessage());
|
||||
//页面展示时,防止出现null状况
|
||||
msg.setCode("");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
package com.electromagnetic.industry.software.common.resp;
|
||||
|
||||
public interface Result {
|
||||
/**
|
||||
* 返回状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Integer getStatus();
|
||||
|
||||
/**
|
||||
* 返回消息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Message getMessage();
|
||||
}
|
||||
Loading…
Reference in New Issue