|
@@ -1,15 +1,15 @@
|
|
|
package cn.cslg.report.service.impl;
|
|
|
|
|
|
+import cn.cslg.report.common.model.dto.ProductDTO;
|
|
|
import cn.cslg.report.common.model.dto.ProductIncludeFilesDTO;
|
|
|
import cn.cslg.report.common.model.vo.PersonnelVO;
|
|
|
+import cn.cslg.report.common.model.vo.ProductIncludeFilesVO;
|
|
|
import cn.cslg.report.common.model.vo.ReportFileStandardVO;
|
|
|
import cn.cslg.report.common.utils.CacheUtils;
|
|
|
-import cn.cslg.report.common.utils.Response;
|
|
|
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
|
|
|
-import cn.cslg.report.mapper.ProductMapper;
|
|
|
-import cn.cslg.report.common.model.dto.ProductDTO;
|
|
|
import cn.cslg.report.entity.Product;
|
|
|
-import cn.cslg.report.common.model.vo.ProductIncludeFilesVO;
|
|
|
+import cn.cslg.report.mapper.ProductMapper;
|
|
|
+import cn.cslg.report.service.IAssoProductFileService;
|
|
|
import cn.cslg.report.service.IProductService;
|
|
|
import cn.cslg.report.service.business.ReportFileService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -33,15 +33,15 @@ import java.util.List;
|
|
|
public class ProductServiceImpl implements IProductService {
|
|
|
private final ProductMapper productMapper; //产品的Mapper层接口
|
|
|
private final ReportFileService reportFileService; //报告系统文件的Service层实现类
|
|
|
- private final AssoProductFileServiceImpl assoProductFileService; //产品文件关联的Service层实现类
|
|
|
+ private final IAssoProductFileService assoProductFileService; //产品文件关联的Service层实现类
|
|
|
private final CacheUtils cacheUtils;
|
|
|
private final LoginUtils loginUtils;
|
|
|
|
|
|
/**
|
|
|
- * 新增产品的业务层方法
|
|
|
+ * 新增产品
|
|
|
*
|
|
|
- * @param productDTO 产品的前端传输DTO类
|
|
|
- * @param files 产品附件
|
|
|
+ * @param productDTO 产品数据前端传输DTO对象
|
|
|
+ * @param files 附件
|
|
|
*/
|
|
|
@Override
|
|
|
public void addProduct(ProductDTO productDTO, List<MultipartFile> files) {
|
|
@@ -68,10 +68,10 @@ public class ProductServiceImpl implements IProductService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 修改产品的业务层方法
|
|
|
+ * 修改产品
|
|
|
*
|
|
|
- * @param productIncludeFilesDTO 产品的新数据
|
|
|
- * @param files 产品的新附件
|
|
|
+ * @param productIncludeFilesDTO 产品新数据
|
|
|
+ * @param files 新附件
|
|
|
*/
|
|
|
@Override
|
|
|
public void updateProduct(ProductIncludeFilesDTO productIncludeFilesDTO, List<MultipartFile> files) {
|
|
@@ -84,7 +84,8 @@ public class ProductServiceImpl implements IProductService {
|
|
|
productMapper.update(product);
|
|
|
|
|
|
//2.根据reportId(报告id)关联查询出产品关联附件的数据信息
|
|
|
- ProductIncludeFilesVO queryResult = productMapper.getStandardByReportId(product.getReportId());
|
|
|
+ Integer reportId = product.getReportId();
|
|
|
+ ProductIncludeFilesVO queryResult = productMapper.getWholeByReportId(reportId);
|
|
|
|
|
|
//3.取出对象中的附件集合属性,遍历取出原所有附件fileIds
|
|
|
List<ReportFileStandardVO> oldReportFiles = queryResult.getReportFiles();
|
|
@@ -123,36 +124,32 @@ public class ProductServiceImpl implements IProductService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据报告id查询产品表数据和报告系统文件表中产品图片数据的业务层方法
|
|
|
+ * 根据报告reportId关联查询产品和产品附件数据(产品表、产品文件关联表、报告系统文件表)
|
|
|
*
|
|
|
* @param reportId 报告id
|
|
|
- * @return 返回查询到的产品数据对象
|
|
|
+ * @return 返回查询到的产品和产品附件数据对象
|
|
|
*/
|
|
|
@Override
|
|
|
public ProductIncludeFilesVO getProduct(Integer reportId) {
|
|
|
log.info("开始处理【查询产品】的业务,参数为:{}", reportId);
|
|
|
- ProductIncludeFilesVO queryResult = productMapper.getStandardByReportId(reportId);
|
|
|
- return productMapper.getStandardByReportId(reportId);
|
|
|
+ return productMapper.getWholeByReportId(reportId);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据报告id删除产品表数据和产品文件关联表数据和报告系统文件表中产品图片数据的业务层方法
|
|
|
+ * 根据报告reportId删除产品及所有关联数据
|
|
|
*
|
|
|
* @param reportId 报告id
|
|
|
*/
|
|
|
@Override
|
|
|
public void deleteProduct(Integer reportId) {
|
|
|
log.info("开始处理【删除产品】的业务,参数为:{}", reportId);
|
|
|
- //1.根据报告id删除产品表数据
|
|
|
- productMapper.deleteByReportId(reportId);
|
|
|
-
|
|
|
- //2.删除产品文件关联表数据:根据报告id关联查询产品数据,取出产品id,根据产品id删除产品与文件关联表数据
|
|
|
+ //1.根据产品productId删除产品文件关联表数据:先根据报告id关联查询产品关联附件的数据,取出产品id,根据产品id删除产品与文件关联表数据
|
|
|
ProductIncludeFilesVO queryResult = this.getProduct(reportId);
|
|
|
Integer productId = queryResult.getId();
|
|
|
assoProductFileService.deleteAssoByProductId(productId);
|
|
|
|
|
|
- //3.删除报告系统文件表中产品图片数据:根据报告id关联查询产品数据,取出产品附件,遍历取出fileId存入集合,调用报告业务层的通过fileId集合删除报告系统文件表数据方法
|
|
|
+ //2.根据附件fileId集合删除报告系统文件表数据:产品关联附件的数据中取出附件数据,遍历附件取出附件fileId存入集合,调用报告的业务层方法删除报告系统文件表数据
|
|
|
List<ReportFileStandardVO> reportFiles = queryResult.getReportFiles();
|
|
|
ArrayList<Integer> list = new ArrayList<>();
|
|
|
for (ReportFileStandardVO reportFile : reportFiles) {
|
|
@@ -160,6 +157,10 @@ public class ProductServiceImpl implements IProductService {
|
|
|
list.add(fileId);
|
|
|
}
|
|
|
reportFileService.deleteFiles(list);
|
|
|
+
|
|
|
+ //3.根据报告reportId删除产品表数据
|
|
|
+ productMapper.deleteByReportId(reportId);
|
|
|
+
|
|
|
log.info("产品删除完成");
|
|
|
|
|
|
}
|