实现部分功能
This commit is contained in:
parent
18c72d0d08
commit
25ee4a5fa2
|
|
@ -1,9 +1,58 @@
|
||||||
package com.electromagnetic.industry.software.manage.controller;
|
package com.electromagnetic.industry.software.manage.controller;
|
||||||
|
|
||||||
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||||
|
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/data/ed/prj")
|
@RequestMapping("/data/ed/prj")
|
||||||
public class ProjectController {
|
public class ProjectController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EdFileInfoService edFileInfoService;
|
||||||
|
|
||||||
|
@RequestMapping("create")
|
||||||
|
public ElectromagneticResult<?> create(@RequestParam String prjName) {
|
||||||
|
return edFileInfoService.createNewPrj(prjName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("delete")
|
||||||
|
public ElectromagneticResult<?> delete(@RequestParam String prjId) {
|
||||||
|
return edFileInfoService.delete(prjId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("modify")
|
||||||
|
public ElectromagneticResult<?> modifyPrjName(@RequestParam String newPrjName, @RequestParam String prjId) {
|
||||||
|
return edFileInfoService.modifyPrjName(prjId, newPrjName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("queryAll")
|
||||||
|
public ElectromagneticResult<?> queryAll() {
|
||||||
|
return edFileInfoService.queryAllPrjInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("addFolder")
|
||||||
|
public ElectromagneticResult<?> addFolder(@RequestParam String folderName, @RequestParam String parentId) {
|
||||||
|
return edFileInfoService.addFolder(parentId, folderName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("folderResort")
|
||||||
|
public ElectromagneticResult<?> folderResort(@RequestBody List<FolderResortDTO> folderResortDTOList) {
|
||||||
|
return edFileInfoService.folderResort(folderResortDTOList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("publish")
|
||||||
|
public ElectromagneticResult<?> publish(@RequestParam String prjId) {
|
||||||
|
return edFileInfoService.publish(prjId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {
|
public interface EdFileInfoMapper extends BaseMapper<EdFileInfo> {
|
||||||
|
|
||||||
|
String maxPrjId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.electromagnetic.industry.software.manage.pojo.models;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@SuperBuilder
|
||||||
|
@Data
|
||||||
|
public class BaseModel {
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "created_time")
|
||||||
|
private Date createdTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@TableField(value = "created_by")
|
||||||
|
private String createdBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "update_time")
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新人
|
||||||
|
*/
|
||||||
|
@TableField(value = "updated_by")
|
||||||
|
private String updatedBy;
|
||||||
|
}
|
||||||
|
|
@ -2,13 +2,14 @@ package com.electromagnetic.industry.software.manage.pojo.models;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.util.Date;
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("ed_file_info")
|
@TableName("ed_file_info")
|
||||||
public class EdFileInfo {
|
@SuperBuilder
|
||||||
|
@Data
|
||||||
|
public class EdFileInfo extends BaseModel {
|
||||||
/**
|
/**
|
||||||
* 主键ID
|
* 主键ID
|
||||||
*/
|
*/
|
||||||
|
|
@ -100,30 +101,6 @@ public class EdFileInfo {
|
||||||
@TableField(value = "save_status")
|
@TableField(value = "save_status")
|
||||||
private Integer saveStatus;
|
private Integer saveStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件创建时间
|
|
||||||
*/
|
|
||||||
@TableField(value = "created_time")
|
|
||||||
private Date createdTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件创建人
|
|
||||||
*/
|
|
||||||
@TableField(value = "created_by")
|
|
||||||
private String createdBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件最后更新时间
|
|
||||||
*/
|
|
||||||
@TableField(value = "update_time")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件最后更新人
|
|
||||||
*/
|
|
||||||
@TableField(value = "updated_by")
|
|
||||||
private String updatedBy;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件夹发布状态,0-未发布,1-已发布
|
* 文件夹发布状态,0-未发布,1-已发布
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FolderResortDTO {
|
||||||
|
private String id;
|
||||||
|
private int sort;
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,58 @@
|
||||||
package com.electromagnetic.industry.software.manage.service;
|
package com.electromagnetic.industry.software.manage.service;
|
||||||
|
|
||||||
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface EdFileInfoService {
|
public interface EdFileInfoService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的工程
|
||||||
|
* @param prjName 新的工程名
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> createNewPrj(String prjName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改项目名称
|
||||||
|
* @param prjId
|
||||||
|
* @param newPrjName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> modifyPrjName(String prjId, String newPrjName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一个项目,做逻辑删除
|
||||||
|
* @param prjId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> delete(String prjId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加子集
|
||||||
|
* @param parentId
|
||||||
|
* @param folderName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> addFolder(String parentId, String folderName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有项目
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> queryAllPrjInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子集拖拽重排序
|
||||||
|
* @param folderResortDTOList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目发布
|
||||||
|
* @param prjId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<?> publish(String prjId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.electromagnetic.industry.software.manage.service;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
public interface FileSystemService {
|
||||||
|
|
||||||
|
void createDirectory(String path);
|
||||||
|
|
||||||
|
void copyFile(String source, String destination);
|
||||||
|
|
||||||
|
void moveFile(String source, String destination);
|
||||||
|
|
||||||
|
void save(InputStream inputStream, String destination);
|
||||||
|
|
||||||
|
void renameFile(String sourcePath, String oldName, String newName);
|
||||||
|
|
||||||
|
boolean checkFolderExist(String newPath);
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,282 @@
|
||||||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.text.StrFormatter;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.electromagnetic.industry.software.common.cons.ElectromagneticConstants;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.EffectFlagEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.EleDataSaveStatusEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.EleDataStatusEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.enums.EleDataTypeEnum;
|
||||||
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
|
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||||
|
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||||
|
import com.electromagnetic.industry.software.common.util.IdWorker;
|
||||||
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
|
import com.electromagnetic.industry.software.manage.mapper.EdFileInfoMapper;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
||||||
|
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||||
|
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class EdFileInfoServiceImpl implements EdFileInfoService {
|
public class EdFileInfoServiceImpl extends ServiceImpl<EdFileInfoMapper, EdFileInfo> implements EdFileInfoService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private FileSystemService fileSystemService;
|
||||||
|
|
||||||
|
@Value("${prj.folder.max.length}")
|
||||||
|
private int prjFolderMaxLength;
|
||||||
|
|
||||||
|
private String eleDataPath;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
String osName = System.getProperty("os.name").toLowerCase();
|
||||||
|
eleDataPath = osName.startsWith("win") ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个新的工程
|
||||||
|
* @param prjName 新的工程名
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElectromagneticResult<?> createNewPrj(String prjName) {
|
||||||
|
// 首先检查工程是否存在
|
||||||
|
// TODO 一个项目如果被废除了,然后又新建了一个同名工程,这种情况怎么处理,需要产品确认。当前这里先按照同名如果存在则抛出异常处理。
|
||||||
|
LambdaQueryWrapper<EdFileInfo> existPrjWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.eq(EdFileInfo::getParentId, "")
|
||||||
|
.isNull(EdFileInfo::getParentId);
|
||||||
|
|
||||||
|
List<EdFileInfo> existEdFileInfos = this.baseMapper.selectList(existPrjWrapper);
|
||||||
|
if (CollUtil.isNotEmpty(existEdFileInfos)) {
|
||||||
|
log.info("{} 已经存在", prjName);
|
||||||
|
ElectromagneticResultUtil.fail("-1", "该项目名称已经存在。");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 保存信息到MySQL
|
||||||
|
int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||||
|
Date now = new Date();
|
||||||
|
String currentUserId = UserThreadLocal.getUserId();
|
||||||
|
String newPrjId = String.valueOf(id + 1);
|
||||||
|
EdFileInfo fileInfo = EdFileInfo.builder()
|
||||||
|
.id(newPrjId)
|
||||||
|
.fileId(IdWorker.getSnowFlakeIdString())
|
||||||
|
.fileName(prjName)
|
||||||
|
.fileVersion(100)
|
||||||
|
.fileTime(EleCommonUtil.getNowTimeStr())
|
||||||
|
.dataType(EleDataTypeEnum.FOLDER.code)
|
||||||
|
.dataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
|
.effectFlag(EffectFlagEnum.EFFECT.code)
|
||||||
|
.saveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||||
|
.filePath(newPrjId)
|
||||||
|
.sort(1)
|
||||||
|
.createdTime(now)
|
||||||
|
.updateTime(now)
|
||||||
|
.createdBy(currentUserId)
|
||||||
|
.updatedBy(currentUserId)
|
||||||
|
.build();
|
||||||
|
this.save(fileInfo);
|
||||||
|
// 保存到文件系统
|
||||||
|
fileSystemService.createDirectory(eleDataPath);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("文件创建失败,具体为--->{}", e.getMessage(), e);
|
||||||
|
return ElectromagneticResultUtil.fail("-1", e.getMessage());
|
||||||
|
}
|
||||||
|
return ElectromagneticResultUtil.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改项目名称
|
||||||
|
* @param prjId
|
||||||
|
* @param newPrjName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElectromagneticResult<?> modifyPrjName(String prjId, String newPrjName) {
|
||||||
|
try {
|
||||||
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class).eq(EdFileInfo::getId, prjId);
|
||||||
|
EdFileInfo fileInfo = this.baseMapper.selectOne(queryWrapper);
|
||||||
|
String oldPrjName = fileInfo.getFileName();
|
||||||
|
String newPath = eleDataPath + File.separator + newPrjName;
|
||||||
|
if (fileSystemService.checkFolderExist(newPath)) {
|
||||||
|
String info = StrFormatter.format("工程名{}已经存在", newPrjName);
|
||||||
|
log.error(info);
|
||||||
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
|
}
|
||||||
|
fileInfo.setFileName(newPrjName);
|
||||||
|
this.baseMapper.updateById(fileInfo);
|
||||||
|
fileSystemService.renameFile(eleDataPath, oldPrjName, newPrjName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("修改工程名异常--->{},{}", newPrjName, e.getMessage(), e);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return ElectromagneticResultUtil.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一个项目,做逻辑删除
|
||||||
|
*
|
||||||
|
* @param prjId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ElectromagneticResult<?> delete(String prjId) {
|
||||||
|
|
||||||
|
List<String> ids = new ArrayList<>();
|
||||||
|
ids.add(prjId);
|
||||||
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.select(EdFileInfo::getId)
|
||||||
|
.likeRight(EdFileInfo::getFilePath, prjId + ElectromagneticConstants.MYSQL_FILE_PATH_SPLIT);
|
||||||
|
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||||
|
edFileInfos.forEach(e -> ids.add(e.getId()));
|
||||||
|
Wrappers.lambdaUpdate(EdFileInfo.class).set(EdFileInfo::getEffectFlag, EffectFlagEnum.NOT_EFFECTIVE.code).in(EdFileInfo::getId, ids);
|
||||||
|
return ElectromagneticResultUtil.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加子集
|
||||||
|
*
|
||||||
|
* @param parentId
|
||||||
|
* @param folderName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElectromagneticResult<?> addFolder(String parentId, String folderName) {
|
||||||
|
|
||||||
|
// 首先判断判断当前深度是否已经达到6层
|
||||||
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.select(EdFileInfo::getId, EdFileInfo::getFilePath)
|
||||||
|
.eq(EdFileInfo::getId, parentId);
|
||||||
|
EdFileInfo edFileInfo = this.baseMapper.selectOne(queryWrapper);
|
||||||
|
String currentPath = edFileInfo.getFilePath();
|
||||||
|
List<String> paths = CollUtil.newArrayList(edFileInfo.getFilePath().split(ElectromagneticConstants.MYSQL_FILE_PATH_SPLIT));
|
||||||
|
if (paths.size() >= prjFolderMaxLength) {
|
||||||
|
String info = "当前子集已达到最大层级,禁止创建子集。";
|
||||||
|
log.error(info);
|
||||||
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
|
}
|
||||||
|
// 判断文件夹名称是否存在
|
||||||
|
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.select(EdFileInfo::getId, EdFileInfo::getFileName)
|
||||||
|
.eq(EdFileInfo::getParentId, parentId));
|
||||||
|
List<String> names = edFileInfos.stream().map(EdFileInfo::getFileName).collect(Collectors.toList());
|
||||||
|
if (names.contains(folderName)) {
|
||||||
|
String info = "该子集名称已存在";
|
||||||
|
log.error(info);
|
||||||
|
return ElectromagneticResultUtil.fail("-1", info);
|
||||||
|
}
|
||||||
|
|
||||||
|
// int id = Integer.parseInt(this.baseMapper.maxPrjId());
|
||||||
|
// Date now = new Date();
|
||||||
|
// String currentUserId = UserThreadLocal.getUserId();
|
||||||
|
// String newPrjId = String.valueOf(id + 1);
|
||||||
|
// EdFileInfo fileInfo = EdFileInfo.builder()
|
||||||
|
// .id(newPrjId)
|
||||||
|
// .fileId(IdWorker.getSnowFlakeIdString())
|
||||||
|
// .fileName(folderName)
|
||||||
|
// .fileVersion(100)
|
||||||
|
// .fileTime(EleCommonUtil.getNowTimeStr())
|
||||||
|
// .dataType(EleDataTypeEnum.FOLDER.code)
|
||||||
|
// .dataStatus(EleDataStatusEnum.NOT_PUBLISHED.code)
|
||||||
|
// .effectFlag(EffectFlagEnum.EFFECT.code)
|
||||||
|
// .saveStatus(EleDataSaveStatusEnum.SUCCESS.code)
|
||||||
|
// .filePath(newPrjId)
|
||||||
|
// .sort(1)
|
||||||
|
// .createdTime(now)
|
||||||
|
// .updateTime(now)
|
||||||
|
// .createdBy(currentUserId)
|
||||||
|
// .updatedBy(currentUserId)
|
||||||
|
// .build();
|
||||||
|
// this.save(fileInfo);
|
||||||
|
// // 保存到文件系统
|
||||||
|
// fileSystemService.createDirectory(eleDataPath);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有项目
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ElectromagneticResult<?> queryAllPrjInfo() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子集拖拽重排序
|
||||||
|
*
|
||||||
|
* @param folderResortDTOList
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ElectromagneticResult<?> folderResort(List<FolderResortDTO> folderResortDTOList) {
|
||||||
|
|
||||||
|
for (FolderResortDTO folderResortDTO : folderResortDTOList) {
|
||||||
|
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
|
.set(EdFileInfo::getSort, folderResortDTO.getSort())
|
||||||
|
.eq(EdFileInfo::getId, folderResortDTO.getId());
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
return ElectromagneticResultUtil.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目发布
|
||||||
|
*
|
||||||
|
* @param prjId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ElectromagneticResult<?> publish(String prjId) {
|
||||||
|
LambdaUpdateWrapper<EdFileInfo> updateWrapper = Wrappers.lambdaUpdate(EdFileInfo.class)
|
||||||
|
.set(EdFileInfo::getDataStatus, EleDataStatusEnum.PUBLISHED.code)
|
||||||
|
.likeRight(EdFileInfo::getFilePath, prjId);
|
||||||
|
this.update(updateWrapper);
|
||||||
|
return ElectromagneticResultUtil.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getPath(List<String> ids) {
|
||||||
|
LambdaQueryWrapper<EdFileInfo> queryWrapper = Wrappers.lambdaQuery(EdFileInfo.class)
|
||||||
|
.select(EdFileInfo::getId, EdFileInfo::getFileName)
|
||||||
|
.in(EdFileInfo::getId, ids);
|
||||||
|
List<EdFileInfo> edFileInfos = this.baseMapper.selectList(queryWrapper);
|
||||||
|
Map<String, String> map = edFileInfos.stream().collect(Collectors.toMap(EdFileInfo::getId, EdFileInfo::getFileName));
|
||||||
|
StringBuilder path = new StringBuilder();
|
||||||
|
for (String id : ids) {
|
||||||
|
String tmp = map.get(id) + File.separator;
|
||||||
|
path.append(tmp);
|
||||||
|
}
|
||||||
|
return path.toString();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FileSystemServiceImpl implements FileSystemService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createDirectory(String path) {
|
||||||
|
FileUtil.mkdir(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copyFile(String source, String destination) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void moveFile(String source, String destination) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(InputStream inputStream, String destination) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renameFile(String sourcePath, String oldName, String newName) {
|
||||||
|
File sourceFile = new File(sourcePath + File.separator + oldName);
|
||||||
|
FileUtil.rename(sourceFile, newName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkFolderExist(String newPath) {
|
||||||
|
return FileUtil.exist(newPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ public class UserServiceImpl implements UserService {
|
||||||
public Boolean checkUserValid(User user) {
|
public Boolean checkUserValid(User user) {
|
||||||
if (user == null
|
if (user == null
|
||||||
|| user.getIsPublished() == PublishEnum.UNPUBLISHED.getCode()
|
|| user.getIsPublished() == PublishEnum.UNPUBLISHED.getCode()
|
||||||
|| user.getEffectFlag() == EffectFlagEnum.EFFECT_FLAG_0.getCode()
|
|| user.getEffectFlag() == EffectFlagEnum.NOT_EFFECTIVE.code
|
||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
} else if (user.getInternshipEndDate() != null && user.getInternshipEndDate().before(now())) {
|
} else if (user.getInternshipEndDate() != null && user.getInternshipEndDate().before(now())) {
|
||||||
|
|
|
||||||
|
|
@ -22,20 +22,22 @@ mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
pagehelper.helperDialect=mysql
|
pagehelper.helperDialect=mysql
|
||||||
pagehelper.reasonable=false
|
pagehelper.reasonable=false
|
||||||
server.port=8888
|
server.port=8888
|
||||||
#windows文件存储目录
|
#windows文件存储目录,用于测试
|
||||||
data.windows.path=E:/comacFileStorage/
|
data.windows.path=E:/tmp/eleData/
|
||||||
#文件缓存路径
|
data.linux.path=/szsd/data/eleData
|
||||||
data.file.cache.dir=/szsd/cache/
|
prj.folder.max.length=6
|
||||||
#文件存储路径
|
##文件缓存路径
|
||||||
data.file.storage.dir=/szsd/fileStorage/
|
#data.file.cache.dir=/szsd/cache/
|
||||||
#上传文件时文件的缓存文件夹名称
|
##文件存储路径
|
||||||
data.upload.cache.dir=upload
|
#data.file.storage.dir=/szsd/fileStorage/
|
||||||
#导出数据时文件的缓存文件夹名称
|
##上传文件时文件的缓存文件夹名称
|
||||||
data.export.cache.dir=export
|
#data.upload.cache.dir=upload
|
||||||
#导入数据时文件的缓存文件夹名称
|
##导出数据时文件的缓存文件夹名称
|
||||||
data.import.cache.dir=import
|
#data.export.cache.dir=export
|
||||||
file.encode.passwd=adknfhkj87654knd
|
##导入数据时文件的缓存文件夹名称
|
||||||
#数据类型中的文件类型为file
|
#data.import.cache.dir=import
|
||||||
data.type.file=file
|
#file.encode.passwd=adknfhkj87654knd
|
||||||
#数据类型中的文件夹类型为folder
|
##数据类型中的文件类型为file
|
||||||
data.type.folder=folder
|
#data.type.file=file
|
||||||
|
##数据类型中的文件夹类型为folder
|
||||||
|
#data.type.folder=folder
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<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>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -4,4 +4,6 @@ public interface ElectromagneticConstants {
|
||||||
|
|
||||||
String EXPORT_FILE_SUFFIX = ".colib";
|
String EXPORT_FILE_SUFFIX = ".colib";
|
||||||
|
|
||||||
|
String MYSQL_FILE_PATH_SPLIT = "_";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,16 @@ import lombok.Getter;
|
||||||
* @version $Id: EffectFlagEnum.java, v 0.1 2024-08-01 18:18
|
* @version $Id: EffectFlagEnum.java, v 0.1 2024-08-01 18:18
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
|
||||||
public enum EffectFlagEnum {
|
public enum EffectFlagEnum {
|
||||||
/**
|
/**
|
||||||
* 有效
|
* 有效
|
||||||
*/
|
*/
|
||||||
EFFECT_FLAG_1(1, "有效"),
|
EFFECT(1, "有效"),
|
||||||
/**
|
/**
|
||||||
* 无效
|
* 无效
|
||||||
*/
|
*/
|
||||||
EFFECT_FLAG_0(0, "无效"),
|
NOT_EFFECTIVE(0, "无效");
|
||||||
;
|
public Integer code;
|
||||||
private Integer code;
|
public String desc;
|
||||||
private String desc;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.electromagnetic.industry.software.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum EleDataSaveStatusEnum {
|
||||||
|
|
||||||
|
UPLOADING(0, "上传中"),
|
||||||
|
SUCCESS(1, "上传成功"),
|
||||||
|
FAIL(2, "上传失败");
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
public String des;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.electromagnetic.industry.software.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum EleDataStatusEnum {
|
||||||
|
|
||||||
|
NOT_PUBLISHED(0, "未发布"),
|
||||||
|
PUBLISHED(1, "已发布"),
|
||||||
|
OCCUPY(2, "占用");
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
public String desc;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.electromagnetic.industry.software.common.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum EleDataTypeEnum {
|
||||||
|
|
||||||
|
FILE(0, "文件夹"),
|
||||||
|
FOLDER(1, "普通文件");
|
||||||
|
|
||||||
|
public int code;
|
||||||
|
public String desc;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.electromagnetic.industry.software.common.exception;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class BizException extends RuntimeException {
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.electromagnetic.industry.software.common.util;
|
package com.electromagnetic.industry.software.common.util;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public final class EleCommonUtil {
|
public final class EleCommonUtil {
|
||||||
|
|
@ -7,6 +9,8 @@ public final class EleCommonUtil {
|
||||||
// 正则表达式模式,匹配中文字符、下划线、连字符、加号、数字和英文字符
|
// 正则表达式模式,匹配中文字符、下划线、连字符、加号、数字和英文字符
|
||||||
private static final String PATTERN = "^[\\u4e00-\\u9fa5a-zA-Z0-9._\\-+]+$";
|
private static final String PATTERN = "^[\\u4e00-\\u9fa5a-zA-Z0-9._\\-+]+$";
|
||||||
|
|
||||||
|
private static final String TIME_FORMAT1 = "yyMMddHHmmssSSS";
|
||||||
|
|
||||||
// 编译正则表达式
|
// 编译正则表达式
|
||||||
private static final Pattern pattern = Pattern.compile(PATTERN);
|
private static final Pattern pattern = Pattern.compile(PATTERN);
|
||||||
|
|
||||||
|
|
@ -37,4 +41,13 @@ public final class EleCommonUtil {
|
||||||
return pattern.matcher(fileFullName).matches();
|
return pattern.matcher(fileFullName).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getNowTimeStr() {
|
||||||
|
// 获取当前时间
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
// 创建日期时间格式化器
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(TIME_FORMAT1);
|
||||||
|
// 格式化当前时间
|
||||||
|
return now.format(formatter);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue