gift

package
v0.0.0-...-0eec0e3 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GiftAssocService

type GiftAssocService interface {
	UpdateNameByGiftID(ctx context.Context, giftName string, giftID string) error
	IsAssignedGift(ctx context.Context, giftID string, cusvisitassocID string) bool
}

type MongoRepository

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

MongoRepository is MongoDB implementation of repository

func NewMongoRepository

func NewMongoRepository(s *mgo.Session) *MongoRepository

NewMongoRepository return new MongoDB repository

func (*MongoRepository) Create

func (r *MongoRepository) Create(ctx context.Context, gift types.Gift) (string, error)

Create a gift

func (*MongoRepository) Delete

func (r *MongoRepository) Delete(ctx context.Context, id string) error

Delete a gift

func (*MongoRepository) FindAll

func (r *MongoRepository) FindAll(ctx context.Context) ([]types.Gift, error)

FindAll return all gifts

func (*MongoRepository) FindByID

func (r *MongoRepository) FindByID(ctx context.Context, id string) (*types.Gift, error)

FindByID return gift base on given id

func (*MongoRepository) Update

func (r *MongoRepository) Update(ctx context.Context, gift types.Gift) error

Update a gift

type Repository

type Repository interface {
	FindByID(ctx context.Context, id string) (*types.Gift, error)
	FindAll(ctx context.Context) ([]types.Gift, error)
	Create(ctx context.Context, gift types.Gift) (string, error)
	Update(ctx context.Context, gift types.Gift) error
	Delete(ctx context.Context, id string) error
}

Repository is an interface of a gift repository

type Service

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

Service is an gift service

func NewService

func NewService(r Repository, assocService GiftAssocService, l glog.Logger) *Service

NewService return a new gift service

func (*Service) Create

func (s *Service) Create(ctx context.Context, gift types.Gift) (string, error)

Create a gifts

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete a gift

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*types.Gift, error)

Get return given gift by his/her id

func (*Service) GetAll

func (s *Service) GetAll(ctx context.Context) ([]types.Gift, error)

GetAll return all gifts from database

func (*Service) Update

func (s *Service) Update(ctx context.Context, gift types.Gift) error

Update a gift

Jump to

Keyboard shortcuts

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