Documentation ¶
Index ¶
- Variables
- func CountComment() int
- func CountPage() int
- func CountPost() int
- func CountPostByArchive(year, month string) (count int, err error)
- func CountPostByTag(tag string) (count int, err error)
- func CountSubscriber() (int, error)
- func CountTag() int
- func DeletePostTagByPostId(postId uint) error
- func InitDB() (*gorm.DB, error)
- func SetAllCommentRead() error
- type BaseModel
- type Comment
- type Link
- type Page
- type Post
- func GetPostById(id string) (*Post, error)
- func ListAllPost(tag string) ([]*Post, error)
- func ListMaxCommentPost() (posts []*Post, err error)
- func ListMaxReadPost() (posts []*Post, err error)
- func ListPostByArchive(year, month string, pageIndex, pageSize int) ([]*Post, error)
- func ListPublishedPost(tag string, pageIndex, pageSize int) ([]*Post, error)
- func MustListMaxCommentPost() (posts []*Post)
- func MustListMaxReadPost() (posts []*Post)
- type PostTag
- type QrArchive
- type SmmsFile
- type Subscriber
- type Tag
- type User
- func (user *User) FirstOrCreate() (*User, error)
- func (user *User) Insert() error
- func (user *User) Lock() error
- func (user *User) Update() error
- func (user *User) UpdateEmail(email string) error
- func (user *User) UpdateGithubUserInfo() error
- func (user *User) UpdateProfile(avatarUrl, nickName string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func CountComment ¶
func CountComment() int
func CountPostByArchive ¶
func CountPostByTag ¶
func CountSubscriber ¶
func DeletePostTagByPostId ¶
func SetAllCommentRead ¶
func SetAllCommentRead() error
Types ¶
type Comment ¶
type Comment struct { BaseModel UserID uint // 用户id Content string // 内容 PostID uint // 文章id ReadState bool `gorm:"default:'0'"` // 阅读状态 //Replies []*Comment // 评论 NickName string `gorm:"-"` AvatarUrl string `gorm:"-"` GithubUrl string `gorm:"-"` }
table comments
func ListCommentByPostID ¶
func ListUnreadComment ¶
func MustListUnreadComment ¶
func MustListUnreadComment() []*Comment
type Link ¶
type Link struct { gorm.Model Name string //名称 Url string //地址 Sort int `gorm:"default:'0'"` //排序 View int //访问次数 }
table link
func GetLinkById ¶
func MustListLinks ¶
func MustListLinks() []*Link
type Page ¶
type Page struct { BaseModel Title string // title Body string // body View int // view count IsPublished bool // published or not }
table pages
func GetPageById ¶
func ListAllPage ¶
func ListPublishedPage ¶
func (*Page) UpdateView ¶
type Post ¶
type Post struct { BaseModel Title string // title Body string // body View int // view count IsPublished bool // published or not Tags []*Tag `gorm:"-"` // tags of post Comments []*Comment `gorm:"-"` // comments of post CommentTotal int `gorm:"-"` // count of comment }
table posts
func GetPostById ¶
func ListAllPost ¶
func ListMaxCommentPost ¶
func ListMaxReadPost ¶
func ListPostByArchive ¶
func ListPublishedPost ¶
func MustListMaxCommentPost ¶
func MustListMaxCommentPost() (posts []*Post)
func MustListMaxReadPost ¶
func MustListMaxReadPost() (posts []*Post)
func (*Post) UpdateView ¶
type QrArchive ¶
type QrArchive struct { ArchiveDate time.Time //month Total int //total Year int // year Month int // month }
query result
func ListPostArchives ¶
func MustListPostArchives ¶
func MustListPostArchives() []*QrArchive
type SmmsFile ¶
type Subscriber ¶
type Subscriber struct { gorm.Model Email string `gorm:"unique_index"` //邮箱 VerifyState bool `gorm:"default:'0'"` //验证状态 SubscribeState bool `gorm:"default:'1'"` //订阅状态 OutTime time.Time //过期时间 SecretKey string // 秘钥 Signature string //签名 }
table subscribe
func GetSubscriberByEmail ¶
func GetSubscriberByEmail(mail string) (*Subscriber, error)
func GetSubscriberById ¶
func GetSubscriberById(id uint) (*Subscriber, error)
func GetSubscriberBySignature ¶
func GetSubscriberBySignature(key string) (*Subscriber, error)
func ListSubscriber ¶
func ListSubscriber(invalid bool) ([]*Subscriber, error)
func (*Subscriber) Update ¶
func (s *Subscriber) Update() error
type Tag ¶
table tags
func ListAllTag ¶
func ListTagByPostId ¶
func MustListTag ¶
func MustListTag() []*Tag
type User ¶
type User struct { gorm.Model Email string `gorm:"unique_index;default:null"` //邮箱 Telephone string `gorm:"unique_index;default:null"` //手机号码 Password string `gorm:"default:null"` //密码 VerifyState string `gorm:"default:'0'"` //邮箱验证状态 SecretKey string `gorm:"default:null"` //密钥 OutTime time.Time //过期时间 GithubLoginId string `gorm:"unique_index;default:null"` // github唯一标识 GithubUrl string //github地址 IsAdmin bool //是否是管理员 AvatarUrl string // 头像链接 NickName string // 昵称 LockState bool `gorm:"default:'0'"` //锁定状态 }
table users
func GetUserByUsername ¶
func (*User) FirstOrCreate ¶
func (*User) UpdateEmail ¶
func (*User) UpdateGithubUserInfo ¶
func (*User) UpdateProfile ¶
Click to show internal directories.
Click to hide internal directories.