zhangnaisong
2023-07-21 dff994a28ff9be38450bc4e7ba540c2831d1206f
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -219,12 +219,14 @@
    @Override
    public String uploadCarPicture(String id, MultipartFile carPicture) {
        ArdSyCar ardSyCarr = ardSyCarMapper.selectArdSyCarById(id);
        List<String> objectNames = new ArrayList();
        if(ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")){
            String objectName = ardSyCarr.getCarPicture().split("/sycar/")[1];
            objectNames.add(objectName);
            MinioUtils.removeObjects("sycar", objectNames);
        if(id != null && !id.equals("")){//id为非必要
            ArdSyCar ardSyCarr = ardSyCarMapper.selectArdSyCarById(id);
            List<String> objectNames = new ArrayList();
            if(ardSyCarr.getCarPicture() != null || !ardSyCarr.getCarPicture().equals("")){
                String objectName = ardSyCarr.getCarPicture().split("/sycar/")[1];
                objectNames.add(objectName);
                MinioUtils.removeObjects("sycar", objectNames);
            }
        }
        //判断文件是否为空
        if (null == carPicture || 0 == carPicture.getSize()) {
@@ -259,10 +261,12 @@
                    .build();
            String presignedObjectUrl = MinioClientSingleton.getMinioClient().getPresignedObjectUrl(getPresignedObjectUrlArgs);
            String ObjectUrl  = presignedObjectUrl.substring(0, presignedObjectUrl.indexOf("?"));
            ArdSyCar ardSyCar = new ArdSyCar();
            ardSyCar.setId(id);
            ardSyCar.setCarPicture(ObjectUrl);
            ardSyCarMapper.updateArdSyCar(ardSyCar);
            if(id != null && !id.equals("")){//id为非必要
                ArdSyCar ardSyCar = new ArdSyCar();
                ardSyCar.setId(id);
                ardSyCar.setCarPicture(ObjectUrl);
                ardSyCarMapper.updateArdSyCar(ardSyCar);
            }
            return ObjectUrl;
        } catch (Exception ex) {
            return "";