xyc
2024-09-28 05a4c18628bba5010c0ce423408cc5f40f864ee0
modules/mainPart/src/main/java/com/zt/life/modules/mainPart/sysPictureBase/controller/SysPictureBaseController.java
@@ -73,42 +73,10 @@
        } else {
            sysPictureBaseService.insert(sysPictureBase);
        }
        if (sysPictureBase.getIsDefault()==1){
            if (sysPictureBase.getId()==null){
                sysPictureBaseService.updateByDefault(sysPictureBase.getId(),sysPictureBase.getProductType());
                sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(),sysPictureBase.getProductType(),null);
            }else{
                if (!sysPictureBase.getId().equals(sysPictureBase.getId())){
                    sysPictureBaseService.updateByDefault(sysPictureBase.getId(),sysPictureBase.getProductType());
                    sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(),sysPictureBase.getProductType(),sysPictureBase.getId());
                }
            }
        if (sysPictureBase.getIsDefault() == 1 && sysPictureBase.getProductType()!=20) {
            sysPictureBaseService.updateByDefault(sysPictureBase.getId(), sysPictureBase.getProductType());
            sysPictureBaseService.updateProdeuctImg(sysPictureBase.getId(), sysPictureBase.getProductType(), null);
        }
/*        if (file != null) {
            BufferedImage bufferedImage = null;
            try {
                String fileName = file.getOriginalFilename();
                String[] arr = fileName.split("\\.");
                String suffixName = arr[arr.length - 1].toLowerCase();
                bufferedImage = ImageIO.read(file.getInputStream());
                // 宽度
                int width = bufferedImage.getWidth();
                sysPictureBase.setWidth(width);
                // 高度
                int height = bufferedImage.getHeight();
                sysPictureBase.setHeight(height);
                sysPictureBaseService.update(sysPictureBase);
                String tempUploadDir = localPath + "/product_img/";
                File dir = new File(tempUploadDir);
                if (!dir.exists()) {
                    dir.mkdirs();
                }
                ImageIO.write(bufferedImage, suffixName, new File(tempUploadDir + sysPictureBase.getId().toString()));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }*/
        return Result.ok();
    }
@@ -136,7 +104,7 @@
            //关流
            outputStream.close();
            in.close();
        }  catch (IOException e) {
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
@@ -151,7 +119,7 @@
            response.getWriter().flush();
            response.getWriter().close();
        }  catch (IOException e) {
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
@@ -161,6 +129,7 @@
        SysPictureBase data = sysPictureBaseService.getDefaultImg(productType);
        return Result.ok(data);
    }
    @DeleteMapping
    @ApiOperation("删除")
    @LogOperation("删除")