datastore

package
v0.0.0-...-ee53a0f Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskItemStatusActive   = 1
	TaskItemStatusArchived = 2

	TaskItemTypeAssignedAssociate                           = 1
	TaskItemTypeFollowUpDidAssociateAndCustomerAgreedToMeet = 2
	TaskItemTypeFollowUpCustomerSurvey                      = 3 // DEPRECATED
	TaskItemTypeFollowUpDidAssociateAcceptJob               = 4
	TaskItemTypeUpdateOngoingJob                            = 5
	TaskItemTypeFollowUpDidAssociateCompleteJob             = 6
	TaskItemTypeFollowUpDidCustomerReviewAssociateAfterJob  = 7
)
View Source
const (
	SortOrderAscending  = 1
	SortOrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type TaskItem

type TaskItem struct {
	ID                                    primitive.ObjectID              `bson:"_id" json:"id"`                                    // 01
	TenantID                              primitive.ObjectID              `bson:"tenant_id" json:"tenant_id,omitempty"`             // 03
	Type                                  int8                            `bson:"type" json:"type"`                                 // 04
	Title                                 string                          `bson:"title" json:"title"`                               // 05
	Description                           string                          `bson:"description" json:"description"`                   // 06
	DueDate                               time.Time                       `bson:"due_date" json:"due_date"`                         // 07
	IsClosed                              bool                            `bson:"is_closed" json:"is_closed"`                       // 08
	WasPostponed                          bool                            `bson:"was_postponed" json:"was_postponed"`               // 09
	ClosingReason                         int8                            `bson:"closing_reason" json:"closing_reason"`             // 10
	ClosingReasonOther                    string                          `bson:"closing_reason_other" json:"closing_reason_other"` // 11
	OrderID                               primitive.ObjectID              `bson:"order_id" json:"order_id"`                         // 12
	OrderType                             int8                            `bson:"order_type" json:"order_type"`                     // 28
	OrderWJID                             uint64                          `bson:"order_wjid" json:"order_wjid"`
	OrderTenantIDWithWJID                 string                          `bson:"order_tenant_id_with_wjid" json:"order_tenant_id_with_wjid"` // OrderTenantIDWithWJID is a combination of `tenancy_id` and `wjid` values written in the following structure `%v_%v`.
	OrderStartDate                        time.Time                       `bson:"order_start_date" json:"order_start_date"`
	OrderDescription                      string                          `bson:"order_description" json:"order_description"`
	OrderSkillSets                        []*TaskItemSkillSet             `bson:"order_skill_sets" json:"order_skill_sets,omitempty"` // Related
	OrderTags                             []*TaskItemTag                  `bson:"order_tags" json:"order_tags,omitempty"`             // Related
	CreatedAt                             time.Time                       `bson:"created_at" json:"created_at"`
	CreatedByUserID                       primitive.ObjectID              `bson:"created_by_user_id" json:"created_by_user_id,omitempty"`
	CreatedByUserName                     string                          `bson:"created_by_user_name" json:"created_by_user_name"`
	CreatedFromIPAddress                  string                          `bson:"created_from_ip_address" json:"created_from_ip_address"`
	ModifiedAt                            time.Time                       `bson:"modified_at" json:"modified_at"`
	ModifiedByUserID                      primitive.ObjectID              `bson:"modified_by_user_id" json:"modified_by_user_id,omitempty"`
	ModifiedByUserName                    string                          `bson:"modified_by_user_name" json:"modified_by_user_name"`
	ModifiedFromIPAddress                 string                          `bson:"modified_from_ip_address" json:"modified_from_ip_address"`
	Status                                int8                            `bson:"status" json:"status"`       // 20
	PublicID                              uint64                          `bson:"public_id" json:"public_id"` // 21
	CustomerID                            primitive.ObjectID              `bson:"customer_id" json:"customer_id"`
	CustomerPublicID                      uint64                          `bson:"customer_public_id" json:"customer_public_id"` // 21
	CustomerOrganizationName              string                          `bson:"customer_organization_name" json:"customer_organization_name"`
	CustomerOrganizationType              int8                            `bson:"customer_organization_type" json:"customer_organization_type"`
	CustomerFirstName                     string                          `bson:"customer_first_name" json:"customer_first_name,omitempty"`
	CustomerLastName                      string                          `bson:"customer_last_name" json:"customer_last_name,omitempty"`
	CustomerName                          string                          `bson:"customer_name" json:"customer_name,omitempty"`
	CustomerLexicalName                   string                          `bson:"customer_lexical_name" json:"customer_lexical_name,omitempty"`
	CustomerGender                        int8                            `bson:"customer_gender" json:"customer_gender"`
	CustomerGenderOther                   string                          `bson:"customer_gender_other" json:"customer_gender_other"`
	CustomerBirthdate                     time.Time                       `bson:"customer_birthdate" json:"customer_birthdate"`
	CustomerEmail                         string                          `bson:"customer_email" json:"customer_email,omitempty"`
	CustomerPhone                         string                          `bson:"customer_phone" json:"customer_phone,omitempty"`
	CustomerPhoneType                     int8                            `bson:"customer_phone_type" json:"customer_phone_type"`
	CustomerPhoneExtension                string                          `bson:"customer_phone_extension" json:"customer_phone_extension"`
	CustomerOtherPhone                    string                          `bson:"customer_other_phone" json:"customer_other_phone"`
	CustomerOtherPhoneExtension           string                          `bson:"customer_other_phone_extension" json:"customer_other_phone_extension"`
	CustomerOtherPhoneType                int8                            `bson:"customer_other_phone_type" json:"customer_other_phone_type"`
	CustomerFullAddressWithoutPostalCode  string                          `bson:"customer_full_address_without_postal_code" json:"customer_full_address_without_postal_code"`
	CustomerFullAddressURL                string                          `bson:"customer_full_address_url" json:"customer_full_address_url"`
	CustomerTags                          []*TaskItemTag                  `bson:"customer_tags" json:"customer_tags,omitempty"` // Related
	AssociateID                           primitive.ObjectID              `bson:"associate_id" json:"associate_id"`
	AssociatePublicID                     uint64                          `bson:"associate_public_id" json:"associate_public_id"` // 21
	AssociateOrganizationName             string                          `bson:"associate_organization_name" json:"associate_organization_name"`
	AssociateOrganizationType             int8                            `bson:"associate_organization_type" json:"associate_organization_type"`
	AssociateFirstName                    string                          `bson:"associate_first_name" json:"associate_first_name,omitempty"`
	AssociateLastName                     string                          `bson:"associate_last_name" json:"associate_last_name,omitempty"`
	AssociateName                         string                          `bson:"associate_name" json:"associate_name,omitempty"`
	AssociateLexicalName                  string                          `bson:"associate_lexical_name" json:"associate_lexical_name,omitempty"`
	AssociateGender                       int8                            `bson:"associate_gender" json:"associate_gender"`
	AssociateGenderOther                  string                          `bson:"associate_gender_other" json:"associate_gender_other"`
	AssociateBirthdate                    time.Time                       `bson:"associate_birthdate" json:"associate_birthdate"`
	AssociateEmail                        string                          `bson:"associate_email" json:"associate_email,omitempty"`
	AssociatePhone                        string                          `bson:"associate_phone" json:"associate_phone,omitempty"`
	AssociatePhoneType                    int8                            `bson:"associate_phone_type" json:"associate_phone_type"`
	AssociatePhoneExtension               string                          `bson:"associate_phone_extension" json:"associate_phone_extension"`
	AssociateOtherPhone                   string                          `bson:"associate_other_phone" json:"associate_other_phone"`
	AssociateOtherPhoneExtension          string                          `bson:"associate_other_phone_extension" json:"associate_other_phone_extension"`
	AssociateOtherPhoneType               int8                            `bson:"associate_other_phone_type" json:"associate_other_phone_type"`
	AssociateFullAddressWithoutPostalCode string                          `bson:"associate_full_address_without_postal_code" json:"associate_full_address_without_postal_code"`
	AssociateFullAddressURL               string                          `bson:"associate_full_address_url" json:"associate_full_address_url"`
	AssociateTags                         []*TaskItemTag                  `bson:"associate_tags" json:"associate_tags,omitempty"` // Related
	AssociateSkillSets                    []*TaskItemSkillSet             `bson:"associate_skill_sets" json:"associate_skill_sets,omitempty"`
	AssociateInsuranceRequirements        []*TaskItemInsuranceRequirement `bson:"associate_insurance_requirements" json:"associate_insurance_requirements,omitempty"`
	AssociateVehicleTypes                 []*TaskItemVehicleType          `bson:"associate_vehicle_types" json:"associate_vehicle_types,omitempty"`
	AssociateTaxID                        string                          `bson:"associate_tax_id" json:"associate_tax_id"`
	AssociateServiceFeeID                 primitive.ObjectID              `bson:"associate_service_fee_id" json:"associate_service_fee_id"`
	AssociateServiceFeeName               string                          `bson:"associate_service_fee_name" json:"associate_service_fee_name"`
	AssociateServiceFeePercentage         float64                         `bson:"associate_service_fee_percentage" json:"associate_service_fee_percentage"`
}

func (*TaskItem) SkillSetIDs

func (t *TaskItem) SkillSetIDs() []primitive.ObjectID

SkillSetIDs is a convinience function which will return an array of skill set ID values from the associate.

type TaskItemAsSelectOption

type TaskItemAsSelectOption struct {
	Value primitive.ObjectID `bson:"_id" json:"value"` // Extract from the database `_id` field and output through API as `value`.
	Label string             `bson:"name" json:"label"`
}

type TaskItemInsuranceRequirement

type TaskItemInsuranceRequirement struct {
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	Name        string             `bson:"name" json:"name"`
	Description string             `bson:"description" json:"description"`
	Status      int8               `bson:"status" json:"status"`
}

type TaskItemListFilter

type TaskItemListFilter struct {
	// Pagination related.
	Cursor    primitive.ObjectID
	PageSize  int64
	SortField string
	SortOrder int8 // 1=ascending | -1=descending

	// Filter related.
	TenantID        primitive.ObjectID
	CustomerID      primitive.ObjectID
	AssociateID     primitive.ObjectID
	OrderID         primitive.ObjectID
	OrderWJID       uint64 // A.K.A. `Workery Job ID`
	Type            int8
	Status          int8
	ExcludeArchived bool
	SearchText      string
	IsClosed        int8
}

type TaskItemListResult

type TaskItemListResult struct {
	Results     []*TaskItem        `json:"results"`
	NextCursor  primitive.ObjectID `json:"next_cursor"`
	HasNextPage bool               `json:"has_next_page"`
}

type TaskItemPaginationListAndCountResult

type TaskItemPaginationListAndCountResult struct {
	Results     []*TaskItem `json:"results"`
	NextCursor  string      `json:"next_cursor"`
	HasNextPage bool        `json:"has_next_page"`
	Count       int64       `json:"count"`
}

TaskItemPaginationListResult represents the paginated list results for the TaskItem records (meaning limited).

type TaskItemPaginationListFilter

type TaskItemPaginationListFilter struct {
	// Pagination related.
	Cursor    string
	PageSize  int64
	SortField string
	SortOrder int8 // 1=ascending | -1=descending

	// Filter related.
	TenantID        primitive.ObjectID
	CustomerID      primitive.ObjectID
	AssociateID     primitive.ObjectID
	OrderID         primitive.ObjectID
	OrderWJID       uint64 // A.K.A. `Workery Job ID`
	Type            int8
	Status          int8
	ExcludeArchived bool
	IsClosed        int8 //0=all, 1=true, 2=false
	SearchText      string

	// InSkillSetIDs filter is used if you want to find one or more skill set
	// ids inside the associate.
	InSkillSetIDs []primitive.ObjectID

	// AllSkillSetIDs filter is used if you want to find all skill set ids for
	// the associate.
	AllSkillSetIDs []primitive.ObjectID
}

type TaskItemPaginationListResult

type TaskItemPaginationListResult struct {
	Results     []*TaskItem `json:"results"`
	NextCursor  string      `json:"next_cursor"`
	HasNextPage bool        `json:"has_next_page"`
}

TaskItemPaginationListResult represents the paginated list results for the task item records (meaning limited).

type TaskItemSkillSet

type TaskItemSkillSet struct {
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	Category    string             `bson:"category" json:"category"`
	SubCategory string             `bson:"sub_category" json:"sub_category"`
	Description string             `bson:"description" json:"description"`
	Status      int8               `bson:"status" json:"status"`
}

type TaskItemStorer

type TaskItemStorer interface {
	Create(ctx context.Context, m *TaskItem) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*TaskItem, error)
	GetByPublicID(ctx context.Context, oldID uint64) (*TaskItem, error)
	GetByEmail(ctx context.Context, email string) (*TaskItem, error)
	GetByVerificationCode(ctx context.Context, verificationCode string) (*TaskItem, error)
	GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*TaskItem, error)
	CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)
	UpdateByID(ctx context.Context, m *TaskItem) error
	ListByFilter(ctx context.Context, f *TaskItemPaginationListFilter) (*TaskItemPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *TaskItemListFilter) ([]*TaskItemAsSelectOption, error)
	ListByCustomerID(ctx context.Context, customerID primitive.ObjectID) (*TaskItemPaginationListResult, error)
	ListByAssociateID(ctx context.Context, associateID primitive.ObjectID) (*TaskItemPaginationListResult, error)
	ListByOrderID(ctx context.Context, orderID primitive.ObjectID) (*TaskItemPaginationListResult, error)
	ListByOrderWJID(ctx context.Context, orderWJID uint64) (*TaskItemPaginationListResult, error)
	CountByFilter(ctx context.Context, f *TaskItemPaginationListFilter) (int64, error)
	ListAndCountByFilter(ctx context.Context, f *TaskItemPaginationListFilter) (*TaskItemPaginationListAndCountResult, error)
	DeleteByID(ctx context.Context, id primitive.ObjectID) error
	PermanentlyDeleteAllByCustomerID(ctx context.Context, customerID primitive.ObjectID) error
	PermanentlyDeleteAllByAssociateID(ctx context.Context, associateID primitive.ObjectID) error
	PermanentlyDeleteAllByOrderID(ctx context.Context, orderID primitive.ObjectID) error
}

