model

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivityKindBasketball = iota + 1
	ActivityKindFootball
	ActivityKindVolleyball
	ActivityKindBadminton
	ActivityKindDinner
	ActivityKindOther
)
View Source
const (
	ActivityTypePrivate = iota + 1
	ActivityTypePublic
	ActivityTypeClub
)
View Source
const (
	ActivityStageSignup = iota + 1
	ActivityStageInProcess
	ActivityStageFinished
	ActivityStageAbort
)
View Source
const (
	ActivityFeeTypeFree = iota + 1
	ActivityFeeTypeFixed
	ActivityFeeTypeAA
	ActivityFeeTypeMaleFixedFemaleAA
	ActivityFeeTypeMaleAAFemaleFixed
)
View Source
const (
	ClubPositionOwner = iota + 1
	ClubPositionMember
	ClubPositionManager
)
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

func GenUniqueKey

func GenUniqueKey(tx *gorm.DB, field string, size int) (key string)

GenUniqueKey generate a unique value for a field in a table.

Types

type Activity added in v0.2.1

type Activity struct {
	BaseField
	ClubID  uint `json:"club_id" gorm:"index"`
	Club    Club `json:"-"`
	Kind    uint `json:"kind" gorm:"index;default:1;comment:活动分类:1羽毛球,2篮球,3足球,4聚餐..."`     // 活动分类:1羽毛球,2篮球,3足球,4聚餐...
	Type    uint `json:"type" gorm:"index;default:1;comment:活动类型:1全局保护,2全局公开,3群组"`         // 活动类型:1全局保护,2全局公开,3群组
	Quota   uint `json:"quota" gorm:"default:1;comment:报名名额"`                              // 报名名额
	Waiting uint `json:"waiting" gorm:"default:1;comment:候补数量限制"`                          // 候补数量限制
	Stage   uint `json:"stage" gorm:"default:1;comment:活动阶段:1报名阶段,2活动阶段,3正常完成和结算,4手动终止活动"` // 活动阶段:1报名阶段,2活动阶段,3正常完成和结算,4手动终止活动
	FeeType uint ``                                                                        // 结算方式:1免费,2活动前,3活动后男女平均,4活动后男固定|女平摊,5活动后男平摊|女固定
	/* 155-byte string literal not displayed */
	FeeMale   uint      `json:"fee_male" gorm:"comment:男费用,单位:分"`            // 男费用,单位:分
	FeeFemale uint      `json:"fee_female" gorm:"comment:女费用,单位:分"`          // 女费用,单位:分
	Address   string    `json:"address" gorm:"comment:活动地址"`                 // 活动地址
	Ahead     uint      `json:"ahead" gorm:"default:24;comment:可提前取消时间(小时)"` // 可提前取消时间(小时)
	BeginAt   time.Time `json:"begin_at" gorm:"index;comment:开始时间"`          // 开始时间
	EndAt     time.Time `json:"end_at" gorm:"index;comment:结束时间"`            // 结束时间
}

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 AdminAction struct {
	Path          string             `json:"path"`
	Name          string             `json:"name"`
	Label         string             `json:"label,omitempty"`
	Icon          string             `json:"icon,omitempty"`
	Class         string             `json:"class,omitempty"`
	WithoutObject bool               `json:"withoutObject"`
	Handler       AdminActionHandler `json:"-"`
}

type AdminActionHandler added in v0.2.0

type AdminActionHandler func(c *fiber.Ctx, obj any) (any, error)

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 AdminBuildContext func(*fiber.Ctx, map[string]any) map[string]any

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 AdminForeign struct {
	Path       string `json:"path"`
	Field      string `json:"field"`
	FieldName  string `json:"-"`
	ForeignKey string `json:"-"`
}

type AdminIcon added in v0.2.0

type AdminIcon struct {
	Url string `json:"url,omitempty"`
	SVG string `json:"svg,omitempty"`
}

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
	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 AdminQueryResult struct {
	TotalCount int              `json:"total,omitempty"`
	Pos        int              `json:"pos,omitempty"`
	Limit      int              `json:"limit,omitempty"`
	Keyword    string           `json:"keyword,omitempty"`
	Items      []map[string]any `json:"items"`
	Objects    []any            `json:"-"`
}

