package account import ( "nos-comptes/internal/storage/dao" "nos-comptes/internal/storage/model" "nos-comptes/internal/utils" ) type Service struct { db *Database } func (s *Service) GetAllAccountOfUser(userId string) ([]*Account, error) { accounts, err := s.db.GetAllAccountOfUser(userId) utils.GetLogger().Warn(err) if e, ok := err.(*dao.Error); ok { switch { case e.Type == dao.ErrTypeNotFound: return nil, &model.ErrNotFound default: return nil, &model.ErrInternalServer } } else if err != nil { return nil, &model.ErrInternalServer } if accounts == nil { return nil, &model.ErrNotFound } return accounts, nil } func NewService(database *Database) *Service { return &Service{db: database} }