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 * 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:"文章列表"` ChartList []*HomeChartListResp `description:"图表列表"` }