publish

package
v0.0.0-...-73c3907 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublishContextKeyPageBuilder  = "pagebuilder"
	PublishContextKeyL10nBuilder  = "l10nbuilder"
	PublishContextKeyEventContext = "eventcontext"
)
View Source
const (
	StatusDraft   = "draft"
	StatusOnline  = "online"
	StatusOffline = "offline"
)

Variables

View Source
var ListPublishModels map[string]interface{}
View Source
var NonVersionPublishModels map[string]interface{}
View Source
var VersionPublishModels map[string]interface{}

Functions

func IsVersion

func IsVersion(obj interface{}) (IsVersion bool)

func SetPrimaryKeysConditionWithoutVersion

func SetPrimaryKeysConditionWithoutVersion(db *gorm.DB, record interface{}, s *schema.Schema) *gorm.DB

func UploadOrDelete

func UploadOrDelete(objs []*PublishAction, storage oss.StorageInterface) (err error)

Types

type AfterPublishInterface

type AfterPublishInterface interface {
	AfterPublish(db *gorm.DB, storage oss.StorageInterface, ctx context.Context) error
}

type AfterUnPublishInterface

type AfterUnPublishInterface interface {
	AfterUnPublish(db *gorm.DB, storage oss.StorageInterface, ctx context.Context) error
}

type Builder

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

func New

func New(db *gorm.DB, storage oss.StorageInterface) *Builder

func (*Builder) Context

func (b *Builder) Context() context.Context

func (*Builder) Publish

func (b *Builder) Publish(record interface{}) (err error)

幂等

func (*Builder) Sync

func (b *Builder) Sync(models ...interface{}) error

func (*Builder) UnPublish

func (b *Builder) UnPublish(record interface{}) (err error)

func (*Builder) WithEventContext

func (b *Builder) WithEventContext(val interface{}) *Builder

func (*Builder) WithL10nBuilder

func (b *Builder) WithL10nBuilder(val interface{}) *Builder

func (*Builder) WithPageBuilder

func (b *Builder) WithPageBuilder(val interface{}) *Builder

func (*Builder) WithValue

func (b *Builder) WithValue(key, val interface{}) *Builder

type List

type List struct {
	PageNumber  int
	Position    int
	ListDeleted bool
	ListUpdated bool
}

func (List) GetListDeleted

func (this List) GetListDeleted() bool

func (List) GetListUpdated

func (this List) GetListUpdated() bool

func (List) GetPageNumber

func (this List) GetPageNumber() int

func (List) GetPosition

func (this List) GetPosition() int

func (*List) SetListDeleted

func (this *List) SetListDeleted(listDeleted bool)

func (*List) SetListUpdated

func (this *List) SetListUpdated(listUpdated bool)

func (*List) SetPageNumber

func (this *List) SetPageNumber(pageNumber int)

func (*List) SetPosition

func (this *List) SetPosition(position int)

type ListInterface

type ListInterface interface {
	GetPageNumber() int
	SetPageNumber(pageNumber int)
	GetPosition() int
	SetPosition(position int)
	GetListDeleted() bool
	SetListDeleted(listDeleted bool)
	GetListUpdated() bool
	SetListUpdated(listUpdated bool)
}

type ListPublishBuilder

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

func NewListPublishBuilder

func NewListPublishBuilder(db *gorm.DB, storage oss.StorageInterface) *ListPublishBuilder

func (*ListPublishBuilder) GetOldItemsFunc

func (b *ListPublishBuilder) GetOldItemsFunc(f func(record interface{}) (result []interface{}, err error)) *ListPublishBuilder

func (*ListPublishBuilder) NeedNextPageFunc

func (b *ListPublishBuilder) NeedNextPageFunc(f func(totalNumberPerPage, currentPageNumber, totalNumberOfItems int) bool) *ListPublishBuilder

func (*ListPublishBuilder) PublishActionsFunc

func (b *ListPublishBuilder) PublishActionsFunc(f func(db *gorm.DB, lp ListPublisher, result []*OnePageItems, indexPage *OnePageItems) (objs []*PublishAction)) *ListPublishBuilder

func (*ListPublishBuilder) Run

func (b *ListPublishBuilder) Run(model interface{}) (err error)

model is a empty struct example: Product{}

func (*ListPublishBuilder) TotalNumberPerPage

func (b *ListPublishBuilder) TotalNumberPerPage(number int) *ListPublishBuilder

func (*ListPublishBuilder) WithValue

func (b *ListPublishBuilder) WithValue(key, val interface{}) *ListPublishBuilder

