From 020a5e6e401d09db1947865bb02a2ca7cf87a240 Mon Sep 17 00:00:00 2001 From: qowevisa Date: Thu, 31 Oct 2024 11:11:39 +0200 Subject: [PATCH] Add implemetation for db.UserIdentifiable for type in db package --- db/type.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/db/type.go b/db/type.go index aec201b..fb4f457 100644 --- a/db/type.go +++ b/db/type.go @@ -15,6 +15,21 @@ type Type struct { User *User } +// Implements db.UserIdentifiable:1 +func (t Type) GetID() uint { + return t.ID +} + +// Implements db.UserIdentifiable:2 +func (t Type) GetUserID() uint { + return t.UserID +} + +// Implements db.UserIdentifiable:3 +func (t *Type) SetUserID(id uint) { + t.UserID = id +} + var ( ERROR_TYPE_NAME_EMPTY = errors.New("The 'Name' field of 'Type' cannot be empty") ERROR_TYPE_NAME_NOT_UNIQUE = errors.New("The 'Name' field of 'Type' have to be unique for user") @@ -36,7 +51,3 @@ func (t *Type) BeforeSave(tx *gorm.DB) error { return nil } - -func (t *Type) GetID() uint { - return t.ID -}