1.增加获取子文件数量接口;2.增加文件下载接口;3.修改上传文件接口

This commit is contained in:
sxlong 2024-11-19 16:50:07 +08:00
parent 6fa792ae48
commit 512f9724d8
10 changed files with 92 additions and 49 deletions

View File

@ -50,8 +50,6 @@ public class EDDataController {
@RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file){
//System.out.println(parentId);
EDDataRequest request = new EDDataRequest();
request.setParentId(parentId);
request.setFileData(file);
@ -73,10 +71,4 @@ public class EDDataController {
}
@ApiOperation(value = "重命名",notes = "")
@RequestMapping(value = "/rename",method = RequestMethod.POST)
public ElectromagneticResult<?> rename(@RequestBody EDDataRequest request){
return ElectromagneticResultUtil.success("重命名");
}
}

View File

@ -61,6 +61,10 @@ public class EDDataInfo {
* 编辑人
*/
private String editor;
/**
* 批量上传时间
*/
private String gmtBatchUpload;
/**
* 创建人
*/

View File

@ -48,6 +48,14 @@ public class EDDataParams implements Serializable {
* 关键词
*/
private String keyWord;
/**
* 批量上传时间
*/
private String gmtBatchUpload;
/**
* 文件数据编码数组
*/
private String[] dataIdArr;
/**
* 文件数据
*/

View File

@ -7,6 +7,8 @@ import com.electromagnetic.industry.software.data.manage.domain.boardservice.ind
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.parames.EDDataParams;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* @author
* @version $Id: EDDataRepos.java, v 0.1 2024-07-29 19:02
@ -25,7 +27,7 @@ public interface EDDataRepository {
* @param parames
* @return
*/
PageInfo<EDDataInfo> getDataInfoList(EDDataParams parames);
List<EDDataInfo> getDataInfoList(EDDataParams parames);
/**
* 获取文件信息
@ -41,13 +43,6 @@ public interface EDDataRepository {
*/
Boolean updateFileInfo(EDDataParams parames);
/**
* 获取子文件数量
* @param parames
* @return
*/
Integer getChildFileCount(EDDataParams parames);
/**
* 下载
* @param parames

View File

@ -3,11 +3,13 @@
*/
package com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.service.impl;
import cn.hutool.poi.excel.cell.CellSetter;
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.parames.EDDataParams;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.repository.EDDataRepository;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.service.EDDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import electromagnetic.data.framework.share.exception.LoggerConstant;
import org.slf4j.Logger;
@ -18,6 +20,7 @@ import javax.annotation.Resource;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/**
* @author
@ -50,9 +53,11 @@ public class EDDataServiceImpl implements EDDataService {
*/
public EDDataPage getDataInfoList(EDDataParams parames)
{
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
List<EDDataInfo> edDataInfoList = edDataRepository.getDataInfoList(parames);
PageInfo<EDDataInfo> pageInfo = new PageInfo<>(edDataInfoList);
EDDataPage edDataPage=new EDDataPage();
//数据查询
PageInfo<EDDataInfo> pageInfo = edDataRepository.getDataInfoList(parames);
edDataPage.setEdDataInfo(pageInfo);
return edDataPage;
}
@ -85,7 +90,22 @@ public class EDDataServiceImpl implements EDDataService {
*/
public Integer getChildFileCount(EDDataParams parames)
{
return edDataRepository.getChildFileCount(parames);
Integer childFileCount = 0;
List<EDDataInfo> edDataInfoList = edDataRepository.getDataInfoList(parames);
for (EDDataInfo edDataInfo : edDataInfoList) {
if(edDataInfo.getDataType().equals("folder"))
{
parames.setParentId(edDataInfo.getDataId());
childFileCount += getChildFileCount(parames);
}
else if(edDataInfo.getDataType().equals("file"))
{
++childFileCount;
}
}
return childFileCount;
}
/**

View File

@ -4,6 +4,9 @@ import com.electromagnetic.industry.software.data.manage.request.indicator.EDDat
import com.electromagnetic.industry.software.data.manage.response.indicator.EDDataPageResponse;
import electromagnetic.data.framework.share.model.ElectromagneticResult;
import java.util.List;
import java.util.Map;
public interface EDDataFacade {
/**
@ -33,7 +36,7 @@ public interface EDDataFacade {
* @param request
* @return
*/
ElectromagneticResult<Boolean> getChildFileCount(EDDataRequest request);
ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request);
/**
* 上传
@ -47,6 +50,6 @@ public interface EDDataFacade {
* @param request
* @return
*/
ElectromagneticResult<Boolean> download(EDDataRequest request);
ElectromagneticResult<Map<String, List<String>>> download(EDDataRequest request);
}

View File

@ -47,6 +47,10 @@ public class EDDataRequest extends BaseRequest {
* 关键词
*/
private String keyWord;
/**
* 文件数据编码数组
*/
private String[] dataIdArr;
/**
* 文件数据
*/

View File

@ -42,11 +42,9 @@ public class EDDataRepositoryImpl implements EDDataRepository {
* @return
*/
@Override
public PageInfo<EDDataInfo> getDataInfoList(EDDataParams parames)
public List<EDDataInfo> getDataInfoList(EDDataParams parames)
{
PageHelper.startPage(parames.getPageIndex(), parames.getPageSize());
List<EDDataInfo> edDataInfoList=edDataMapper.getDataInfoList(parames);
return new PageInfo<>(edDataInfoList);
return edDataMapper.getDataInfoList(parames);
}
/**
@ -75,17 +73,6 @@ public class EDDataRepositoryImpl implements EDDataRepository {
return edDataMapper.updateFileInfo(parames);
}
/**
* 获取子文件数量
* @param parames
* @return
*/
@Override
public Integer getChildFileCount(EDDataParams parames)
{
return edDataMapper.getChildFileCount(parames);
}
/**
* 下载
* @param parames

View File

@ -16,6 +16,7 @@
<result column="data_status" jdbcType="VARCHAR" property="dataStatus" />
<result column="note" jdbcType="VARCHAR" property="note" />
<result column="editor" jdbcType="VARCHAR" property="editor" />
<result column="gmt_batch_upload" jdbcType="TIMESTAMP" property="gmtBatchUpload" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="creator_name" jdbcType="VARCHAR" property="creatorName" />
<result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
@ -38,16 +39,18 @@
insert into ed_data_info (id, category_id,
data_id, data_no, data_name,
data_type, file_type, version,
content, implant_json, data_status,note,
editor, creator, creator_name, gmt_create,
content, implant_json, data_status,
note, editor, gmt_batch_upload,
creator, creator_name, gmt_create,
modifier, modifier_name, gmt_modified,
effect_flag
)
values (#{id,jdbcType=VARCHAR}, #{categoryId,jdbcType=VARCHAR},
#{dataId,jdbcType=VARCHAR}, #{dataNo,jdbcType=VARCHAR}, #{dataName,jdbcType=VARCHAR},
#{dataType,jdbcType=VARCHAR}, #{fileType,jdbcType=VARCHAR},#{version,jdbcType=VARCHAR},
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR},
#{editor,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{content,jdbcType=VARCHAR}, #{implantJson,jdbcType=VARCHAR}, #{dataStatus,jdbcType=VARCHAR},
#{note,jdbcType=VARCHAR}, #{editor,jdbcType=VARCHAR}, #{gmtBatchUpload,jdbcType=TIMESTAMP},
#{creator,jdbcType=VARCHAR}, #{creatorName,jdbcType=VARCHAR}, now(), #{modifier,jdbcType=VARCHAR},
#{modifierName,jdbcType=VARCHAR},now(),1
)
</insert>

View File

@ -20,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.nio.file.Path;
import java.util.*;
@Service
public class EDDataFacadeImpl implements EDDataFacade {
@ -148,11 +149,13 @@ public class EDDataFacadeImpl implements EDDataFacade {
* @param request
* @return
*/
public ElectromagneticResult<Boolean> getChildFileCount(EDDataRequest request)
public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
Integer fileCount = edDataService.getChildFileCount(parames);
return ElectromagneticResultUtil.success(Boolean.TRUE);
Map<String, Integer> result = new HashMap<>();
result.put("fileCount", fileCount);
return ElectromagneticResultUtil.success(result);
}
/**
@ -210,11 +213,15 @@ public class EDDataFacadeImpl implements EDDataFacade {
parentFolderPath = implantJsonObject.getString("folderPath");
parentFolderIdPath = implantJsonObject.getString("folderIdPath");
if(!parentFolderPath.isEmpty())
parentFolderPath = parentFolderPath + "/" + edDataInfoParent.getDataName();
parentFolderPath += "/" ;
if(!parentFolderIdPath.isEmpty())
parentFolderIdPath += "/" ;
parentFolderPath += edDataInfoParent.getDataName();
parentFolderIdPath += edDataInfoParent.getDataId();
}
// 文件保存目录路径
String fileSavePath = storageDirectory + "/" + parentFolderPath + fileFullName;
String fileSavePath = storageDirectory + "/" + parentFolderPath + "/" + fileFullName;
// 这里可以添加将文件保存到本地磁盘或其他存储介质的逻辑
File saveFile = new File(fileSavePath);
@ -273,11 +280,31 @@ public class EDDataFacadeImpl implements EDDataFacade {
* @param request
* @return
*/
public ElectromagneticResult<Boolean> download(EDDataRequest request)
public ElectromagneticResult<Map<String, List<String>>> download(EDDataRequest request)
{
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
edDataService.download(parames);
return ElectromagneticResultUtil.success(Boolean.TRUE);
//EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
// 获取文件存储的文件夹路径
String storageDirectory = "D:/fileTemp";
EDDataParams parames = new EDDataParams();
List<String> dataPathArr = new ArrayList();
for(String dataId : request.getDataIdArr())
{
parames.setDataId(dataId);
EDDataInfo edDataInfo = edDataService.getDataInfo(parames);
if(edDataInfo != null)
{
JSONObject implantJsonObject = JSON.parseObject(edDataInfo.getImplantJson());
String filePath = implantJsonObject.getString("folderPath");
filePath = storageDirectory + "/" + filePath + "/" + edDataInfo.getDataName();
dataPathArr.add(filePath);
}
}
Map<String, List<String>> result = new HashMap<>();
result.put("urlArr", dataPathArr);
return ElectromagneticResultUtil.success(result);
}