TaskItemStorer Interface for user.

func NewDatastore

func NewDatastore(appCfg *c.Conf, loggerp *slog.Logger, client *mongo.Client) TaskItemStorer

type TaskItemStorerImpl

type TaskItemStorerImpl struct {
	Logger     *slog.Logger
	DbClient   *mongo.Client
	Collection *mongo.Collection
}

func (TaskItemStorerImpl) CheckIfExistsByEmail

func (impl TaskItemStorerImpl) CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)

func (TaskItemStorerImpl) CountByFilter

func (TaskItemStorerImpl) Create

func (impl TaskItemStorerImpl) Create(ctx context.Context, u *TaskItem) error

func (TaskItemStorerImpl) DeleteByID

func (impl TaskItemStorerImpl) DeleteByID(ctx context.Context, id primitive.ObjectID) error

func (TaskItemStorerImpl) GetByEmail

func (impl TaskItemStorerImpl) GetByEmail(ctx context.Context, email string) (*TaskItem, error)

func (TaskItemStorerImpl) GetByID

func (TaskItemStorerImpl) GetByPublicID

func (impl TaskItemStorerImpl) GetByPublicID(ctx context.Context, oldID uint64) (*TaskItem, error)

func (TaskItemStorerImpl) GetByVerificationCode

func (impl TaskItemStorerImpl) GetByVerificationCode(ctx context.Context, verificationCode string) (*TaskItem, error)

