customer

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 CusVisitAssocService

type CusVisitAssocService interface {
	UpdateNameByCusID(ctx context.Context, customerName string, customerID string) error
	IsAssignedCustomer(ctx context.Context, customerID string, visitID 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, customer types.Customer) (string, error)

Create a customer

func (*MongoRepository) Delete

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

Delete a customer

func (*MongoRepository) FindAll

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

FindAll return all customers

func (*MongoRepository) FindByID

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

FindByID return customer base on given id

func (*MongoRepository) Update

func (r *MongoRepository) Update(ctx context.Context, customer types.Customer) error

Update a customer

type Repository

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

Repository is an interface of a customer repository

type Service

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

Service is an customer service

func NewService

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

NewService return a new customer service

func (*Service) Create

func (s *Service) Create(ctx context.Context, customer types.Customer) (string, error)

Create a customer

func (*Service) Delete

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

Delete a customer

func (*Service) Get

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

Get return given customer by his/her id

func (*Service) GetAll

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

Get All return all customer from database

func (*Service) Update

func (s *Service) Update(ctx context.Context, customer types.Customer) error

Update a customer

Jump to

Keyboard shortcuts

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