type ListPublisher

type ListPublisher interface {
	GetListUrl(pageNumber string) string
	GetListContent(db *gorm.DB, onePageItems *OnePageItems) string
	Sort(array []interface{})
}

type OnePageItems

type OnePageItems struct {
	Items      []interface{}
	PageNumber int
}

type PublishAction

type PublishAction struct {
	Url      string
	Content  string
	IsDelete bool
}

type PublishInterface

type PublishInterface interface {
	GetPublishActions(db *gorm.DB, ctx context.Context, storage oss.StorageInterface) (actions []*PublishAction, err error)
}

type Schedule

type Schedule struct {
	ScheduledStartAt *time.Time `gorm:"index"`
	ScheduledEndAt   *time.Time `gorm:"index"`

	ActualStartAt *time.Time
	ActualEndAt   *time.Time
}

func (Schedule) GetPublishedAt

func (schedule Schedule) GetPublishedAt() *time.Time

func (Schedule) GetScheduledEndAt

func (schedule Schedule) GetScheduledEndAt() *time.Time

func (Schedule) GetScheduledStartAt

func (schedule Schedule) GetScheduledStartAt() *time.Time

func (Schedule) GetUnPublishedAt

func (schedule Schedule) GetUnPublishedAt() *time.Time

func (*Schedule) SetPublishedAt

func (schedule *Schedule) SetPublishedAt(v *time.Time)

func (*Schedule) SetScheduledEndAt

func (schedule *Schedule) SetScheduledEndAt(v *time.Time)

func (*Schedule) SetScheduledStartAt

func (schedule *Schedule) SetScheduledStartAt(v *time.Time)

func (*Schedule) SetUnPublishedAt

func (schedule *Schedule) SetUnPublishedAt(v *time.Time)

type ScheduleInterface

type ScheduleInterface interface {
	GetStatus() string

	GetScheduledStartAt() *time.Time
	GetScheduledEndAt() *time.Time
	SetScheduledStartAt(v *time.Time)
	SetScheduledEndAt(v *time.Time)

	GetPublishedAt() *time.Time
	GetUnPublishedAt() *time.Time
	SetPublishedAt(v *time.Time)
	SetUnPublishedAt(v *time.Time)
}

type SchedulePublishBuilder

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

func NewSchedulePublishBuilder

func NewSchedulePublishBuilder(publisher *Builder) *SchedulePublishBuilder

func (*SchedulePublishBuilder) Run

func (b *SchedulePublishBuilder) Run(model interface{}) (err error)

model is a empty struct example: Product{}

func (*SchedulePublishBuilder) WithValue

func (b *SchedulePublishBuilder) WithValue(key, val interface{}) *SchedulePublishBuilder

type SchedulePublisher

type SchedulePublisher interface {
	SchedulePublisherDBScope(db *gorm.DB) *gorm.DB
}

type Status

type Status struct {
	Status    string `gorm:"default:'draft'"`
	OnlineUrl string
}

func (Status) GetOnlineUrl

func (status Status) GetOnlineUrl() string

func (Status) GetStatus

func (status Status) GetStatus() string

func (*Status) SetOnlineUrl

func (status *Status) SetOnlineUrl(onlineUrl string)

func (*Status) SetStatus

func (status *Status) SetStatus(s string)

type StatusInterface

type StatusInterface interface {
	GetStatus() string
	SetStatus(s string)
	GetOnlineUrl() string
	SetOnlineUrl(s string)
}

type UnPublishInterface

type UnPublishInterface interface {
	GetUnPublishActions(db *gorm.DB, ctx context.Context, storage oss.StorageInterface) (actions []*PublishAction, err error)
}

type Version

type Version struct {
	Version       string `gorm:"primary_key;size:128"`
	VersionName   string
	ParentVersion string
	OnlineVersion bool `gorm:"index;default:false"`
}

func (*Version) CreateVersion

func (version *Version) CreateVersion(db *gorm.DB, paramID string, obj interface{}) (string, error)

func (Version) GetVersion

func (version Version) GetVersion() string

func (Version) GetVersionName

func (version Version) GetVersionName() string

func (*Version) SetVersion

func (version *Version) SetVersion(v string)

func (*Version) SetVersionName

func (version *Version) SetVersionName(v string)

type VersionInterface

type VersionInterface interface {
	GetVersion() string
	SetVersion(v string)
	GetVersionName() string
	SetVersionName(v string)
	CreateVersion(db *gorm.DB, paramID string, obj interface{}) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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