Documentation ¶
Index ¶
- Constants
- func CheckTaxonomyNameExist(db *gorm.DB, name, taxonomy string) bool
- type Knowledge
- type KnowledgeItem
- func (ki *KnowledgeItem) Create(db *gorm.DB) error
- func (ki *KnowledgeItem) Delete(db *gorm.DB) error
- func (ki *KnowledgeItem) Get(db *gorm.DB, where string, whereArgs []interface{}) ([]*KnowledgeItem, int64, error)
- func (ki *KnowledgeItem) GetAll(db *gorm.DB) ([]*KnowledgeItem, error)
- func (ki *KnowledgeItem) GetByID(db *gorm.DB) error
- func (ki *KnowledgeItem) GetItemContent(db *gorm.DB, where string, order string) ([]*KnowledgeItemContent, error)
- func (ki *KnowledgeItem) GetLargeIndexInLevel(db *gorm.DB) (uint64, error)
- func (ki *KnowledgeItem) Save(db *gorm.DB) error
- func (ki *KnowledgeItem) TableName() string
- type KnowledgeItemContent
- type Media
- func (m *Media) BeforeCreate(tx *gorm.DB) (err error)
- func (m *Media) Count(db *gorm.DB, where string, whereArgs []interface{}) (count int64, err error)
- func (m *Media) Create(db *gorm.DB) error
- func (m *Media) Delete(db *gorm.DB) error
- func (m *Media) GetByID(db *gorm.DB) error
- func (m *Media) List(db *gorm.DB, where string, whereArgs []interface{}, offset, limit int) (medias []*Media, err error)
- func (m *Media) TableName() string
- func (m *Media) TotalNumber(db *gorm.DB) (totalMedia int64, err error)
- func (m *Media) Update(db *gorm.DB) (err error)
- type Model
- type Option
- type Post
- func (p *Post) CheckSlug(db *gorm.DB) bool
- func (p *Post) Count(db *gorm.DB, where string, whereArgs []interface{}) (int64, error)
- func (p *Post) Create(db *gorm.DB) error
- func (p *Post) Delete(db *gorm.DB) error
- func (p *Post) GetByID(db *gorm.DB) error
- func (p *Post) List(db *gorm.DB, where string, whereArgs []interface{}, offset, number int, ...) ([]*Post, error)
- func (p *Post) Save(db *gorm.DB) error
- func (p *Post) TableName() string
- func (p *Post) TotalNumber(db *gorm.DB, postType string) (totalPost int64, err error)
- func (p *Post) TotalView(db *gorm.DB) (totalViews int64, err error)
- type PostMeta
- type Subject
- func (s *Subject) CheckSubjectNameExist(db *gorm.DB) bool
- func (s *Subject) Create(db *gorm.DB) error
- func (s *Subject) Delete(db *gorm.DB) error
- func (s *Subject) GetAll(db *gorm.DB) ([]*Subject, error)
- func (s *Subject) GetByID(db *gorm.DB) error
- func (s *Subject) IfSubjectHasChild(db *gorm.DB, subjectID uint64) bool
- func (s *Subject) Save(db *gorm.DB) error
- func (s *Subject) TableName() string
- func (s *Subject) Update(db *gorm.DB) error
- type SubjectRelationships
- type Term
- type TermRelationships
- type TermTaxonomy
- func (t *TermTaxonomy) Count(db *gorm.DB, where string, whereArgs []interface{}) (int64, error)
- func (t *TermTaxonomy) Create(db *gorm.DB) error
- func (t *TermTaxonomy) Delete(db *gorm.DB) error
- func (t *TermTaxonomy) Get(db *gorm.DB, where string, whereArgs []interface{}) ([]*TermTaxonomy, error)
- func (t *TermTaxonomy) GetAllByType(db *gorm.DB, taxomonyType string) ([]*TermTaxonomy, error)
- func (t *TermTaxonomy) GetByTermID(db *gorm.DB) error
- func (t *TermTaxonomy) GetColumnByTermID(db *gorm.DB, columns ...string) error
- func (t *TermTaxonomy) GetTermTaxonomyByTermID(db *gorm.DB) error
- func (t *TermTaxonomy) Save(db *gorm.DB) error
- func (t *TermTaxonomy) TableName() string
- func (t *TermTaxonomy) Update(db *gorm.DB, columns ...string) error
- type User
- func (u *User) Count(db *gorm.DB, where string, whereArgs []interface{}) (int64, error)
- func (u *User) Create(db *gorm.DB) error
- func (u *User) Delete(db *gorm.DB) error
- func (u *User) Encrypt() (err error)
- func (u *User) Get(db *gorm.DB) error
- func (u *User) GetByID(db *gorm.DB) error
- func (u *User) List(db *gorm.DB, where string, whereArgs []interface{}, offset, number int) ([]*User, error)
- func (u *User) TableName() string
- func (u *User) Update(db *gorm.DB) error
Constants ¶
const ( // KnowledgeTypeNote knowledge type of note KnowledgeTypeNote = "note" // KnowledgeTypeDoc knowledge type of document KnowledgeTypeDoc = "doc" )
const ( // PostTypeArticle post type of article PostTypeArticle = "article" // PostTypePage post type of page PostTypePage = "page" // PostStatusPublish post status of published post PostStatusPublish = "publish" // PostStatusDraft post status of draft post PostStatusDraft = "draft" // PostStatusDeleted post status of deleted post PostStatusDeleted = "deleted" )
const DefaultUnCategorizedID = 1
DefaultUnCategorizedID the default category's ID
const KnowledgeItemContentStatusCommon = 0
KnowledgeItemContentStatusCommon knowledge item content not current version
const KnowledgeItemContentStatusCurrent = 1
KnowledgeItemContentStatusCurrent knowledge item content current(published) version
const ResourceTypePicture = "picture"
ResourceTypePicture resource type of picture
const StatusNormal = 1
StatusNormal normal status value
const UsageCover = "cover"
UsageCover usage for cover
const UsageDefault = "common"
UsageDefault default usage
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Knowledge ¶ added in v0.4.0
type Knowledge struct { Model Name string `gorm:"column:name;not null"` Slug string `gorm:"column:slug;not null"` Type string `gorm:"column:type;not null"` Description string `gorm:"column:description;not null"` CoverImage uint64 `gorm:"column:cover_image;not null;default:0"` Status uint8 `gorm:"column:status;not null;default:1"` LastUpdated sql.NullTime `gorm:"column:last_updated;default:null"` }
Knowledge the definition of knowledge base model Note: because of the cover image will be uploaded first by a api, here do not consider to use a association mode
type KnowledgeItem ¶ added in v0.4.0
type KnowledgeItem struct { Model KnowledgeID uint64 `gorm:"column:knowledge_id;not null"` Symbol uint64 `gorm:"column:symbol;not null"` UserID uint64 `gorm:"column:user_id;not null"` Title string `gorm:"column:title;not null"` ContentVersion uint64 `gorm:"column:content_version;not null"` ParentID uint64 `gorm:"column:parent_id;not null;default:0"` Level uint64 `gorm:"column:level;not null;default:0"` Index int64 `gorm:"column:index;not null;default:0"` CommentCount uint64 `gorm:"column:comment_count;not null;default:0"` ViewCount uint64 `gorm:"column:view_count;not null;default:0"` LastPublished sql.NullTime `gorm:"column:last_published;default:null"` ItemContents []KnowledgeItemContent `gorm:"foreignKey:KnowledgeItemID"` }
func (*KnowledgeItem) Create ¶ added in v0.4.0
func (ki *KnowledgeItem) Create(db *gorm.DB) error
Create create a new knowledge item
func (*KnowledgeItem) Delete ¶ added in v0.4.0
func (ki *KnowledgeItem) Delete(db *gorm.DB) error
Delete delete the knowledge item by id
func (*KnowledgeItem) Get ¶ added in v0.4.0
func (ki *KnowledgeItem) Get(db *gorm.DB, where string, whereArgs []interface{}) ([]*KnowledgeItem, int64, error)
Get get all by condition
func (*KnowledgeItem) GetAll ¶ added in v0.4.0
func (ki *KnowledgeItem) GetAll(db *gorm.DB) ([]*KnowledgeItem, error)
GetAll get all knowledge items by knowledge id
func (*KnowledgeItem) GetByID ¶ added in v0.4.0
func (ki *KnowledgeItem) GetByID(db *gorm.DB) error
GetByID get knowledge item by ID
func (*KnowledgeItem) GetItemContent ¶ added in v0.4.0
func (ki *KnowledgeItem) GetItemContent(db *gorm.DB, where string, order string) ([]*KnowledgeItemContent, error)
GetLastContent get item contents
func (*KnowledgeItem) GetLargeIndexInLevel ¶ added in v0.4.0
func (ki *KnowledgeItem) GetLargeIndexInLevel(db *gorm.DB) (uint64, error)
GetLargeIndexInLevel get the largest index value in the same level
func (*KnowledgeItem) Save ¶ added in v0.4.0
func (ki *KnowledgeItem) Save(db *gorm.DB) error
Save update knowledge item
func (*KnowledgeItem) TableName ¶ added in v0.4.0
func (ki *KnowledgeItem) TableName() string
TableName is the knowledge item table name in db
type KnowledgeItemContent ¶ added in v0.4.0
type KnowledgeItemContent struct { ID uint64 `gorm:"primaryKey;autoIncrement;column:id"` KnowledgeItemID uint64 `gorm:"column:knowledge_item_id;not null"` Version uint64 `gorm:"column:version;not null"` Status uint8 `gorm:"column:status;not null;default:0"` Content string `gorm:"column:content;not null"` UpdatedAt time.Time `gorm:"column:updated_time;not null"` }
func (*KnowledgeItemContent) Create ¶ added in v0.4.0
func (kic *KnowledgeItemContent) Create(db *gorm.DB) error
Create save the new version knowledge item content
func (*KnowledgeItemContent) GetByVersion ¶ added in v0.4.0
func (kic *KnowledgeItemContent) GetByVersion(db *gorm.DB) (*KnowledgeItemContent, error)
GetByVersion get knowledge item by version
func (*KnowledgeItemContent) Save ¶ added in v0.4.0
func (kic *KnowledgeItemContent) Save(db *gorm.DB) error
Save update knowledge item content
func (*KnowledgeItemContent) TableName ¶ added in v0.4.0
func (kic *KnowledgeItemContent) TableName() string
TableName is the knowledge item table name in db
type Media ¶
type Media struct { Model UserID uint64 `gorm:"column:upload_user_id;not null"` Title string `gorm:"column:title;not null"` Slug string `gorm:"column:slug;not null"` Description string `gorm:"column:description;not null"` GUID string `gorm:"column:guid;not null"` Type string `gorm:"column:type;not null;default:picture"` MimeType string `gorm:"column:mime_type;not null"` Usage string `gorm:"column:usage;not null"` Status uint64 `gorm:"column:status;not null;default:1"` }
MediaModel the definition of media model
func (*Media) BeforeCreate ¶
BeforeCreate set values before create Set file type by mime-type
func (*Media) List ¶
func (m *Media) List(db *gorm.DB, where string, whereArgs []interface{}, offset, limit int) (medias []*Media, err error)
List get media list
func (*Media) TotalNumber ¶
TotalNumber get total number of media
type Model ¶
type Model struct { ID uint64 `gorm:"primaryKey;autoIncrement;column:id"` CreatedAt time.Time `gorm:"column:created_time;not null"` UpdatedAt time.Time `gorm:"column:updated_time;not null"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_time;DEFAULT null" sql:"index"` }
Model base model
type Option ¶
type Option struct { ID uint64 `gorm:"primaryKey;autoIncrement;column:id"` OptionName string `gorm:"column:option_name;not null"` OptionValue string `gorm:"column:option_value;not null"` Autoload uint64 `gorm:"column:autoload;not null"` }
Option site options
func (*Option) GetAllAutoLoad ¶ added in v0.4.1
GetAllAutoLoad get options need autoload
type Post ¶
type Post struct { Model UserID uint64 `gorm:"column:user_id;not null"` PostType string `gorm:"column:post_type;not null;default:article"` Title string `gorm:"column:title;not null"` ContentMarkdown string `gorm:"column:content_markdown;not null"` ContentHTML string `gorm:"column:content_html;not null"` Slug string `gorm:"column:slug;not null"` ParentID uint64 `gorm:"column:parent_id;not null"` // set to 0 now, use for draft history feature in the future Status string `gorm:"column:status;not null;default:publish"` CommentStatus uint64 `gorm:"column:comment_status;not null;default:1"` IfTop uint64 `gorm:"column:if_top;not null"` GUID string `gorm:"column:guid;not null"` CoverPicture string `gorm:"column:cover_picture;not null"` CommentCount uint64 `gorm:"column:comment_count;not null"` ViewCount uint64 `gorm:"column:view_count;not null"` PostDate sql.NullTime `gorm:"column:posted_time;not null"` }
PostModel is the struct model for post
func (*Post) CheckSlug ¶
PageCheckSlugExist check the slug if already exist ErrRecordNotFound => False exist => True
func (*Post) List ¶
func (p *Post) List(db *gorm.DB, where string, whereArgs []interface{}, offset, number int, order string) ([]*Post, error)
List get post list
func (*Post) TotalNumber ¶
TotalNumber count total number of post by post type
type PostMeta ¶
type PostMeta struct { ID uint64 `gorm:"primaryKey;autoIncrement;column:id"` PostID uint64 `gorm:"column:post_id;not null"` MetaKey string `gorm:"column:meta_key;not null"` MetaValue string `gorm:"column:meta_value;not null"` }
PostMetaModel meta data for post
func (*PostMeta) GetAllByPostID ¶
GetAllByPostID get all meta data by post id
func (*PostMeta) GetOneByPostID ¶
GetOneByPostID get one specific meta by metakey and post id
type Subject ¶
type Subject struct { Model ParentID uint64 `gorm:"column:parent_id;not null"` Name string `gorm:"column:name;not null"` Slug string `gorm:"column:slug;not null"` Description string `gorm:"column:description;not null"` CoverImage uint64 `gorm:"column:cover_image;not null"` IsEnd uint64 `gorm:"column:is_end;not null"` Count uint64 `gorm:"column:count;not null"` LastUpdated sql.NullTime `gorm:"column:last_updated"` }
SubjectModel the definition of subject model
func (*Subject) CheckSubjectNameExist ¶
CheckSubjectNameExist check the subject name if is already exist
func (*Subject) IfSubjectHasChild ¶
IfSubjectHasChild check if subject has children
type SubjectRelationships ¶
type SubjectRelationships struct { ObjectID uint64 `gorm:"column:object_id;not null;primaryKey"` SubjectID uint64 `gorm:"column:subject_id;not null;primaryKey"` OrderNum string `gorm:"column:order_num;not null"` }
SubjectRelationshipsModel `pt_subject_relationships` 's struct
func (*SubjectRelationships) DeleteByCondition ¶
func (s *SubjectRelationships) DeleteByCondition(db *gorm.DB, where string, whereArgs []interface{}) error
DeleteByCondition delete records by condition
func (*SubjectRelationships) GetAllByObjectID ¶
func (s *SubjectRelationships) GetAllByObjectID(db *gorm.DB, objectID uint64) ([]*SubjectRelationships, error)
GetAllByObjectID get article's related subject
func (*SubjectRelationships) TableName ¶
func (s *SubjectRelationships) TableName() string
TableName SubjectRelationshipsModel's binding db name
type Term ¶
type Term struct { ID uint64 `gorm:"column:term_id;not null;primary_key"` Name string `gorm:"column:name;not null"` Slug string `gorm:"column:slug;not null"` Description string `gorm:"column:description;not null"` Count uint64 `gorm:"column:count;not null"` }
Term `pt_terms`'s struct for taxomony info
type TermRelationships ¶
type TermRelationships struct { ObjectID uint64 `gorm:"column:object_id;not null;primaryKey"` TermTaxonomyID uint64 `gorm:"column:term_taxonomy_id;not null;primaryKey"` TermOrder string `gorm:"column:term_order;not null"` }
TermRelationships `pt_term_relationships` 's struct taxomony raltionships with object
func (*TermRelationships) Delete ¶
func (t *TermRelationships) Delete(db *gorm.DB) error
Delete delete a record
func (*TermRelationships) DeleteByCondition ¶
func (t *TermRelationships) DeleteByCondition(db *gorm.DB, where string, whereArgs []interface{}) error
DeleteByCondition delete records by condition
func (*TermRelationships) TableName ¶
func (c *TermRelationships) TableName() string
TableName TermRelationshipsModel's binding db name
type TermTaxonomy ¶
type TermTaxonomy struct { ID uint64 `gorm:"column:term_taxonomy_id;not null;primaryKey"` Term Term `gorm:"foreignKey:TermID;references:ID"` TermID uint64 `gorm:"column:term_id;not null"` ParentTermID uint64 `gorm:"column:parent_term_id;not null"` Level uint64 `gorm:"column:level;not null;default:1"` Taxonomy string `gorm:"column:taxonomy;not null"` TermGroup uint64 `gorm:"column:term_group;default:0;not null"` }
TermTaxonomy `pt_term_taxonomy`'s struct
func (*TermTaxonomy) Create ¶
func (t *TermTaxonomy) Create(db *gorm.DB) error
Create creates a new taxonomy
func (*TermTaxonomy) Get ¶
func (t *TermTaxonomy) Get(db *gorm.DB, where string, whereArgs []interface{}) ([]*TermTaxonomy, error)
Get get all by condition
func (*TermTaxonomy) GetAllByType ¶
func (t *TermTaxonomy) GetAllByType(db *gorm.DB, taxomonyType string) ([]*TermTaxonomy, error)
GetAllByType gets terms and taxonomy_terms by type(category, tag)
func (*TermTaxonomy) GetByTermID ¶
func (t *TermTaxonomy) GetByTermID(db *gorm.DB) error
GetByTermID get term taxonomy by term id
func (*TermTaxonomy) GetColumnByTermID ¶
func (t *TermTaxonomy) GetColumnByTermID(db *gorm.DB, columns ...string) error
func (*TermTaxonomy) GetTermTaxonomyByTermID ¶
func (t *TermTaxonomy) GetTermTaxonomyByTermID(db *gorm.DB) error
GetTermTaxonomyByTermID get taxonomy terms info by term_id
func (*TermTaxonomy) TableName ¶
func (t *TermTaxonomy) TableName() string
TableName TermTaxonomyModel's binding db name
type User ¶
type User struct { Model Username string `gorm:"column:account;unique;not null" validate:"min=1,max=60"` Password string `gorm:"column:password;not null" validate:"min=6,max=255"` Nickname string `gorm:"column:nickname;not null"` Email string `gorm:"column:email;unique"` Avatar string `gorm:"column:avatar"` PageURL string `gorm:"column:page_url"` Status int `gorm:"column:status;default:1" sql:"index"` Roles string `gorm:"column:role;default:subscriber"` }
User user model