From b56a8ba5accbaf510b69ee5aee0c4aa8715174bb Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 17 Jan 2024 17:14:45 -0500 Subject: [PATCH] feat: add PinByID --- account/account.go | 12 ++++++++++++ interfaces/account.go | 1 + 2 files changed, 13 insertions(+) diff --git a/account/account.go b/account/account.go index 917d62d..0d02e42 100644 --- a/account/account.go +++ b/account/account.go @@ -184,3 +184,15 @@ func (s AccountServiceImpl) PinByHash(hash string, accountID uint) error { return nil } + +func (s AccountServiceImpl) PinByID(uploadId uint, accountID uint) error { + // Create a pin with the retrieved upload ID and matching account ID + pinQuery := models.Pin{UploadID: uploadId, UserID: accountID} + result := s.portal.Database().Create(&pinQuery) + + if result.Error != nil { + return result.Error + } + + return nil +} diff --git a/interfaces/account.go b/interfaces/account.go index 66304f0..769856d 100644 --- a/interfaces/account.go +++ b/interfaces/account.go @@ -13,4 +13,5 @@ type AccountService interface { AccountPins(id uint64, createdAfter uint64) ([]models.Pin, error) DeletePinByHash(hash string, accountID uint) error PinByHash(hash string, accountID uint) error + PinByID(uploadId uint, accountID uint) error }