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 +}