trip

package
v0.0.0-...-f52bcce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Package trip The user fly trip reservations

Index

Constants

View Source
const Name = "trip"
View Source
const PluralName = "trips"

Variables

View Source
var (

	// ErrInvalidField the given field is invalid
	ErrInvalidField = errors.New("the given field is invalid")
)

Functions

func FieldsMetadata

func FieldsMetadata() map[string]*entity.FieldMetadata

FieldsMetadata returns the trip Entity fields metadata.

Types

type EntityDMO

type EntityDMO struct {
	// contains filtered or unexported fields
}

EntityDMO base entity Data Mapper Object

func NewEntityDMO

func NewEntityDMO(key []byte) *EntityDMO

NewEntityDMO constructor function of EntityDMO

func (*EntityDMO) DecryptString

func (dmo *EntityDMO) DecryptString(value string) (string, error)

DecryptString decrypt the given string

func (*EntityDMO) EncryptString

func (dmo *EntityDMO) EncryptString(value string) (string, error)

EncryptString encrypts the given string

type EntityQRO

type EntityQRO struct {
	Id_      *string `json:"id,omitempty"`
	Created_ *int64  `json:"created,omitempty"`
	Updated_ *int64  `json:"updated,omitempty"`

	Departure_ *string `json:"departure,omitempty"`

	Arrival_ *string `json:"arrival,omitempty"`

	Miles_ *int64 `json:"miles,omitempty"`

	From_ *int64 `json:"from,omitempty"`

	To_ *int64 `json:"to,omitempty"`

	UserId_ *string `json:"userId,omitempty"`

	QRO
}

func (*EntityQRO) FieldValue

func (qro *EntityQRO) FieldValue(field string) interface{}

func (*EntityQRO) HydrateFromEntity

func (qro *EntityQRO) HydrateFromEntity(ety *TripEntity, fields ...string) error

type IEntityDMO

type IEntityDMO interface {
	ToEntity() (*TripEntity, error)
	HydrateFromEntity(entity *TripEntity) error
	Id() string
	Created() int64
	Updated() int64
	Departure() string
	Arrival() string
	Miles() int64
	From() int64
	To() int64
	UserId() string
}

IEntityDMO interface to defines the Data Mapper Object implementation

type IEntityDTO

type IEntityDTO interface {
	Id() string
	Created() int64
	Updated() int64

	Departure() string
	Arrival() string
	Miles() int64
	From() int64
	To() int64
	UserId() string
}

IEntityDTO interface to defines the Data Transfer Object implementation

type IRepository

type IRepository interface {
	IRepositoryBase // DO NOT REMOVE this line. IRepositoryBase defines all CRUD operations for the entity and the TQL

}

type IRepositoryBase

type IRepositoryBase interface {
	Save(entity *TripEntity) error
	FetchByID(id string) (*TripEntity, error)
	Update(entity *TripEntity) error
	DeleteByID(id string) error

	Query(q *tql.Query, metadata map[string]string) ([]*TripEntity, error)

	DeleteByUser(userId string) error
}

IRepositoryBase interface to defines the base repository implementation

type IService

type IService interface {
	IServiceBase // DO NOT REMOVE this line. IServiceBase defines all CRUD operations for the entity

}

IService interface that aggregates IServiceBase. All of your use cases should be added here.

type IServiceBase

type IServiceBase interface {
	IServiceBaseRel
	Create(ctx context.IDataMap, entity *TripEntity) (*TripEntity, error)
	Read(ctx context.IDataMap, id string) (*TripEntity, error)
	Update(ctx context.IDataMap, entity *TripEntity) (*TripEntity, error)
	Delete(ctx context.IDataMap, id string) error
	Query(q *tql.Query) (*tql.Result, error)
}

IServiceBase interface to defines the service basis implementation

type IServiceBaseRel

type IServiceBaseRel interface {
	BelongsToUser(userId string, items int64, page int64) ([]*TripEntity, error)
	DeleteByUser(userId string) error
}

IServiceBaseRel interface to defines the relationship methods

type QRO

type QRO struct {
}

type Service

type Service struct {
	*ServiceBase // DO NOT REMOVE this line. ServiceBase implements IServiceBase interface
}

