|
@@ -174,7 +174,26 @@ type ReportListResp struct {
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func GetReportListCountV1(condition string, pars []interface{}) (count int, err error) {
|
|
|
- sql := `SELECT COUNT(1) AS count FROM report as a WHERE 1=1 `
|
|
|
+ sql := `SELECT COUNT(1) AS count FROM report as a
|
|
|
+ LEFT JOIN classify_visible c ON (
|
|
|
+ CASE
|
|
|
+ WHEN a.classify_id_third > 0 THEN a.classify_id_third
|
|
|
+ WHEN a.classify_id_second > 0 THEN a.classify_id_second
|
|
|
+ ELSE a.classify_id_first
|
|
|
+ END
|
|
|
+ ) = c.classify_id AND c.admin_id =?
|
|
|
+ WHERE 1=1 AND (c.admin_id IS NULL OR c.admin_id =?) AND a.id NOT IN (
|
|
|
+ SELECT id FROM report ta
|
|
|
+ JOIN classify_visible tb ON (
|
|
|
+ CASE
|
|
|
+ WHEN ta.classify_id_third > 0 THEN ta.classify_id_third
|
|
|
+ WHEN ta.classify_id_second > 0 THEN ta.classify_id_second
|
|
|
+ ELSE ta.classify_id_first
|
|
|
+ END
|
|
|
+ ) = tb.classify_id
|
|
|
+ GROUP BY ta."id"
|
|
|
+ HAVING SUM(CASE WHEN tb.admin_id = ? THEN 1 ELSE 0 END) = 0
|
|
|
+ ) `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
@@ -193,7 +212,26 @@ func GetReportListCountV1(condition string, pars []interface{}) (count int, err
|
|
|
// @return items []*ReportList
|
|
|
// @return err error
|
|
|
func GetReportListV1(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
- sql := `SELECT * FROM report as a WHERE 1=1 `
|
|
|
+ sql := `SELECT * FROM report as a
|
|
|
+ LEFT JOIN classify_visible c ON (
|
|
|
+ CASE
|
|
|
+ WHEN a.classify_id_third > 0 THEN a.classify_id_third
|
|
|
+ WHEN a.classify_id_second > 0 THEN a.classify_id_second
|
|
|
+ ELSE a.classify_id_first
|
|
|
+ END
|
|
|
+ ) = c.classify_id AND c.admin_id =?
|
|
|
+ WHERE 1=1 AND (c.admin_id IS NULL OR c.admin_id =?) AND a.id NOT IN (
|
|
|
+ SELECT id FROM report ta
|
|
|
+ JOIN classify_visible tb ON (
|
|
|
+ CASE
|
|
|
+ WHEN ta.classify_id_third > 0 THEN ta.classify_id_third
|
|
|
+ WHEN ta.classify_id_second > 0 THEN ta.classify_id_second
|
|
|
+ ELSE ta.classify_id_first
|
|
|
+ END
|
|
|
+ ) = tb.classify_id
|
|
|
+ GROUP BY ta."id"
|
|
|
+ HAVING SUM(CASE WHEN tb.admin_id = ? THEN 1 ELSE 0 END) = 0
|
|
|
+ ) `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
@@ -232,13 +270,32 @@ func GetReportPvUvByReportIdList(reportIdList []int) (items []ReportPvUv, err er
|
|
|
func GetReportListCountByGrant(condition string, pars []interface{}) (count int, err error) {
|
|
|
sql := `SELECT a.id FROM report as a
|
|
|
JOIN report_grant b on a.id=b.report_id
|
|
|
- WHERE 1=1 `
|
|
|
+ LEFT JOIN classify_visible c ON (
|
|
|
+ CASE
|
|
|
+ WHEN a.classify_id_third > 0 THEN a.classify_id_third
|
|
|
+ WHEN a.classify_id_second > 0 THEN a.classify_id_second
|
|
|
+ ELSE a.classify_id_first
|
|
|
+ END
|
|
|
+ ) = c.classify_id AND c.admin_id =?
|
|
|
+ WHERE 1=1 AND (c.admin_id IS NULL OR c.admin_id =?) AND a.id NOT IN (
|
|
|
+ SELECT id FROM report ta
|
|
|
+ JOIN classify_visible tb ON (
|
|
|
+ CASE
|
|
|
+ WHEN ta.classify_id_third > 0 THEN ta.classify_id_third
|
|
|
+ WHEN ta.classify_id_second > 0 THEN ta.classify_id_second
|
|
|
+ ELSE ta.classify_id_first
|
|
|
+ END
|
|
|
+ ) = tb.classify_id
|
|
|
+ GROUP BY ta."id"
|
|
|
+ HAVING SUM(CASE WHEN tb.admin_id = ? THEN 1 ELSE 0 END) = 0
|
|
|
+ ) `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
sql += " GROUP BY a.id "
|
|
|
|
|
|
sql = `SELECT COUNT(1) AS count FROM (` + sql + `) d`
|
|
|
+
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
@@ -254,7 +311,26 @@ func GetReportListCountByGrant(condition string, pars []interface{}) (count int,
|
|
|
// @return items []*ReportList
|
|
|
// @return err error
|
|
|
func GetReportListByGrant(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
- sql := `SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,a.create_time,a.modify_time,a.state,a.publish_time,a.pre_publish_time,a.stage,a.msg_is_send,a.pre_msg_send,a.video_url,a.video_name,a.video_play_seconds,a.report_code,a.video_size,a.report_version,a.ths_msg_is_send,a.has_chapter,a.chapter_type,a.old_report_id,a.msg_send_time,a.admin_id,a.admin_real_name,a.approve_time,a.approve_id,a.detail_img_url,a.detail_pdf_url,a.last_modify_admin_id,a.last_modify_admin_name,a.content_modify_time,a.pv,a.uv,a.canvas_color,a.need_splice,a.head_resource_id,a.end_resource_id,a.classify_id_third,a.classify_name_third,a.collaborate_type,a.report_layout,a.is_public_publish,a.report_create_time,a.inherit_report_id,a.voice_generate_type,a.report_source FROM report as a JOIN report_grant b on a.id = b.report_id WHERE 1=1 `
|
|
|
+ sql := `SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,a.create_time,a.modify_time,a.state,a.publish_time,a.pre_publish_time,a.stage,a.msg_is_send,a.pre_msg_send,a.video_url,a.video_name,a.video_play_seconds,a.report_code,a.video_size,a.report_version,a.ths_msg_is_send,a.has_chapter,a.chapter_type,a.old_report_id,a.msg_send_time,a.admin_id,a.admin_real_name,a.approve_time,a.approve_id,a.detail_img_url,a.detail_pdf_url,a.last_modify_admin_id,a.last_modify_admin_name,a.content_modify_time,a.pv,a.uv,a.canvas_color,a.need_splice,a.head_resource_id,a.end_resource_id,a.classify_id_third,a.classify_name_third,a.collaborate_type,a.report_layout,a.is_public_publish,a.report_create_time,a.inherit_report_id,a.voice_generate_type,a.report_source FROM report as a JOIN report_grant b on a.id = b.report_id
|
|
|
+ LEFT JOIN classify_visible c ON (
|
|
|
+ CASE
|
|
|
+ WHEN a.classify_id_third > 0 THEN a.classify_id_third
|
|
|
+ WHEN a.classify_id_second > 0 THEN a.classify_id_second
|
|
|
+ ELSE a.classify_id_first
|
|
|
+ END
|
|
|
+ ) = c.classify_id AND c.admin_id =?
|
|
|
+ WHERE 1=1 AND (c.admin_id IS NULL OR c.admin_id =?) AND a.id NOT IN (
|
|
|
+ SELECT id FROM report ta
|
|
|
+ JOIN classify_visible tb ON (
|
|
|
+ CASE
|
|
|
+ WHEN ta.classify_id_third > 0 THEN ta.classify_id_third
|
|
|
+ WHEN ta.classify_id_second > 0 THEN ta.classify_id_second
|
|
|
+ ELSE ta.classify_id_first
|
|
|
+ END
|
|
|
+ ) = tb.classify_id
|
|
|
+ GROUP BY ta."id"
|
|
|
+ HAVING SUM(CASE WHEN tb.admin_id = ? THEN 1 ELSE 0 END) = 0
|
|
|
+ ) `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|