Optimize list attachment api

This commit is contained in:
2024-08-07 01:02:03 +08:00
parent 13893e87f7
commit 3e000b6f9e
2 changed files with 25 additions and 11 deletions

View File

@ -55,6 +55,10 @@ func GetAttachmentCache(id uint) (models.Attachment, bool) {
return models.Attachment{}, false
}
func CacheAttachment(id uint, item models.Attachment) {
metadataCache.Store(id, item)
}
func NewAttachmentMetadata(tx *gorm.DB, user models.Account, file *multipart.FileHeader, attachment models.Attachment) (models.Attachment, error) {
attachment.Uuid = uuid.NewString()
attachment.Size = file.Size