jiangping
2023-09-19 62f53cc6c69c02bbe91a5010ee98f293ae3746bb
server/service/src/main/java/com/doumee/service/business/impl/BaseGoodsServiceImpl.java
@@ -81,9 +81,9 @@
    @Override
    public Integer create(BaseGoodsCreateOrUpdateRequest baseGoods) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO).eq("name",baseGoods.getName()))>0){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在");
        }
//        if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO).eq("name",baseGoods.getName()))>0){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在");
//        }
        Integer integer = baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>().eq("ISDELETED", Constants.ZERO));
        BaseGoods insert = new BaseGoods();
@@ -173,11 +173,11 @@
    public void update(BaseGoodsCreateOrUpdateRequest baseGoods) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>()
                .eq("ISDELETED",Constants.ZERO).ne("id",baseGoods.getId())
                .eq("name",baseGoods.getName()))>0){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在");
        }
//        if(baseGoodsMapper.selectCount(new QueryWrapper<BaseGoods>()
//                .eq("ISDELETED",Constants.ZERO).ne("id",baseGoods.getId())
//                .eq("name",baseGoods.getName()))>0){
//            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+baseGoods.getName()+"】已存在");
//        }
        UpdateWrapper<BaseGoods> wrapper = new UpdateWrapper<>();
        wrapper.lambda()
@@ -421,9 +421,10 @@
                throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,录入数据为空!");
            }
            //处理批量上传
            String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLATFORM).getCode();
            String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode();
            String platformDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PLATFORM).getCode();
            String basePath = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode()
                    + proDir + File.separator ;
                    + proDir + platformDir ;
            OssModel ossModel = baseDataService.initOssModel();
            for (int index = 0; index < dataList.size(); index++) {
                BaseGoodsImportDTO  s = dataList.get(index);
@@ -468,7 +469,7 @@
                brandQuery.lambda()
                        .eq(Brand::getIsdeleted,Constants.ZERO);
                brandQuery.lambda()
                        .eq(Brand::getType,Constants.ZERO);
                        .eq(Brand::getType,Constants.ONE);
                Brand brand = brandMapper.selectOne(brandQuery.last("limit 1"));
                if (Objects.isNull(brand)){
@@ -482,7 +483,7 @@
                        File[]  files = dir.listFiles();
                        if(files!=null && files.length>0){
                            for(File f:files){
                                if(StringUtils.isBlank(baseCategory.getImgurl()) && isImgFile(f)){
                                if(isImgFile(f)){
                                    //取第一张图片作为列表图
                                    baseGoods.setImgurl(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f));
                                }
@@ -513,7 +514,7 @@
                    for(int i=0;i<mulFiles.size();i++){
                        String str = mulFiles.get(i);
                        Multifile f = new Multifile();
                        f.setObjType(Constants.ZERO);
                        f.setObjType(Constants.ONE);
                        f.setName(str);
                        f.setType(Constants.ZERO);
                        f.setObjId(baseGoods.getId());