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) @RequestMapping(value = "/upload", consumes = "multipart/form-data",method = RequestMethod.POST)
public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId, public ElectromagneticResult<?> upload(@RequestParam("parentId") String parentId,
@RequestParam("file") MultipartFile file){ @RequestParam("file") MultipartFile file){
//System.out.println(parentId);
EDDataRequest request = new EDDataRequest(); EDDataRequest request = new EDDataRequest();
request.setParentId(parentId); request.setParentId(parentId);
request.setFileData(file); 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 editor;
/**
* 批量上传时间
*/
private String gmtBatchUpload;
/** /**
* 创建人 * 创建人
*/ */

View File

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

View File

@ -3,11 +3,13 @@
*/ */
package com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.service.impl; 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.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;
import com.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.repository.EDDataRepository; 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.electromagnetic.industry.software.data.manage.domain.boardservice.indicator.service.EDDataService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import electromagnetic.data.framework.share.exception.LoggerConstant; import electromagnetic.data.framework.share.exception.LoggerConstant;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -18,6 +20,7 @@ import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.List;
/** /**
* @author * @author
@ -50,9 +53,11 @@ public class EDDataServiceImpl implements EDDataService {
*/ */
public EDDataPage getDataInfoList(EDDataParams parames) 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(); EDDataPage edDataPage=new EDDataPage();
//数据查询
PageInfo<EDDataInfo> pageInfo = edDataRepository.getDataInfoList(parames);
edDataPage.setEdDataInfo(pageInfo); edDataPage.setEdDataInfo(pageInfo);
return edDataPage; return edDataPage;
} }
@ -85,7 +90,22 @@ public class EDDataServiceImpl implements EDDataService {
*/ */
public Integer getChildFileCount(EDDataParams parames) 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 com.electromagnetic.industry.software.data.manage.response.indicator.EDDataPageResponse;
import electromagnetic.data.framework.share.model.ElectromagneticResult; import electromagnetic.data.framework.share.model.ElectromagneticResult;
import java.util.List;
import java.util.Map;
public interface EDDataFacade { public interface EDDataFacade {
/** /**
@ -33,7 +36,7 @@ public interface EDDataFacade {
* @param request * @param request
* @return * @return
*/ */
ElectromagneticResult<Boolean> getChildFileCount(EDDataRequest request); ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request);
/** /**
* 上传 * 上传
@ -47,6 +50,6 @@ public interface EDDataFacade {
* @param request * @param request
* @return * @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 keyWord;
/**
* 文件数据编码数组
*/
private String[] dataIdArr;
/** /**
* 文件数据 * 文件数据
*/ */

View File

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

View File

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

View File

@ -20,6 +20,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; import java.nio.file.Path;
import java.util.*;
@Service @Service
public class EDDataFacadeImpl implements EDDataFacade { public class EDDataFacadeImpl implements EDDataFacade {
@ -148,11 +149,13 @@ public class EDDataFacadeImpl implements EDDataFacade {
* @param request * @param request
* @return * @return
*/ */
public ElectromagneticResult<Boolean> getChildFileCount(EDDataRequest request) public ElectromagneticResult<Map<String, Integer>> getChildFileCount(EDDataRequest request)
{ {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request); EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
Integer fileCount = edDataService.getChildFileCount(parames); 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"); parentFolderPath = implantJsonObject.getString("folderPath");
parentFolderIdPath = implantJsonObject.getString("folderIdPath"); parentFolderIdPath = implantJsonObject.getString("folderIdPath");
if(!parentFolderPath.isEmpty()) 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); File saveFile = new File(fileSavePath);
@ -273,11 +280,31 @@ public class EDDataFacadeImpl implements EDDataFacade {
* @param request * @param request
* @return * @return
*/ */
public ElectromagneticResult<Boolean> download(EDDataRequest request) public ElectromagneticResult<Map<String, List<String>>> download(EDDataRequest request)
{ {
EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request); //EDDataParams parames= EDDataMappers.INSTANCE.getEDDataParames(request);
edDataService.download(parames);
return ElectromagneticResultUtil.success(Boolean.TRUE); // 获取文件存储的文件夹路径
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);
} }