12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(1) AS count
- FROM cygx_article AS a
- WHERE a.publish_status=1 `
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
- FROM cygx_article AS a
- WHERE a.publish_status=1 `
- if condition != "" {
- sql += condition
- }
- sql += ` ORDER BY publish_date DESC,article_id DESC LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type HomeListResp struct {
- HaveResearch bool `description:"是否有研选权限"`
- Paging *paging.PagingItem
- List []*HomeArticle
- }
- type HomeArtAndChartListResp struct {
- HaveResearch bool `description:"是否有研选权限"`
- Paging *paging.PagingItem
- List []*HomeArticle `description:"文章列表"`
- }
|