feat: move entity and usecase to root folder

This commit is contained in:
Elton Minetto
2020-10-12 07:35:29 -03:00
parent 2c0f46aff1
commit 3e4eb2e616
33 changed files with 109 additions and 138 deletions
+3 -6
View File
@@ -3,8 +3,7 @@ package repository
import (
"strings"
"github.com/eminetto/clean-architecture-go-v2/domain"
"github.com/eminetto/clean-architecture-go-v2/domain/entity"
"github.com/eminetto/clean-architecture-go-v2/entity"
)
//BookInmem in memory repo
@@ -29,8 +28,7 @@ func (r *BookInmem) Create(e *entity.Book) (entity.ID, error) {
//Get a book
func (r *BookInmem) Get(id entity.ID) (*entity.Book, error) {
if r.m[id] == nil {
// return nil, fmt.Errorf("not found")
return nil, domain.ErrNotFound
return nil, entity.ErrNotFound
}
return r.m[id], nil
}
@@ -68,8 +66,7 @@ func (r *BookInmem) List() ([]*entity.Book, error) {
//Delete a book
func (r *BookInmem) Delete(id entity.ID) error {
if r.m[id] == nil {
// return fmt.Errorf("not found")
return domain.ErrNotFound
return entity.ErrNotFound
}
r.m[id] = nil
return nil
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"database/sql"
"time"
"github.com/eminetto/clean-architecture-go-v2/domain/entity"
"github.com/eminetto/clean-architecture-go-v2/entity"
)
//BookMySQL mysql repo
+3 -6
View File
@@ -4,8 +4,7 @@ import (
"fmt"
"strings"
"github.com/eminetto/clean-architecture-go-v2/domain"
"github.com/eminetto/clean-architecture-go-v2/domain/entity"
"github.com/eminetto/clean-architecture-go-v2/entity"
)
//UserInmem in memory repo
@@ -30,8 +29,7 @@ func (r *UserInmem) Create(e *entity.User) (entity.ID, error) {
//Get an user
func (r *UserInmem) Get(id entity.ID) (*entity.User, error) {
if r.m[id] == nil {
// return nil, fmt.Errorf("not found")
return nil, domain.ErrNotFound
return nil, entity.ErrNotFound
}
return r.m[id], nil
}
@@ -55,8 +53,7 @@ func (r *UserInmem) Search(query string) ([]*entity.User, error) {
}
}
if len(d) == 0 {
// return nil, fmt.Errorf("not found")
return nil, domain.ErrNotFound
return nil, entity.ErrNotFound
}
return d, nil
+1 -1
View File
@@ -5,7 +5,7 @@ import (
"fmt"
"time"
"github.com/eminetto/clean-architecture-go-v2/domain/entity"
"github.com/eminetto/clean-architecture-go-v2/entity"
)
//UserMySQL mysql repo