From ae355b23cadc5a87b32dc8e65eb34b6a59f10b4d Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sat, 29 Mar 2025 14:02:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BE=AA=E7=8E=AF=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/file.go | 5 +++++ proto/file_req.go | 6 ------ service/fileService.go | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dao/file.go b/dao/file.go index 8366939..e25766c 100644 --- a/dao/file.go +++ b/dao/file.go @@ -41,6 +41,11 @@ type FileAuthListResp struct { FileStoreName string `gorm:"column:file_store_name;type:varchar(255);uniqueIndex:idx_file_name"` } +type UserFileListResp struct { + FileAuth + FileStoreName string `json:"file_store_name" form:"file_store_name"` +} + func CreateFile(fileStoreName, fileName, fileType, filePath, md5Str string, fileSize, authID int, NeedAuth bool) File { file := File{FileStoreName: fileStoreName, FileName: fileName, FileType: fileType, FilePath: filePath, FileSize: fileSize, AuthID: authID, NeedAuth: NeedAuth, Md5: md5Str} result := DB.Create(&file) diff --git a/proto/file_req.go b/proto/file_req.go index a711fe2..cb06742 100644 --- a/proto/file_req.go +++ b/proto/file_req.go @@ -1,7 +1,6 @@ package proto import ( - "StuAcaWorksAI/dao" "time" ) @@ -33,8 +32,3 @@ type SearchOneConfigFileResp struct { FilePath string `json:"file_path" form:"file_path"` Content string `json:"content" form:"content"` } - -type UserFileListResp struct { - dao.FileAuth - FileStoreName string `json:"file_store_name" form:"file_store_name"` -} diff --git a/service/fileService.go b/service/fileService.go index 3711079..2deaf1d 100644 --- a/service/fileService.go +++ b/service/fileService.go @@ -249,16 +249,16 @@ func CreateUserFile(userID int, fileAuthName string, fileID int, UploadType stri return fileAuth } -func FindUserFileList(userID int, uploadType string) []proto.UserFileListResp { +func FindUserFileList(userID int, uploadType string) []dao.UserFileListResp { fileList, files := dao.FileUserFileList(userID, uploadType) filesM := make(map[uint]dao.File) for _, file := range files { filesM[file.ID] = file } - var res []proto.UserFileListResp + var res []dao.UserFileListResp for _, file := range fileList { fileStoreName := filesM[uint(file.FileID)].FileStoreName - r := proto.UserFileListResp{FileAuth: file, FileStoreName: fileStoreName} + r := dao.UserFileListResp{FileAuth: file, FileStoreName: fileStoreName} res = append(res, r) } log.Println("FindUserFileList res:", len(res))