1234567891011121314151617181920212223242526272829303132333435363738 |
- package models
- import (
- "fmt"
- "rdluck_tools/orm"
- "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 ?,? `
- fmt.Println(sql)
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type HomeListResp struct {
- Paging *paging.PagingItem
- List []*HomeArticle
- }
|