|
@@ -13,13 +13,17 @@ func GetBySandboxId(id uint32) (item *Sandbox, err error) {
|
|
|
// GetPageListByWhere 分页获取活动列表
|
|
|
func GetPageListByWhere(condition string, pars []interface{}, startSize, pageSize int) (total int64, list []*Sandbox, err error) {
|
|
|
// 获取查询总数量
|
|
|
- err = global.MYSQL["data"].Model(Sandbox{}).Where(condition, pars...).Count(&total).Error
|
|
|
+ sql := "select count(1) from sandbox AS s JOIN sandbox_classify AS c ON c.sandbox_classify_id = s.sandbox_classify_id WHERE " + condition + " order by s.modify_time desc,s.sandbox_id desc"
|
|
|
+ err = global.MYSQL["data"].Raw(sql, pars...).Scan(&total).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 获取列表数据
|
|
|
- err = global.MYSQL["data"].Model(Sandbox{}).Where(condition, pars...).Order("modify_time desc,sandbox_id desc").Offset(startSize).Limit(pageSize).Find(&list).Error
|
|
|
+ sql = "select s.* from sandbox AS s JOIN sandbox_classify AS c ON c.sandbox_classify_id = s.sandbox_classify_id WHERE " + condition + " order by s.modify_time desc,s.sandbox_id desc"
|
|
|
+ sql += " limit ?,? "
|
|
|
+ pars = append(pars, startSize, pageSize)
|
|
|
+ err = global.MYSQL["data"].Raw(sql, pars...).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|