Documentation ¶
Index ¶
- func Migrate(migrater AutoMigrater)
- type AutoMigrater
- type AutoMigraterMock
- type Config
- type Creator
- type Database
- type Email
- type EmailsGatherer
- type Finder
- type Image
- type Link
- type NameProcessor
- type Phone
- type PhonesGatherer
- type Service
- type ServiceProcessor
- type ServiceProcessorMock
- type ServiceRepository
- func (r *ServiceRepository) AppendImage(src string, service *Service)
- func (r *ServiceRepository) AppendLink(url string, service *Service)
- func (r *ServiceRepository) AppendPhone(phone string, service *Service)
- func (r *ServiceRepository) CreateService(service *Service) []error
- func (r *ServiceRepository) GatherEmails(service *Service)
- func (r *ServiceRepository) GatherPhones(service *Service)
- func (r *ServiceRepository) IsServiceWithURLExists(url string) bool
- func (r *ServiceRepository) NewService(url, source, title string) *Service
- func (r *ServiceRepository) ProcessName(service *Service)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoMigrater ¶
AutoMigrater auto migrate the DB
type AutoMigraterMock ¶
AutoMigraterMock logs errors.
func (*AutoMigraterMock) AutoMigrate ¶
func (m *AutoMigraterMock) AutoMigrate(values ...interface{}) *gorm.DB
AutoMigrate is a method mock
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the cmd configuration struct.
type Email ¶
type Email struct { gorm.Model Email string `gorm:"type:varchar(100);not null;index:email" valid:"email"` ServiceID uint }
Email is the email struct
type EmailsGatherer ¶
type EmailsGatherer interface {
GatherEmails(service *Service)
}
EmailsGatherer gather emails
type Image ¶
type Image struct { gorm.Model Src string `gorm:"size:255;not null;index:src" valid:"url"` ServiceID uint }
Image is the image struct
type NameProcessor ¶
type NameProcessor interface {
ProcessName(service *Service)
}
NameProcessor processes names
type Phone ¶
type Phone struct { gorm.Model Phone string `gorm:"type:varchar(100);not null;index:phone"` ServiceID uint }
Phone is the email struct
type PhonesGatherer ¶
type PhonesGatherer interface {
GatherPhones(service *Service)
}
PhonesGatherer gather phones
type Service ¶
type Service struct { gorm.Model URL string `gorm:"size:255;not null;unique_index;" valid:"url"` Source string `gorm:"size:255;not null;index:source;" valid:"required"` Title string `gorm:"size:255;not null;" valid:"required"` Description string `gorm:"type:text;index:description;"` FullName string `gorm:"type:varchar(255);"` FirstName string `gorm:"type:varchar(255);"` MiddleName string `gorm:"type:varchar(255);"` LastName string `gorm:"type:varchar(255);"` Country string `gorm:"type:varchar(255);"` City string `gorm:"type:varchar(255);"` Address string `gorm:"index:addr"` Avatar string `gorm:"size:255;" valid:"url,optional"` Phones []Phone `gorm:"foreignkey:ServiceID"` Emails []Email `gorm:"foreignkey:ServiceID"` Images []Image `gorm:"foreignkey:ServiceID"` Links []Link `gorm:"foreignkey:ServiceID"` Processor ServiceProcessor `gorm:"-"` }
Service is the service struct
func (*Service) BeforeSave ¶
BeforeSave runs before saving the object
type ServiceProcessor ¶
type ServiceProcessor interface { NameProcessor EmailsGatherer PhonesGatherer }
ServiceProcessor interface
type ServiceProcessorMock ¶
ServiceProcessorMock is a mock struct
func (*ServiceProcessorMock) GatherEmails ¶
func (s *ServiceProcessorMock) GatherEmails(service *Service)
GatherEmails is a method mock
func (*ServiceProcessorMock) GatherPhones ¶
func (s *ServiceProcessorMock) GatherPhones(service *Service)
GatherPhones is a method mock
func (*ServiceProcessorMock) ProcessName ¶
func (s *ServiceProcessorMock) ProcessName(service *Service)
ProcessName is a method mock
type ServiceRepository ¶
type ServiceRepository struct {
// contains filtered or unexported fields
}
ServiceRepository is the service repository struct
func NewServiceRepository ¶
func NewServiceRepository(database Database) *ServiceRepository
NewServiceRepository return a new ServiceRepository
func (*ServiceRepository) AppendImage ¶
func (r *ServiceRepository) AppendImage(src string, service *Service)
AppendImage adds an image to the service.
func (*ServiceRepository) AppendLink ¶
func (r *ServiceRepository) AppendLink(url string, service *Service)
AppendLink adds a link to the service.
func (*ServiceRepository) AppendPhone ¶
func (r *ServiceRepository) AppendPhone(phone string, service *Service)
AppendPhone adds a phone to the service.
func (*ServiceRepository) CreateService ¶
func (r *ServiceRepository) CreateService(service *Service) []error
CreateService creates a new service
func (*ServiceRepository) GatherEmails ¶
func (r *ServiceRepository) GatherEmails(service *Service)
GatherEmails tries to get the emails from the description
func (*ServiceRepository) GatherPhones ¶
func (r *ServiceRepository) GatherPhones(service *Service)
GatherPhones tries to get the phones from the description
func (*ServiceRepository) IsServiceWithURLExists ¶
func (r *ServiceRepository) IsServiceWithURLExists(url string) bool
IsServiceWithURLExists checks if a service with the provided URL exists
func (*ServiceRepository) NewService ¶
func (r *ServiceRepository) NewService(url, source, title string) *Service
NewService return a service object
func (*ServiceRepository) ProcessName ¶
func (r *ServiceRepository) ProcessName(service *Service)
ProcessName tries to get the first name and last name from the full name