Skip to content

Instantly share code, notes, and snippets.

@mlimaloureiro
mlimaloureiro / final
Last active November 25, 2017 19:46
.
├──delivery // Serve content via HTTP? CLI? everything related to that should be here
| └── http
| ├── app.go // where we have our GIN app
| ├── app_test.go // our app tests
| ├── context // some gin dependencies
| | ├── context.go
| │ └── mocks
| │ └── Context.go
| ├── controllers // our controllers
package awsdynamodb
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
// the object we want to return
package usecase_test
import (
"testing"
"github.com/stretchr/testify/assert"
// tests make you think what we want to accomplish and to design first. we know that we
// need some object that will hold account information even before we creating it
accountDomain "github.com/uniplaces/uniplaces-ap-api/domain/account"
"github.com/uniplaces/uniplaces-ap-api/usecase"
.
├── delivery // Serve content via HTTP? CLI? everything related to that should be here
|
├── domain // Where we have our domain logic
|
├── infrastructure // Where we have our implementation details (Database connections, Queues, External services)
|
└── usecase // The glue between our delivery layer and our domain layer. Different
// Delivery mechanisms probably will have the same use cases or very similiar
// use cases, this allows you to use the same code for different mechanisms by
package account
// Account is our account domain model
type Account struct {
ID string
Username string
Type string
}
package repository
import (
accountDomain "github.com/uniplaces/uniplaces-ap-api/domain/account"
)
// Account allows to interact with user account
type Account interface {
GetAccountByUsername(username string, accountType accountDomain.Type) (*accountDomain.Account, error)
}
package usecase
import (
"fmt"
accountDomain "github.com/uniplaces/uniplaces-ap-api/domain/account"
"github.com/uniplaces/uniplaces-ap-api/usecase/repository"
)
// NewAccountInteractor returns initialised pointer to Account interactor
.
├── delivery // Serve content via HTTP? CLI? everything related to that should be here
|
├── domain
│   └── account
│      └── account.go
|
├── infrastructure // Where we have our implementation details (Database connections, Queues, External services)
|
├── usecase // The glue
https://www.uniplaces.com/accommodation/lisbon/31162?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/21533?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/25334?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/41259?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/43611?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/1169?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/452?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/43499?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/43511?move-in=2017-02-15&move-out=2018-01-01
https://www.uniplaces.com/accommodation/lisbon/41500?move-in=2017-02-15&move-out=2018-01-01
[
{
"id": 26549,
"accommodation_provider_id": "c92a8822-a2ad-47f9-92fb-017698291deb",
"score": 3,
"quality": 42,
"available_from_diff": 7,
"is_enquire": false
},
{