src/main/java/com/whyc/controller/MaterialController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/MaterialMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/MaterialService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/MaterialMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/MaterialController.java
@@ -53,4 +53,10 @@ public Response zipParse(MultipartFile file) throws IOException, InvalidFormatException { return service.zipParse(file); } @ApiOperation(value = "根据物料id查询返回附件文件夹下所有的文件列表",notes = "9.3修改后使用") @GetMapping("getAttachByMaterialId") public Response getAttachByMaterialId(@RequestParam int MaterialId){ return service.getAttachByMaterialId(MaterialId); } } src/main/java/com/whyc/mapper/MaterialMapper.java
@@ -26,5 +26,6 @@ void disableStatus(List<Material> materialList); List<Material> getListByCodeAndModelList2(List<ProductBom> bomList); //根据物料id查询返回附件文件夹下所有的文件列表 Material getAttachByMaterialId(int materialId); } src/main/java/com/whyc/service/MaterialService.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.whyc.dto.FileDirPath; import com.whyc.dto.Response; import com.whyc.mapper.MaterialMapper; import com.whyc.pojo.DocUser; @@ -306,4 +307,27 @@ } return response.setII(1,true,list,filePath); } //根据物料id查询返回附件文件夹下所有的文件列表 public Response getAttachByMaterialId(int materialId) { String fileDirName = FileDirPath.getFileDirName(); Material material=mapper.getAttachByMaterialId(materialId); boolean flag=false; String[] fileNames=null; if(material.getFileUrl()!=null&&!material.getFileUrl().isEmpty()){ File file = new File(fileDirName+File.separator+material.getFileUrl()); if(!file.exists()) { flag=false; }else{ fileNames = file.list();//获取该文件夹下的所有文件以及目录的名字 if(fileNames.length>0){ flag=true; for (int i=0;i<fileNames.length;i++){ fileNames[i]=fileDirName+File.separator+material.getFileUrl()+fileNames[i]; } } } } return new Response().setII(1,flag,fileNames,"文件列表返回"); } } src/main/resources/mapper/MaterialMapper.xml
@@ -230,4 +230,7 @@ select id,sub_code,sub_model from db_doc.tb_material where sub_code = #{item.subCode} and sub_model = #{item.subModel} </foreach> </select> <select id="getAttachByMaterialId" resultType="com.whyc.pojo.Material"> select * from db_doc.tb_material WHERE id = #{materialId} limit 1 </select> </mapper>