|
@@ -200,17 +200,30 @@ func GetPushReportListByClassifyIds(classifyFirstIds, classifySecondIds, classif
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetPushReportCount() (count int, err error) {
|
|
|
+func GetPushReportCount(classifyIds []int) (count int, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := ` SELECT COUNT(*) AS count FROM report_push_status WHERE state=1 AND report_type=1 `
|
|
|
- err = o.Raw(sql).QueryRow(&count)
|
|
|
+ var pars []interface{}
|
|
|
+ if len(classifyIds) > 0 {
|
|
|
+ sql += " AND (classify_id_first IN (%s) OR classify_id_second IN (%s) OR classify_id_third IN (%s))"
|
|
|
+ sql = fmt.Sprintf(sql, utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)))
|
|
|
+ pars = append(pars, classifyIds, classifyIds, classifyIds)
|
|
|
+ }
|
|
|
+ err = o.Raw(sql, pars...).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-func GetPushReportListByPage(startSize, pageSize int) (items []*ReportPushView, err error) {
|
|
|
+func GetPushReportListByPage(classifyIds []int, startSize, pageSize int) (items []*ReportPushView, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := ` SELECT * FROM report_push_status WHERE state=1 AND report_type=1 ORDER BY publish_time DESC LIMIT ?,? `
|
|
|
- _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
|
|
|
+ sql := ` SELECT * FROM report_push_status WHERE state=1 AND report_type=1 `
|
|
|
+ var pars []interface{}
|
|
|
+ if len(classifyIds) > 0 {
|
|
|
+ sql += ` AND (classify_id_first IN (%s) OR classify_id_second IN (%s) OR classify_id_third IN (%s)) `
|
|
|
+ sql = fmt.Sprintf(sql, utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)), utils.GetOrmReplaceHolder(len(classifyIds)))
|
|
|
+ pars = append(pars, classifyIds, classifyIds, classifyIds)
|
|
|
+ }
|
|
|
+ sql += ` ORDER BY publish_time DESC LIMIT ?,? `
|
|
|
+ _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|