table

package
v1.2.25 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPrimaryKeyName = "id"
	DefaultConnectionName = "default"
)

Variables

This section is empty.

Functions

func SetServices

func SetServices(srv service.List)

Types

type BaseTable

type BaseTable struct {
	Info           *types.InfoPanel
	Form           *types.FormPanel
	NewForm        *types.FormPanel
	Detail         *types.InfoPanel
	CanAdd         bool
	Editable       bool
	Deletable      bool
	Exportable     bool
	OnlyInfo       bool
	OnlyDetail     bool
	OnlyNewForm    bool
	OnlyUpdateForm bool
	PrimaryKey     PrimaryKey
}

func (*BaseTable) GetActualNewForm

func (base *BaseTable) GetActualNewForm() *types.FormPanel

func (*BaseTable) GetCanAdd

func (base *BaseTable) GetCanAdd() bool

func (*BaseTable) GetDeletable

func (base *BaseTable) GetDeletable() bool

func (*BaseTable) GetDetail

func (base *BaseTable) GetDetail() *types.InfoPanel

func (*BaseTable) GetDetailFromInfo

func (base *BaseTable) GetDetailFromInfo() *types.InfoPanel

func (*BaseTable) GetEditable

func (base *BaseTable) GetEditable() bool

func (*BaseTable) GetExportable

func (base *BaseTable) GetExportable() bool

func (*BaseTable) GetForm

func (base *BaseTable) GetForm() *types.FormPanel

func (*BaseTable) GetInfo

func (base *BaseTable) GetInfo() *types.InfoPanel

func (*BaseTable) GetNewForm

func (base *BaseTable) GetNewForm() *types.FormPanel

func (*BaseTable) GetOnlyDetail

func (base *BaseTable) GetOnlyDetail() bool

func (*BaseTable) GetOnlyInfo

func (base *BaseTable) GetOnlyInfo() bool

func (*BaseTable) GetOnlyNewForm

func (base *BaseTable) GetOnlyNewForm() bool

func (*BaseTable) GetOnlyUpdateForm

func (base *BaseTable) GetOnlyUpdateForm() bool

func (*BaseTable) GetPaginator

func (base *BaseTable) GetPaginator(size int, params parameter.Parameters, extraHtml ...template.HTML) types.PaginatorAttribute

func (*BaseTable) GetPrimaryKey

func (base *BaseTable) GetPrimaryKey() PrimaryKey

type Columns

type Columns []string

type Config

type Config struct {
	Driver         string
	DriverMode     string
	Connection     string
	CanAdd         bool
	Editable       bool
	Deletable      bool
	Exportable     bool
	PrimaryKey     PrimaryKey
	SourceURL      string
	GetDataFun     GetDataFun
	OnlyInfo       bool
	OnlyNewForm    bool
	OnlyUpdateForm bool
	OnlyDetail     bool
}

func DefaultConfig

func DefaultConfig() Config

func DefaultConfigWithDriver

func DefaultConfigWithDriver(driver string) Config

func DefaultConfigWithDriverAndConnection

func DefaultConfigWithDriverAndConnection(driver, conn string) Config

func (Config) SetCanAdd

func (config Config) SetCanAdd(canAdd bool) Config

func (Config) SetConnection

func (config Config) SetConnection(connection string) Config

func (Config) SetDeletable

func (config Config) SetDeletable(deletable bool) Config

func (Config) SetDriverMode

func (config Config) SetDriverMode(mode string) Config

func (Config) SetEditable

func (config Config) SetEditable(editable bool) Config

func (Config) SetExportable

func (config Config) SetExportable(exportable bool) Config

func (Config) SetGetDataFun

func (config Config) SetGetDataFun(fun GetDataFun) Config

func (Config) SetOnlyDetail

func (config Config) SetOnlyDetail() Config

func (Config) SetOnlyInfo

func (config Config) SetOnlyInfo() Config

func (Config) SetOnlyNewForm

func (config Config) SetOnlyNewForm() Config

func (Config) SetOnlyUpdateForm

func (config Config) SetOnlyUpdateForm() Config

func (Config) SetPrimaryKey

func (config Config) SetPrimaryKey(name string, typ db.DatabaseType) Config

func (Config) SetPrimaryKeyType

func (config Config) SetPrimaryKeyType(typ string) Config

func (Config) SetSourceURL

func (config Config) SetSourceURL(url string) Config

type DefaultTable

type DefaultTable struct {
	*BaseTable
	// contains filtered or unexported fields
}

DefaultTable is an implementation of table.Table

func (*DefaultTable) Copy

func (tb *DefaultTable) Copy() Table

Copy copy a new table.Table from origin DefaultTable

func (*DefaultTable) DeleteData

func (tb *DefaultTable) DeleteData(id string) error

DeleteData delete data.

func (*DefaultTable) GetData

