Documentation ¶
Index ¶
- Constants
- Variables
- func AddArticle(article *Article) error
- func AddArticles(articles []*Article) error
- func AddRepo(repo *Repo) error
- func AddTag(tag Tag) error
- func AddTags(tags []*Tag) error
- func CreateUser(user *User) error
- func DeleteArticlesByRepo(repoName string) error
- func DeleteArticlesByTag(repoName string, tagName string) error
- func DeleteRepo(repoName string) error
- func DeleteTag(repoName string, tagName string) error
- func DeleteTagsByRepo(repoName string) error
- func GetAllRepoNames() ([]string, error)
- func GetArticleList(repoName string, tagName string) ([]string, error)
- func GetCurrentRepo(userID uint64) (string, error)
- func GetTagsBySearchName(repoName, tagName string) ([]string, error)
- func GetTopTagInfosByRepo(repoName string) ([]string, error)
- func Init()
- func SetCurrentRepo(userID uint64, repo string) error
- func SetStatus(userID uint64, status int)
- func TruncateArticles() error
- func TruncateRepo() (err error)
- func TruncateTags() error
- func UpdateArticle(id uint64, title string, html string) error
- func UpdateUser(userID uint64, val map[string]interface{}) error
- func UpdateUserAllowedRepos(userID uint64, repos []string) error
- type Article
- type ArticleTagInfo
- type Articles
- type Repo
- type Tag
- type TagView
- type User
- type UserApplyInfo
Constants ¶
View Source
const ( // 未激活 STATUS_NOT_ACTIVE = iota // 申请中 STATUS_APPLYING // 激活 STATUS_ACTIVE // 禁用 STATUS_BANNED )
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func DeleteArticlesByRepo ¶
DeleteArticlesByRepo 删除该 Repo 下的 Article
func DeleteArticlesByTag ¶
DeleteArticlesByTagID 删除该 Tag 下的 Article
func DeleteRepo ¶
func DeleteTagsByRepo ¶
DeleteTagsByRepo 清空某个 repo 下的 Tags
func GetAllRepoNames ¶
func GetArticleList ¶
GetArticleList 根据仓库名和标签名获取 Article 列表信息
func GetTagsBySearchName ¶
GetTagsBySearchName 根据 repo 名和 tagName 搜索 Tags
func GetTopTagInfosByRepo ¶
GetTopTagInfosByRepo 根据 repo 名获取所有一级标签的名称
func TruncateRepo ¶
func TruncateRepo() (err error)
func UpdateArticle ¶
UpdateArticle 更新文章
func UpdateUserAllowedRepos ¶
UpdateUserAllowedRepos 授予用户可访问的仓库列表
Types ¶
type Article ¶
type Article struct { ID uint64 `gorm:"primary_key"` Title string `gorm:"type:varchar(100);index:title;not null"` // 文章标题 Path string `gorm:"type:varchar(200);not null"` // 文件路径 RawPath string `gorm:"type:varchar(200);not null"` // 原始文件路径 HTML string `gorm:"type:text"` // Markdown 渲染后的 HTML TagName string RepoName string Tag Tag `gorm:"foreignkey:TagName;association_foreignkey:Name;PRELOAD:false;save_associations:false"` // 标签 Repo Repo `gorm:"foreignkey:RepoName;association_foreignkey:Name;PRELOAD:false;save_associations:false"` // 仓库 }
Article 文章
func GetArticle ¶
GetArticle 通过仓库名、标签名、文章名获取 Article
type ArticleTagInfo ¶
type ArticleTagInfo struct { TagName string `gorm:"column:tag_name" json:"tag"` ArticleName string `gorm:"column:title" json:"article"` }
ArticleTagInfo 标签-文章
func GetArticlesBySearchParam ¶
func GetArticlesBySearchParam(repoName string, articleName string) ([]ArticleTagInfo, error)
GetArticlesBySearchParam 通过仓库名、文章名搜索 Articles
type Repo ¶
type Tag ¶
type Tag struct { ID uint64 `gorm:"primary_key"` Path string `gorm:"type:varchar(200);index:path;not null"` // Tag 目录路径 Name string `gorm:"type:varchar(200);index:name;not null"` // 标签名称(多级拼合) ParentPath sql.NullString `gorm:"type:varchar(200);index:parent_path;default: null"` // 父标签路径 RepoName string Repo Repo `gorm:"foreignkey:RepoName;association_foreignkey:Name;PRELOAD:false;save_associations:false"` }
Tag 标签
func GetRootTagsByRepo ¶
GetRootTagsByRepo 根据 repo 名获取所有一级标签的 Tag 信息
func GetTagsByRepoName ¶
GetTagsByRepo 根据 repo 名获取所有 Tag 信息
type User ¶
type User struct { ID uint64 `gorm:"primary_key"` Email string `gorm:"type:varchar(100);unique_index"` NickName string `gorm:"size:30"` Password string `json:"-"` IsAdmin bool Repos string `json:"-"` CurrentRepoName string `json:"current_repo"` RepoNames []string `gorm:"-" json:"repos"` ApplyMessage string `json:"-"` Status int }
User 用户
func GetAvailableUserByID ¶
GetAvailableUserByID 用ID获取可登录用户
func GetUserByEmail ¶
GetUserByEmail 根据 Email 获取 User
func (*User) CheckPassword ¶
CheckPassword 校验密码
type UserApplyInfo ¶
func GetApplyingUserInfo ¶
func GetApplyingUserInfo() ([]UserApplyInfo, error)
GetApplyingUserInfo 获取申请的用户信息
Click to show internal directories.
Click to hide internal directories.