Documentation
¶
Index ¶
- Constants
- func GenUniqueKey(tx *gorm.DB, field string, size int) (key string)
- type AdminAccessCheck
- type AdminAction
- type AdminActionHandler
- type AdminAttribute
- type AdminBuildContext
- type AdminField
- type AdminForeign
- type AdminIcon
- type AdminObject
- type AdminQueryResult
- type AdminScript
- type AdminSelectOption
- type AdminValue
- type BaseContent
- type BeforeCreateFunc
- type BeforeDeleteFunc
- type BeforeQueryRenderFunc
- type BeforeRenderFunc
- type BeforeUpdateFunc
- type Category
- type CategoryItem
- type CategoryItems
- type Comment
- type Config
- type ContentIcon
- type ContentQueryResult
- type Filter
- type GetDB
- type Group
- type GroupMember
- type GroupPermission
- type Media
- type MediaFolder
- type Order
- type Page
- type Post
- type PrepareQuery
- type Profile
- type PublishLog
- type QueryByTagsForm
- type QueryByTagsResult
- type QueryForm
- type QueryResult
- type QueryView
- type RelationContent
- type RenderCategory
- type RenderContent
- type Site
- type StringArray
- type SummaryResult
- type TagsForm
- type UploadResult
- type User
- type WebObject
- type WebObjectPrimaryField
Constants ¶
View Source
const ( PermissionAll = "all" PermissionCreate = "create" PermissionUpdate = "update" PermissionRead = "read" PermissionDelete = "delete" )
View Source
const ( GroupRoleAdmin = "admin" GroupRoleMember = "member" )
View Source
const ( GroupTypeAdmin = "admin" // admin, for /admin path with permissions check GroupTypeApp = "app" )
View Source
const ( FilterOpIsNot = "is not" FilterOpEqual = "=" FilterOpNotEqual = "<>" FilterOpIn = "in" FilterOpNotIn = "not_in" FilterOpGreater = ">" FilterOpGreaterOrEqual = ">=" FilterOpLess = "<" FilterOpLessOrEqual = "<=" FilterOpLike = "like" FilterOpBetween = "between" )
View Source
const ( OrderOpDesc = "desc" OrderOpAsc = "asc" )
View Source
const ( GET = 1 << 1 CREATE = 1 << 2 EDIT = 1 << 3 DELETE = 1 << 4 QUERY = 1 << 5 )
View Source
const (
DefaultQueryLimit = 102400 // 100k
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AdminAccessCheck ¶ added in v0.2.0
type AdminAccessCheck func(c *fiber.Ctx, obj *AdminObject) error
Access control
type AdminAction ¶ added in v0.2.0
type AdminActionHandler ¶ added in v0.2.0
type AdminAttribute ¶ added in v0.2.0
type AdminAttribute struct {
Default any `json:"default,omitempty"`
Choices []AdminSelectOption `json:"choices,omitempty"`
SingleChoice bool `json:"singleChoice,omitempty"`
Widget string `json:"widget,omitempty"`
FilterWidget string `json:"filterWidget,omitempty"`
Help string `json:"help,omitempty"`
}
type AdminBuildContext ¶ added in v0.2.0
type AdminField ¶ added in v0.2.0
type AdminField struct {
Placeholder string `json:"placeholder,omitempty"` // Placeholder of the filed
Label string `json:"label"` // Label of the filed
NotColumn bool `json:"notColumn,omitempty"` // Not a column
Required bool `json:"required,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
Tag string `json:"tag,omitempty"`
Attribute *AdminAttribute `json:"attribute,omitempty"`
CanNull bool `json:"canNull,omitempty"`
IsArray bool `json:"isArray,omitempty"`
Primary bool `json:"primary,omitempty"`
Foreign *AdminForeign `json:"foreign,omitempty"`
IsAutoID bool `json:"isAutoId,omitempty"`
IsPtr bool `json:"isPtr,omitempty"`
ElemType reflect.Type `json:"-"`
FieldName string `json:"-"`
}
type AdminForeign ¶ added in v0.2.0
type AdminObject ¶ added in v0.2.0
type AdminObject struct {
Model any `json:"-"`
Group string `json:"group"` // Group name
Name string `json:"name"` // Name of the object
Desc string `json:"desc,omitempty"` // Description
Path string `json:"path"` // Path prefix
Shows []string `json:"shows"` // Show fields
Orders []Order `json:"orders"` // Default orders of the object
Editables []string `json:"editables"` // Editable fields
Filterables []string `json:"filterables"` // Filterable fields
Orderables []string `json:"orderables"` // Orderable fields, can override Orders
Searchables []string `json:"searchables"` // Searchable fields
Requireds []string `json:"requireds,omitempty"` // Required fields
PrimaryKeys []string `json:"primaryKeys"` // Primary keys name
UniqueKeys []string `json:"uniqueKeys"` // Primary keys name
PluralName string `json:"pluralName"`
Fields []AdminField `json:"fields"`
EditPage string `json:"editpage,omitempty"`
ListPage string `json:"listpage,omitempty"`
Scripts []AdminScript `json:"scripts,omitempty"`
Styles []string `json:"styles,omitempty"`
Permissions map[string]bool `json:"permissions,omitempty"`
Actions []AdminAction `json:"actions,omitempty"`
Icon *AdminIcon `json:"icon,omitempty"`
Invisible bool `json:"invisible,omitempty"`
Attributes map[string]AdminAttribute `json:"-"` // Field's extra attributes
AccessCheck AdminAccessCheck `json:"-"` // Access control function
GetDB GetDB `json:"-"`
BeforeCreate BeforeCreateFunc `json:"-"`
BeforeRender BeforeRenderFunc `json:"-"`
BeforeUpdate BeforeUpdateFunc `json:"-"`
BeforeDelete BeforeDeleteFunc `json:"-"`
TableName string `json:"-"`
ModelElem reflect.Type `json:"-"`
Ignores map[string]bool `json:"-"`
PrimaryKeyMaping map[string]string `json:"-"`
MarkDeletedField string `json:"-"`
Weight int `json:"-"`
}
type AdminQueryResult ¶ added in v0.2.0
type AdminScript ¶ added in v0.2.0
type AdminSelectOption ¶ added in v0.2.0
type AdminValue ¶ added in v0.2.0
type BaseContent ¶
type BaseContent struct {
UpdatedAt time.Time `json:"updatedAt" gorm:"index"`
CreatedAt time.Time `json:"createdAt" gorm:"index"`
Thumbnail string `json:"thumbnail,omitempty" gorm:"size:500"`
Tags string `json:"tags,omitempty" gorm:"size:200;index"`
Title string `json:"title,omitempty" gorm:"size:200"`
Alt string `json:"alt,omitempty"`
Description string `json:"description,omitempty"`
Keywords string `json:"keywords,omitempty"`
CreatorID uint `json:"-"`
Creator User `json:"-"`
Author string `json:"author" gorm:"size:64"`
Published bool `json:"published"`
PublishedAt sql.NullTime `json:"publishedAt"`
ContentType string `json:"contentType" gorm:"size:32"`
Remark string `json:"remark"`
}
type BeforeQueryRenderFunc ¶ added in v0.2.0
type BeforeQueryRenderFunc func(ctx *fiber.Ctx, r *QueryResult) (any, error)
type BeforeRenderFunc ¶ added in v0.2.0
type BeforeUpdateFunc ¶ added in v0.2.0
type Category ¶
type Category struct {
SiteID string `json:"siteId" gorm:"uniqueIndex:,composite:_site_uuid"`
Site Site `json:"-"`
UUID string `json:"uuid" gorm:"size:12;uniqueIndex:,composite:_site_uuid"`
Name string `json:"name" gorm:"size:200"`
Items CategoryItems `json:"items,omitempty"`
Count int `json:"count" gorm:"-"`
}
func (*Category) FindItem ¶
func (category *Category) FindItem(path string) *CategoryItem
type CategoryItem ¶
type CategoryItem struct {
Path string `json:"path"`
Name string `json:"name"`
Icon *ContentIcon `json:"icon,omitempty"`
Children CategoryItems `json:"children,omitempty"`
Count int `json:"count" gorm:"-"`
}
func (*CategoryItem) Scan ¶
func (s *CategoryItem) Scan(input interface{}) error
type CategoryItems ¶
type CategoryItems []CategoryItem
func (*CategoryItems) Scan ¶
func (s *CategoryItems) Scan(input interface{}) error
type ContentIcon ¶ added in v0.2.0
type ContentIcon AdminIcon
func (*ContentIcon) Scan ¶ added in v0.2.0
func (s *ContentIcon) Scan(input interface{}) error
type ContentQueryResult ¶
type ContentQueryResult struct {
*QueryResult
Relations []RelationContent `json:"relations,omitempty"`
Suggestions []RelationContent `json:"suggestions,omitempty"`
}
type Filter ¶ added in v0.2.0
type Group ¶
type GroupMember ¶
type GroupPermission ¶
type GroupPermission struct {
Permissions []string
}
permission format users.read,users.create,users.update,users.delete, user.* pages.publish,pages.update,page.delete,page.*
func (*GroupPermission) Scan ¶
func (p *GroupPermission) Scan(value interface{}) error
type Media ¶
type Media struct {
BaseContent
Size int64 `json:"size"`
Directory bool `json:"directory" gorm:"index"`
Path string `json:"path" gorm:"size:200;uniqueIndex:,composite:_path_name"`
Name string `json:"name" gorm:"size:200;uniqueIndex:,composite:_path_name"`
Ext string `json:"ext" gorm:"size:100"`
Dimensions string `json:"dimensions" gorm:"size:200"` // x*y
StorePath string `json:"-" gorm:"size:300"`
External bool `json:"external"`
PublicUrl string `json:"publicUrl,omitempty" gorm:"-"`
}
func (*Media) BuildPublicUrls ¶
type MediaFolder ¶
type Page ¶
type Page struct {
BaseContent
SiteID string `json:"siteId" gorm:"primaryKey;uniqueIndex:,composite:_site_id"`
Site Site `json:"-"`
ID string `json:"id" gorm:"primaryKey;size:100;uniqueIndex:,composite:_site_id"`
IsDraft bool `json:"isDraft"`
Draft string `json:"-"`
Body string `json:"body"`
PreviewURL string `json:"previewUrl,omitempty" gorm:"size:200"`
CategoryID string `json:"categoryId,omitempty" gorm:"size:64;index:,composite:_category_id_path" label:"Category"`
CategoryPath string `json:"categoryPath,omitempty" gorm:"size:64;index:,composite:_category_id_path"`
}
type Post ¶
type Post struct {
BaseContent
SiteID string `json:"siteId" gorm:"primaryKey;uniqueIndex:,composite:_site_id"`
Site Site `json:"-"`
ID string `json:"id" gorm:"primaryKey;size:100;uniqueIndex:,composite:_site_id"`
IsDraft bool `json:"isDraft"`
Draft string `json:"-"`
Body string `json:"body"`
PreviewURL string `json:"previewUrl,omitempty" gorm:"size:200"`
CategoryID string `json:"categoryId,omitempty" gorm:"size:64;index:,composite:_category_id_path" label:"Category"`
CategoryPath string `json:"categoryPath,omitempty" gorm:"size:64;index:,composite:_category_id_path"`
}
type PrepareQuery ¶ added in v0.2.0
type Profile ¶
type PublishLog ¶
type PublishLog struct {
ID uint `json:"id" gorm:"primarykey"`
CreatedAt time.Time `json:"createdAt"`
AuthorID uint `json:"-"`
Author User `json:"author"`
Content string `json:"content" gorm:"size:12;index:idx_content_with_id"` // post_id or page_id
ContentID string `json:"contentId" gorm:"size:100;index:idx_content_with_id"` // post_id or page_id
Body string `json:"body"`
}
type QueryByTagsForm ¶
type QueryByTagsResult ¶
type QueryForm ¶ added in v0.2.0
type QueryForm struct {
Pos int `json:"pos"`
Limit int `json:"limit"`
Keyword string `json:"keyword,omitempty"`
Filters []Filter `json:"filters,omitempty"`
Orders []Order `json:"orders,omitempty"`
ForeignMode bool `json:"foreign"` // for foreign key
ViewFields []string `json:"-"` // for view
SearchFields []string `json:"-"` // for keyword
}
type QueryResult ¶ added in v0.2.0
type QueryView ¶ added in v0.2.0
type QueryView struct {
Path string `json:"path"`
Method string `json:"method"`
Desc string `json:"desc"`
Prepare PrepareQuery
}
type RelationContent ¶
type RelationContent struct {
BaseContent
SiteID string `json:"siteId"`
ID string `json:"id"`
}
type RenderCategory ¶
type RenderContent ¶
type RenderContent struct {
BaseContent
ID string `json:"id"`
SiteID string `json:"siteId"`
Category *RenderCategory `json:"category,omitempty"`
PageData any `json:"data,omitempty"`
PostBody string `json:"body,omitempty"`
IsDraft bool `json:"isDraft"`
Relations []RelationContent `json:"relations,omitempty"`
Suggestions []RelationContent `json:"suggestions,omitempty"`
}
type Site ¶
type StringArray ¶
type StringArray []string
func (*StringArray) Scan ¶
func (s *StringArray) Scan(input interface{}) error
type SummaryResult ¶
type SummaryResult struct {
SiteCount int64 `json:"sites"`
PageCount int64 `json:"pages"`
PostCount int64 `json:"posts"`
CategoryCount int64 `json:"categories"`
MediaCount int64 `json:"media"`
LatestPosts []*RenderContent `json:"latestPosts"`
BuildTime string `json:"buildTime"`
CanExport bool `json:"canExport"`
}
type UploadResult ¶ added in v0.2.0
type UploadResult struct {
PublicUrl string `json:"publicUrl"`
Thumbnail string `json:"thumbnail"`
Path string `json:"path"`
Name string `json:"name"`
External bool `json:"external"`
StorePath string `json:"storePath"`
Dimensions string `json:"dimensions"`
Ext string `json:"ext"`
Size int64 `json:"size"`
ContentType string `json:"contentType"`
}
type User ¶
type User struct {
ID uint `json:"-" gorm:"primaryKey"`
CreatedAt time.Time `json:"-" gorm:"autoCreateTime"`
UpdatedAt time.Time `json:"-" gorm:"autoUpdateTime"`
Email string `json:"email" gorm:"size:128;uniqueIndex"`
Password string `json:"-" gorm:"size:128"`
Phone string `json:"phone,omitempty" gorm:"size:64;index"`
FirstName string `json:"firstName,omitempty" gorm:"size:128"`
LastName string `json:"lastName,omitempty" gorm:"size:128"`
DisplayName string `json:"displayName,omitempty" gorm:"size:128"`
IsSuperUser bool `json:"-"`
IsStaff bool `json:"-"`
Enabled bool `json:"-"`
Activated bool `json:"-"`
LastLogin *time.Time `json:"lastLogin,omitempty"`
LastLoginIP string `json:"-" gorm:"size:128"`
Source string `json:"-" gorm:"size:64;index"`
Locale string `json:"locale,omitempty" gorm:"size:20"`
Timezone string `json:"timezone,omitempty" gorm:"size:200"`
Profile *Profile `json:"profile,omitempty"`
AuthToken string `json:"token,omitempty" gorm:"-"`
}
func (*User) GetProfile ¶
func (*User) GetVisibleName ¶
type WebObject ¶ added in v0.2.0
type WebObject struct {
Model any
Group string
Name string
Desc string
AuthRequired bool
Editables []string
Filterables []string
Orderables []string
Searchables []string
GetDB GetDB
BeforeCreate BeforeCreateFunc
BeforeUpdate BeforeUpdateFunc
BeforeDelete BeforeDeleteFunc
BeforeRender BeforeRenderFunc
BeforeQueryRender BeforeQueryRenderFunc
Views []QueryView
AllowMethods int
PrimaryKeys []WebObjectPrimaryField
UniqueKeys []WebObjectPrimaryField
TableName string
// Model type
ModelElem reflect.Type
// Map json tag to struct field name. such as:
// UUID string `json:"id"` => {"id" : "UUID"}
JsonToFields map[string]string
// Map json tag to field kind. such as:
// UUID string `json:"id"` => {"id": string}
JsonToKinds map[string]reflect.Kind
}
Click to show internal directories.
Click to hide internal directories.