From 157eeeff8d3f42fe0c185d23ff434a9d94b4cf12 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Tue, 30 Sep 2025 13:33:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductScreenController.java | 5 + .../bonus/business/mapper/ProductMapper.java | 2 + .../service/ProductScreenService.java | 2 + .../service/impl/ProductScreenImpl.java | 103 ++++++++++-------- .../mapper/business/TbProductMapper.xml | 9 +- 5 files changed, 76 insertions(+), 45 deletions(-) diff --git a/bonus-business/src/main/java/com/bonus/business/controller/ProductScreenController.java b/bonus-business/src/main/java/com/bonus/business/controller/ProductScreenController.java index 351b814..6fa410e 100644 --- a/bonus-business/src/main/java/com/bonus/business/controller/ProductScreenController.java +++ b/bonus-business/src/main/java/com/bonus/business/controller/ProductScreenController.java @@ -34,4 +34,9 @@ public class ProductScreenController { return service.getProductDetails(product) ; } + @PostMapping("/getProductDetailsById") + public AjaxResult getProductDetailsById(@RequestBody TbProduct product ){ + return service.getProductDetailsById(product) ; + } + } diff --git a/bonus-business/src/main/java/com/bonus/business/mapper/ProductMapper.java b/bonus-business/src/main/java/com/bonus/business/mapper/ProductMapper.java index cd10103..a2d0961 100644 --- a/bonus-business/src/main/java/com/bonus/business/mapper/ProductMapper.java +++ b/bonus-business/src/main/java/com/bonus/business/mapper/ProductMapper.java @@ -121,4 +121,6 @@ public interface ProductMapper { * @return */ Integer getProductOnCz(TbProduct product); + + TbProductCase getProductDetailsById(String id); } diff --git a/bonus-business/src/main/java/com/bonus/business/service/ProductScreenService.java b/bonus-business/src/main/java/com/bonus/business/service/ProductScreenService.java index 9882f67..c28a2fa 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/ProductScreenService.java +++ b/bonus-business/src/main/java/com/bonus/business/service/ProductScreenService.java @@ -17,4 +17,6 @@ public interface ProductScreenService { * @return */ AjaxResult getProductDetails(TbProduct product); + + AjaxResult getProductDetailsById(TbProduct product); } diff --git a/bonus-business/src/main/java/com/bonus/business/service/impl/ProductScreenImpl.java b/bonus-business/src/main/java/com/bonus/business/service/impl/ProductScreenImpl.java index 0a46736..4809d5d 100644 --- a/bonus-business/src/main/java/com/bonus/business/service/impl/ProductScreenImpl.java +++ b/bonus-business/src/main/java/com/bonus/business/service/impl/ProductScreenImpl.java @@ -38,22 +38,22 @@ public class ProductScreenImpl implements ProductScreenService { @Autowired - public FileServiceUtils fileServiceUtils; + public FileServiceUtils fileServiceUtils; @Override public AjaxResult getProductList(TbProduct product) { - try{ - List list=mapper.getProductList(product); - if(StringUtils.isNotEmpty(list)){ - list.forEach(vo->{ - String url = fileServiceUtils.getFileUrl(vo.getLinkImage(),null); - // String url = minioUtil.getFileUrl(minioConfig.getBucketName(),vo.getLinkImage(), GlobalUtils.FILE_TIMES); + try { + List list = mapper.getProductList(product); + if (StringUtils.isNotEmpty(list)) { + list.forEach(vo -> { + String url = fileServiceUtils.getFileUrl(vo.getLinkImage(), null); + // String url = minioUtil.getFileUrl(minioConfig.getBucketName(),vo.getLinkImage(), GlobalUtils.FILE_TIMES); vo.setLinkImage(url); }); } - return AjaxResult.success(list); - }catch (Exception e){ + return AjaxResult.success(list); + } catch (Exception e) { log.error(e.toString()); } return AjaxResult.success(new ArrayList()); @@ -61,59 +61,76 @@ public class ProductScreenImpl implements ProductScreenService { /** * 查看宣传物料信息 + * * @param product * @return */ @Override public AjaxResult getProductDetails(TbProduct product) { - try{ + try { //详情 - TbProduct vo=mapper.getProductDetails(product); - if(vo!=null){ + TbProduct vo = mapper.getProductDetails(product); + if (vo != null) { //封面图 - String url = fileServiceUtils.getFileUrl(vo.getLinkImage(),null); - // String url = minioUtil.getFileUrl(minioConfig.getBucketName(),vo.getLinkImage(), GlobalUtils.FILE_TIMES); + String url = fileServiceUtils.getFileUrl(vo.getLinkImage(), null); + // String url = minioUtil.getFileUrl(minioConfig.getBucketName(),vo.getLinkImage(), GlobalUtils.FILE_TIMES); vo.setLinkImage(url); - // vo.setLinkImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName()+vo.getLinkImage()); + // vo.setLinkImage(minioConfig.getUrl()+"/"+minioConfig.getBucketName()+vo.getLinkImage()); getProductDetails(product, vo, productMapper, minioUtil); //查询 宣传手册和宣传视频 - List list=mapper.getMaterialList(vo); - List videoList=new ArrayList<>(); - List fileList=new ArrayList<>(); - if(StringUtils.isNotEmpty(list)){ - list.forEach(vo1->{ - String imageUlr = fileServiceUtils.getFileUrl(vo1.getImage(),null); - String path = fileServiceUtils.getFileUrl(vo1.getFilePath(),null); - // String imageUlr = minioUtil.getFileUrl(minioConfig.getBucketName(),vo1.getImage(), GlobalUtils.FILE_TIMES); - // String path = minioUtil.getFileUrl(minioConfig.getBucketName(),vo1.getFilePath(), GlobalUtils.FILE_TIMES); - vo1.setImage(imageUlr); - vo1.setUrl(path); - if("0".equals(vo1.getFileType())){ - videoList.add(vo1); - }else { - fileList.add(vo1); - } - }); - vo.setVideoList(videoList); - vo.setFileList(fileList); + List list = mapper.getMaterialList(vo); + List videoList = new ArrayList<>(); + List fileList = new ArrayList<>(); + if (StringUtils.isNotEmpty(list)) { + list.forEach(vo1 -> { + String imageUlr = fileServiceUtils.getFileUrl(vo1.getImage(), null); + String path = fileServiceUtils.getFileUrl(vo1.getFilePath(), null); + // String imageUlr = minioUtil.getFileUrl(minioConfig.getBucketName(),vo1.getImage(), GlobalUtils.FILE_TIMES); + // String path = minioUtil.getFileUrl(minioConfig.getBucketName(),vo1.getFilePath(), GlobalUtils.FILE_TIMES); + vo1.setImage(imageUlr); + vo1.setUrl(path); + if ("0".equals(vo1.getFileType())) { + videoList.add(vo1); + } else { + fileList.add(vo1); + } + }); + vo.setVideoList(videoList); + vo.setFileList(fileList); } } return AjaxResult.success(vo); - }catch (Exception e){ + } catch (Exception e) { log.error(e.toString()); } return AjaxResult.success(product); } - public void getProductDetails(TbProduct product, TbProduct vo, ProductMapper productMapper, MinioUtil minioUtil) { - List productCases= productMapper.getProductCaseList(product.getId()); - for (TbProductCase productCase:productCases) { + @Override + public AjaxResult getProductDetailsById(TbProduct product) { + TbProductCase productCase = productMapper.getProductDetailsById(product.getId()); + //产品案例 + List caseImages = productMapper.getCaseImageByTable(productCase.getId(), "tb_product_case"); + if (StringUtils.isNotEmpty(caseImages)) { + caseImages.forEach(image -> { + String path = fileServiceUtils.getFileUrl(image.getFilePath(), image.getBucketName()); + // String path = minioUtil.getFileUrl(image.getBucketName(),image.getFilePath(), GlobalUtils.FILE_TIMES); + image.setUrl(path); + }); + productCase.setImageList(caseImages); + } + return AjaxResult.success(productCase); + } + + public void getProductDetails(TbProduct product, TbProduct vo, ProductMapper productMapper, MinioUtil minioUtil) { + List productCases = productMapper.getProductCaseList(product.getId()); + for (TbProductCase productCase : productCases) { //产品案例 - List caseImages= productMapper.getCaseImageByTable(productCase.getId(),"tb_product_case"); - if(StringUtils.isNotEmpty(caseImages)){ - caseImages.forEach(image->{ - String path = fileServiceUtils.getFileUrl(image.getFilePath(),image.getBucketName()); - // String path = minioUtil.getFileUrl(image.getBucketName(),image.getFilePath(), GlobalUtils.FILE_TIMES); + List caseImages = productMapper.getCaseImageByTable(productCase.getId(), "tb_product_case"); + if (StringUtils.isNotEmpty(caseImages)) { + caseImages.forEach(image -> { + String path = fileServiceUtils.getFileUrl(image.getFilePath(), image.getBucketName()); + // String path = minioUtil.getFileUrl(image.getBucketName(),image.getFilePath(), GlobalUtils.FILE_TIMES); image.setUrl(path); }); productCase.setImageList(caseImages); diff --git a/bonus-business/src/main/resources/mapper/business/TbProductMapper.xml b/bonus-business/src/main/resources/mapper/business/TbProductMapper.xml index 5bf8185..3384590 100644 --- a/bonus-business/src/main/resources/mapper/business/TbProductMapper.xml +++ b/bonus-business/src/main/resources/mapper/business/TbProductMapper.xml @@ -76,6 +76,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where product_id=#{id} + insert into tb_product @@ -158,7 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from tb_product where id in + delete from tb_product where id in #{id} @@ -177,4 +182,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{id} - \ No newline at end of file +