func (tb *DefaultTable) GetData(params parameter.Parameters) (PanelInfo, error)

GetData query the data set.

func (*DefaultTable) GetDataWithId

func (tb *DefaultTable) GetDataWithId(param parameter.Parameters) (FormInfo, error)

GetDataWithId query the single row of data.

func (*DefaultTable) GetDataWithIds

func (tb *DefaultTable) GetDataWithIds(params parameter.Parameters) (PanelInfo, error)

GetDataWithIds query the data set.

func (*DefaultTable) GetNewFormInfo

func (tb *DefaultTable) GetNewFormInfo() FormInfo

func (*DefaultTable) InsertData

func (tb *DefaultTable) InsertData(dataList form.Values) error

InsertData insert data.

func (*DefaultTable) PreProcessValue

func (tb *DefaultTable) PreProcessValue(dataList form.Values, typ types.PostType) form.Values

func (*DefaultTable) UpdateData

func (tb *DefaultTable) UpdateData(dataList form.Values) error

UpdateData update data.

type FormInfo

type FormInfo struct {
	FieldList         types.FormFields        `json:"field_list"`
	GroupFieldList    types.GroupFormFields   `json:"group_field_list"`
	GroupFieldHeaders types.GroupFieldHeaders `json:"group_field_headers"`
	Title             string                  `json:"title"`
	Description       string                  `json:"description"`
}

type Generator

type Generator func(ctx *context.Context) Table

type GeneratorList

type GeneratorList map[string]Generator

func (GeneratorList) Add

func (g GeneratorList) Add(key string, gen Generator)

func (GeneratorList) Combine

func (g GeneratorList) Combine(list GeneratorList) GeneratorList

func (GeneratorList) CombineAll

func (g GeneratorList) CombineAll(gens []GeneratorList) GeneratorList

type GetDataFromURLRes

type GetDataFromURLRes struct {
	Data []map[string]interface{}
	Size int
}

type GetDataFun

type GetDataFun func(params parameter.Parameters) ([]map[string]interface{}, int)

type PanelInfo

type PanelInfo struct {
	Thead          types.Thead              `json:"thead"`
	InfoList       types.InfoList           `json:"info_list"`
	FilterFormData types.FormFields         `json:"filter_form_data"`
	Paginator      types.PaginatorAttribute `json:"-"`
	Title          string                   `json:"title"`
	Description    string                   `json:"description"`
}

type PrimaryKey

type PrimaryKey struct {
	Type db.DatabaseType
	Name string
}

type SystemTable

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

func NewSystemTable

func NewSystemTable(conn db.Connection, c *config.Config) *SystemTable

func (*SystemTable) GetGenerateForm

func (s *SystemTable) GetGenerateForm(ctx *context.Context) (generateTool Table)

func (*SystemTable) GetManagerTable

func (s *SystemTable) GetManagerTable(ctx *context.Context) (managerTable Table)

func (*SystemTable) GetMenuTable

func (s *SystemTable) GetMenuTable(ctx *context.Context) (menuTable Table)

func (*SystemTable) GetNormalManagerTable

func (s *SystemTable) GetNormalManagerTable(ctx *context.Context) (managerTable Table)

func (*SystemTable) GetOpTable

func (s *SystemTable) GetOpTable(ctx *context.Context) (opTable Table)

func (*SystemTable) GetPermissionTable

func (s *SystemTable) GetPermissionTable(ctx *context.Context) (permissionTable Table)

func (*SystemTable) GetRolesTable

func (s *SystemTable) GetRolesTable(ctx *context.Context) (roleTable Table)

func (*SystemTable) GetSiteTable

func (s *SystemTable) GetSiteTable(ctx *context.Context) (siteTable Table)

type Table

type Table interface {
	GetInfo() *types.InfoPanel
	GetDetail() *types.InfoPanel
	GetDetailFromInfo() *types.InfoPanel
	GetForm() *types.FormPanel
	GetNewForm() *types.FormPanel
	GetActualNewForm() *types.FormPanel

	GetCanAdd() bool
	GetEditable() bool
	GetDeletable() bool
	GetExportable() bool

	GetPrimaryKey() PrimaryKey

	GetData(params parameter.Parameters) (PanelInfo, error)
	GetDataWithIds(params parameter.Parameters) (PanelInfo, error)
	GetDataWithId(params parameter.Parameters) (FormInfo, error)
	UpdateData(dataList form.Values) error
	InsertData(dataList form.Values) error
	DeleteData(pk string) error

	GetNewFormInfo() FormInfo

	GetOnlyInfo() bool
	GetOnlyDetail() bool
	GetOnlyNewForm() bool
	GetOnlyUpdateForm() bool

	Copy() Table
}

func NewDefaultTable

func NewDefaultTable(cfgs ...Config) Table

Jump to

Keyboard shortcuts

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