initial commit 2

This commit is contained in:
Senad Uka
2018-04-25 13:16:36 +02:00
parent c1520d169c
commit 99c10b75fb
167 changed files with 25057 additions and 0 deletions

19
domain/contract/cache.go Normal file
View File

@@ -0,0 +1,19 @@
package contract
import "time"
// CacheManager defines the main caching interface
// - Get methods can return domain.ErrCacheMiss
type CacheManager interface {
GetItem(key string) ([]byte, error)
SetItem(key string, data []byte) error
GetString(key string) (string, error)
SetString(key string, data string) error
GetStruct(key string, data interface{}) error
SetStruct(key string, data interface{}) error
GetExpiration(key string) (time.Duration, error)
SetExpiration(key string, expiration time.Duration) error
}

16
domain/contract/data.go Normal file
View File

@@ -0,0 +1,16 @@
package contract
// DataManager holds the methods that manipulates the main data.
type DataManager interface {
repoManager
Begin() (TransactionManager, error)
Close() error
}
// TransactionManager holds the methods that manipulates the main
// data, from within a transaction.
type TransactionManager interface {
repoManager
Rollback() error
Commit() error
}

104
domain/contract/repo.go Normal file
View File

@@ -0,0 +1,104 @@
package contract
import (
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
)
type repoManager interface {
Users() UserRepo
Rides() RideRepo
Visits() VisitRepo
Provider() ProviderRepo
Notification() NotificationRepo
Profile() ProfileRepo
Organization() OrganizationRepo
}
// UserRepo defines the data set for users
type UserRepo interface {
GetAll() (list []entity.User, err error)
GetByID(userID int64) (retVal entity.User, err error)
GetByUUID(uuid string, profile string) (entity.User, error)
Login(email string, pass string) (entity.User, error)
FullLogin(loginType string, key string, pass string, profile string) (entity.User, error)
Create(user entity.User) (entity.User, error)
GetUsersByProfile(profile string) ([]entity.User, error)
SaveAddress(address entity.Address) (entity.Address, error)
GetAddressByUUID(addressUUID string) (entity.Address, error)
GetContactType() (retVal []entity.ContactType, err error)
RemoveAddress(addressUUID string) error
}
// RideRepo defines the data set for Rides
type RideRepo interface {
Save(ride entity.Ride) (entity.Ride, error)
GetAll(user entity.User) ([]entity.Ride, error)
GetByID(id int64, user entity.User) (entity.Ride, error)
GetByUUID(uuid string, user entity.User) (entity.Ride, error)
GetByInternalID(internalID string) (entity.Ride, error)
GetByUserID(userID int64, user entity.User) ([]entity.Ride, error)
GetByUserUUID(userUUID string, user entity.User) ([]entity.Ride, error)
GetByUUIDAndUserUUID(UUID string, userUUID string) (entity.Ride, error)
UpdateStatus(rideUUID string, status string) error
Update(hook entity.WebhookResponse, user entity.User) (entity.Ride, error)
GetLastRideByPhoneNumber(phoneNumber string) (entity.Ride, error)
GetLastRideByDriversNumber(phoneNumber string) (entity.Ride, error)
GetByInternalPassengerID(internalPassengerID string) (entity.Ride, error)
GetByVisitUUID(visitUUID string, user entity.User) ([]entity.Ride, error)
GetByVisitUUIDAndTripType(visitUUID string, tripTypeKey string, user entity.User) (entity.Ride, error)
}
// ProviderRepo defines the data set for Provider
type ProviderRepo interface {
Save(providers []entity.ProviderResponse, user entity.User) ([]entity.Provider, error)
GetAll(user entity.User) ([]entity.Provider, error)
Get(query string, lat float64, long float64, distance int64, planCode string, productID string, mukID string, internalID string, sort string, user entity.User) ([]entity.Provider, error)
GetByMukID(mukID string, user entity.User) (entity.Provider, error)
}
// NotificationRepo defines the data set for Notification
type NotificationRepo interface {
Create(notification entity.Notification) (entity.Notification, error)
GetByUserUUIDAndReadStatus(userUUID string, status string, isRead bool) ([]entity.Notification, error)
GetByUserUUID(userUUID string, status string) ([]entity.Notification, error)
ReadStatus(notificationUUID string, readed bool) error
GetLastNotificationFromPhoneNumber(notificationType string, phoneNumber string, status string) (entity.Notification, error)
}
// ProviderRepo defines the data set for Rides
type OrganizationRepo interface {
GetAllTypes() ([]entity.OrganizationType, error)
GetByType(organizationTypeKey string) ([]entity.Organization, error)
GetByUUID(organizationUUID string) (entity.Organization, error)
GetContactsByOrganizationUUID(organizationUUID string) ([]entity.OrganizationContact, error)
GetContactsByOrganizationID(organizationID int64) ([]entity.OrganizationContact, error)
GetContactsByUUID(contactUUID string) (entity.OrganizationContact, error)
GetAddressByOrganizationUUID(organizationUUID string) ([]entity.OrganizationAddress, error)
GetAddressByOrganizationID(organizationID int64) ([]entity.OrganizationAddress, error)
GetAddressByUUID(contactUUID string) (entity.OrganizationAddress, error)
GetByID(organizationID int64) (entity.Organization, error)
GetChildsByID(organizationID int64) ([]entity.Organization, error)
GetByName(name string, searchType string) ([]entity.Organization, error)
SetParentOrganization(organizationID int64, parentOrganizationID int64) error
InactivateOrganizationAddress(address entity.OrganizationAddress) error
SetOrganizationAddress(address entity.OrganizationAddress) (entity.OrganizationAddress, error)
InactivateOrganizationContact(contact entity.OrganizationContact) error
SetOrganizationContact(contact entity.OrganizationContact) (entity.OrganizationContact, error)
AddOrganization(organization entity.Organization) (entity.Organization, error)
GetTypeByKey(key string) (entity.OrganizationType, error)
}
// VisitRepo defines the data set for Rides
type VisitRepo interface {
Create(visit entity.Visit) (entity.Visit, error)
GetAll(user entity.User) ([]entity.Visit, error)
GetByUUID(visitUUID string, user entity.User) (entity.Visit, error)
GetByID(visitID int64, user entity.User) (entity.Visit, error)
}
type ProfileRepo interface {
GetAll() ([]entity.Profile, error)
GetByKey(key string) (entity.Profile, error)
GetVisibles(visible bool) ([]entity.Profile, error)
GetByOrganizationType(organizationTypeID int64) ([]entity.Profile, error)
}

12
domain/contract/tnc.go Normal file
View File

@@ -0,0 +1,12 @@
package contract
type tncManager interface {
TNC() TNCManager
}
//TNCManager defines the integration with any TNC
type TNCManager interface {
GetETA(lag float64, log float64, params map[string]interface{}) (interface{}, error)
GetDrivers(lag float64, log float64) (interface{}, error)
GetTypes(lag float64, log float64, params map[string]interface{}) (interface{}, error)
}