|
@@ -6,10 +6,11 @@ import (
|
|
|
"eta_gn/eta_api/global"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
- "gorm.io/gorm"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "gorm.io/gorm"
|
|
|
)
|
|
|
|
|
|
// 报告状态
|
|
@@ -181,6 +182,34 @@ func GetReportListCountV1(condition string, pars []interface{}) (count int, err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func GetReportListCountV1(condition string, pars []interface{}) (count int, err error) {
|
|
|
+// 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
|
|
|
+// }
|
|
|
+// err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
// GetReportListV1
|
|
|
// @Description: 获取普通报告列表的数据
|
|
|
// @author: Roc
|
|
@@ -204,6 +233,38 @@ func GetReportListV1(condition string, pars []interface{}, startSize, pageSize i
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// func GetReportListV1(condition string, pars []interface{}, startSize, pageSize int) (items []*ReportList, err error) {
|
|
|
+// 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
|
|
|
+// }
|
|
|
+// // 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
|
|
|
+// sql += `ORDER BY FIELD(state,3,1,4,5,6,2), modify_time DESC LIMIT ?,?`
|
|
|
+// pars = append(pars, startSize)
|
|
|
+// pars = append(pars, pageSize)
|
|
|
+// err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
type ReportPvUv struct {
|
|
|
ReportId int
|
|
|
PvTotal int
|
|
@@ -231,7 +292,7 @@ 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 `
|
|
|
+ WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
@@ -242,6 +303,39 @@ func GetReportListCountByGrant(condition string, pars []interface{}) (count int,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 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
|
|
|
+// 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
|
|
|
+// }
|
|
|
+
|
|
|
// GetReportListByGrant
|
|
|
// @Description: 获取共享报告列表的数据
|
|
|
// @author: Roc
|
|
@@ -274,6 +368,47 @@ func GetReportListByGrant(condition string, pars []interface{}, startSize, pageS
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 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
|
|
|
+// 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
|
|
|
+// }
|
|
|
+// // 排序:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过
|
|
|
+// sql += ` GROUP BY 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
|
|
|
+
|
|
|
+// ORDER BY CASE a."state"
|
|
|
+// WHEN 3 THEN 1
|
|
|
+// WHEN 1 THEN 2
|
|
|
+// WHEN 4 THEN 3
|
|
|
+// WHEN 5 THEN 4
|
|
|
+// WHEN 6 THEN 5
|
|
|
+// ELSE 6
|
|
|
+// END, a.modify_time DESC LIMIT ?,?`
|
|
|
+// pars = append(pars, startSize)
|
|
|
+// pars = append(pars, pageSize)
|
|
|
+// err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
|
+// return
|
|
|
+// }
|
|
|
+
|
|
|
func GetReportListCount(condition string, pars []interface{}) (count int, err error) {
|
|
|
sql := `SELECT COUNT(1) AS count FROM report WHERE 1=1 `
|
|
|
if condition != "" {
|