fileupdater

package
v0.3.20 Latest Latest
Warning

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

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

Documentation

Overview

Package fileupdater 编辑内容时更新相关引用文件的关联关系 用法:fileupdater.New(fileModel.NewEmbedded(ctx)).Set(`表名称`,`字段名称`,主键ID).Add(`/test/image.jpg`,false)

Index

Constants

This section is empty.

Variables

View Source
var Debug = false

Functions

func GenUpdater

func GenUpdater(m factory.Model, cond db.Compound, otherFieldAndValues ...FieldValue) func(field string, content string) error

GenUpdater 生成Updater

Types

type CallbackFunc

type CallbackFunc func(m factory.Model) (tableID string, content string, property *Property)

func GenCallbackDefault

func GenCallbackDefault(fieldName string, fieldValues ...FieldValue) CallbackFunc

func GenCallbackWithCond

func GenCallbackWithCond(cond db.Compound, fieldValues ...FieldValue) CallbackFunc

func (CallbackFunc) AsWithEvent

func (c CallbackFunc) AsWithEvent(m factory.Model, _ string) (string, string, *Property)

type CallbackFuncWithEvent

type CallbackFuncWithEvent func(m factory.Model, event string) (tableID string, content string, property *Property)

type FieldValue

type FieldValue map[string]ValueFunc

func FieldValueWith

func FieldValueWith(field string, value ValueFunc) FieldValue

func (FieldValue) Delete

func (f FieldValue) Delete(fields ...string) FieldValue

func (FieldValue) Set

func (f FieldValue) Set(field string, value ValueFunc) FieldValue

type FileUpdater

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

func New

func New(reler Reler) *FileUpdater

func (*FileUpdater) Add

func (f *FileUpdater) Add(content *string, embedded bool) (err error)

func (*FileUpdater) Delete

func (f *FileUpdater) Delete() (err error)

func (*FileUpdater) Edit

func (f *FileUpdater) Edit(content *string, embedded bool) (err error)

func (*FileUpdater) Handle

func (f *FileUpdater) Handle(event string, content *string, embedded bool) error

func (*FileUpdater) Set

func (f *FileUpdater) Set(table string, field string, tableID string) *FileUpdater

func (*FileUpdater) SetField

func (f *FileUpdater) SetField(field string) *FileUpdater

func (*FileUpdater) SetProject

func (f *FileUpdater) SetProject(project string) *FileUpdater

func (*FileUpdater) SetSeperator

func (f *FileUpdater) SetSeperator(seperator string) *FileUpdater

func (*FileUpdater) SetTable

func (f *FileUpdater) SetTable(table string) *FileUpdater

func (*FileUpdater) SetTableID

func (f *FileUpdater) SetTableID(tableID string) *FileUpdater

type Listener

type Listener interface {
	SetTableName(table string) Listener
	Listen()
	ListenByOptions(fieldName string, setters ...OptionSetter)
	Add(fieldName string, setters ...OptionSetter) Listener
	BuildOptions(fieldName string, setters ...OptionSetter) *Options
	Delete(fieldNames ...string) Listener
}

type OptionSetter

type OptionSetter func(o *Options)

func OptCallback

func OptCallback(callbackFunc CallbackFunc) OptionSetter

func OptEmbedded

func OptEmbedded(embedded bool) OptionSetter

func OptFieldName

func OptFieldName(fieldName string) OptionSetter

func OptFieldValue

func OptFieldValue(field string, value ValueFunc) OptionSetter

func OptGenCallback

func OptGenCallback(cond db.Compound, fieldValues ...FieldValue) OptionSetter

func OptSameFields

func OptSameFields(sameFields ...string) OptionSetter

func OptSeperator

func OptSeperator(seperator string) OptionSetter

func OptTableName

func OptTableName(tableName string) OptionSetter

type Options

type Options struct {
	TableName  string                // 数据表名称
	FieldName  string                // 数据表字段名
	SameFields []string              // 数据表类似字段名
	Embedded   bool                  // 是否为嵌入图片
	Seperator  string                // 文件字段中多个文件路径之间的分隔符,空字符串代表为单个文件
	Callback   CallbackFuncWithEvent `json:"-" xml:"-"`
	FieldValue FieldValue            `json:"-" xml:"-"`
}

type Property

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

Property 附加属性

func NewProperty

func NewProperty() *Property

func NewPropertyWith

func NewPropertyWith(m factory.Model, cond db.Compound, otherFieldAndValues ...FieldValue) *Property

NewPropertyWith 创建并生成带默认Updater的实例

func (*Property) Embedded

func (pro *Property) Embedded() sql.NullBool

func (*Property) Exit

func (pro *Property) Exit() bool

func (*Property) GenUpdater

func (pro *Property) GenUpdater(m factory.Model, cond db.Compound, otherFieldAndValues ...FieldValue) *Property

func (*Property) Seperator

func (pro *Property) Seperator() sql.NullString

func (*Property) SetEmbedded

func (pro *Property) SetEmbedded(on bool) *Property

func (*Property) SetExit

func (pro *Property) SetExit(exit bool) *Property

func (*Property) SetSeperator

func (pro *Property) SetSeperator(sep string) *Property

func (*Property) SetUpdater

func (pro *Property) SetUpdater(updater func(field string, content string) error) *Property

func (*Property) Updater

func (pro *Property) Updater() func(field string, content string) error

type Reler

type Reler interface {
	RelationFiles(project string, table string, field string, tableID string, content string, seperator ...string) error
	RelationEmbeddedFiles(project string, table string, field string, tableID string, content string) error
	DeleteByTableID(project string, table string, tableID string) error
	FileIDs() []uint64
	ReplacedViewURLs() map[string]string
	Context() echo.Context
}

type ValueFunc

type ValueFunc func(fieldName string, fieldValue string) interface{}

func ThumbValue

func ThumbValue(width int, height int) ValueFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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