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 SetAllCommentRead() error
- type BaseModel
- type Comment
- type GithubUserInfo
- type Link
- type Page
- type Post
- func GetPostById(id 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
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 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 GithubUserInfo ¶
type GithubUserInfo struct { AvatarURL string `json:"avatar_url"` Bio string `json:"bio"` Blog string `json:"blog"` Company string `json:"company"` CreatedAt string `json:"created_at"` Email string `gorm:"unique_index;default:null" json:"email"` EventsURL string `json:"events_url"` Followers int `json:"followers"` FollowersURL string `json:"followers_url"` Following int `json:"following"` FollowingURL string `json:"following_url"` GistsURL string `json:"gists_url"` GravatarID string `gorm:"unique_index;default:null" json:"gravatar_id"` Hireable string `json:"hireable"` HTMLURL string `json:"html_url"` ID int `json:"id"` Location string `json:"location"` Login string `gorm:"unique_index" json:"login"` Name string `json:"name"` OrganizationsURL string `json:"organizations_url"` PublicGists int `json:"public_gists"` PublicRepos int `json:"public_repos"` ReceivedEventsURL string `json:"received_events_url"` ReposURL string `json:"repos_url"` SiteAdmin bool `json:"site_admin"` StarredURL string `json:"starred_url"` SubscriptionsURL string `json:"subscriptions_url"` Type string `json:"type"` UpdatedAt string `json:"updated_at"` URL string `gorm:"default:null" json:"url"` UserID uint }
Github User Info
type Link ¶
type Link struct { gorm.Model Name string `json:"name" form:"name" validate:"required"` Url string `json:"url" form:"url" validate:"required,url"` Sort int `gorm:"default:'0'"` //排序 View int //访问次数 }
table link
func MustListLinks ¶
func MustListLinks() []*Link
type Page ¶
type Page struct { gorm.Model Title string `json:"title" form:"title" validate:"required"` // title Body string `json:"body" form:"body"` // body View int `form:"-" json:"-"` // view count IsPublished bool `json:"is_published" form:"is_published"` // published or not CommentTotal int `gorm:"-"` // count of comment LikeTotal int `gorm:"_"` }
table pages
func ListPublishedPage ¶
func (*Page) UpdateView ¶
type Post ¶
type Post struct { BaseModel Title string `json:"title" form:"title" validate:"required"` // title Body string `json:"body" form:"body" validate:"required"` // body View int // view count IsPublished bool `json:"is_published" form:"is_published"` PostTags []*PostTag `gorm:""` Tags []*Tag `gorm:"many2many:post_tags;"` // tags of post Comments []*Comment `gorm:"-"` // comments of post CommentTotal int `gorm:"-"` // count of comment LikeTotal int `gorm:"_"` Keyword string `gorm:"size:255;not null" json:"keyword" form:"keyword" validate:"required"` }
func ListMaxCommentPost ¶
func ListMaxReadPost ¶
func ListPostByArchive ¶
func ListPublishedPost ¶
获取已发布的博文
func MustListMaxCommentPost ¶
func MustListMaxCommentPost() (posts []*Post)
func MustListMaxReadPost ¶
func MustListMaxReadPost() (posts []*Post)
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" json:"email" form:"email"` //邮箱 VerifyState bool `gorm:"default:'0'" json:"verify_state" form:"verify_state" ` //验证状态 SubscribeState bool `gorm:"default:'1'" json:"subscribe_state" form:"subscribe_state" ` //订阅状态 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 ¶
type Tag struct { BaseModel Name string `gorm:"UNIQUE_INDEX;not null" json:"name" form:"name" validate:"required"` // tag name Total int `gorm:"-" json:"total" form:"total"` // count of post Posts []*Post `gorm:"many2many:post_tags;"` }
table tags
func ListTagByPostId ¶
func MustListTag ¶
func MustListTag() []*Tag
type User ¶
type User struct { gorm.Model Email string `gorm:"unique_index;default:null" json:"email" form:"email" validate:"required,email"` //邮箱 Telephone string `gorm:"unique_index;default:null" json:"telephone" form:"telephone" validate:"required"` //手机号码 Password string `gorm:"default:null" json:"password" form:"password" validate:"required"` //密码 VerifyState string `gorm:"default:'0'" json:"verify_state"` //邮箱验证状态 SecretKey string `gorm:"default:null" form:"secret_key" json:"secret_key"` //密钥 OutTime time.Time //过期时间 GithubLoginId string `gorm:"unique_index;default:null" json:"github_login_id"` // github唯一标识 GithubUrl string //github地址 IsAdmin bool //是否是管理员 AvatarUrl string `form:"avatar_url" json:"avatar_url"` // 头像链接 NickName string `form:"nick_name" json:"nick_name"` // 昵称 LockState bool `gorm:"default:'0'"` //锁定状态 ModifyPasswordHash string `gorm:"default:null"` ModifyPasswordTime time.Time `gorm:"default:'1990-01-01 00:00:00'"` GithubUserInfo GithubUserInfo }
table users
func (*User) FirstOrCreate ¶
Click to show internal directories.
Click to hide internal directories.