| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.UserOperation; |
| | | import com.whyc.dto.FileDirPath; |
| | | import com.whyc.dto.Response; |
| | |
| | | wrapper.orderByAsc("file_name"); |
| | | wrapper.orderByAsc("version"); |
| | | List list=mapper.selectList(wrapper); |
| | | return new Response().setII(1,list.size()>0,list,"软件信息返回"); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"软件信息返回"); |
| | | } |
| | | //根据subcode查询软件列表 |
| | | public Response getSoftBySubCode(String subCode) { |
| | |
| | | try { |
| | | // 转码防止乱码 |
| | | //resp.addHeader("Content-Disposition", "attachment;filename=" + new String(softwareName.getBytes("UTF-8"), "ISO8859-1")); |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( software.getFileName(), "utf-8")); |
| | | resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode ( software.getFileName()+".zip", "utf-8")); |
| | | OutputStream out = resp.getOutputStream(); |
| | | FileInputStream in = new FileInputStream(fileDirName+File.separator+software.getFileUrl()); |
| | | int len=0; |
| | |
| | | file2Name = file2Name.substring(0,file2Name.lastIndexOf(".")) + "_" + dateUnion +file2Name.substring(file2Name.lastIndexOf(".")); |
| | | //存储路径 |
| | | String rootFile = CommonUtil.getRootFile(); |
| | | String softwareDir = rootFile + software.getOwner() + File.separator + dateUnion; |
| | | String softwareDir = rootFile + "software" + File.separator + software.getOwner() + File.separator + dateUnion; |
| | | String softwareHttpUrl = softwareDir.substring(softwareDir.lastIndexOf("doc_file"+ File.separator + "software")); |
| | | File softwareDirFile = new File(softwareDir); |
| | | if(!softwareDirFile.exists()){ |
| | | softwareDirFile.mkdirs(); |
| | |
| | | file1.transferTo(new File(softwareDir+File.separator+file1Name)); |
| | | file2.transferTo(new File(softwareDir+File.separator+file2Name)); |
| | | //设置路径 |
| | | softwareList.forEach(software1 -> { |
| | | software1.setFileUrl(softwareDir); |
| | | for (Software software1:softwareList){ |
| | | software1.setFileUrl(softwareHttpUrl+File.separator+file1Name); |
| | | software1.setExcelUrl(softwareHttpUrl+File.separator+file2Name); |
| | | software1.setCreateTime(date); |
| | | }); |
| | | } |
| | | //写入数据库 |
| | | insertBatch(softwareList); |
| | | return new Response().setII(1,"上传完成"); |