type AdminScript added in v0.2.0

type AdminScript struct {
	Src    string `json:"src"`
	Onload bool   `json:"onload,omitempty"`
}

type AdminSelectOption added in v0.2.0

type AdminSelectOption struct {
	Label string `json:"label"`
	Value any    `json:"value"`
}

type AdminValue added in v0.2.0

type AdminValue struct {
	Value any    `json:"value"`
	Label string `json:"label,omitempty"`
}

type BaseContent

type BaseContent struct {
	UpdatedAt   time.Time    `json:"updated_at" gorm:"index"`
	CreatedAt   time.Time    `json:"created_at" 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:"published_at"`
	ContentType string       `json:"content_type" gorm:"size:32"`
	Remark      string       `json:"remark"`
}

type BaseField added in v0.2.1

type BaseField struct {
	ID          uint      `json:"id" gorm:"primarykey;autoIncrement:true"`
	UpdatedAt   time.Time `json:"updated_at" gorm:"autoCreateTime"`
	CreatedAt   time.Time `json:"created_at" gorm:"autoUpdateTime"`
	SiteID      string    `json:"site_id" gorm:"uniqueIndex:,composite:_site_name"`
	Site        Site      `json:"-"`
	Name        string    `json:"title" gorm:"size:200;uniqueIndex:,composite:_site_name"`
	Description string    `json:"description,omitempty"`
	CreatorID   uint      `json:"-" gorm:"index"`
	Creator     User      `json:"-"`
}

type BeforeCreateFunc added in v0.2.0

type BeforeCreateFunc func(ctx *fiber.Ctx, vptr any) error

type BeforeDeleteFunc added in v0.2.0

type BeforeDeleteFunc func(ctx *fiber.Ctx, vptr any) error

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 BeforeRenderFunc func(ctx *fiber.Ctx, vptr any) (any, error)

type BeforeUpdateFunc added in v0.2.0

type BeforeUpdateFunc func(ctx *fiber.Ctx, vptr any, vals map[string]any) error

type Category

