whycxzp
2023-02-24 e0b305d53c2d34bf8b818f2964da0f6055be7320
修复产品定制新增接口问题
2个文件已修改
20 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/ProductController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/ProductService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ProductController.java
@@ -112,6 +112,13 @@
        return service.zipParse(file,baseProduct);
    }
    /**
     * 这个接口是进行产品新增,产品bom新增的接口.
     * 新增方式有很多,有直接从zip解析新增产品,也可以基于原有产品复制进行定制等.需要注意兼容!
     * @param product 产品新增,bom新增,产品版本更新
     * @return
     * @throws IOException
     */
    @PostMapping
    @ApiOperation(value = "新增",notes = "解析时返回的绝对路径,需要回传到字段fileUrl")
    public Response add(@RequestBody Product product) throws IOException {
src/main/java/com/whyc/service/ProductService.java
@@ -311,6 +311,13 @@
        return list;
    }
    /**
     * 这个接口是进行产品新增,产品bom新增的接口.
     * 新增方式有很多,有直接从zip解析新增产品,也可以基于原有产品复制进行定制等.需要注意兼容!
     * @param product 产品新增,bom新增,产品版本更新
     * @return
     * @throws IOException
     */
    @Transactional
    public Response add(Product product) throws IOException {
        String parentCode = product.getParentCode();
@@ -318,7 +325,6 @@
        String parentModel = product.getParentModel();
        List<ProductBom> bomList = product.getBomList();
        String zipFilePath = product.getFileUrl();
        String fileUrl = zipFilePath.substring(0,zipFilePath.lastIndexOf(File.separator));
        Date date = new Date();
        boolean isCopyCustom = false;
        Product relatedProduct = null;
@@ -331,6 +337,11 @@
                relatedProduct = getById(product.getId());
            }
        }
        //不是基于产品复制,则必定存在zip包,必然存在路径
        String fileUrl = null;
        if(!isCopyCustom) {
            fileUrl = zipFilePath.substring(0, zipFilePath.lastIndexOf(File.separator));
        }
        //查询新增产品最新的版本号
        ProductHistory latestProduct = phService.getLatestVersion(parentCode, customCode);
        ProductHistory enabledProduct = phService.getEnabledByParentCodeAndCustomCode(parentCode, customCode);