model

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NamingStrategy schema.NamingStrategy

Functions

func AutoMigrate

func AutoMigrate()

AutoMigrate 自动生成表

func CamelName

func CamelName(name string) string

func CamelName2

func CamelName2(name string) string

func ConvertGoType

func ConvertGoType(f *MetadataField) string

func ConvertTSType

func ConvertTSType(f *MetadataField) string

func Copy

func Copy(pageName string, id string) error

func CopyMetadata

func CopyMetadata(id string) error

func CopyPage

func CopyPage(id string) error

func Create

func Create(pageName string, m map[string]interface{}) error

func CreateMetadata

func CreateMetadata(md *Metadata) error

func CreatePage

func CreatePage(m *Page) error

func Delete

func Delete(pageName string, id string) (err error)

func DeleteMetadata

func DeleteMetadata(id string) (err error)

func DeletePage

func DeletePage(id string) (err error)

func Enable

func Enable(pageName string, id string, enable bool) error

func EnablePage

func EnablePage(id string, enable bool) error

func GetAll

func GetAll(pageName string) (list []map[string]interface{}, err error)

func GetChildrenList added in v1.0.1

func GetChildrenList(location map[string]interface{}, treeMap map[string][]map[string]interface{}) (err error)

func GetDetailById

func GetDetailById(pageName string, id string) (data map[string]interface{}, err error)

func GetDetailByName

func GetDetailByName(pageName, name string) (map[string]interface{}, error)

func GetTree

func GetTree(pageName string) (list []map[string]interface{}, total int64, err error)

func GetTreeMap added in v1.0.1

func GetTreeMap(page *Page) (treeMap map[string][]map[string]interface{}, err error)

func Init

func Init(connStr string, debug bool)

Init Init

func LcFirst

func LcFirst(s string) string

func LowerSnakeCase

func LowerSnakeCase(s string) string

func MetadataFieldsToPB

func MetadataFieldsToPB(in []MetadataField) []*apipb.MetadataField

func MetadataToPB

func MetadataToPB(in *Metadata) *apipb.MetadataInfo

func MetadatasToPB

func MetadatasToPB(in []*Metadata) []*apipb.MetadataInfo

func PBToPageButtons

func PBToPageButtons(btns []*PageButton) []*apipb.PageButton

func PageFieldsToPB

func PageFieldsToPB(in []*PageField) []*apipb.PageField

func PageToPB

func PageToPB(in *Page) *apipb.PageInfo

func PageToolBarToPB

func PageToolBarToPB(in *PageToolBar) *apipb.PageToolBar

func PagesToPB

func PagesToPB(in []*Page) []*apipb.PageInfo

func Query

func Query(req *QueryRequest, resp *QueryResponse)

func QueryMetadata

func QueryMetadata(req *apipb.QueryMetadataRequest, resp *apipb.QueryMetadataResponse)

func QueryPage

func QueryPage(req *apipb.QueryPageRequest, resp *apipb.QueryPageResponse)

func RecursiveRefMetadata

func RecursiveRefMetadata(md *Metadata, preload *[]string)

func RemoveLastChar

func RemoveLastChar(s string) string

func SortButtons added in v1.0.1

func SortButtons(buttons []*PageButton)

func SortFields added in v1.0.1

func SortFields(fields []*PageField)

func Update

func Update(pageName string, m map[string]interface{}) error

func UpdateMetadata

func UpdateMetadata(md *Metadata) error

func UpdatePage

func UpdatePage(m *Page) error

Types

type Metadata

type Metadata struct {
	model.Model
	Name           string          `json:"name" gorm:"size:100;index"`
	DisplayName    string          `json:"displayName" gorm:"size:100;comment:显示名字"`
	Level          int32           `json:"level"`
	ParentID       string          `json:"parentID"`
	Description    string          `json:"description" gorm:"size:200;"`
	Package        string          `json:"package" gorm:"size:100"`
	MetadataFields []MetadataField `json:"metadataFields"`
	Children       []*Metadata     `json:"children" gorm:"-"`
	UniqueFields   string          `json:"-" gorm:"-"`
	Fields         string          `json:"-" gorm:"-"`
	Preload        string          `json:"-" gorm:"-"`
	System         string          `json:"system" gorm:"index;size:100"`
}

func GetAllMetadatas

func GetAllMetadatas() (mds []*Metadata, err error)

func GetMetadataById

func GetMetadataById(id string) (*Metadata, error)

func GetMetadataByName

