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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommentStatusActive   = 1
	CommentStatusArchived = 2
	BelongsToCustomer     = 1
	BelongsToAssociate    = 2
	BelongsToOrder        = 3
	BelongsToStaff        = 4
)
View Source
const (
	OrderAscending  = 1
	OrderDescending = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID                    primitive.ObjectID `bson:"_id" json:"id"`
	BelongsTo             int8               `bson:"belongs_to" json:"belongs_to"`
	CustomerID            primitive.ObjectID `bson:"customer_id" json:"customer_id,omitempty"`
	CustomerName          string             `bson:"customer_name" json:"customer_name"`
	AssociateID           primitive.ObjectID `bson:"associate_id" json:"associate_id,omitempty"`
	AssociateName         string             `bson:"associate_name" json:"associate_name"`
	OrderID               primitive.ObjectID `bson:"order_id" json:"order_id,omitempty"`
	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`.
	OrderIncidentID       primitive.ObjectID `bson:"order_incident_id" json:"order_incident_id,omitempty"`
	OrderIncidentPublicID uint64             `bson:"order_incident_public_id" json:"order_incident_public_id"`
	StaffID               primitive.ObjectID `bson:"staff_id" json:"staff_id,omitempty"`
	StaffName             string             `bson:"staff_name" json:"staff_name"`
	TenantID              primitive.ObjectID `bson:"tenant_id" json:"tenant_id,omitempty"`
	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"`
	Content               string             `bson:"content" json:"content"`
	Status                int8               `bson:"status" json:"status"`
	PublicID              uint64             `bson:"public_id" json:"public_id"`
}

type CommentAsSelectOption

type CommentAsSelectOption 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 CommentPaginationListFilter

type CommentPaginationListFilter 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
	StaffID         primitive.ObjectID
	Status          int8
	ExcludeArchived bool
	SearchText      string
	BelongsTo       int8
}

type CommentPaginationListResult

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

CommentPaginationListResult represents the paginated list results for the associate records.

type CommentStorer

type CommentStorer interface {
	Create(ctx context.Context, m *Comment) error
	GetByID(ctx context.Context, id primitive.ObjectID) (*Comment, error)
	GetByPublicID(ctx context.Context, oldID uint64) (*Comment, error)
	GetByEmail(ctx context.Context, email string) (*Comment, error)
	GetByVerificationCode(ctx context.Context, verificationCode string) (*Comment, error)
	GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*Comment, error)
	CheckIfExistsByEmail(ctx context.Context, email string) (bool, error)
	UpdateByID(ctx context.Context, m *Comment) error
	ListByFilter(ctx context.Context, f *CommentPaginationListFilter) (*CommentPaginationListResult, error)
	ListByOrderID(ctx context.Context, orderID primitive.ObjectID) (*CommentPaginationListResult, error)
	ListByOrderWJID(ctx context.Context, orderWJID uint64) (*CommentPaginationListResult, error)
	ListAsSelectOptionByFilter(ctx context.Context, f *CommentPaginationListFilter) ([]*CommentAsSelectOption, 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
	PermanentlyDeleteAllByStaffID(ctx context.Context, staffID primitive.ObjectID) error
	PermanentlyDeleteAllByOrderID(ctx context.Context, orderID primitive.ObjectID) error
}

CommentStorer Interface for user.

func NewDatastore

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

type CommentStorerImpl

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

func (CommentStorerImpl) CheckIfExistsByEmail

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

func (CommentStorerImpl) Create

func (impl CommentStorerImpl) Create(ctx context.Context, u *Comment) error

func (CommentStorerImpl) DeleteByID

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

func (CommentStorerImpl) GetByEmail

func (impl CommentStorerImpl) GetByEmail(ctx context.Context, email string) (*Comment, error)

func (CommentStorerImpl) GetByID

func (impl CommentStorerImpl) GetByID(ctx context.Context, id primitive.ObjectID) (*Comment, error)

func (CommentStorerImpl) GetByPublicID

func (impl CommentStorerImpl) GetByPublicID(ctx context.Context, oldID uint64) (*Comment, error)

func (CommentStorerImpl) GetByVerificationCode

func (impl CommentStorerImpl) GetByVerificationCode(ctx context.Context, verificationCode string) (*Comment, error)

func (CommentStorerImpl) GetLatestByTenantID

func (impl CommentStorerImpl) GetLatestByTenantID(ctx context.Context, tenantID primitive.ObjectID) (*Comment, error)

func (CommentStorerImpl) ListAsSelectOptionByFilter

func (impl CommentStorerImpl) ListAsSelectOptionByFilter(ctx context.Context, f *CommentPaginationListFilter) ([]*CommentAsSelectOption, error)

func (CommentStorerImpl) ListByFilter

func (CommentStorerImpl) ListByOrderID

func (CommentStorerImpl) ListByOrderWJID

func (impl CommentStorerImpl) ListByOrderWJID(ctx context.Context, orderWJID uint64) (*CommentPaginationListResult, error)

func (*CommentStorerImpl) PermanentlyDeleteAllByAssociateID

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

func (*CommentStorerImpl) PermanentlyDeleteAllByCustomerID

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

func (*CommentStorerImpl) PermanentlyDeleteAllByOrderID

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

func (*CommentStorerImpl) PermanentlyDeleteAllByStaffID

func (impl *CommentStorerImpl) PermanentlyDeleteAllByStaffID(ctx context.Context, staffID primitive.ObjectID) error

func (CommentStorerImpl) UpdateByID

func (impl CommentStorerImpl) UpdateByID(ctx context.Context, m *Comment) error

Jump to

Keyboard shortcuts

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