Documentation ¶
Index ¶
- Variables
- func CacheFlushAll()
- func CacheWarmUp()
- func ChildCommentCacheDel(parentID uint)
- func ChildCommentCacheSave(parentID uint, childID uint)
- func CommentCacheDel(comment *Comment)
- func CommentCacheSave(comment *Comment) error
- func ContainsComment(comments []Comment, targetID uint) bool
- func ContainsCookedComment(comments []CookedComment, targetID uint) bool
- func CreateComment(comment *Comment) error
- func CreatePage(page *Page) error
- func CreateSite(site *Site) error
- func CreateUser(user *User) error
- func DB() *gorm.DB
- func DelCache(name string) error
- func DelComment(comment *Comment) error
- func DelCommentChildren(parentID uint) error
- func DelPage(page *Page) error
- func DelSite(site *Site) error
- func DelUser(user *User) error
- func FindAndStoreCache(name string, dest interface{}, queryDBResult func() interface{}) error
- func FindCache(name string, dest interface{}) error
- func FindUserIdsByEmail(email string) []uint
- func GetAllAdminIDs() []uint
- func GetTitleByURL(url string) (string, error)
- func GetUserAllCommentIDs(userID uint) []uint
- func GetVoteNum(targetID uint, voteType string) int
- func GetVoteNumUpDown(targetID uint, voteTo string) (int, int)
- func IsAdminUser(userID uint) bool
- func IsAdminUserByNameEmail(name string, email string) bool
- func MigrateModels()
- func PageCacheDel(page *Page)
- func PageCacheSave(page *Page) error
- func SetDB(db *gorm.DB)
- func SiteCacheDel(site *Site)
- func SiteCacheSave(site *Site) error
- func StoreCache(name string, source interface{}) error
- func SyncFromConf()
- func UpdateComment(comment *Comment) error
- func UpdatePage(page *Page) error
- func UpdateSite(site *Site) error
- func UpdateUser(user *User) error
- func UserCacheDel(user *User)
- func UserCacheSave(user *User) error
- func UserNotifyMarkAllAsRead(userID uint) error
- type Artran
- type Comment
- func (c *Comment) FetchPage() Page
- func (c *Comment) FetchSite() Site
- func (c *Comment) FetchUser() User
- func (c *Comment) GetLinkToReply(notifyKey ...string) string
- func (c Comment) IsAllowReply() bool
- func (c Comment) IsEmpty() bool
- func (c *Comment) ToArtran() Artran
- func (c *Comment) ToCooked() CookedComment
- func (c *Comment) ToCookedForEmail() CookedCommentForEmail
- type CookedComment
- type CookedCommentForEmail
- type CookedNotify
- type CookedPage
- type CookedSite
- type CookedUser
- type CookedUserForAdmin
- type Notify
- func (n *Notify) FetchComment() Comment
- func (n *Notify) FetchUser() User
- func (n *Notify) GenerateKey()
- func (n *Notify) GetParentComment() Comment
- func (n *Notify) GetReadLink() string
- func (n Notify) IsEmpty() bool
- func (n *Notify) SetComment(comment Comment)
- func (n *Notify) SetEmailed() error
- func (n *Notify) SetInitial() error
- func (n *Notify) SetRead() error
- func (n *Notify) ToCooked() CookedNotify
- type Page
- type Site
- type User
- type Vote
- type VoteType
Constants ¶
This section is empty.
Variables ¶
View Source
var (
CacheFindGroup = new(singleflight.Group)
)
Functions ¶
func ChildCommentCacheDel ¶
func ChildCommentCacheDel(parentID uint)
func ChildCommentCacheSave ¶
缓存 父ID=>子ID 评论数据
func CommentCacheDel ¶
func CommentCacheDel(comment *Comment)
func CommentCacheSave ¶
func ContainsComment ¶
func ContainsCookedComment ¶
func ContainsCookedComment(comments []CookedComment, targetID uint) bool
func CreateComment ¶
func CreatePage ¶
func CreateSite ¶
func CreateUser ¶
func DelComment ¶
func FindAndStoreCache ¶
func GetAllAdminIDs ¶
func GetAllAdminIDs() []uint
func GetTitleByURL ¶
func GetUserAllCommentIDs ¶
func IsAdminUser ¶
func IsAdminUserByNameEmail ¶
func MigrateModels ¶
func MigrateModels()
func PageCacheDel ¶
func PageCacheDel(page *Page)
func PageCacheSave ¶
func SiteCacheDel ¶
func SiteCacheDel(site *Site)
func SiteCacheSave ¶
func StoreCache ¶
func SyncFromConf ¶
func SyncFromConf()
func UpdatePage ¶
func UpdateSite ¶
func UpdateUser ¶
func UserCacheDel ¶
func UserCacheDel(user *User)
func UserCacheSave ¶
func UserNotifyMarkAllAsRead ¶
Types ¶
type Artran ¶
type Artran struct { ID string `json:"id"` Rid string `json:"rid"` Content string `json:"content"` UA string `json:"ua"` IP string `json:"ip"` IsCollapsed string `json:"is_collapsed"` // bool => string "true" or "false" IsPending string `json:"is_pending"` // bool IsPinned string `json:"is_pinned"` // bool // vote VoteUp string `json:"vote_up"` VoteDown string `json:"vote_down"` // date CreatedAt string `json:"created_at"` UpdatedAt string `json:"updated_at"` // user Nick string `json:"nick"` Email string `json:"email"` Link string `json:"link"` BadgeName string `json:"badge_name"` BadgeColor string `json:"badge_color"` // page PageKey string `json:"page_key"` PageTitle string `json:"page_title"` PageAdminOnly string `json:"page_admin_only"` // bool // site SiteName string `json:"site_name"` SiteUrls string `json:"site_urls"` }
数据行囊 (n 个 Artran 组成一个 Artrans) Fields All String type (FAS)
type Comment ¶
type Comment struct { gorm.Model Content string PageKey string `gorm:"index;size:255"` SiteName string `gorm:"index;size:255"` UserID uint `gorm:"index"` UA string IP string Rid uint `gorm:"index"` // 父评论 ID IsCollapsed bool `gorm:"default:false"` // 折叠 IsPending bool `gorm:"default:false"` // 待审 IsPinned bool `gorm:"default:false"` // 置顶 VoteUp int VoteDown int // contains filtered or unexported fields }
func FindCommentChildren ¶
func FindCommentChildrenShallow ¶
(Cached:parent-comments)
func (*Comment) GetLinkToReply ¶
获取评论回复链接
func (Comment) IsAllowReply ¶
func (*Comment) ToCooked ¶
func (c *Comment) ToCooked() CookedComment
func (*Comment) ToCookedForEmail ¶
func (c *Comment) ToCookedForEmail() CookedCommentForEmail
type CookedComment ¶
type CookedComment struct { ID uint `json:"id"` Content string `json:"content"` ContentMarked string `json:"content_marked"` UserID uint `json:"user_id"` Nick string `json:"nick"` EmailEncrypted string `json:"email_encrypted"` Link string `json:"link"` UA string `json:"ua"` Date string `json:"date"` IsCollapsed bool `json:"is_collapsed"` IsPending bool `json:"is_pending"` IsPinned bool `json:"is_pinned"` IsAllowReply bool `json:"is_allow_reply"` Rid uint `json:"rid"` BadgeName string `json:"badge_name"` BadgeColor string `json:"badge_color"` Visible bool `json:"visible"` VoteUp int `json:"vote_up"` VoteDown int `json:"vote_down"` PageKey string `json:"page_key"` PageURL string `json:"page_url"` SiteName string `json:"site_name"` }
func CookAllComments ¶
func CookAllComments(comments []Comment) []CookedComment
type CookedCommentForEmail ¶
type CookedCommentForEmail struct { CookedComment Content string `json:"content"` ContentRaw string `json:"content_raw"` Nick string `json:"nick"` Email string `json:"email"` IP string `json:"ip"` Datetime string `json:"datetime"` Date string `json:"date"` Time string `json:"time"` PageKey string `json:"page_key"` PageTitle string `json:"page_title"` Page CookedPage `json:"page"` SiteName string `json:"site_name"` Site CookedSite `json:"site"` }
type CookedNotify ¶
type CookedNotify struct { ID uint `json:"id"` UserID uint `json:"user_id"` CommentID uint `json:"comment_id"` IsRead bool `json:"is_read"` IsEmailed bool `json:"is_emailed"` ReadLink string `json:"read_link"` }
func FindUnreadNotifies ¶
func FindUnreadNotifies(userID uint) []CookedNotify
type CookedPage ¶
type CookedPage struct { ID uint `json:"id"` AdminOnly bool `json:"admin_only"` Key string `json:"key"` URL string `json:"url"` Title string `json:"title"` SiteName string `json:"site_name"` VoteUp int `json:"vote_up"` VoteDown int `json:"vote_down"` PV int `json:"pv"` }
func CookAllPages ¶
func CookAllPages(pages []Page) []CookedPage
type CookedSite ¶
type CookedSite struct { ID uint `json:"id"` Name string `json:"name"` Urls []string `json:"urls"` UrlsRaw string `json:"urls_raw"` FirstUrl string `json:"first_url"` }
func FindAllSitesCooked ¶
func FindAllSitesCooked() []CookedSite
type CookedUser ¶
type CookedUser struct { ID uint `json:"id"` Name string `json:"name"` Email string `json:"email"` Link string `json:"link"` BadgeName string `json:"badge_name"` BadgeColor string `json:"badge_color"` IsAdmin bool `json:"is_admin"` SiteNames []string `json:"site_names"` SiteNamesRaw string `json:"site_names_raw"` ReceiveEmail bool `json:"receive_email"` }
type CookedUserForAdmin ¶
type CookedUserForAdmin struct { CookedUser LastIP string `json:"last_ip"` LastUA string `json:"last_ua"` IsInConf bool `json:"is_in_conf"` CommentCount int64 `json:"comment_count"` }
type Notify ¶
type Notify struct { gorm.Model UserID uint `gorm:"index"` // 通知对象 (接收通知的用户 ID) CommentID uint `gorm:"index"` // 待查看的评论 IsRead bool ReadAt *time.Time IsEmailed bool EmailAt *time.Time Key string `gorm:"index;size:255"` // contains filtered or unexported fields }
func FindCreateNotify ¶
func FindNotifyByKey ¶
func (*Notify) FetchComment ¶
func (*Notify) GetParentComment ¶
func (*Notify) GetReadLink ¶
func (*Notify) SetComment ¶
func (*Notify) SetEmailed ¶
func (*Notify) SetInitial ¶
func (*Notify) ToCooked ¶
func (n *Notify) ToCooked() CookedNotify
type Page ¶
type Page struct { gorm.Model Key string `gorm:"index;size:255"` // 页面 Key(一般为不含 hash/query 的完整 url) Title string AdminOnly bool SiteName string `gorm:"index;size:255"` VoteUp int VoteDown int PV int // contains filtered or unexported fields }
func FindPageByID ¶
func (Page) ToCooked ¶
func (p Page) ToCooked() CookedPage
type Site ¶
func FindCreateSite ¶
func FindSiteByID ¶
func (Site) ToCooked ¶
func (s Site) ToCooked() CookedSite
type User ¶
type User struct { gorm.Model Name string `gorm:"index;size:255"` Email string `gorm:"index;size:255"` Link string Password string BadgeName string BadgeColor string LastIP string LastUA string IsAdmin bool SiteNames string ReceiveEmail bool `gorm:"default:true"` // 配置文件中添加的 IsInConf bool }
func GetAllAdmins ¶
func GetAllAdmins() []User
func (*User) SetPasswordEncrypt ¶
func (User) ToCooked ¶
func (u User) ToCooked() CookedUser
func (User) ToCookedForAdmin ¶
func (u User) ToCookedForAdmin() CookedUserForAdmin
Source Files ¶
Click to show internal directories.
Click to hide internal directories.