models

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Model

	TicketID int64
	Owner    string
	Content  string
	Metadata string
}

Comment is the entity model of comments table.

type CommentRepository

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

CommentRepository is the repository implementation of Comment model.

func NewCommentRepository

func NewCommentRepository(logger *zap.SugaredLogger, db *pgxpool.Pool) *CommentRepository

NewCommentRepository returns back a newly created and ready to use CommentRepository.

func (*CommentRepository) DeleteByID

func (r *CommentRepository) DeleteByID(ctx context.Context, id int64) *errors.Type

DeleteByID tries to delete a comment from comments table.

func (*CommentRepository) Insert

func (r *CommentRepository) Insert(ctx context.Context, comment Comment) *errors.Type

Insert tries to insert a comment into comments table.

func (*CommentRepository) LoadByID

func (r *CommentRepository) LoadByID(ctx context.Context, id int64) (*Comment, *errors.Type)

LoadByID tries to load a comment from comments table.

func (*CommentRepository) Update

func (r *CommentRepository) Update(ctx context.Context, comment *Comment) *errors.Type

Update tries to update a comment record.

type Model

type Model struct {
	ID         int64
	CreatedAt  time.Time
	ModifiedAt time.Time
}

Model is a basic database model abstraction that only includes required columns for all models.

type Ticket

type Ticket struct {
	Model

	Issuer          string
	Owner           string
	Subject         string
	Content         string
	Metadata        string
	ImportanceLevel TicketImportanceLevel
	Status          TicketStatus
	Comments        []*Comment
}

Ticket is the entity model of tickets table.

type TicketImportanceLevel

type TicketImportanceLevel string

TicketImportanceLevel model.

const (
	TicketImportanceLevelLow      TicketImportanceLevel = "LOW"
	TicketImportanceLevelMedium   TicketImportanceLevel = "MEDIUM"
	TicketImportanceLevelHigh     TicketImportanceLevel = "HIGH"
	TicketImportanceLevelCritical TicketImportanceLevel = "CRITICAL"
)

Different importance level instances.

type TicketRepository

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

TicketRepository is the repository implementation of Ticket model.

func NewTicketRepository

func NewTicketRepository(logger *zap.SugaredLogger, db *pgxpool.Pool) *TicketRepository

NewTicketRepository returns back a newly created and ready to use TicketRepository.

func (*TicketRepository) DeleteByID

func (r *TicketRepository) DeleteByID(ctx context.Context, id int64) *errors.Type

DeleteByID tries to delete a ticket and all of its comments.

func (*TicketRepository) Filter

func (r *TicketRepository) Filter(ctx context.Context, issuer, owner string, importanceLevel TicketImportanceLevel,
	status TicketStatus, fromDate, toDate string, pageNumber, pageSize int) ([]*Ticket, bool, *errors.Type)

Filter tries to filter tickets. If there is another page of result when loading tickets, the second returned value will be true, otherwise false.

func (*TicketRepository) Insert

func (r *TicketRepository) Insert(ctx context.Context, ticket Ticket) *errors.Type

Insert tries to insert a ticket into tickets table.

func (*TicketRepository) LoadByID

func (r *TicketRepository) LoadByID(ctx context.Context, id int64) (*Ticket, *errors.Type)

LoadByID tries to load a ticket and its comments from tickets table.

func (*TicketRepository) Update

func (r *TicketRepository) Update(ctx context.Context, ticket *Ticket) *errors.Type

Update tries to update a ticket record.

type TicketStatus

type TicketStatus string

TicketStatus model.

const (
	TicketStatusNew      TicketStatus = "NEW"
	TicketStatusReplied  TicketStatus = "REPLIED"
	TicketStatusResolved TicketStatus = "RESOLVED"
	TicketStatusClosed   TicketStatus = "CLOSED"
	TicketStatusBlocked  TicketStatus = "BLOCKED"
)

Different ticket status instances.

Jump to

Keyboard shortcuts

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