提交 8b7e0373 authored 作者: 任建彩's avatar 任建彩

feat:关联内容

1.resource
上级 52531222
......@@ -25,6 +25,7 @@ import com.zrqx.resource.model.vo.goodslibrary.GoodsLibraryListVO;
import com.zrqx.resource.model.vo.goodslibrary.GoodsLibraryVO;
import com.zrqx.resource.service.*;
import com.zrqx.resource.solr.SolrManage;
import com.zrqx.util.datatype.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
......@@ -33,6 +34,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -85,18 +87,29 @@ public class GoodsLibraryController {
@PostMapping(value = "/updateZip")
public CallBack<Boolean> updateZip(@RequestBody UpdateZipForm form) throws Exception {
GoodsLibrary goodsLibrary = service.getById(form.getId());
//批量获取关联资源的文件fileName
QueryResourceRelationForm entity = new QueryResourceRelationForm();
entity.setId(form.getId());
List<ResourceRelationVO> list = resourceRelationService.queryByIdAndResourceType(entity);
List<String> fileNames = resourceRelationService.queryRelationFileNameList(list);
FileDownloadForm fileForm = new FileDownloadForm();
fileForm.setFileNames(fileNames);
fileForm.setName(goodsLibrary.getName());
//打包zip
String zipFileName = fileClient.wholeDownload(fileForm);
goodsLibrary.setFileName(zipFileName);
return CallBack.success(service.updateById(goodsLibrary));
if(goodsLibrary!=null) {
if (StringUtils.isNotBlank(goodsLibrary.getFileName())) {
String path = "/opt/upload/wyzyk/" + goodsLibrary.getFileName();
File file = new File(path);
if (file.exists() && file.isDirectory()) {
String[] cmd = new String[]{"/bin/sh", "-c", "rm -rf " + path};
Runtime.getRuntime().exec(cmd);
}
}
//批量获取关联资源的文件fileName
QueryResourceRelationForm entity = new QueryResourceRelationForm();
entity.setId(form.getId());
List<ResourceRelationVO> list = resourceRelationService.queryByIdAndResourceType(entity);
List<String> fileNames = resourceRelationService.queryRelationFileNameList(list);
FileDownloadForm fileForm = new FileDownloadForm();
fileForm.setFileNames(fileNames);
fileForm.setName(goodsLibrary.getName());
//打包zip
String zipFileName = fileClient.wholeDownload(fileForm);
goodsLibrary.setFileName(zipFileName);
service.updateById(goodsLibrary);
}
return CallBack.success(true);
}
@ApiOperation(value = "查询关联File文件", notes = "查询关联File文件")
@GetMapping(value = "/getRelationFile")
......
......@@ -9,6 +9,4 @@ import lombok.Data;
public class UpdateZipForm {
@ApiModelProperty("商品id,新增时不需要填写")
private String id;
@ApiModelProperty("zip文件名称")
private String fileName;
}
......@@ -295,14 +295,14 @@ public class ResourceRelationServiceImpl extends ServiceImpl<ResourceRelationMap
if (e.getResourceType() != null) {
if (e.getResourceType().equals(AllResourceTypeEnum.VIDEO.getCode())) {
VideoLibrary vl = videoLibraryMapper.selectById(e.getResourceId());
if (vl != null && vl.getIsDownload().equals("0")) {
if (vl != null && vl.getIsDownload().equals("0") && StringUtils.isNotBlank(vl.getVideo())) {
e.setFileName(vl.getVideo());
listFile.add(e.getFileName());
}
}
if (e.getResourceType().equals(AllResourceTypeEnum.AUDIO.getCode())) {
AudioLibrary al = audioLibraryMapper.selectById(e.getResourceId());
if (al != null && al.getIsDownload().equals("0")) {
if (al != null && al.getIsDownload().equals("0")&& StringUtils.isNotBlank(al.getAudio()) ) {
e.setFileName(al.getAudio());
listFile.add(e.getFileName());
}
......@@ -310,7 +310,7 @@ public class ResourceRelationServiceImpl extends ServiceImpl<ResourceRelationMap
//pdf
if (e.getResourceType().equals(AllResourceTypeEnum.PDF.getCode())) {
PdfLibrary pdfLibrary = pdfLibraryMapper.selectById(e.getResourceId());
if (pdfLibrary != null && pdfLibrary.getIsDownload().equals("0")) {
if (pdfLibrary != null && pdfLibrary.getIsDownload().equals("0") && StringUtils.isNotBlank(pdfLibrary.getPdf())) {
e.setFileName(pdfLibrary.getPdf());
listFile.add(e.getFileName());
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论