add user crud interface in impl

This commit is contained in:
2025-12-18 10:49:56 +02:00
parent 603f007c63
commit 53761db1e0
5 changed files with 190 additions and 0 deletions

36
internal/user/service.go Normal file
View File

@@ -0,0 +1,36 @@
package user
import "fmt"
type Service struct {
store UserCRUD
}
func NewService(store UserCRUD) (UserCRUD, error) {
if store == nil {
return nil, fmt.Errorf("store is nil")
}
return &Service{
store: store,
}, nil
}
func (s *Service) Create(user *User) error {
return s.store.Create(user)
}
func (s *Service) GetByID(id int64) (*User, error) {
return s.store.GetByID(id)
}
func (s *Service) GetByUsername(username string) (*User, error) {
return s.store.GetByUsername(username)
}
func (s *Service) Update(user *User) error {
return s.store.Update(user)
}
func (s *Service) Delete(id int64) error {
return s.store.Delete(id)
}