修复file上传未设置到用户

This commit is contained in:
junleea 2025-03-28 19:53:25 +08:00
parent af76f6b50d
commit 05e40343b5
2 changed files with 13 additions and 1 deletions

View File

@ -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})
}

View File

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