|
@@ -24,11 +24,11 @@ ORDER BY
|
|
}
|
|
}
|
|
|
|
|
|
// GetListByReportId 根据报告ID获取章节列表
|
|
// GetListByReportId 根据报告ID获取章节列表
|
|
-func GetListByReportId(reportId int, classifyNameFirst string) (list []*ReportChapter, err error) {
|
|
|
|
|
|
+func GetListByReportId(reportId int, classifyNameFirst string) (list []*ReportChapter, err error) {
|
|
var where string
|
|
var where string
|
|
- if classifyNameFirst == "周报"{
|
|
|
|
|
|
+ if classifyNameFirst == "周报" {
|
|
where = "report_id = ? AND is_edit = 1 AND publish_state = 2"
|
|
where = "report_id = ? AND is_edit = 1 AND publish_state = 2"
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
where = "report_id = ? AND publish_state = 2"
|
|
where = "report_id = ? AND publish_state = 2"
|
|
}
|
|
}
|
|
|
|
|
|
@@ -41,11 +41,11 @@ func GetListByReportId(reportId int, classifyNameFirst string) (list []*ReportCh
|
|
}
|
|
}
|
|
|
|
|
|
// GetListByReportIdTypeIds 根据报告ID、章节类型ID获取章节列表
|
|
// GetListByReportIdTypeIds 根据报告ID、章节类型ID获取章节列表
|
|
-func GetListByReportIdTypeIds(reportId int, typeIds []int, classifyNameFirst string) (list []*ReportChapter, err error) {
|
|
|
|
|
|
+func GetListByReportIdTypeIds(reportId int, typeIds []int, classifyNameFirst string) (list []*ReportChapter, err error) {
|
|
var where string
|
|
var where string
|
|
- if classifyNameFirst == "周报"{
|
|
|
|
|
|
+ if classifyNameFirst == "周报" {
|
|
where = "report_id = ? AND type_id in (?) AND is_edit = 1 AND publish_state = 2 "
|
|
where = "report_id = ? AND type_id in (?) AND is_edit = 1 AND publish_state = 2 "
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
where = "report_id = ? AND type_id in (?) AND publish_state = 2 "
|
|
where = "report_id = ? AND type_id in (?) AND publish_state = 2 "
|
|
}
|
|
}
|
|
|
|
|
|
@@ -58,7 +58,7 @@ func GetListByReportIdTypeIds(reportId int, typeIds []int, classifyNameFirst str
|
|
}
|
|
}
|
|
|
|
|
|
// GetContentById 根据ID获取章节详情
|
|
// GetContentById 根据ID获取章节详情
|
|
-func GetContentById(id int, typeIds []int) (info *ReportChapter, err error) {
|
|
|
|
|
|
+func GetContentById(id int, typeIds []int) (info *ReportChapter, err error) {
|
|
err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id, is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size, report_type, video_size").
|
|
err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id, is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size, report_type, video_size").
|
|
Where("report_chapter_id = ? and type_id in (?) AND publish_state = 2 ", id, typeIds).
|
|
Where("report_chapter_id = ? and type_id in (?) AND publish_state = 2 ", id, typeIds).
|
|
First(&info).Error
|
|
First(&info).Error
|
|
@@ -82,7 +82,7 @@ func GetReportIdsByTypeIdsAndClass(typeIds []int, classifyNameFirst string) (rep
|
|
}
|
|
}
|
|
|
|
|
|
// GetTypeIdById 根据ID获取章节类型
|
|
// GetTypeIdById 根据ID获取章节类型
|
|
-func GetTypeIdById(id int) (info *ReportChapter, err error) {
|
|
|
|
|
|
+func GetTypeIdById(id int) (info *ReportChapter, err error) {
|
|
err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id, type_id").
|
|
err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id, type_id").
|
|
Where("report_chapter_id = ? AND publish_state = 2 ", id).
|
|
Where("report_chapter_id = ? AND publish_state = 2 ", id).
|
|
First(&info).Error
|
|
First(&info).Error
|
|
@@ -92,13 +92,12 @@ func GetTypeIdById(id int) (info *ReportChapter, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// GetByTypeIdsAndReportIds 根据章节ID和ReportIds查询报告
|
|
// GetByTypeIdsAndReportIds 根据章节ID和ReportIds查询报告
|
|
-func GetByTypeIdsAndReportIds(typeIds []int, reportIds []int, classifyNameFirst string) (list []*ReportChapter, err error) {
|
|
|
|
|
|
+func GetByTypeIdsAndReportIds(typeIds []int, reportIds []int, classifyNameFirst string) (list []*ReportChapter, err error) {
|
|
var where string
|
|
var where string
|
|
- if classifyNameFirst == "周报"{
|
|
|
|
|
|
+ if classifyNameFirst == "周报" {
|
|
where = "report_id in (?) AND type_id in (?) AND is_edit = 1 AND publish_state = 2 "
|
|
where = "report_id in (?) AND type_id in (?) AND is_edit = 1 AND publish_state = 2 "
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
where = "report_id in (?) AND type_id in (?) AND publish_state = 2 "
|
|
where = "report_id in (?) AND type_id in (?) AND publish_state = 2 "
|
|
}
|
|
}
|
|
|
|
|
|
@@ -123,7 +122,7 @@ func GetChapterByReportIdTypeId(reportId, typeId int) (chapter *ReportChapter, e
|
|
Where("report_id = ? and type_id = ?", reportId, typeId).
|
|
Where("report_id = ? and type_id = ?", reportId, typeId).
|
|
First(&chapter).Error
|
|
First(&chapter).Error
|
|
if err == utils.ErrNoRow {
|
|
if err == utils.ErrNoRow {
|
|
- err =nil
|
|
|
|
|
|
+ err = nil
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -170,4 +169,12 @@ ORDER BY
|
|
sql = fmt.Sprintf(sql, firstName)
|
|
sql = fmt.Sprintf(sql, firstName)
|
|
err = global.MYSQL["rddp"].Raw(sql).First(&items).Error
|
|
err = global.MYSQL["rddp"].Raw(sql).First(&items).Error
|
|
return
|
|
return
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetItemById 主键获取章节
|
|
|
|
+func GetItemById(chapterId int) (item *ReportChapter, err error) {
|
|
|
|
+ err = global.MYSQL["rddp"].Model(ReportChapter{}).
|
|
|
|
+ Where("report_chapter_id = ? AND publish_state = 2", chapterId).
|
|
|
|
+ First(&item).Error
|
|
|
|
+ return
|
|
|
|
+}
|