|
@@ -24,7 +24,7 @@ INNER JOIN
|
|
|
SELECT classify_id_first, max( publish_time ) AS max_publish_time
|
|
|
FROM report
|
|
|
WHERE
|
|
|
- state = 2
|
|
|
+ state IN (2, 6)
|
|
|
AND classify_name_first !="权益研报"
|
|
|
AND classify_id_second IN ?
|
|
|
GROUP BY
|
|
@@ -32,7 +32,7 @@ GROUP BY
|
|
|
) t2
|
|
|
ON t1.classify_id_first = t2.classify_id_first AND
|
|
|
t1.publish_time = t2.max_publish_time
|
|
|
- WHERE t1.state = 2
|
|
|
+ WHERE t1.state IN (2, 6)
|
|
|
AND t1.classify_name_first !="权益研报"
|
|
|
AND t1.classify_id_second IN ?`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, classifyIdSeconds).Scan(&reportList).Error
|
|
@@ -43,7 +43,7 @@ GROUP BY
|
|
|
func GetReportsByClassifyIdSecondsAndDate(classifyIdSeconds []int, publishTime string) (reportList []*Report, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_name_first").
|
|
|
- Where("classify_id_second in (?) and state = 2 and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
|
|
|
+ Where("classify_id_second in (?) and state IN (2, 6) and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -51,7 +51,7 @@ func GetReportsByClassifyIdSecondsAndDate(classifyIdSeconds []int, publishTime s
|
|
|
func GetListByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int, offset, limit int) (reportList []*Report, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
|
- Where("id in (?) and classify_id_first=? and state = 2 ", ids, classifyIdFirst).
|
|
|
+ Where("id in (?) and classify_id_first=? and state IN (2, 6) ", ids, classifyIdFirst).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -63,7 +63,7 @@ func GetListByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int, offset, limi
|
|
|
func GetListCountByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int) (total int64, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
|
- Where("id in (?) and classify_id_first=? and state = 2 ", ids, classifyIdFirst).
|
|
|
+ Where("id in (?) and classify_id_first=? and state IN (2, 6) ", ids, classifyIdFirst).
|
|
|
Count(&total).Error
|
|
|
return
|
|
|
}
|
|
@@ -72,7 +72,7 @@ func GetListCountByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int) (total
|
|
|
func GetListByClassifyIdSeconds(classifyIdSeconds []int, offset, limit int) (reportList []*Report, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
|
- Where("classify_id_second in (?) and state = 2 ", classifyIdSeconds).
|
|
|
+ Where("classify_id_second in (?) and state IN (2, 6) ", classifyIdSeconds).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -84,7 +84,7 @@ func GetListByClassifyIdSeconds(classifyIdSeconds []int, offset, limit int) (rep
|
|
|
func GetListCountByClassifyIdSeconds(classifyIdSeconds []int) (total int64, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
|
- Where("classify_id_second in (?) and state = 2 ", classifyIdSeconds).
|
|
|
+ Where("classify_id_second in (?) and state IN (2, 6) ", classifyIdSeconds).
|
|
|
Count(&total).Error
|
|
|
return
|
|
|
}
|
|
@@ -93,7 +93,7 @@ func GetListCountByClassifyIdSeconds(classifyIdSeconds []int) (total int64, err
|
|
|
func GetListByClassifyIdFirst(classifyIdFirst int, offset, limit int) (reportList []*Report, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
|
- Where("classify_id_first=? and state = 2 ", classifyIdFirst).
|
|
|
+ Where("classify_id_first=? and state IN (2, 6) ", classifyIdFirst).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -105,14 +105,14 @@ func GetListByClassifyIdFirst(classifyIdFirst int, offset, limit int) (reportLis
|
|
|
func GetListCountByClassifyIdFirst(classifyIdFirst int) (total int64, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
|
- Where("classify_id_first=? and state = 2 ", classifyIdFirst).
|
|
|
+ Where("classify_id_first=? and state IN (2, 6) ", classifyIdFirst).
|
|
|
Count(&total).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetLatestByReportIds 根据ids获取报告
|
|
|
func GetLatestByReportIds(ids []int) (item *Report, err error) {
|
|
|
- err = global.MYSQL["rddp"].Where("id in ? and state = 2", ids).Order("publish_time desc, id desc").First(&item).Error
|
|
|
+ err = global.MYSQL["rddp"].Where("id in ? and state IN (2, 6)", ids).Order("publish_time desc, id desc").First(&item).Error
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
|
}
|
|
@@ -121,7 +121,7 @@ func GetLatestByReportIds(ids []int) (item *Report, err error) {
|
|
|
|
|
|
// GetPublishByReportId 根据id获取报告
|
|
|
func GetPublishByReportId(id int) (item *Report, err error) {
|
|
|
- err = global.MYSQL["rddp"].Where("id = ? and state = 2", id).First(&item).Error
|
|
|
+ err = global.MYSQL["rddp"].Where("id = ? and state IN (2, 6)", id).First(&item).Error
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
|
}
|
|
@@ -140,7 +140,7 @@ func GetByReportId(id int) (item *Report, err error) {
|
|
|
// GetByReportIds 根据id获取报告
|
|
|
func GetByReportIds(ids []int) (list []*Report, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
- Where("id in (?) and state = 2", ids).
|
|
|
+ Where("id in (?) and state IN (2, 6)", ids).
|
|
|
Select("id, create_time").
|
|
|
Scan(&list).Error
|
|
|
if err == utils.ErrNoRow {
|
|
@@ -174,7 +174,7 @@ INNER JOIN
|
|
|
SELECT classify_id_first, classify_id_second, max( publish_time ) AS max_publish_time
|
|
|
FROM report
|
|
|
WHERE
|
|
|
- state = 2
|
|
|
+ state IN (2, 6)
|
|
|
AND classify_id_first = ?
|
|
|
AND classify_id_second IN ?
|
|
|
GROUP BY
|
|
@@ -183,7 +183,7 @@ GROUP BY
|
|
|
ON t1.classify_id_second = t2.classify_id_second AND
|
|
|
t1.classify_id_first = t2.classify_id_first AND
|
|
|
t1.publish_time = t2.max_publish_time
|
|
|
- WHERE t1.state = 2
|
|
|
+ WHERE t1.state IN (2, 6)
|
|
|
AND t1.classify_id_first = ?
|
|
|
AND t1.classify_id_second IN ?`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdFirst, classifyIdSeconds, classifyIdFirst, classifyIdSeconds).Scan(&reportList).Error
|
|
@@ -201,7 +201,7 @@ func GetReportListByCondition(condition string, pars []interface{}) (list []*Rep
|
|
|
func GetListByClassifyIdSecond(classifyIdSecond int, offset, limit int) (reportList []*Report, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time, author, video_name, video_url, video_play_seconds, abstract").
|
|
|
- Where("classify_id_second = ? and state = 2 ", classifyIdSecond).
|
|
|
+ Where("classify_id_second = ? and state IN (2, 6) ", classifyIdSecond).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -215,7 +215,7 @@ func GetListByClassifyIdSecond(classifyIdSecond int, offset, limit int) (reportL
|
|
|
// GetListCountByClassifyIdSecond 按照二级分类总条数
|
|
|
func GetListCountByClassifyIdSecond(classifyIdSecond int) (total int64, err error) {
|
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
- Where("classify_id_second=? and state = 2 ", classifyIdSecond).Count(&total).Error
|
|
|
+ Where("classify_id_second=? and state IN (2, 6) ", classifyIdSecond).Count(&total).Error
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
|
}
|
|
@@ -260,7 +260,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state = 2
|
|
|
+ AND state IN (2, 6)
|
|
|
)
|
|
|
UNION
|
|
|
|
|
@@ -298,7 +298,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state = 2
|
|
|
+ AND state IN (2, 6)
|
|
|
)
|
|
|
UNION
|
|
|
|
|
@@ -347,7 +347,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state = 2
|
|
|
+ AND state IN (2, 6)
|
|
|
ORDER BY publish_time DESC LIMIT 3
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Scan(&list).Error
|
|
@@ -376,7 +376,7 @@ WHERE
|
|
|
r.classify_name_first = c.classify_name
|
|
|
AND c.show_type = 2
|
|
|
AND c.is_show = 1
|
|
|
- AND state = 2
|
|
|
+ AND state IN (2, 6)
|
|
|
ORDER BY publish_time DESC LIMIT 1
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql).First(&list).Error
|
|
@@ -398,7 +398,7 @@ FROM
|
|
|
report as a
|
|
|
JOIN classify as b
|
|
|
WHERE
|
|
|
- a.state = 2
|
|
|
+ a.state IN (2, 6)
|
|
|
AND a.classify_name_first = "%v"
|
|
|
AND a.classify_id_second = %v
|
|
|
AND a.classify_id_second = b.id
|
|
@@ -419,7 +419,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state = 2
|
|
|
+ AND state IN (2, 6)
|
|
|
ORDER BY publish_time DESC, id desc LIMIT ? OFFSET ?
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, limit, offset).Scan(&list).Error
|
|
@@ -435,7 +435,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state = 2
|
|
|
+ AND state IN (2, 6)
|
|
|
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Count(&total).Error
|
|
@@ -445,7 +445,7 @@ WHERE
|
|
|
// GetListByReportIds 根据IDs获取列表
|
|
|
func GetListByReportIds(reportIds []int) (list []*Report, err error) {
|
|
|
var where string
|
|
|
- where = `state = 2`
|
|
|
+ where = `state IN (2, 6)`
|
|
|
if len(reportIds) > 0 {
|
|
|
where += ` AND id IN (?)`
|
|
|
}
|