func (TaskItemStorerImpl) GetLatestByTenantID

func (impl TaskItemStorerImpl) GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*TaskItem, error)

func (TaskItemStorerImpl) ListAsSelectOptionByFilter

func (impl TaskItemStorerImpl) ListAsSelectOptionByFilter(ctx context.Context, f *TaskItemListFilter) ([]*TaskItemAsSelectOption, error)

func (TaskItemStorerImpl) ListByAssociateID

func (impl TaskItemStorerImpl) ListByAssociateID(ctx context.Context, associateID primitive.ObjectID) (*TaskItemPaginationListResult, error)

func (TaskItemStorerImpl) ListByCustomerID

func (impl TaskItemStorerImpl) ListByCustomerID(ctx context.Context, customerID primitive.ObjectID) (*TaskItemPaginationListResult, error)

func (TaskItemStorerImpl) ListByFilter

func (TaskItemStorerImpl) ListByOrderID

func (TaskItemStorerImpl) ListByOrderWJID

func (impl TaskItemStorerImpl) ListByOrderWJID(ctx context.Context, orderWJID uint64) (*TaskItemPaginationListResult, error)

func (*TaskItemStorerImpl) PermanentlyDeleteAllByAssociateID

func (impl *TaskItemStorerImpl) PermanentlyDeleteAllByAssociateID(ctx context.Context, associateID primitive.ObjectID) error

func (*TaskItemStorerImpl) PermanentlyDeleteAllByCustomerID

func (impl *TaskItemStorerImpl) PermanentlyDeleteAllByCustomerID(ctx context.Context, customerID primitive.ObjectID) error

func (*TaskItemStorerImpl) PermanentlyDeleteAllByOrderID

func (impl *TaskItemStorerImpl) PermanentlyDeleteAllByOrderID(ctx context.Context, orderID primitive.ObjectID) error

func (TaskItemStorerImpl) UpdateByID

func (impl TaskItemStorerImpl) UpdateByID(ctx context.Context, m *TaskItem) error

type TaskItemTag

type TaskItemTag struct {
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	Text        string             `bson:"text" json:"text"`
	Description string             `bson:"description" json:"description"`
	Status      int8               `bson:"status" json:"status"`
}

type TaskItemVehicleType

type TaskItemVehicleType struct {
	ID          primitive.ObjectID `bson:"_id" json:"id"`
	Name        string             `bson:"name" json:"name"`
	Description string             `bson:"description" json:"description"`
	Status      int8               `bson:"status" json:"status"`
}

Jump to

Keyboard shortcuts

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