yangys
2024-03-31 53c8d3e3bd3596132b362f20e52aef380d493a84
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.qianwen.smartman.modules.system.service.impl;
 
import java.io.IOException;
import java.lang.invoke.SerializedLambda;
import java.util.List;
import com.qianwen.smartman.common.utils.Lambda;
import com.qianwen.smartman.common.utils.PictureUtil;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.core.oss.model.BladeFile;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.resource.builder.oss.OssBuilder;
import com.qianwen.smartman.modules.system.dto.GalleryItemDTO;
import com.qianwen.smartman.modules.system.entity.GalleryItem;
import com.qianwen.smartman.modules.system.mapper.GalleryItemMapper;
import com.qianwen.smartman.modules.system.service.IGalleryItemService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
 
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/service/impl/GalleryItemServiceImpl.class */
public class GalleryItemServiceImpl extends BaseServiceImpl<GalleryItemMapper, GalleryItem> implements IGalleryItemService {
    private final OssBuilder ossBuilder;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = false;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getId();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    public GalleryItemServiceImpl(final OssBuilder ossBuilder) {
        this.ossBuilder = ossBuilder;
    }
 
    @Override // org.springblade.modules.system.service.IGalleryItemService
    @Transactional
    public GalleryItem save(MultipartFile file, GalleryItemDTO galleryItemDTO) throws IOException {
        GalleryItem galleryItem = new GalleryItem();
        galleryItem.setGalleryId(galleryItemDTO.getGalleryId());
        galleryItem.setThumbnail(PictureUtil.compressBase64(file.getBytes(), 10L));
        BladeFile bladeFile = this.ossBuilder.visualTemplate().putFile(file.getOriginalFilename(), file);
        galleryItem.setName(bladeFile.getName());
        galleryItem.setOriginalName(bladeFile.getOriginalName());
        galleryItem.setLink(bladeFile.getName());
        galleryItem.setExtension(PictureUtil.getSuffix(file));
        save(galleryItem);
        return galleryItem;
    }
 
    @Override // org.springblade.modules.system.service.IGalleryItemService
    public boolean remove(List<String> ids) {
        List<GalleryItem> galleryItems = list(Lambda.in((v0) -> {
            return v0.getId();
        }, ids));
        galleryItems.forEach(item -> {
            this.ossBuilder.template().removeFile(item.getName());
        });
        return removeByIds(Func.toLongList(ids));
    }
}