zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
 
package org.jeecg.modules.doc.vo;
 
import cn.hutool.core.io.FileTypeUtil;
 
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.jeecg.modules.doc.util.CharsetUtils;
import org.jeecg.modules.doc.util.UFOPUtils;
 
public abstract class Previewer {
    public ThumbImage thumbImage;
 
    protected abstract InputStream getInputStream(String fileUrl);
 
    public void imageThumbnailPreview(HttpServletResponse httpServletResponse, String fileUrl) {
 
        boolean isVideo = UFOPUtils.isVideoFile(FilenameUtils.getExtension(fileUrl));
        String thumbnailImgUrl = fileUrl;
        if (isVideo) {
            thumbnailImgUrl = fileUrl.replace("." + FilenameUtils.getExtension(fileUrl), ".jpg");
        }
 
        File cacheFile = UFOPUtils.getCacheFile(thumbnailImgUrl);
        ServletOutputStream outputStream;
        if (cacheFile.exists()) {
            FileInputStream fis = null;
            outputStream = null;
 
            try {
                fis = new FileInputStream(cacheFile);
                outputStream = httpServletResponse.getOutputStream();
                IOUtils.copy(fis, outputStream);
            } catch (IOException var26) {
                var26.printStackTrace();
            } finally {
                IOUtils.closeQuietly(fis);
                IOUtils.closeQuietly(outputStream);
            }
        } else {
            InputStream inputstream = null;
            outputStream = null;
            InputStream in = null;
 
            try {
                inputstream = this.getInputStream(fileUrl);
                if (inputstream != null) {
                    outputStream = httpServletResponse.getOutputStream();
                    int thumbImageWidth = this.thumbImage.getWidth();
                    int thumbImageHeight = this.thumbImage.getHeight();
                    int width = thumbImageWidth == 0 ? 150 : thumbImageWidth;
                    int height = thumbImageHeight == 0 ? 150 : thumbImageHeight;
                    String type = FileTypeUtil.getType(this.getInputStream(fileUrl));
                    boolean isImageFile = UFOPUtils.isImageFile(type);
                    if (isVideo) {
                        in = VideoOperation.thumbnailsImage(inputstream, cacheFile, width, height);
                    } else if (isImageFile) {
                        in = ImageOperation.thumbnailsImage(inputstream, cacheFile, width, height);
                    } else {
                        in = inputstream;
                    }
 
                    IOUtils.copy(in, outputStream);
                }
            } catch (IOException var25) {
                var25.printStackTrace();
            } finally {
                IOUtils.closeQuietly(in);
                IOUtils.closeQuietly(inputstream);
                IOUtils.closeQuietly(outputStream);
 
 
            }
        }
 
    }
 
    public void imageOriginalPreview(HttpServletResponse httpServletResponse, String fileUrl) {
        InputStream inputStream = null;
        OutputStream outputStream = null;
 
        try {
            inputStream = this.getInputStream(fileUrl);
            outputStream = httpServletResponse.getOutputStream();
            byte[] bytes = IOUtils.toByteArray(inputStream);
            bytes = CharsetUtils.convertTxtCharsetToUTF8(bytes, FilenameUtils.getExtension(fileUrl));
            outputStream.write(bytes);
        } catch (IOException var9) {
            var9.printStackTrace();
        } finally {
            IOUtils.closeQuietly(inputStream);
            IOUtils.closeQuietly(outputStream);
 
 
        }
 
    }
 
    public Previewer() {
    }
 
    public ThumbImage getThumbImage() {
        return this.thumbImage;
    }
 
    public void setThumbImage(final ThumbImage thumbImage) {
        this.thumbImage = thumbImage;
    }
 
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Previewer)) {
            return false;
        } else {
            Previewer other = (Previewer)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                Object this$thumbImage = this.getThumbImage();
                Object other$thumbImage = other.getThumbImage();
                if (this$thumbImage == null) {
                    if (other$thumbImage != null) {
                        return false;
                    }
                } else if (!this$thumbImage.equals(other$thumbImage)) {
                    return false;
                }
 
                return true;
            }
        }
    }
 
    protected boolean canEqual(final Object other) {
        return other instanceof Previewer;
    }
 
    public int hashCode() {
        int result = 1;
        Object $thumbImage = this.getThumbImage();
        result = result * 59 + ($thumbImage == null ? 43 : $thumbImage.hashCode());
        return result;
    }
 
    public String toString() {
        return "Previewer(thumbImage=" + this.getThumbImage() + ")";
    }
}