From 05e40343b56047d219d5ee9d61fb31cd8eb70318 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Fri, 28 Mar 2025 19:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfile=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=9C=AA=E8=AE=BE=E7=BD=AE=E5=88=B0=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/file.go | 9 ++++++++- service/fileService.go | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/handler/file.go b/handler/file.go index 60fa2e9..a66ec15 100644 --- a/handler/file.go +++ b/handler/file.go @@ -257,6 +257,13 @@ func UploadFileV2(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"error": "save file info failed", "code": proto.SaveFileInfoFailed, "message": "failed"}) return } + //添加用户文件 + fileAuth := service.CreateUserFile(id1, file_record.FileName, int(file_record.ID), uploadType) + if fileAuth.ID != 0 { + c.JSON(http.StatusOK, gin.H{"error": "save user file info failed", "code": proto.SaveFileInfoFailed, "message": "failed"}) + return + } + file_record.FilePath = "" - c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": file_record}) + c.JSON(http.StatusOK, gin.H{"code": proto.SuccessCode, "message": "success", "data": file_record, "file_auth": fileAuth}) } diff --git a/service/fileService.go b/service/fileService.go index 3d8590a..1e29216 100644 --- a/service/fileService.go +++ b/service/fileService.go @@ -242,3 +242,8 @@ func DeleteUserFile(userID, fileAuthID int) error { err := dao.DeleteFileAuthByID(fileAuthID) return err } + +func CreateUserFile(userID int, fileAuthName string, fileID int, UploadType string) dao.FileAuth { + fileAuth := dao.CreateFileAuth(userID, fileID, fileAuthName, UploadType, 1, "") + return fileAuth +}