func GetMetadataByName(name string) (*Metadata, error)

func GetMetadataTree

func GetMetadataTree() (list []*Metadata, total int64, err error)

func PBToMetadata

func PBToMetadata(in *apipb.MetadataInfo) *Metadata

func (*Metadata) FieldSort added in v1.0.1

func (md *Metadata) FieldSort()

func (*Metadata) InitGenCode added in v1.0.1

func (md *Metadata) InitGenCode()

func (*Metadata) Sort added in v1.0.1

func (md *Metadata) Sort()

type MetadataField

type MetadataField struct {
	model.Model
	MetadataID   string `json:"metadataID"`
	Name         string `json:"name" gorm:"size:100;"`
	Type         string `json:"type" gorm:"size:50;comment:基础数据类型"`
	Length       int32  `json:"length" gorm:"comment:字段长度"`
	NotNull      bool   `json:"notNull" gorm:"comment:是否可以为空"`
	Comment      string `json:"comment" gorm:"size:200;"`
	IsArray      bool   `json:"isArray" gorm:"comment:数组"`
	RefMetadata  string `json:"refMetadata" gorm:"size:100;comment:引用其他元数据"`
	DisplayName  string `json:"displayName" gorm:"size:100;comment:显示名字"`
	ShowInTable  bool   `json:"showInTable" gorm:"comment:是否在列表中显示"`
	ShowInEdit   bool   `json:"showInEdit" gorm:"comment:是否在编辑中显示"`
	Component    string `json:"component" gorm:"size:100;comment:显示组件类型"`
	Unique       bool   `json:"unique" gorm:"comment:唯一索引"`
	Index        bool   `json:"index" gorm:"comment:索引"`
	DefaultValue string `json:"defaultValue" gorm:"size:100;comment:默认值"`
	ShowInQuery  bool   `json:"showInQuery" gorm:"comment:查询条件"`
	Order        int32  `json:"order" gorm:"comment:显示顺序"`
	Like         bool   `json:"like" gorm:"comment:like查询"`
	Copier       bool   `json:"copier" gorm:"comment:是否不拷贝"`
}

func GetMetadataFieldByMDId

func GetMetadataFieldByMDId(mdID string) ([]*MetadataField, error)

func PBToMetadataFields

func PBToMetadataFields(in []*apipb.MetadataField) []MetadataField

type Page

type Page struct {
	model.Model
	Name                 string       `json:"name" gorm:"size:100;uniqueindex:uidx1" `
	Enable               bool         `json:"enable" gorm:"comment:是否启用"`
	MetadataID           string       `json:"metadataID" gorm:"" `
	Metadata             *Metadata    `json:"metadata" gorm:"" copier:"-"`
	PageSize             uint32       `json:"pageSize" gorm:"comment:每页数量" `
	Editable             string       `json:"editable" gorm:"size:100" `
	ShowIndex            bool         `json:"showIndex" gorm:"comment:是否显示序号"`
	ShowSelection        bool         `json:"showSelection" gorm:"显示批量操作"`
	ToolBar              *PageToolBar `json:"toolBar" gorm:"" `
	Fields               []*PageField `json:"fields" gorm:"" `
	Path                 string       `json:"path" gorm:"size:200;comment:接口前缀,例如/api/core/auth/user"`
	Title                string       `json:"title" gorm:"size:100"`
	Description          string       `json:"description" gorm:"size:500"`
	SearchDefaultValue   string       `json:"searchDefaultValue" gorm:"size:300"`
	EditFormID           string       `json:"editFormID"`
	SearchFormID         string       `json:"searchFormID"`
	AddFormID            string       `json:"addFormID"`
	ViewFormID           string       `json:"viewFormID"`
	Type                 int32        `json:"type" gorm:"index;comment:1-表格 2-树形"`
	SubmitBefore         string       `json:"submitBefore" gorm:"comment:提交前执行"`
	SubmitAfter          string       `json:"submitAfter" gorm:"comment:提交成功后执行"`
	LoadDetailBefore     string       `json:"loadDetailBefore" gorm:"comment:加载明细前执行"`
	LoadDetailAfter      string       `json:"loadDetailAfter" gorm:"comment:加载明细成功后执行"`
	QueryBefore          string       `json:"queryBefore" gorm:"comment:查询前执行"`
	QueryAfter           string       `json:"queryAfter" gorm:"comment:查询成功后执行"`
	ListAvatarField      string       `json:"listAvatarField" gorm:"size:100"`
	ListTitleField       string       `json:"listTitleField" gorm:"size:100"`
	ListDescriptionField string       `json:"listDescriptionField" gorm:"size:100"`
	ListContentField     string       `json:"listContentField" gorm:"size:100"`
	ListLoadType         int32        `json:"listLoadType"`

	CardAvatarField      string        `json:"cardAvatarField" gorm:"size:100"`
	CardTitleField       string        `json:"cardTitleField" gorm:"size:100"`
	CardDescriptionField string        `json:"cardDescriptionField" gorm:"size:100"`
	CardContentField     string        `json:"cardContentField" gorm:"size:100"`
	CardLoadType         int32         `json:"cardLoadType"`
	CardImageField       string        `json:"cardImageField" gorm:"size:100"`
	Buttons              []*PageButton `json:"buttons"`
}

