Documentation ¶
Index ¶
- func DB() *gorm.DB
- func ScopesCursorID(id int64) func(db *gorm.DB) *gorm.DB
- func ScopesCursorRank(rank float64) func(db *gorm.DB) *gorm.DB
- func ScopesTag(tags []int64) func(db *gorm.DB) *gorm.DB
- type Article
- func (article *Article) GetArticle(limit, offset, tag int, order string) (articles []Article)
- func (article *Article) GetArticleByID(id int)
- func (article *Article) GetArticleByURL(url string)
- func (article *Article) GetArticleCursorByID(id, limit int, tags []int64) (articles []Article)
- func (article *Article) GetArticleCursorByRank(rank float64, limit int, tags []int64) (articles []Article)
- func (article *Article) GetHotArticleByTag(limit, offset, tag int) (articles []Article)
- func (article *Article) GetNewArticleByTag(limit, offset, tag int) (articles []Article)
- func (article *Article) Hot(limit, offset int) (articles []Article)
- func (article *Article) New(limit, offset int) (articles []Article)
- func (article *Article) Save()
- type Media
- type Post
- type Tag
- func (tag *Tag) GetAllTags() (tags []Tag)
- func (tag *Tag) GetTagByID(id int)
- func (tag *Tag) GetTagByName(name string)
- func (tag *Tag) GetTagsByIDS(ids []int64) (tags []Tag)
- func (tag *Tag) GetTagsByTitle(name string) (tags []Tag)
- func (tag *Tag) GetTagsByType(name string) (tags []Tag)
- func (tag *Tag) Save()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScopesCursorID ¶
ScopesCursorID 生成ID查询条件
func ScopesCursorRank ¶
ScopesCursorRank 生成rank查询条件
Types ¶
type Article ¶
type Article struct { ID uint `gorm:"primary_key"` Title string // 标题 Author string // 作者 Cover string // 封面 Intro string // 介绍 PubAt time.Time `sql:"index"` // 微信文章发布时间 MediaID uint // Media Media Like int64 `gorm:"default:0"` Hate int64 `gorm:"default:0"` View int64 `gorm:"default:0"` // 点击次数,通过它进行计算排名 URL string `gorm:"type:varchar(255);unique_index"` // 微信文章地址 Rank float64 `sql:"index"` // 排行 Tags pq.Int64Array `gorm:"type:int[]"` // 标签 State int CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
Article 文章列表
func (*Article) GetArticle ¶
GetArticle 获取文章
func (*Article) GetArticleByID ¶
GetArticleByID 获取Article
func (*Article) GetArticleByURL ¶
GetArticleByURL 通过url获取Article 如果没有的话进行初始化 (注:此url由文章详细页获得)
func (*Article) GetArticleCursorByID ¶
GetArticleCursorByID 以ID为游标获取数据
func (*Article) GetArticleCursorByRank ¶
func (article *Article) GetArticleCursorByRank(rank float64, limit int, tags []int64) (articles []Article)
GetArticleCursorByRank 以Rank为游标获取数据
func (*Article) GetHotArticleByTag ¶
GetHotArticleByTag 获取文章
func (*Article) GetNewArticleByTag ¶
GetNewArticleByTag 获取文章
type Media ¶
type Media struct { ID uint `gorm:"primary_key"` AppID string `gorm:"type:varchar(100);unique_index"` AppName string Cover string Intro string State int CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` Tags pq.Int64Array `gorm:"type:int[]"` // 标签(文章继承) Articles []Article }
Media 微信公众号
func (*Media) GetMediaByAppID ¶
GetMediaByAppID appID 获取公众号
type Post ¶
type Post struct { ID uint `gorm:"primary_key"` URL string `gorm:"type:varchar(255);unique_index"` ArticleURL string State int CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
Post has and belongs to many languages, use `Post_languages` as join table
func (*Post) GetPostByURL ¶
GetPostByURL 通过url获取post 如果没有的话进行初始化 (注:此url由文章详细页获得)
type Tag ¶
type Tag struct { ID uint `gorm:"primary_key"` Pid uint IsShow int Type string Title string Name string `gorm:"type:varchar(100);unique_index"` Intro string CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
Tag 标签属性 (不存在相同的标签)
func (*Tag) GetTagsByIDS ¶
GetTagsByIDS 通过ID获取标签
func (*Tag) GetTagsByTitle ¶
GetTagsByTitle 通过属性获取标签
func (*Tag) GetTagsByType ¶
GetTagsByType 通过属性获取标签
Click to show internal directories.
Click to hide internal directories.