type Category struct {
	SiteID string        `json:"site_id" 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

func (CategoryItem) Value

func (s CategoryItem) Value() (driver.Value, error)

type CategoryItems

type CategoryItems []CategoryItem

func (*CategoryItems) Scan

func (s *CategoryItems) Scan(input interface{}) error

func (CategoryItems) Value

func (s CategoryItems) Value() (driver.Value, error)

type Club added in v0.2.1

type Club struct {
	BaseField
	Scores  uint   `json:"scores" gorm:"default:0;comment:俱乐部积分"` // 俱乐部积分
	Level   uint   `json:"level" gorm:"default:1;comment:俱乐部等级"`  // 俱乐部等级
	Notice  string `json:"notice" gorm:"comment:俱乐部公告"`           // 俱乐部公告
	Address string `json:"address" gorm:"comment:俱乐部总部地址"`        // 俱乐部总部地址
}

func (Club) String added in v0.2.1

func (s Club) String() string

type ClubMember added in v0.2.1

type ClubMember struct {
	ID          uint      `json:"-" gorm:"primaryKey;autoIncrement"`
	CreatedAt   time.Time `json:"-" gorm:"autoCreateTime"`
	Scores      uint      `json:"scores" gorm:"default:0"`
	UserID      uint      `json:"-"`
	User        User      `json:"user"`
	ClubID      uint      `json:"-"`
	Club        Club      `json:"club"`
	Position    uint      `json:"position" gorm:"default:1;comment:群组职位"`    // 群组职位
	DisplayName string    `json:"display_name" gorm:"size:200;comment:群组昵称"` // 群组昵称
	EnterAt     time.Time `json:"enter_at" gorm:"comment:进入群组时间"`            // 进入群组时间
}

type Comment

type Comment struct {
	gorm.Model
	Body   string `gorm:"column:body;not null" json:"body"`
	Email  string `gorm:"column:email;not null" json:"email"`
	IP     string `gorm:"column:ip;not null" json:"ip"`
	Post   Post
	PostID uint
	UserID uint `gorm:"column:user_id;not null" json:"user_id"`
	User   User
}

type Config

type Config struct {
	ID    uint   `json:"id" gorm:"primaryKey"`
	Key   string `json:"key" gorm:"size:128;uniqueIndex"`
	Desc  string `json:"desc" gorm:"size:200"`
	Value string
}

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

func (ContentIcon) Value added in v0.2.0

func (s ContentIcon) Value() (driver.Value, 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 Filter struct {
	IsTimeType bool   `json:"-"`
	Name       string `json:"name"`
	Op         string `json:"op"`
	Value      any    `json:"value"`
}

func (*Filter) GetQuery added in v0.2.0

func (f *Filter) GetQuery() string

GetQuery return the combined filter SQL statement. such as "age >= ?", "name IN ?".

type Group

type Group struct {
	ID         uint            `json:"-" gorm:"primaryKey;autoIncrement"`
	CreatedAt  time.Time       `json:"-" gorm:"autoCreateTime"`
	UpdatedAt  time.Time       `json:"-"`
	Name       string          `json:"name" gorm:"size:200"`
	Type       string          `json:"type" gorm:"size:24;index"`
	Extra      string          `json:"extra"`
	Permission GroupPermission `json:"-"`
}

func (Group) String

func (g Group) String() string

type GroupMember

type GroupMember struct {
	ID        uint      `json:"-" gorm:"primaryKey;autoIncrement"`
	CreatedAt time.Time `json:"-" gorm:"autoCreateTime"`
	UserID    uint      `json:"-"`
	User      User      `json:"user"`
	GroupID   uint      `json:"-"`
	Group     Group     `json:"group"`
	Role      string    `json:"role" gorm:"size:60"`
}

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

func (GroupPermission) Value

func (p GroupPermission) Value() (driver.Value, 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:"public_url,omitempty" gorm:"-"`
}

func (*Media) BuildPublicUrls

func (m *Media) BuildPublicUrls(mediaHost string, mediaPrefix string)

type MediaFolder

type MediaFolder struct {
	Name         string `json:"name"`
	Path         string `json:"path"`
	FilesCount   int64  `json:"filesCount"`
	FoldersCount int64  `json:"foldersCount"`
}

type Order added in v0.2.0

type Order struct {
	Name string `json:"name"`
	Op   string `json:"op"`
}

func (*Order) GetQuery added in v0.2.0

func (f *Order) GetQuery() string

GetQuery return the combined order SQL statement. such as "id DESC".

type Page

type Page struct {
	BaseContent
	SiteID       string `json:"site_id" gorm:"primaryKey;uniqueIndex:,composite:_site_id"`
	Site         Site   `json:"-"`
	ID           string `json:"id" gorm:"primaryKey;size:100;uniqueIndex:,composite:_site_id"`
	IsDraft      bool   `json:"is_draft"`
	Draft        string `json:"-"`
	Body         string `json:"body"`
	PreviewURL   string `json:"preview_url,omitempty" gorm:"size:200"`
	CategoryID   string `json:"category_id,omitempty" gorm:"size:64;index:,composite:_category_id_path" label:"Category"`
	CategoryPath string `json:"category_path,omitempty" gorm:"size:64;index:,composite:_category_id_path"`
}

type Post

type Post struct {
	BaseContent
	SiteID       string `json:"site_id" gorm:"primaryKey;uniqueIndex:,composite:_site_id"`
	Site         Site   `json:"-"`
	ID           string `json:"id" gorm:"primaryKey;size:100;uniqueIndex:,composite:_site_id"`
	IsDraft      bool   `json:"is_draft"`
	Draft        string `json:"-"`
	Body         string `json:"body"`
	PreviewURL   string `json:"preview_url,omitempty" gorm:"size:200"`
	CategoryID   string `json:"category_id,omitempty" gorm:"size:64;index:,composite:_category_id_path" label:"Category"`
	CategoryPath string `json:"category_path,omitempty" gorm:"size:64;index:,composite:_category_id_path"`
}

