Files
triggerssmith/internal/user/service.go

37 lines
648 B
Go

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