Service defines your use cases. Extends from ServiceBase to get the CRUD operations

func NewService

func NewService(repo IRepository, logger log.ILogger) *Service

NewService Service constructor function

type ServiceBase

type ServiceBase struct {
	// contains filtered or unexported fields
}

ServiceBase implements the interface IServiceBase

func (*ServiceBase) BelongsToUser

func (s *ServiceBase) BelongsToUser(userId string, items int64, page int64) ([]*TripEntity, error)

BelongsToUser fetch a list of TripEntity that belongs to User given the userId

func (*ServiceBase) Create

func (s *ServiceBase) Create(ctx context.IDataMap, ety *TripEntity) (*TripEntity, error)

Create given a new entity this one is populated with ID and creation timestamp and finally saved into the repository

func (*ServiceBase) Delete

func (s *ServiceBase) Delete(ctx context.IDataMap, id string) error

Delete removes the entity given its id

func (*ServiceBase) DeleteByUser

func (s *ServiceBase) DeleteByUser(userId string) error

DeleteByUser remove all trip given the userId

func (*ServiceBase) Query

func (s *ServiceBase) Query(q *tql.Query) (*tql.Result, error)

Query executes the given query (TQL) and returns the query result

func (*ServiceBase) Read

func (s *ServiceBase) Read(ctx context.IDataMap, id string) (*TripEntity, error)

Read returns a pointer to TripEntity given its id

func (*ServiceBase) Update

func (s *ServiceBase) Update(ctx context.IDataMap, ety *TripEntity) (*TripEntity, error)

Update returns a pointer to TripEntity after update it

type TripEntity

type TripEntity struct {
	// contains filtered or unexported fields
}

TripEntity The user fly trip reservations

func New

func New() *TripEntity

New is a TripEntity constructor function

func (TripEntity) Arrival

func (e TripEntity) Arrival() string

Arrival The trip arrival airport

func (TripEntity) Created

func (e TripEntity) Created() int64

func (TripEntity) Departure

func (e TripEntity) Departure() string

Departure The trip departure airport

func (TripEntity) FieldsMetadata

func (e TripEntity) FieldsMetadata() map[string]*entity.FieldMetadata

func (TripEntity) From

func (e TripEntity) From() int64

From The trip from date

func (TripEntity) Id

func (e TripEntity) Id() string

func (TripEntity) Miles

func (e TripEntity) Miles() int64

Miles The trip miles

func (TripEntity) SetArrival

func (e TripEntity) SetArrival(arrival string) error

SetArrival The trip arrival airport

func (TripEntity) SetCreated

func (e TripEntity) SetCreated(created int64)

func (TripEntity) SetDeparture

func (e TripEntity) SetDeparture(departure string) error

SetDeparture The trip departure airport

func (TripEntity) SetFrom

func (e TripEntity) SetFrom(from int64) error

SetFrom The trip from date

func (TripEntity) SetId

func (e TripEntity) SetId(id string)

func (TripEntity) SetMiles

func (e TripEntity) SetMiles(miles int64) error

SetMiles The trip miles

func (TripEntity) SetTo

func (e TripEntity) SetTo(to int64) error

SetTo The trip to date

func (TripEntity) SetUpdated

func (e TripEntity) SetUpdated(updated int64)

func (TripEntity) SetUserId

func (e TripEntity) SetUserId(userId string) error

SetUserId The userId relationship

func (TripEntity) String

func (e TripEntity) String() string

String returns the string representation of the entityBase

func (TripEntity) TRN

func (e TripEntity) TRN() *trn.TRN

func (TripEntity) To

func (e TripEntity) To() int64

To The trip to date

func (TripEntity) Updated

func (e TripEntity) Updated() int64

func (TripEntity) UserId

func (e TripEntity) UserId() string

UserId The userId relationship

Directories

Path Synopsis
inputs
http/gin
Package gin input
Package gin input
outputs
memory
Package memory is an output adapter to store entities in memory
Package memory is an output adapter to store entities in memory
mongodb
Package mongodb is an output adapter to store entities in MongoDB
Package mongodb is an output adapter to store entities in MongoDB
testing
mocks
Package mocks the service trip.Service for testing purpose
Package mocks the service trip.Service for testing purpose

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL