Documentation
¶
Overview ¶
Package comment contains all the required operations to manage comments done in the work items.
Index ¶
- type Comment
- type GormCommentRepository
- func (m *GormCommentRepository) Count(ctx context.Context, parent string) (int, error)
- func (m *GormCommentRepository) Create(ctx context.Context, comment *Comment, creatorID uuid.UUID) error
- func (m *GormCommentRepository) Delete(ctx context.Context, commentID uuid.UUID, suppressorID uuid.UUID) error
- func (m *GormCommentRepository) List(ctx context.Context, parent string, start *int, limit *int) ([]Comment, uint64, error)
- func (m *GormCommentRepository) Load(ctx context.Context, id uuid.UUID) (*Comment, error)
- func (m *GormCommentRepository) Save(ctx context.Context, comment *Comment, modifierID uuid.UUID) error
- func (m *GormCommentRepository) TableName() string
- type GormCommentRevisionRepository
- type Repository
- type Revision
- type RevisionRepository
- type RevisionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct {
gormsupport.Lifecycle
ID uuid.UUID `sql:"type:uuid default uuid_generate_v4()" gorm:"primary_key"` // This is the ID PK field
ParentID string
CreatedBy uuid.UUID `sql:"type:uuid"` // Belongs To Identity
Body string
Markup string
}
Comment describes a single comment
func (Comment) GetETagData ¶
func (m Comment) GetETagData() []interface{}
GetETagData returns the field values to use to generate the ETag
func (Comment) GetLastModified ¶
GetLastModified returns the last modification time
type GormCommentRepository ¶
type GormCommentRepository struct {
// contains filtered or unexported fields
}
GormCommentRepository is the implementation of the storage interface for Comments.
func (*GormCommentRepository) Create ¶
func (m *GormCommentRepository) Create(ctx context.Context, comment *Comment, creatorID uuid.UUID) error
Create creates a new record.
func (*GormCommentRepository) Delete ¶
func (m *GormCommentRepository) Delete(ctx context.Context, commentID uuid.UUID, suppressorID uuid.UUID) error
Delete a single comment
func (*GormCommentRepository) List ¶
func (m *GormCommentRepository) List(ctx context.Context, parent string, start *int, limit *int) ([]Comment, uint64, error)
List all comments related to a single item
func (*GormCommentRepository) Save ¶
func (m *GormCommentRepository) Save(ctx context.Context, comment *Comment, modifierID uuid.UUID) error
Save a single comment
func (*GormCommentRepository) TableName ¶
func (m *GormCommentRepository) TableName() string
TableName overrides the table name settings in Gorm to force a specific table name in the database.
type GormCommentRevisionRepository ¶
type GormCommentRevisionRepository struct {
// contains filtered or unexported fields
}
GormCommentRevisionRepository implements CommentRevisionRepository using gorm
func NewRevisionRepository ¶
func NewRevisionRepository(db *gorm.DB) *GormCommentRevisionRepository
NewRevisionRepository creates a GormCommentRevisionRepository
func (*GormCommentRevisionRepository) Create ¶
func (r *GormCommentRevisionRepository) Create(ctx context.Context, modifierID uuid.UUID, revisionType RevisionType, c Comment) error
Create stores a new revision for the given comment.
type Repository ¶
type Repository interface {
Create(ctx context.Context, comment *Comment, creator uuid.UUID) error
Save(ctx context.Context, comment *Comment, modifier uuid.UUID) error
Delete(ctx context.Context, commentID uuid.UUID, suppressor uuid.UUID) error
List(ctx context.Context, parent string, start *int, limit *int) ([]Comment, uint64, error)
Load(ctx context.Context, id uuid.UUID) (*Comment, error)
Count(ctx context.Context, parent string) (int, error)
}
Repository describes interactions with comments
func NewRepository ¶
func NewRepository(db *gorm.DB) Repository
NewRepository creates a new storage type.
type Revision ¶
type Revision struct {
ID uuid.UUID `gorm:"primary_key"`
// the timestamp of the modification
Time time.Time `gorm:"column:revision_time"`
// the type of modification
Type RevisionType `gorm:"column:revision_type"`
// the identity of author of the comment modification
ModifierIdentity uuid.UUID `sql:"type:uuid" gorm:"column:modifier_id"`
// the id of the comment that changed
CommentID uuid.UUID `gorm:"column:comment_id"`
// the id of the parent of the comment that changed
CommentParentID string `gorm:"column:comment_parent_id"`
// the body of the comment (nil when comment was deleted)
CommentBody *string `gorm:"column:comment_body"`
// the markup used to input the comment body (nil when comment was deleted)
CommentMarkup *string `gorm:"column:comment_markup"`
}
Revision represents a version of a comment
type RevisionRepository ¶
type RevisionRepository interface {
// Create stores a new revision for the given comment.
Create(ctx context.Context, modifierID uuid.UUID, revisionType RevisionType, comment Comment) error
// List retrieves all revisions for a given comment
List(ctx context.Context, workitemID uuid.UUID) ([]Revision, error)
}
RevisionRepository encapsulates storage & retrieval of historical versions of comments
type RevisionType ¶
type RevisionType int
RevisionType defines the type of revision for a comment
const ( // RevisionTypeCreate a comment creation RevisionTypeCreate RevisionType // 1 // RevisionTypeDelete a comment deletion RevisionTypeDelete // 2 // RevisionTypeUpdate a comment update RevisionTypeUpdate // 4 )