|
|
@@ -3,6 +3,7 @@ package implement |
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
@@ -26,7 +27,7 @@ func (a ArticleDb) GetArticle(id string) (m *model.Article, err error) { |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
func (a ArticleDb) ArticleCateByTypeId(typeId string) (m *model.Article, err error) { |
|
|
|
func (a ArticleDb) ArticleByTypeId(typeId string) (m *model.Article, err error) { |
|
|
|
m = new(model.Article) |
|
|
|
has, err := a.Db.Where("is_show=1 and type_id=?", typeId).Get(m) |
|
|
|
if err != nil { |
|
|
@@ -44,3 +45,36 @@ func (a ArticleDb) ArticleByCid(cid string) (*[]model.Article, error) { |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (a ArticleDb) FindArticle(page, limit, pid, cateId string) (*[]model.Article, error) { |
|
|
|
var m []model.Article |
|
|
|
sess := a.Db.Where("1=1") |
|
|
|
start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) |
|
|
|
if pid != "" { |
|
|
|
sess.And("pid=?", pid) |
|
|
|
} |
|
|
|
if cateId != "" { |
|
|
|
sess.And("cate_id=?", cateId) |
|
|
|
} |
|
|
|
err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("sort desc,id desc").Find(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
func (a ArticleDb) FindArticleAndTotal(page, limit, pid, cateId string) (*[]model.Article, int64, error) { |
|
|
|
var m []model.Article |
|
|
|
sess := a.Db.Where("1=1") |
|
|
|
start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) |
|
|
|
if pid != "" { |
|
|
|
sess.And("pid=?", pid) |
|
|
|
} |
|
|
|
if cateId != "" { |
|
|
|
sess.And("cate_id=?", cateId) |
|
|
|
} |
|
|
|
count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("sort desc,id desc").FindAndCount(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, count, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, count, nil |
|
|
|
} |