Add infrastructure
This commit is contained in:
28
services/entry/pkg/db/postgres/userrepo.go
Normal file
28
services/entry/pkg/db/postgres/userrepo.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type UserDto struct {
|
||||
}
|
||||
|
||||
type InMemoryUserRepository struct {
|
||||
users map[int]*UserDto
|
||||
}
|
||||
|
||||
func NewInMemoryUserRepository() *InMemoryUserRepository {
|
||||
return &InMemoryUserRepository{
|
||||
users: make(map[int]*UserDto),
|
||||
}
|
||||
}
|
||||
|
||||
func (ur *InMemoryUserRepository) Get(ctx context.Context, id int) (*UserDto, error) {
|
||||
user := ur.users[id]
|
||||
if user == nil {
|
||||
return nil, errors.New("user is not in database")
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
Reference in New Issue
Block a user