|
@@ -25,15 +25,15 @@ INNER JOIN
|
|
|
SELECT classify_id_first, max( publish_time ) AS max_publish_time
|
|
|
FROM report
|
|
|
WHERE
|
|
|
- state IN (2, 6)
|
|
|
+ state IN (2, 6) and is_public_publish=1
|
|
|
AND classify_name_first !="权益研报"
|
|
|
AND classify_id_second IN ?
|
|
|
GROUP BY
|
|
|
- classify_id_first
|
|
|
+ classify_id_first
|
|
|
) t2
|
|
|
ON t1.classify_id_first = t2.classify_id_first AND
|
|
|
t1.publish_time = t2.max_publish_time
|
|
|
- WHERE t1.state IN (2, 6)
|
|
|
+ WHERE t1.state IN (2, 6) and t1.is_public_publish=1
|
|
|
AND t1.classify_name_first !="权益研报"
|
|
|
AND t1.classify_id_second IN ?`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, classifyIdSeconds).Scan(&reportList).Error
|
|
@@ -44,7 +44,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 IN (2, 6) and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
|
|
|
+ Where("classify_id_second in (?) and state IN (2, 6) and is_public_publish=1 and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -52,7 +52,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 IN (2, 6) ", ids, classifyIdFirst).
|
|
|
+ Where("id in (?) and classify_id_first=? and state IN (2, 6) and is_public_publish=1 ", ids, classifyIdFirst).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -64,7 +64,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 IN (2, 6) ", ids, classifyIdFirst).
|
|
|
+ Where("id in (?) and classify_id_first=? and state IN (2, 6) and is_public_publish=1 ", ids, classifyIdFirst).
|
|
|
Count(&total).Error
|
|
|
return
|
|
|
}
|
|
@@ -73,7 +73,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 IN (2, 6) ", classifyIdSeconds).
|
|
|
+ Where("classify_id_second in (?) and state IN (2, 6) and is_public_publish=1 ", classifyIdSeconds).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -85,7 +85,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 IN (2, 6) ", classifyIdSeconds).
|
|
|
+ Where("classify_id_second in (?) and state IN (2, 6) and is_public_publish=1 ", classifyIdSeconds).
|
|
|
Count(&total).Error
|
|
|
return
|
|
|
}
|
|
@@ -94,7 +94,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 IN (2, 6) ", classifyIdFirst).
|
|
|
+ Where("classify_id_first=? and state IN (2, 6) and is_public_publish=1 ", classifyIdFirst).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -106,14 +106,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 IN (2, 6) ", classifyIdFirst).
|
|
|
+ Where("classify_id_first=? and state IN (2, 6) and is_public_publish=1 ", classifyIdFirst).
|
|
|
Count(&total).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetLatestByReportIds 根据ids获取报告
|
|
|
func GetLatestByReportIds(ids []int) (item *Report, err error) {
|
|
|
- err = global.MYSQL["rddp"].Where("id in ? and state IN (2, 6)", ids).Order("publish_time desc, id desc").First(&item).Error
|
|
|
+ err = global.MYSQL["rddp"].Where("id in ? and state IN (2, 6) and is_public_publish=1", ids).Order("publish_time desc, id desc").First(&item).Error
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
|
}
|
|
@@ -122,7 +122,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 IN (2, 6)", id).First(&item).Error
|
|
|
+ err = global.MYSQL["rddp"].Where("id = ? and state IN (2, 6) and is_public_publish=1", id).First(&item).Error
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
|
}
|
|
@@ -141,7 +141,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 IN (2, 6)", ids).
|
|
|
+ Where("id in (?) and state IN (2, 6) and is_public_publish=1", ids).
|
|
|
Select("id, create_time").
|
|
|
Scan(&list).Error
|
|
|
if err == utils.ErrNoRow {
|
|
@@ -175,7 +175,7 @@ INNER JOIN
|
|
|
SELECT classify_id_first, classify_id_second, max( publish_time ) AS max_publish_time
|
|
|
FROM report
|
|
|
WHERE
|
|
|
- state IN (2, 6)
|
|
|
+ state IN (2, 6) and is_public_publish=1
|
|
|
AND classify_id_first = ?
|
|
|
AND classify_id_second IN ?
|
|
|
GROUP BY
|
|
@@ -184,7 +184,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 IN (2, 6)
|
|
|
+ WHERE t1.state IN (2, 6) and t1.is_public_publish=1
|
|
|
AND t1.classify_id_first = ?
|
|
|
AND t1.classify_id_second IN ?`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdFirst, classifyIdSeconds, classifyIdFirst, classifyIdSeconds).Scan(&reportList).Error
|
|
@@ -202,7 +202,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 IN (2, 6) ", classifyIdSecond).
|
|
|
+ Where("classify_id_second = ? and state IN (2, 6) and is_public_publish=1 ", classifyIdSecond).
|
|
|
Order("publish_time desc, id desc").
|
|
|
Offset(offset).
|
|
|
Limit(limit).
|
|
@@ -216,7 +216,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 IN (2, 6) ", classifyIdSecond).Count(&total).Error
|
|
|
+ Where("classify_id_second=? and state IN (2, 6) and is_public_publish=1 ", classifyIdSecond).Count(&total).Error
|
|
|
if err == utils.ErrNoRow {
|
|
|
err = nil
|
|
|
}
|
|
@@ -261,7 +261,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
)
|
|
|
UNION
|
|
|
|
|
@@ -299,7 +299,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
)
|
|
|
UNION
|
|
|
|
|
@@ -348,7 +348,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
ORDER BY publish_time DESC LIMIT 3
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Scan(&list).Error
|
|
@@ -378,7 +378,7 @@ WHERE
|
|
|
AND c.show_type = 2
|
|
|
AND c.is_show = 1
|
|
|
AND c.enabled = 1
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
ORDER BY publish_time DESC LIMIT 1
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql).First(&list).Error
|
|
@@ -400,7 +400,7 @@ FROM
|
|
|
report as a
|
|
|
JOIN classify as b
|
|
|
WHERE
|
|
|
- a.state IN (2, 6)
|
|
|
+ a.state IN (2, 6) and a.is_public_publish=1
|
|
|
AND a.classify_name_first = "%v"
|
|
|
AND a.classify_id_second = %v
|
|
|
AND a.classify_id_second = b.id
|
|
@@ -421,7 +421,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
ORDER BY publish_time DESC, id desc LIMIT ? OFFSET ?
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, limit, offset).Scan(&list).Error
|
|
@@ -437,7 +437,7 @@ WHERE
|
|
|
classify_name_first != "晨报"
|
|
|
AND classify_name_first != "周报"
|
|
|
AND classify_id_second in ?
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
|
|
|
`
|
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Count(&total).Error
|
|
@@ -447,7 +447,7 @@ WHERE
|
|
|
// GetListByReportIds 根据IDs获取列表
|
|
|
func GetListByReportIds(reportIds []int) (list []*Report, err error) {
|
|
|
var where string
|
|
|
- where = `state IN (2, 6)`
|
|
|
+ where = `state IN (2, 6) and is_public_publish=1`
|
|
|
if len(reportIds) > 0 {
|
|
|
where += ` AND id IN (?)`
|
|
|
}
|
|
@@ -508,7 +508,7 @@ FROM
|
|
|
WHERE
|
|
|
has_chapter != 1
|
|
|
AND ( ` + condition + ` )
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
)
|
|
|
UNION
|
|
|
|
|
@@ -526,8 +526,9 @@ a.publish_time
|
|
|
FROM
|
|
|
report_chapter AS a
|
|
|
JOIN report_chapter_permission_mapping AS b on a.report_chapter_id=b.report_chapter_id
|
|
|
+JOIN report as ru on a.report_id=ru.id
|
|
|
WHERE
|
|
|
- a.publish_state = 2
|
|
|
+ a.publish_state = 2 and ru.is_public_publish=1
|
|
|
AND b.chart_permission_id = ?
|
|
|
)
|
|
|
ORDER BY publish_time DESC, report_id desc LIMIT ? OFFSET ?
|
|
@@ -546,7 +547,7 @@ FROM
|
|
|
WHERE
|
|
|
has_chapter != 1
|
|
|
AND classify_id_second in ?
|
|
|
- AND state IN (2, 6)
|
|
|
+ AND state IN (2, 6) and is_public_publish=1
|
|
|
)
|
|
|
UNION
|
|
|
|
|
@@ -556,8 +557,9 @@ a.report_chapter_id
|
|
|
FROM
|
|
|
report_chapter AS a
|
|
|
JOIN report_chapter_permission_mapping AS b on a.report_chapter_id=b.report_chapter_id
|
|
|
+JOIN report as ru on a.report_id=ru.id
|
|
|
WHERE
|
|
|
- a.publish_state = 2
|
|
|
+ a.publish_state = 2 and ru.is_public_publish=1
|
|
|
AND b.chart_permission_id = ?
|
|
|
)
|
|
|
)
|
|
@@ -589,7 +591,7 @@ func GetLatestReportByClassifyId(firstId, secondId, thirdId int) (items *pc.Late
|
|
|
FROM
|
|
|
report as a
|
|
|
WHERE
|
|
|
- a.state IN (2, 6)
|
|
|
+ a.state IN (2, 6) and a.is_public_publish=1
|
|
|
AND a.classify_id_first = ?
|
|
|
AND a.classify_id_second = ?
|
|
|
AND a.classify_id_third = ?
|