func GetAllPage

func GetAllPage() (list []*Page, err error)

func GetPageByID

func GetPageByID(id string) (*Page, error)

func GetPageByName

func GetPageByName(name string) (*Page, error)

func PBToPage

func PBToPage(in *apipb.PageInfo) *Page

type PageButton

type PageButton struct {
	ID       string `json:"id"`
	PageID   string `json:"pageID" gorm:"" copier:"-"`
	Key      string `json:"key" gorm:"size:100"`
	Label    string `json:"label" gorm:"size:200"`
	Expanded bool   `json:"expanded"`
	ShowType string `json:"showType" gorm:"size:50"`
	Href     string `json:"href" gorm:"size:200"`
	HrefFunc string `json:"hrefFunc"`
	Script   string `json:"script"`
	Index    int32  `json:"index"`
	Enable   bool   `json:"enable" gorm:"comment:是否启用;index"`
}

func PageButtonsToPB

func PageButtonsToPB(versions []*apipb.PageButton) []*PageButton

type PageField

type PageField struct {
	model.Model
	PageID         string `json:"pageID" gorm:"" copier:"-"`
	Name           string `json:"name" gorm:"size:100;comment:字段名" copier:"-"`
	Title          string `json:"title" gorm:"size:100;comment:显示名称" copier:"-"`
	Copyable       bool   `json:"copyable" gorm:"comment:显示复制按钮" copier:"-"`
	Ellipsis       bool   `json:"ellipsis" gorm:"comment:是否自动缩略" copier:"-"`
	RowKey         bool   `json:"rowKey" gorm:"comment:Row Key" copier:"-"`
	Sort           int32  `json:"sort"`
	ShowInTable    bool   `json:"showInTable"`
	ValueEnum      string `json:"valueEnum" gorm:"size:500;comment:枚举值转换"`
	Component      string `json:"component" gorm:"size:200;comment:组件"`
	ComponentProps string `json:"componentProps" gorm:"size:500"`
	DataType       string `json:"dataType" gorm:"size:100;comment:数据类型"`
	LabelField     string `json:"labelField" gorm:"size:100"`
	ValueField     string `json:"valueField" gorm:"size:100"`
}

func PBToPageFields

func PBToPageFields(in []*apipb.PageField) []*PageField

type PageToolBar

type PageToolBar struct {
	model.Model
	PageID     string `json:"pageID" gorm:"" copier:"-"`
	FullScreen bool   `json:"fullScreen" gorm:"comment:全屏" copier:"-"`
	Reload     bool   `json:"reload" gorm:"comment:刷新" copier:"-"`
	Setting    bool   `json:"setting" gorm:"" copier:"-"`
	Render     string `json:"render" gorm:"size:500" copier:"-"`
	ShowAdd    bool   `json:"showAdd" gorm:"comment:是否显示新增按钮"`
	AddScript  string `json:"addScript"`
}

func PBToPageToolBar

func PBToPageToolBar(in *apipb.PageToolBar) *PageToolBar

type QueryMetadataRequest

type QueryMetadataRequest struct {
	model.CommonRequest
	Name     string `json:"name" form:"name" uri:"name"`
	ParentID string `json:"parentID" form:"parentID" uri:"parentID"`
}

type QueryMetadataResponse

type QueryMetadataResponse struct {
	model.CommonResponse
	Data []*Metadata `json:"data"`
}

type QueryRequest

type QueryRequest struct {
	model.CommonRequest
	PageName string                 `json:"pageName" form:"pageName" uri:"pageName"`
	Data     map[string]interface{} `json:"data" form:"data" uri:"data"`
}

type QueryResponse

type QueryResponse struct {
	model.CommonResponse
	Data []map[string]interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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