Documentation ¶
Index ¶
- func CheckPageSlugExist(pageID uint64, slug string) bool
- func CheckSubjectNameExist(subjectID uint64, name string) bool
- func CheckTaxonomyNameExist(name, taxonomy string) bool
- func CreateSubject(r *SubjectCreateRequest) error
- func CreateTaxonomy(r *TaxonomyCreateRequest) error
- func CreateUser(u *UserCreateRequest) (string, string, error)
- func DeleteMedia(userID uint64) error
- func DeletePost(postType string, articleID uint64) error
- func DeleteSubject(subjectID uint64) error
- func DeleteTaxonomy(termID uint64, taxonomyType string) error
- func DeleteUser(userID int) error
- func GetArticleSubejctID(articleID uint64) ([]uint64, error)
- func GetDefaultOptionNamesByType(settingType string) []string
- func GetMediaByID(ID uint64) (*model.Media, error)
- func GetOptionsByType(settingType string) (map[string]string, error)
- func IfTaxonomyHasChild(termID uint64, taxonomyType string) (bool, error)
- func RestorePost(postID uint64) error
- func TrashPost(postID uint64) error
- func UpdateArticle(a *ArticleUpdateRequest) error
- func UpdateMedia(r *MediaUpdateRequest, userID int) (err error)
- func UpdateOptions(options map[string]interface{}) error
- func UpdatePage(p *PageUpdateRequest) (err error)
- func UpdateSubject(r *SubjectUpdateRequest) error
- func UpdateTaxonomy(r *TaxonomyUpdateRequest, termID uint64) error
- func UpdateUser(u *UserUpdateRequest, userID int) error
- func UpdateUserAvatar(c *gin.Context, userID string, file *multipart.FileHeader) error
- func UpdateUserPassword(u *UserUpdatePasswordRequest, userID int) error
- func UpdateUserStatus(u *UserUpdateStatusRequest, userID int) error
- func UploadMedia(c *gin.Context, userID, usage string, file *multipart.FileHeader) (ID uint64, GUID string, err error)
- type ArticleCreateRequest
- type ArticleCreateResponse
- type ArticleDetail
- type ArticleListRequest
- type ArticleListResponse
- type ArticleUpdateRequest
- type DashboardData
- type ListTheme
- type LoginRequest
- type MediaDetail
- type MediaInfo
- type MediaList
- type MediaListRequest
- type MediaListResponse
- type MediaUpdateRequest
- type MediaUploadResponse
- type OptionListResponse
- type OptionUpdateRequest
- type PageCreateRequest
- type PageCreateResponse
- type PageDetail
- type PageListRequest
- type PageListResponse
- type PageUpdateRequest
- type PostInfo
- type PostList
- type SubjectCreateRequest
- type SubjectDetail
- type SubjectTreeNode
- type SubjectUpdateRequest
- type TaxonomyCreateRequest
- type TaxonomyUpdateRequest
- type TermInfo
- type Token
- type TreeNode
- type UserCreateRequest
- type UserCreateResponse
- type UserInfo
- type UserList
- type UserListRequest
- type UserListResponse
- type UserUpdatePasswordRequest
- type UserUpdateRequest
- type UserUpdateStatusRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPageSlugExist ¶ added in v0.3.0
CheckPageSlugExist check if page slug name exist
func CheckSubjectNameExist ¶ added in v0.3.0
CheckSubjectNameExist check the subject name
func CheckTaxonomyNameExist ¶ added in v0.3.0
CheckTaxonomyNameExist check if taxonomy name are aleady exist
func CreateSubject ¶ added in v0.3.0
func CreateSubject(r *SubjectCreateRequest) error
CreateSubject create a subject
func CreateTaxonomy ¶ added in v0.3.0
func CreateTaxonomy(r *TaxonomyCreateRequest) error
CreateTaxonomy create term taxonomy
func CreateUser ¶ added in v0.3.0
func CreateUser(u *UserCreateRequest) (string, string, error)
CreateUser create a new user
func DeletePost ¶
DeletePost delete post by soft delete Note: meta data was reserved
func DeleteSubject ¶
DeleteSubject delete subject directly
func DeleteTaxonomy ¶
DeleteTaxonomy delete term directly
func GetArticleSubejctID ¶ added in v0.3.0
GetArticleSubejct get article's subject by article id
func GetDefaultOptionNamesByType ¶ added in v0.3.0
GetDefaultOptionsByType get default setting's option name
func GetMediaByID ¶ added in v0.3.0
GetMediaByID get media by ID
func GetOptionsByType ¶
GetOptionsByType get default options by setting type
func IfTaxonomyHasChild ¶
IfTaxonomyHasChild check the taxonomy has children or not
func RestorePost ¶
RestorePost restore the post which had been put to the trash this restore action will set the post as a draft status
func TrashPost ¶
TrashPost put the post into the trash by "delete" button The different between DeleteArticle and TrashPost is that TrashPost just set the status to deleted
func UpdateArticle ¶
func UpdateArticle(a *ArticleUpdateRequest) error
UpdateArticle update article TODO: In this version, article meta data just update description, it should be more than one choise.
func UpdateMedia ¶
func UpdateMedia(r *MediaUpdateRequest, userID int) (err error)
UpdateMedia update media info
func UpdateOptions ¶
UpdateOptions update options
func UpdateSubject ¶
func UpdateSubject(r *SubjectUpdateRequest) error
UpdateSubject udpate subject info
func UpdateTaxonomy ¶
func UpdateTaxonomy(r *TaxonomyUpdateRequest, termID uint64) error
UpdateTaxonomy update term and term taxonomy
func UpdateUser ¶
func UpdateUser(u *UserUpdateRequest, userID int) error
UpdateUser update user info by id
func UpdateUserAvatar ¶
UpdateUserAvatar update user avatar
func UpdateUserPassword ¶
func UpdateUserPassword(u *UserUpdatePasswordRequest, userID int) error
UpdateUserPassword just reset user's password
func UpdateUserStatus ¶
func UpdateUserStatus(u *UserUpdateStatusRequest, userID int) error
UpdateUserStatus update user status
func UploadMedia ¶ added in v0.3.0
func UploadMedia(c *gin.Context, userID, usage string, file *multipart.FileHeader) (ID uint64, GUID string, err error)
UploadMedia upload media and save record
Types ¶
type ArticleCreateRequest ¶ added in v0.3.0
type ArticleCreateRequest struct { Status string `json:"status"` Title string `json:"title"` Content string `json:"content"` ContentHTML string `json:"content_html"` Description string `json:"description"` CommentStatus uint64 `json:"comment_status"` CoverPicture string `json:"cover_picture"` PostedTime string `json:"posted_time"` IfTop uint64 `json:"if_top"` Category []uint64 `json:"category"` Tag []uint64 `json:"tag"` Subject []uint64 `json:"subject"` }
ArticleCreateRequest struct of article create params
type ArticleCreateResponse ¶ added in v0.3.0
ArticleCreateResponse return the new article id and url
func CreateArticle ¶ added in v0.3.0
func CreateArticle(r *ArticleCreateRequest, userID uint64) (*ArticleCreateResponse, error)
CreateArticle create article
type ArticleDetail ¶
type ArticleDetail struct { ID uint64 `json:"id"` Title string `json:"title"` ContentMarkdown string `json:"content_markdown"` Status string `json:"status"` CommentStatus uint64 `json:"comment_status"` IfTop uint64 `json:"if_top"` GUID string `json:"guid"` CoverPicture string `json:"cover_picture"` PostDate string `json:"post_date"` MetaData map[string]interface{} `json:"meta_date"` Category []uint64 `json:"category"` Tag []uint64 `json:"tag"` Subject []uint64 `json:"subject"` }
ArticleDetail struct for article info detail
func GetArticleDetail ¶
func GetArticleDetail(articleID uint64) (*ArticleDetail, error)
GetArticleDetail get article detail by id
type ArticleListRequest ¶ added in v0.3.0
type ArticleListRequest struct { Title string `form:"title"` Page int `form:"page"` Number int `form:"number"` Sort string `form:"sort"` Status string `form:"status"` }
ArticleListRequest is the article list request struct
type ArticleListResponse ¶ added in v0.3.0
type ArticleListResponse struct { TotalCount int64 `json:"totalCount"` TotalPage uint64 `json:"totalPage"` ArticleList []*PostInfo `json:"articleList"` }
ArticleListResponse is the article list response struct
type ArticleUpdateRequest ¶ added in v0.3.0
type ArticleUpdateRequest struct { ID uint64 `json:"id"` Status string `json:"status"` Title string `json:"title"` Content string `json:"content"` ContentHTML string `json:"content_html"` Description string `json:"description"` CommentStatus uint64 `json:"comment_status"` CoverPicture string `json:"cover_picture"` PostedTime string `json:"posted_time"` IfTop uint64 `json:"if_top"` Category []uint64 `json:"category"` Tag []uint64 `json:"tag"` Subject []uint64 `json:"subject"` }
ArticleUpdateRequest struct for update article
type DashboardData ¶ added in v0.2.1
type DashboardData struct { TotalViews int64 TotalComments int64 TotalArticles int64 TotalMedia int64 }
DashboardData some statistics index
func GetDashboardStatisticsData ¶ added in v0.2.1
func GetDashboardStatisticsData() (*DashboardData, error)
GetDashboardStatisticsData get dashboard statistics data TODO store in cache first
type LoginRequest ¶ added in v0.3.0
type LoginRequest struct { Username string `json:"username" binding:"required"` Password string `json:"password" binding:"required"` }
LoginRequest is the login request params struct
type MediaDetail ¶
type MediaDetail struct { MediaInfo Slug string `json:"slug"` Description string `json:"description"` }
MediaDetail media info in detail inclue Mediainfo struct
func GetMediaDetail ¶ added in v0.3.0
func GetMediaDetail(ID uint64) (*MediaDetail, error)
GetMedia return media info if database select success
type MediaInfo ¶
type MediaInfo struct { ID uint64 `json:"id"` Title string `json:"title"` GUID string `json:"url"` Type string `json:"type"` UploadTime string `json:"upload_time"` }
MediaInfo is the media struct for media list
type MediaListRequest ¶ added in v0.3.0
MediaListRequest is the media list request struct
type MediaListResponse ¶ added in v0.3.0
type MediaListResponse struct { TotalCount int64 `json:"totalCount"` MediaList []*MediaInfo `json:"mediaList"` }
MediaListResponse returns total number of media and current page of media
type MediaUpdateRequest ¶ added in v0.3.0
type MediaUpdateRequest struct { ID uint64 `json:"id"` Title string `json:"title"` Slug string `json:"slug"` Description string `json:"description"` }
MediaUpdateRequest is the update media request params struct
type MediaUploadResponse ¶ added in v0.3.0
MediaUploadResponse is the upload media request's response struct
type OptionListResponse ¶ added in v0.3.0
type OptionListResponse struct { Options map[string]string `json:"options"` ExtraData interface{} `json:"extraData"` }
OptionListResponse option list and extra data if exist
func ListOption ¶ added in v0.3.0
func ListOption(settingType string) (*OptionListResponse, error)
ListOption get option list by setting type
type OptionUpdateRequest ¶ added in v0.3.0
type OptionUpdateRequest struct {
Parms map[string]interface{}
}
OptionUpdateRequest update request include params which are dynamitly
type PageCreateRequest ¶ added in v0.3.0
type PageCreateRequest struct { Status string `json:"status"` Title string `json:"title"` Content string `json:"content"` ContentHTML string `json:"content_html"` Description string `json:"description"` CommentStatus uint64 `json:"comment_status"` CoverPicture string `json:"cover_picture"` PostedTime string `json:"posted_time"` Slug string `json:"slug"` PageTemplate string `json:"page_template"` ParentID uint64 `json:"parent_id"` }
PageCreateRequest struct of page create params
type PageCreateResponse ¶ added in v0.3.0
PageCreateResponse return the new page id and url
func CreatePage ¶ added in v0.3.0
func CreatePage(r *PageCreateRequest, userID uint64) (*PageCreateResponse, error)
CreatePage create page
type PageDetail ¶
type PageDetail struct { ID uint64 `json:"id"` Title string `json:"title"` ContentMarkdown string `json:"content_markdown"` Slug string `json:"slug"` ParentID uint64 `json:"parent_id"` Status string `json:"status"` CommentStatus uint64 `json:"comment_status"` GUID string `json:"guid"` CoverPicture string `json:"cover_picture"` PostDate string `json:"post_date"` MetaData map[string]interface{} `json:"meta_date"` }
PageDetail struct for page info detail
func GetPageDetail ¶
func GetPageDetail(pageID uint64) (*PageDetail, error)
GetPageDetail get page detail by id
type PageListRequest ¶ added in v0.3.0
type PageListRequest struct { Title string `form:"title"` Page int `form:"page"` Number int `form:"number"` Sort string `form:"sort"` Status string `form:"status"` }
PageListRequest is the page list request struct
type PageListResponse ¶ added in v0.3.0
type PageListResponse struct { TotalCount int64 `json:"totalCount"` TotalPage uint64 `json:"totalPage"` PageList []*PostInfo `json:"pageList"` }
PageListResponse is the page list response struct
type PageUpdateRequest ¶ added in v0.3.0
type PageUpdateRequest struct { ID uint64 `json:"id"` Status string `json:"status"` Title string `json:"title"` Content string `json:"content"` ContentHTML string `json:"content_html"` Description string `json:"description"` CommentStatus uint64 `json:"comment_status"` CoverPicture string `json:"cover_picture"` PostedTime string `json:"posted_time"` Slug string `json:"slug"` PageTemplate string `json:"page_template"` ParentID uint64 `json:"parent_id"` }
PageUpdateRequest struct of page update params
type PostInfo ¶
type PostInfo struct { ID uint64 `json:"id"` UserID uint64 `json:"userId"` Title string `json:"title"` Status string `json:"status"` PostDate string `json:"post_date"` CommentCount uint64 `json:"comment_count"` ViewCount uint64 `json:"view_count"` }
PostInfo is post info for post list
func ListArticle ¶ added in v0.3.0
func ListArticle(postType string, r *ArticleListRequest) ([]*PostInfo, int64, error)
ListArticle article list
type SubjectCreateRequest ¶ added in v0.3.0
type SubjectCreateRequest struct { Name string `json:"name"` Slug string `json:"slug"` ParentID uint64 `json:"parent_id"` CoverImage uint64 `json:"cover_image"` Description string `json:"description"` }
SubjectCreateRequest struct bind to create subject
type SubjectDetail ¶
type SubjectDetail struct { ID uint64 `json:"id"` ParentID uint64 `json:"parent_id"` Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` CoverImage uint64 `json:"cover_image"` CoverImageStatus string `json:"cover_image_status"` CoverURL string `json:"cover_url"` }
SubjectDetail subject info
func GetSubjectInfo ¶
func GetSubjectInfo(subjectID uint64) (*SubjectDetail, error)
GetSubjectInfo get subject detail by id
type SubjectTreeNode ¶
type SubjectTreeNode struct { ID uint64 `json:"id"` ParentID uint64 `json:"parent_id"` Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` Count uint64 `json:"count"` LastUpdated string `json:"last_updated"` Children []*SubjectTreeNode `json:"children"` }
SubjectTreeNode tree struct of subject list
func GetSubjectList ¶
func GetSubjectList() ([]*SubjectTreeNode, error)
GetSubjectList get subject list by tree struct
type SubjectUpdateRequest ¶ added in v0.3.0
type SubjectUpdateRequest struct { ID uint64 `json:"ID"` Name string `json:"name"` Slug string `json:"slug"` ParentID uint64 `json:"parent_id"` CoverImage uint64 `json:"cover_image"` Description string `json:"description"` }
SubjectUpdateRequest struct bind to update subject
type TaxonomyCreateRequest ¶ added in v0.3.0
type TaxonomyCreateRequest struct { Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` ParentID uint64 `json:"parentId"` Taxonomy string `json:"taxonomy"` // category or tag }
TaxonomyCreateRequest struct to crate taxonomy include category and tag
type TaxonomyUpdateRequest ¶ added in v0.3.0
type TaxonomyUpdateRequest struct { ID uint64 `json:"id"` Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` ParentID uint64 `json:"parentId"` Taxonomy string `json:"taxonomy"` // category or tag }
TaxonomyUpdateRequest param struct to update taxonomy include category and tag
type TermInfo ¶
type TermInfo struct { ID uint64 `json:"term_id"` Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` Pid uint64 `json:"parent_term_id"` Level uint64 `json:"level"` }
TermInfo terms info
func GetTaxonomyInfo ¶
GetTaxonomyInfo get term info by term_id
type TreeNode ¶
type TreeNode struct { ID uint64 `json:"id"` Name string `json:"name"` Slug string `json:"slug"` Description string `json:"description"` Count uint64 `json:"count"` TermID uint64 `json:"term_id"` ParentTermID uint64 `json:"pid"` Level uint64 `json:"level"` Children []*TreeNode `json:"children"` }
TreeNode TaxonomyTree's node struct
func GetTaxonomyList ¶
GetTaxonomyList get taxonomy tree by type and return a tree structure
func GetTaxonomyTree ¶
func GetTaxonomyTree(allTermTaxonomy []*model.TermTaxonomy, pid uint64) []*TreeNode
GetTaxonomyTree return a taxonomy tree
type UserCreateRequest ¶ added in v0.3.0
type UserCreateRequest struct { Account string `form:"account"` Nickname string `form:"nickname"` Email string `form:"email"` Role string `form:"role"` Password string `form:"password"` PasswordAgain string `form:"passwordAgain"` Website string `form:"website"` }
CreateRequest is the create user request params struct
type UserCreateResponse ¶ added in v0.3.0
CreateResponse is the create user request's response struct
type UserInfo ¶
type UserInfo struct { ID uint64 `json:"id"` Accout string `json:"account"` Nickname string `json:"nickname"` Email string `json:"email"` Avatar string `json:"avatar"` Roles string `json:"roles"` Status int `json:"status"` Website string `json:"website"` RegisteredTime string `json:"registered_time"` DeletedTime string `json:"deleted_time"` }
UserInfo is the user struct for user list
func GetUserByToken ¶ added in v0.3.0
GetUserByToken get userInfo by token(JWT)
type UserListRequest ¶ added in v0.3.0
type UserListRequest struct { Username string `form:"username"` Number int `form:"number"` Page int `form:"page"` Status int `form:"status"` Role string `form:"role"` }
ListRequest is the user list request struct
type UserListResponse ¶ added in v0.3.0
type UserListResponse struct { TotalCount int64 `json:"totalCount"` UserList []*UserInfo `json:"userList"` }
ListResponse is the use list response struct
type UserUpdatePasswordRequest ¶ added in v0.3.0
type UserUpdatePasswordRequest struct { ID uint64 `json:"id"` Password string `json:"password" binding:"required"` PasswordAgain string `json:"passwordAgain" binding:"required"` }
UpdatePasswordRequest user for reset user's password during the profile page
type UserUpdateRequest ¶ added in v0.3.0
type UserUpdateRequest struct { ID uint64 `json:"id"` Nickname string `json:"nickname"` Email string `json:"email" binding:"required"` Role string `json:"role" binding:"required"` Website string `json:"website"` }
UpdateRequest is the update user request params struct
type UserUpdateStatusRequest ¶ added in v0.3.0
type UserUpdateStatusRequest struct { ID uint64 `json:"id"` Status int `json:"status" binding:"required"` }
UpdateStatusRequest only use for update user status