1.编写上传文件接口;2.修改并添加相关接口。
This commit is contained in:
parent
dae581a856
commit
ce18fd577e
|
|
@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
@RequestMapping("/data/ed/file")
|
@RequestMapping("/data/ed/file")
|
||||||
@RestController
|
@RestController
|
||||||
|
|
@ -38,13 +39,23 @@ public class EDDataController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取子文件数量",notes = "")
|
||||||
|
@RequestMapping(value = "/getChildFileCount",method = RequestMethod.POST)
|
||||||
|
public ElectromagneticResult<?> getChildFileCount(@RequestBody EDDataRequest request){
|
||||||
|
return edDataFacade.getChildFileCount(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "上传",notes = "")
|
@ApiOperation(value = "上传",notes = "")
|
||||||
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
|
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
|
||||||
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file,
|
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
|
||||||
@RequestParam("parentId") String parentId){
|
@RequestParam("file") MultipartFile file){
|
||||||
System.out.println(parentId);
|
|
||||||
// return edDataFacade.upload(request);
|
//System.out.println(parentId);
|
||||||
return null;
|
EDDataRequest request = new EDDataRequest();
|
||||||
|
request.setParentId(parentId);
|
||||||
|
request.setFileData(file);
|
||||||
|
return edDataFacade.upload(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ spring.datasource.typd=com.alibaba.druid.pool.DruidDataSource
|
||||||
#spring.datasource.url=jdbc:mysql://${DATASOURCE_URL:obproxy-0c63.ops.cloud.cic.inter}:3306/${DATASOURCE_HOST:dataplatform_ptst}?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
#spring.datasource.url=jdbc:mysql://${DATASOURCE_URL:obproxy-0c63.ops.cloud.cic.inter}:3306/${DATASOURCE_HOST:dataplatform_ptst}?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
#spring.datasource.username=${DATASOURCE_NAME:dataplatform@ProjectTest_tenant5#testdb}
|
#spring.datasource.username=${DATASOURCE_NAME:dataplatform@ProjectTest_tenant5#testdb}
|
||||||
#spring.datasource.password=${DATASOURCE_PASSWORD:Y7G6v4_3ijn77K_Kbl_U85}
|
#spring.datasource.password=${DATASOURCE_PASSWORD:Y7G6v4_3ijn77K_Kbl_U85}
|
||||||
spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
spring.datasource.url=jdbc:mysql://139.196.179.195:3306/em_data?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true&rewriteBatchedStatements=true
|
||||||
spring.datasource.username=root
|
spring.datasource.username=comac
|
||||||
spring.datasource.password=123456
|
spring.datasource.password=2024*Comac
|
||||||
|
|
||||||
|
|
||||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@ public class EDDataParams implements Serializable {
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String note;
|
private String note;
|
||||||
|
/**
|
||||||
|
* 是否有效
|
||||||
|
*/
|
||||||
|
private String effectFlag;
|
||||||
/**
|
/**
|
||||||
* 关键词
|
* 关键词
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ import com.github.pagehelper.PageInfo;
|
||||||
public interface EDDataRepository {
|
public interface EDDataRepository {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件夹
|
* 创建文件/文件夹数据信息
|
||||||
* @param edDataInfo
|
* @param edDataInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean createFolder(EDDataInfo edDataInfo);
|
Boolean createDataInfo(EDDataInfo edDataInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件信息列表
|
* 获取文件信息列表
|
||||||
|
|
@ -27,6 +27,13 @@ public interface EDDataRepository {
|
||||||
*/
|
*/
|
||||||
PageInfo<EDDataInfo> getDataInfoList(EDDataParams parames);
|
PageInfo<EDDataInfo> getDataInfoList(EDDataParams parames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件信息
|
||||||
|
* @param parames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EDDataInfo getDataInfo(EDDataParams parames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
* @param parames
|
* @param parames
|
||||||
|
|
@ -35,11 +42,11 @@ public interface EDDataRepository {
|
||||||
Boolean updateFileInfo(EDDataParams parames);
|
Boolean updateFileInfo(EDDataParams parames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 获取子文件数量
|
||||||
* @param parames
|
* @param parames
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean upload(EDDataParams parames);
|
Integer getChildFileCount(EDDataParams parames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载
|
* 下载
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ import com.electromagnetic.industry.software.data.manage.domain.boardservice.ind
|
||||||
public interface EDDataService {
|
public interface EDDataService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件夹
|
* 创建文件/文件夹数据信息
|
||||||
* @param edDataInfo
|
* @param edDataInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean createFolder(EDDataInfo edDataInfo);
|
Boolean createDataInfo(EDDataInfo edDataInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件信息列表
|
* 获取文件信息列表
|
||||||
|
|
@ -20,6 +20,13 @@ public interface EDDataService {
|
||||||
*/
|
*/
|
||||||
EDDataPage getDataInfoList(EDDataParams parames);
|
EDDataPage getDataInfoList(EDDataParams parames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件信息
|
||||||
|
* @param parames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
EDDataInfo getDataInfo(EDDataParams parames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
* @param parames
|
* @param parames
|
||||||
|
|
@ -28,11 +35,11 @@ public interface EDDataService {
|
||||||
Boolean updateFileInfo(EDDataParams parames);
|
Boolean updateFileInfo(EDDataParams parames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 获取子文件数量
|
||||||
* @param parames
|
* @param parames
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean upload(EDDataParams parames);
|
Integer getChildFileCount(EDDataParams parames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下载
|
* 下载
|
||||||
|
|
@ -41,4 +48,18 @@ public interface EDDataService {
|
||||||
*/
|
*/
|
||||||
Boolean download(EDDataParams parames);
|
Boolean download(EDDataParams parames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查文件夹是否存在
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean checkFolderIsExist(String path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建多级目录
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean createMultiLevelDirectory(String path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author
|
* @author
|
||||||
|
|
@ -30,13 +33,13 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件夹
|
* 创建文件/文件夹数据信息
|
||||||
* @param edDataInfo
|
* @param edDataInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Boolean createFolder(EDDataInfo edDataInfo)
|
public Boolean createDataInfo(EDDataInfo edDataInfo)
|
||||||
{
|
{
|
||||||
edDataRepository.createFolder(edDataInfo);
|
edDataRepository.createDataInfo(edDataInfo);
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,6 +57,16 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
return edDataPage;
|
return edDataPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件信息
|
||||||
|
* @param parames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public EDDataInfo getDataInfo(EDDataParams parames)
|
||||||
|
{
|
||||||
|
return edDataRepository.getDataInfo(parames);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
* @param parames
|
* @param parames
|
||||||
|
|
@ -66,14 +79,13 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 获取子文件数量
|
||||||
* @param parames
|
* @param parames
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Boolean upload(EDDataParams parames)
|
public Integer getChildFileCount(EDDataParams parames)
|
||||||
{
|
{
|
||||||
edDataRepository.upload(parames);
|
return edDataRepository.getChildFileCount(parames);
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -87,6 +99,30 @@ public class EDDataServiceImpl implements EDDataService {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查文件夹是否存在
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean checkFolderIsExist(String path)
|
||||||
|
{
|
||||||
|
return Files.exists(Paths.get(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建多级目录
|
||||||
|
* @param path
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean createMultiLevelDirectory(String path)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Files.createDirectories(Paths.get(path));
|
||||||
|
return Boolean.TRUE;
|
||||||
|
} catch (IOException e) {
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +28,13 @@ public interface EDDataFacade {
|
||||||
*/
|
*/
|
||||||
ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request);
|
ElectromagneticResult<Boolean> updateFileInfo(EDDataRequest request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取子文件数量
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElectromagneticResult<Boolean> getChildFileCount(EDDataRequest request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 上传
|
||||||
* @param request
|
* @param request
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ public class EDDataRequest extends BaseRequest {
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
private String note;
|
private String note;
|
||||||
|
/**
|
||||||
|
* 是否有效
|
||||||
|
*/
|
||||||
|
private String effectFlag;
|
||||||
/**
|
/**
|
||||||
* 关键词
|
* 关键词
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.electromagnetic.industry.software.data.manage.repository.dao;
|
||||||
|
|
||||||
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
|
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
|
||||||
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
|
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
|
||||||
|
import com.electromagnetic.industry.software.data.manage.request.indicator.EDDataRequest;
|
||||||
|
import electromagnetic.data.framework.share.model.ElectromagneticResult;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -30,5 +32,19 @@ public interface EDDataMapper {
|
||||||
*/
|
*/
|
||||||
Boolean updateFileInfo(EDDataParams parames);
|
Boolean updateFileInfo(EDDataParams parames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取子文件数量
|
||||||
|
* @param parames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Integer getChildFileCount(EDDataParams parames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取目录路径
|
||||||
|
* @param categoryId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getDirectoryPath(String categoryId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -25,13 +25,13 @@ public class EDDataRepositoryImpl implements EDDataRepository {
|
||||||
private EDDataMapper edDataMapper;
|
private EDDataMapper edDataMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建文件夹
|
* 创建文件/文件夹数据信息
|
||||||
*
|
*
|
||||||
* @param edDataInfo
|
* @param edDataInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean createFolder(EDDataInfo edDataInfo)
|
public Boolean createDataInfo(EDDataInfo edDataInfo)
|
||||||
{
|
{
|
||||||
return edDataMapper.createDataInfo(edDataInfo);
|
return edDataMapper.createDataInfo(edDataInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -49,6 +49,18 @@ public class EDDataRepositoryImpl implements EDDataRepository {
|
||||||
return new PageInfo<>(edDataInfoList);
|
return new PageInfo<>(edDataInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取文件信息
|
||||||
|
* @param parames
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EDDataInfo getDataInfo(EDDataParams parames)
|
||||||
|
{
|
||||||
|
List<EDDataInfo> edDataInfoList=edDataMapper.getDataInfoList(parames);
|
||||||
|
return edDataInfoList.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
* @param parames
|
* @param parames
|
||||||
|
|
@ -61,16 +73,14 @@ public class EDDataRepositoryImpl implements EDDataRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 获取子文件数量
|
||||||
* @param parames
|
* @param parames
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean upload(EDDataParams parames)
|
public Integer getChildFileCount(EDDataParams parames)
|
||||||
{
|
{
|
||||||
//return edDataMapper.upload(parames);
|
return edDataMapper.getChildFileCount(parames);
|
||||||
//edDataMapper.createDataInfo(edDataInfo);
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -86,4 +96,5 @@ public class EDDataRepositoryImpl implements EDDataRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -86,10 +86,15 @@
|
||||||
<if test="note != null and note!=''">
|
<if test="note != null and note!=''">
|
||||||
note = #{note,jdbcType=VARCHAR},
|
note = #{note,jdbcType=VARCHAR},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="effectFlag != null and effectFlag!=''">
|
||||||
|
effect_flag = #{effectFlag,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
gmt_modified = now()
|
gmt_modified = now()
|
||||||
</set>
|
</set>
|
||||||
where data_id = #{dataId,jdbcType=VARCHAR} and effect_flag = 1
|
where data_id = #{dataId,jdbcType=VARCHAR} and effect_flag = 1
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.electromagnetic.industry.software.data.manage.service.facade;
|
package com.electromagnetic.industry.software.data.manage.service.facade;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
|
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataInfo;
|
||||||
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataPage;
|
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.model.EDDataPage;
|
||||||
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
|
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
|
||||||
|
|
@ -17,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class EDDataFacadeImpl implements EDDataFacade {
|
public class EDDataFacadeImpl implements EDDataFacade {
|
||||||
|
|
@ -58,7 +61,36 @@ public class EDDataFacadeImpl implements EDDataFacade {
|
||||||
edDataInfo.setVersion("1.0.0");
|
edDataInfo.setVersion("1.0.0");
|
||||||
edDataInfo.setDataStatus("publish");
|
edDataInfo.setDataStatus("publish");
|
||||||
|
|
||||||
edDataService.createFolder(edDataInfo);
|
String newFolderPath = "";
|
||||||
|
// 获取上级目录的名称
|
||||||
|
if(!request.getParentId().isEmpty()) {
|
||||||
|
EDDataParams parames = new EDDataParams();
|
||||||
|
parames.setParentId(request.getParentId());
|
||||||
|
EDDataInfo edDataInfoParent = edDataService.getDataInfo(parames);
|
||||||
|
String folderName = edDataInfoParent.getDataName();
|
||||||
|
String folderId = edDataInfoParent.getDataId();
|
||||||
|
|
||||||
|
// 记录当前目录的文件夹路径和文件夹id路径
|
||||||
|
JSONObject implantJsonObject = JSON.parseObject(edDataInfoParent.getImplantJson());
|
||||||
|
String folderPath = implantJsonObject.getString("folderPath");
|
||||||
|
String folderIdPath = implantJsonObject.getString("folderIdPath");
|
||||||
|
newFolderPath = folderPath + folderName;
|
||||||
|
implantJsonObject.put("folderPath", newFolderPath);
|
||||||
|
implantJsonObject.put("folderIdPath", folderIdPath + folderId);
|
||||||
|
String newImplantJson = implantJsonObject.toJSONString();
|
||||||
|
edDataInfo.setImplantJson(newImplantJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isSuccess = edDataService.createDataInfo(edDataInfo);
|
||||||
|
if(isSuccess)
|
||||||
|
{
|
||||||
|
// 获取文件存储的文件夹路径
|
||||||
|
String storageDirectory = "D:/fileTemp/" + newFolderPath;
|
||||||
|
if(!edDataService.checkFolderIsExist(storageDirectory)) {
|
||||||
|
edDataService.createMultiLevelDirectory(storageDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,8 +115,8 @@ public class EDDataFacadeImpl implements EDDataFacade {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新文件信息
|
* 更新文件信息
|
||||||
* WISDOM_UPDATE_FILESTATUS
|
* WISDOM_UPDATE_FILEINFO
|
||||||
* /data/ed/file/updateFileStatus
|
* /data/ed/file/updateFileInfo
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -95,6 +127,20 @@ public class EDDataFacadeImpl implements EDDataFacade {
|
||||||
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取子文件数量
|
||||||
|
* WISDOM_GET_CHILDFILECOUNT
|
||||||
|
* /data/ed/file/getChildFileCount
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ElectromagneticResult<Boolean> getChildFileCount(EDDataRequest request)
|
||||||
|
{
|
||||||
|
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||||
|
Integer fileCount = edDataService.getChildFileCount(parames);
|
||||||
|
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传
|
* 上传
|
||||||
* WISDOM_UPLOAD
|
* WISDOM_UPLOAD
|
||||||
|
|
@ -105,7 +151,6 @@ public class EDDataFacadeImpl implements EDDataFacade {
|
||||||
public ElectromagneticResult<Boolean> upload(EDDataRequest request)
|
public ElectromagneticResult<Boolean> upload(EDDataRequest request)
|
||||||
{
|
{
|
||||||
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
|
||||||
edDataService.upload(parames);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 获取目录编码ID
|
// 获取目录编码ID
|
||||||
|
|
@ -121,15 +166,76 @@ public class EDDataFacadeImpl implements EDDataFacade {
|
||||||
|
|
||||||
// 获取文件名
|
// 获取文件名
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
|
// 获取文件类型
|
||||||
|
String fileType = "";
|
||||||
|
if (fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) {
|
||||||
|
fileType = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取文件存储的文件夹路径
|
||||||
|
String storageDirectory = "D:/fileTemp";
|
||||||
|
if(!edDataService.checkFolderIsExist(storageDirectory)) {
|
||||||
|
edDataService.createMultiLevelDirectory(storageDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
String parentFolderPath = "";
|
||||||
|
String parentFolderIdPath = "";
|
||||||
|
|
||||||
|
// 获取上级文件夹路径
|
||||||
|
{
|
||||||
|
EDDataParams folderParames = new EDDataParams();
|
||||||
|
folderParames.setParentId(categoryId);
|
||||||
|
EDDataInfo edDataInfoParent = edDataService.getDataInfo(folderParames);
|
||||||
|
JSONObject implantJsonObject = JSON.parseObject(edDataInfoParent.getImplantJson());
|
||||||
|
parentFolderPath = implantJsonObject.getString("folderPath");
|
||||||
|
parentFolderIdPath = implantJsonObject.getString("folderIdPath");
|
||||||
|
if(!parentFolderPath.isEmpty())
|
||||||
|
parentFolderPath += "/";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件保存目录路径
|
||||||
|
String fileSavePath = storageDirectory + "/" + parentFolderPath + fileName;
|
||||||
|
|
||||||
// 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑
|
// 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑
|
||||||
// 例如,假设要保存到项目的 /uploads 目录下(需要确保该目录存在且可写)
|
File saveFile = new File(fileSavePath);
|
||||||
file.transferTo(new File("fileData/" + fileName));
|
|
||||||
|
|
||||||
// 根据目录编码ID和文件名等信息可以进行进一步的处理,比如将文件保存到对应目录等
|
// 将文件保存到硬盘
|
||||||
// 这里只是示例,假设打印相关信息
|
file.transferTo(saveFile);
|
||||||
System.out.println("目录编码ID: " + categoryId);
|
|
||||||
System.out.println("文件名: " + fileName);
|
// 文件数据信息写到数据库
|
||||||
|
{
|
||||||
|
// 临时数据设置
|
||||||
|
if(Boolean.TRUE) {
|
||||||
|
if (request.getUserId() == null || request.getUserId().isEmpty()) request.setUserId(IdWorker.getSnowFlakeIdString());
|
||||||
|
if (request.getUserName() == null || request.getUserName().isEmpty()) request.setUserName("user");
|
||||||
|
if (request.getName() == null || request.getName().isEmpty()) request.setName("testFolder");
|
||||||
|
if (request.getParentId() == null || request.getParentId().isEmpty()) request.setParentId(IdWorker.getSnowFlakeIdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建新文件数据
|
||||||
|
EDDataInfo edDataInfo = new EDDataInfo();
|
||||||
|
edDataInfo.setCreator(request.getUserId());
|
||||||
|
edDataInfo.setCreatorName(request.getUserName());
|
||||||
|
edDataInfo.setModifier(request.getUserId());
|
||||||
|
edDataInfo.setModifierName(request.getUserName());
|
||||||
|
edDataInfo.setCategoryId(request.getParentId());
|
||||||
|
edDataInfo.setDataName(request.getName());
|
||||||
|
edDataInfo.setNote(request.getNote());
|
||||||
|
|
||||||
|
edDataInfo.setDataId(IdWorker.getSnowFlakeIdString());
|
||||||
|
edDataInfo.setDataNo(IdWorker.getSnowFlakeIdString());
|
||||||
|
edDataInfo.setDataType("file");
|
||||||
|
edDataInfo.setVersion("1.0.0");
|
||||||
|
edDataInfo.setDataStatus("publish");
|
||||||
|
|
||||||
|
JSONObject newImplantJsonObject = new JSONObject();
|
||||||
|
newImplantJsonObject.put("folderPath", parentFolderPath);
|
||||||
|
newImplantJsonObject.put("folderIdPath", parentFolderIdPath);
|
||||||
|
edDataInfo.setImplantJson(newImplantJsonObject.toJSONString());
|
||||||
|
|
||||||
|
boolean isSuccess = edDataService.createDataInfo(edDataInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 如果文件上传成功,返回成功消息
|
// 如果文件上传成功,返回成功消息
|
||||||
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
return ElectromagneticResultUtil.success(Boolean.TRUE);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue