|
@@ -40,7 +40,7 @@ GROUP BY
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportsByClassifyIdSecondsAndDate 根据时间和报告分类筛选出合适的记录
|
|
// GetReportsByClassifyIdSecondsAndDate 根据时间和报告分类筛选出合适的记录
|
|
-func GetReportsByClassifyIdSecondsAndDate( classifyIdSeconds []int, publishTime string) (reportList []*Report, err error) {
|
|
|
|
|
|
+func GetReportsByClassifyIdSecondsAndDate(classifyIdSeconds []int, publishTime string) (reportList []*Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Select("id, classify_name_first").
|
|
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 = 2 and publish_time > ? ", classifyIdSeconds, publishTime).Scan(&reportList).Error
|
|
@@ -48,7 +48,7 @@ func GetReportsByClassifyIdSecondsAndDate( classifyIdSeconds []int, publishTime
|
|
}
|
|
}
|
|
|
|
|
|
// GetListByIDsAndClassifyIdFirst 分页查询
|
|
// GetListByIDsAndClassifyIdFirst 分页查询
|
|
-func GetListByIDsAndClassifyIdFirst( ids []int, classifyIdFirst int, offset , limit int) (reportList []*Report, err error) {
|
|
|
|
|
|
+func GetListByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int, offset, limit int) (reportList []*Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
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 = 2 ", ids, classifyIdFirst).
|
|
@@ -60,7 +60,7 @@ func GetListByIDsAndClassifyIdFirst( ids []int, classifyIdFirst int, offset , l
|
|
}
|
|
}
|
|
|
|
|
|
// GetListCountByIDsAndClassifyIdFirst 分页查询
|
|
// GetListCountByIDsAndClassifyIdFirst 分页查询
|
|
-func GetListCountByIDsAndClassifyIdFirst( ids []int, classifyIdFirst int) (total int64, err error) {
|
|
|
|
|
|
+func GetListCountByIDsAndClassifyIdFirst(ids []int, classifyIdFirst int) (total int64, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
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 = 2 ", ids, classifyIdFirst).
|
|
@@ -69,7 +69,7 @@ func GetListCountByIDsAndClassifyIdFirst( ids []int, classifyIdFirst int) (total
|
|
}
|
|
}
|
|
|
|
|
|
// GetListByClassifyIdSeconds 分页查询
|
|
// GetListByClassifyIdSeconds 分页查询
|
|
-func GetListByClassifyIdSeconds( classifyIdSeconds []int, offset , limit int) (reportList []*Report, err error) {
|
|
|
|
|
|
+func GetListByClassifyIdSeconds(classifyIdSeconds []int, offset, limit int) (reportList []*Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
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 = 2 ", classifyIdSeconds).
|
|
@@ -81,7 +81,7 @@ func GetListByClassifyIdSeconds( classifyIdSeconds []int, offset , limit int) (r
|
|
}
|
|
}
|
|
|
|
|
|
// GetListCountByClassifyIdSeconds
|
|
// GetListCountByClassifyIdSeconds
|
|
-func GetListCountByClassifyIdSeconds( classifyIdSeconds []int) (total int64, err error) {
|
|
|
|
|
|
+func GetListCountByClassifyIdSeconds(classifyIdSeconds []int) (total int64, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
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 = 2 ", classifyIdSeconds).
|
|
@@ -90,7 +90,7 @@ func GetListCountByClassifyIdSeconds( classifyIdSeconds []int) (total int64, err
|
|
}
|
|
}
|
|
|
|
|
|
// GetListByClassifyIdFirst 按照类型分页查询
|
|
// GetListByClassifyIdFirst 按照类型分页查询
|
|
-func GetListByClassifyIdFirst(classifyIdFirst int, offset , limit int) (reportList []*Report, err error) {
|
|
|
|
|
|
+func GetListByClassifyIdFirst(classifyIdFirst int, offset, limit int) (reportList []*Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time").
|
|
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 = 2 ", classifyIdFirst).
|
|
@@ -139,7 +139,10 @@ func GetByReportId(id int) (item *Report, err error) {
|
|
|
|
|
|
// GetByReportIds 根据id获取报告
|
|
// GetByReportIds 根据id获取报告
|
|
func GetByReportIds(ids []int) (list []*Report, err error) {
|
|
func GetByReportIds(ids []int) (list []*Report, err error) {
|
|
- err = global.MYSQL["rddp"].Model(Report{}).Where("id in (?) and state = 2", ids).Select("id, create_time").Scan(&list).Error
|
|
|
|
|
|
+ err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
|
+ Where("id in (?) and state = 2", ids).
|
|
|
|
+ Select("id, create_time").
|
|
|
|
+ Scan(&list).Error
|
|
if err == utils.ErrNoRow {
|
|
if err == utils.ErrNoRow {
|
|
err = nil
|
|
err = nil
|
|
}
|
|
}
|
|
@@ -195,7 +198,7 @@ func GetReportListByCondition(condition string, pars []interface{}) (list []*Rep
|
|
}
|
|
}
|
|
|
|
|
|
// GetListByClassifyIdSecond 按照二级类型分页查询
|
|
// GetListByClassifyIdSecond 按照二级类型分页查询
|
|
-func GetListByClassifyIdSecond(classifyIdSecond int, offset , limit int) (reportList []*Report, err error) {
|
|
|
|
|
|
+func GetListByClassifyIdSecond(classifyIdSecond int, offset, limit int) (reportList []*Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
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").
|
|
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 = 2 ", classifyIdSecond).
|
|
@@ -209,7 +212,6 @@ func GetListByClassifyIdSecond(classifyIdSecond int, offset , limit int) (repor
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// GetListCountByClassifyIdSecond 按照二级分类总条数
|
|
// GetListCountByClassifyIdSecond 按照二级分类总条数
|
|
func GetListCountByClassifyIdSecond(classifyIdSecond int) (total int64, err error) {
|
|
func GetListCountByClassifyIdSecond(classifyIdSecond int) (total int64, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
@@ -220,9 +222,8 @@ func GetListCountByClassifyIdSecond(classifyIdSecond int) (total int64, err erro
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// GetReportList 获取报告列表
|
|
// GetReportList 获取报告列表
|
|
-func GetReportList(condition string, pars []interface{}, offset , limit int) (list []*Report, err error) {
|
|
|
|
|
|
+func GetReportList(condition string, pars []interface{}, offset, limit int) (list []*Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
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, create_time, video_url, video_name, video_play_seconds, abstract").
|
|
Select("id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time, author, create_time, video_url, video_name, video_play_seconds, abstract").
|
|
Where(condition, pars...).
|
|
Where(condition, pars...).
|
|
@@ -241,7 +242,7 @@ func GetReportListCount(condition string, pars []interface{}) (total int64, err
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportCollectListByPermission 根据权限相关的分类查询报告和章节
|
|
// GetReportCollectListByPermission 根据权限相关的分类查询报告和章节
|
|
-func GetReportCollectListByPermission(classifyIdSeconds []int, typeIds []int, offset , limit int) (list []*response.ReportCollectListItem, err error) {
|
|
|
|
|
|
+func GetReportCollectListByPermission(classifyIdSeconds []int, typeIds []int, offset, limit int) (list []*response.ReportCollectListItem, err error) {
|
|
sql := `( SELECT
|
|
sql := `( SELECT
|
|
id AS report_id,
|
|
id AS report_id,
|
|
0 AS report_chapter_id,
|
|
0 AS report_chapter_id,
|
|
@@ -285,8 +286,9 @@ WHERE
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, typeIds, limit, offset).Scan(&list).Error
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, typeIds, limit, offset).Scan(&list).Error
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+
|
|
// GetReportCollectCountByPermission 查询汇总报告总页数
|
|
// GetReportCollectCountByPermission 查询汇总报告总页数
|
|
-func GetReportCollectCountByPermission(classifyIdSeconds []int, typeIds []int) (total int64, err error) {
|
|
|
|
|
|
+func GetReportCollectCountByPermission(classifyIdSeconds []int, typeIds []int) (total int64, err error) {
|
|
sql := `select count(*) from ( ( SELECT
|
|
sql := `select count(*) from ( ( SELECT
|
|
id AS report_id,
|
|
id AS report_id,
|
|
0 AS report_chapter_id
|
|
0 AS report_chapter_id
|
|
@@ -316,7 +318,7 @@ WHERE
|
|
}
|
|
}
|
|
|
|
|
|
// GetReportByOldReportId 根据老后台的research_report_id查找新的报告ID
|
|
// GetReportByOldReportId 根据老后台的research_report_id查找新的报告ID
|
|
-func GetReportByOldReportId(oldReportId uint64)(item *Report, err error) {
|
|
|
|
|
|
+func GetReportByOldReportId(oldReportId uint64) (item *Report, err error) {
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
err = global.MYSQL["rddp"].Model(Report{}).
|
|
Where("old_report_id=?", oldReportId).First(&item).Error
|
|
Where("old_report_id=?", oldReportId).First(&item).Error
|
|
if err == utils.ErrNoRow {
|
|
if err == utils.ErrNoRow {
|
|
@@ -326,7 +328,7 @@ func GetReportByOldReportId(oldReportId uint64)(item *Report, err error) {
|
|
}
|
|
}
|
|
|
|
|
|
// GetLatestReportByPermission 根据权限相关的分类查询最新的三篇专栏报告
|
|
// GetLatestReportByPermission 根据权限相关的分类查询最新的三篇专栏报告
|
|
-func GetLatestReportByPermission(classifyIdSeconds []int) (list []*pc.LatestReport, err error) {
|
|
|
|
|
|
+func GetLatestReportByPermission(classifyIdSeconds []int) (list []*pc.LatestReport, err error) {
|
|
sql := `SELECT
|
|
sql := `SELECT
|
|
id AS report_id,
|
|
id AS report_id,
|
|
0 AS report_chapter_id,
|
|
0 AS report_chapter_id,
|
|
@@ -353,7 +355,7 @@ WHERE
|
|
}
|
|
}
|
|
|
|
|
|
// GetLatestReport 获取最新专栏信息
|
|
// GetLatestReport 获取最新专栏信息
|
|
-func GetLatestReport() (list *pc.LatestReport, err error) {
|
|
|
|
|
|
+func GetLatestReport() (list *pc.LatestReport, err error) {
|
|
sql := `SELECT
|
|
sql := `SELECT
|
|
r.id AS report_id,
|
|
r.id AS report_id,
|
|
0 AS report_chapter_id,
|
|
0 AS report_chapter_id,
|
|
@@ -408,7 +410,7 @@ ORDER BY
|
|
}
|
|
}
|
|
|
|
|
|
// GetCommoditiesReportCollectListByPermission 根据权限相关的分类查询大宗商品报告
|
|
// GetCommoditiesReportCollectListByPermission 根据权限相关的分类查询大宗商品报告
|
|
-func GetCommoditiesReportCollectListByPermission(classifyIdSeconds []int, offset , limit int) (list []*Report, err error) {
|
|
|
|
|
|
+func GetCommoditiesReportCollectListByPermission(classifyIdSeconds []int, offset, limit int) (list []*Report, err error) {
|
|
sql := ` SELECT
|
|
sql := ` SELECT
|
|
id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time, author, create_time, video_url, video_name, video_play_seconds, abstract
|
|
id, classify_id_first, classify_name_first, classify_id_second, classify_name_second, title, stage, publish_time, author, create_time, video_url, video_name, video_play_seconds, abstract
|
|
FROM
|
|
FROM
|
|
@@ -425,7 +427,7 @@ WHERE
|
|
}
|
|
}
|
|
|
|
|
|
// GetCommoditiesReportCollectCountByPermission 查询大宗商品报告总页数
|
|
// GetCommoditiesReportCollectCountByPermission 查询大宗商品报告总页数
|
|
-func GetCommoditiesReportCollectCountByPermission(classifyIdSeconds []int) (total int64, err error) {
|
|
|
|
|
|
+func GetCommoditiesReportCollectCountByPermission(classifyIdSeconds []int) (total int64, err error) {
|
|
sql := `select count(*)
|
|
sql := `select count(*)
|
|
FROM
|
|
FROM
|
|
report
|
|
report
|
|
@@ -438,4 +440,19 @@ WHERE
|
|
`
|
|
`
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Count(&total).Error
|
|
err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Count(&total).Error
|
|
return
|
|
return
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetListByReportIds 根据IDs获取列表
|
|
|
|
+func GetListByReportIds(reportIds []int) (list []*Report, err error) {
|
|
|
|
+ var where string
|
|
|
|
+ where = `state = 2`
|
|
|
|
+ if len(reportIds) > 0 {
|
|
|
|
+ where += ` AND id IN (?)`
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ err = global.MYSQL["rddp"].Model(Report{}).
|
|
|
|
+ Where(where, reportIds).
|
|
|
|
+ Order("id asc").
|
|
|
|
+ Scan(&list).Error
|
|
|
|
+ return
|
|
|
|
+}
|