type PrepareQuery added in v0.2.0

type PrepareQuery func(c *fiber.Ctx) (*QueryForm, error)

type Profile

type Profile struct {
	Avatar  string         `json:"avatar,omitempty"`
	Gender  string         `json:"gender,omitempty"`
	City    string         `json:"city,omitempty"`
	Region  string         `json:"region,omitempty"`
	Country string         `json:"country,omitempty"`
	Extra   map[string]any `json:"extra,omitempty"`
}

func (*Profile) Scan

func (p *Profile) Scan(value interface{}) error

func (Profile) Value

func (p Profile) Value() (driver.Value, error)

type PublishLog

type PublishLog struct {
	ID        uint      `json:"id" gorm:"primarykey"`
	CreatedAt time.Time `json:"created_at"`
	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:"content_id" gorm:"size:100;index:idx_content_with_id"` // post_id or page_id
	Body      string    `json:"body"`
}

type QueryByTagsForm

type QueryByTagsForm struct {
	Tags  []string `json:"tags" binding:"required"`
	Limit int      `json:"limit"`
	Pos   int      `json:"pos"`
	TagsForm
}

type QueryByTagsResult

type QueryByTagsResult struct {
	Items []any `json:"items"`
	Total int   `json:"total"`
	Limit int   `json:"limit"`
	Pos   int   `json:"pos"`
}

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 QueryResult struct {
	TotalCount int    `json:"total,omitempty"`
	Pos        int    `json:"pos,omitempty"`
	Limit      int    `json:"limit,omitempty"`
	Keyword    string `json:"keyword,omitempty"`
	Items      []any  `json:"items"`
}

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:"site_id"`
	ID     string `json:"id"`
}

type RenderCategory

type RenderCategory struct {
	UUID     string `json:"uuid"`
	Name     string `json:"name"`
	Path     string `json:"path,omitempty"`
	PathName string `json:"path_name,omitempty"`
}

type RenderContent

type RenderContent struct {
	BaseContent
	ID          string            `json:"id"`
	SiteID      string            `json:"site_id"`
	Category    *RenderCategory   `json:"category,omitempty"`
	PageData    any               `json:"data,omitempty"`
	PostBody    string            `json:"body,omitempty"`
	IsDraft     bool              `json:"is_draft"`
	Relations   []RelationContent `json:"relations,omitempty"`
	Suggestions []RelationContent `json:"suggestions,omitempty"`
}

type Site

type Site struct {
	UpdatedAt time.Time `json:"updated_at"`
	CreatedAt time.Time `json:"created_at"`
	Domain    string    `json:"domain" gorm:"primarykey;size:200"`
	Name      string    `json:"name" gorm:"size:200"`
	Preview   string    `json:"preview" gorm:"size:200"`
	Disallow  bool      `json:"disallow"`
}

func (Site) String

func (s Site) String() string

type StringArray

type StringArray []string

func (*StringArray) Scan

func (s *StringArray) Scan(input interface{}) error

func (StringArray) Value

func (s StringArray) Value() (driver.Value, 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 TagsForm

type TagsForm struct {
	SiteId       string `json:"site_id"`
	CategoryId   string `json:"category_id"`
	CategoryPath string `json:"category_path"`
}

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;autoIncrement"`
	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:"first_name,omitempty" gorm:"size:128"`
	LastName    string     `json:"last_name,omitempty" gorm:"size:128"`
	DisplayName string     `json:"display_name,omitempty" gorm:"size:128"`
	IsSuperUser bool       `json:"-"`
	IsStaff     bool       `json:"-"`
	Enabled     bool       `json:"-"`
	Activated   bool       `json:"-"`
	LastLogin   *time.Time `json:"last_login,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 (u *User) GetProfile() Profile

func (*User) GetVisibleName

func (u *User) GetVisibleName() string

func (User) String

func (u User) String() string

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
	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
}

type WebObjectPrimaryField added in v0.2.0

type WebObjectPrimaryField struct {
	IsPrimary bool
	Name      string
	Kind      reflect.Kind
	JSONName  string
}

Jump to

Keyboard shortcuts

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