From fcd37a598db258d385b57dbd1896b8fe13422e9f Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Tue, 8 Apr 2025 14:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=88=9B=E5=BB=BA=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BE=85=E8=BD=AC=E6=8D=A2=E6=96=87=E4=BB=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/fileService.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/service/fileService.go b/service/fileService.go index 0580b9d..eb667f6 100644 --- a/service/fileService.go +++ b/service/fileService.go @@ -338,9 +338,33 @@ func GetFileWillConvertContentFileList(userID int) ([]dao.File, error) { if user.Role != "admin" { return nil, errors.New("no permission") } - return dao.GetFileWillConvertContentFileList() + files, err2 := dao.GetFileWillConvertContentFileList() + if err2 != nil { + return nil, err2 + } + var res []dao.File + for _, file := range files { + fileType := strings.Split(file.FileStoreName, ".")[1] + //如果文件类型是图片则不需要返回 + if fileType == "jpg" || fileType == "png" || fileType == "jpeg" || fileType == "gif" { + continue + } + //如果文件类型是视频则不需要返回 + if fileType == "mp4" || fileType == "avi" || fileType == "rmvb" || fileType == "mkv" { + continue + } + //如果文件类型是音频则不需要返回 + if fileType == "mp3" || fileType == "wav" || fileType == "wma" { + continue + } + //如果文件类型是压缩包则不需要返回 + if fileType == "zip" || fileType == "rar" || fileType == "7z" { + continue + } + res = append(res, file) + } + return res, nil } - func readFileContent(filePath string) (string, error) { file, err := os.Open(filePath) if err != nil {