|
@@ -1,85 +1,85 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
+ "eta_gn/eta_api/global"
|
|
|
"eta_gn/eta_api/models/report"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
// ReportChapter 报告章节
|
|
|
type ReportChapter struct {
|
|
|
- ReportChapterId int `orm:"column(report_chapter_id);pk" description:"报告章节ID"`
|
|
|
- ReportId int `description:"报告ID"`
|
|
|
- ReportType string `description:"报告类型 day-晨报 week-周报"`
|
|
|
- ClassifyIdFirst int `description:"一级分类id"`
|
|
|
- ClassifyNameFirst string `description:"一级分类名称"`
|
|
|
- TypeId int `description:"品种ID"`
|
|
|
- TypeName string `description:"品种名称"`
|
|
|
- Title string `description:"标题"`
|
|
|
- Abstract string `description:"摘要"`
|
|
|
- AddType int `description:"新增方式:1:新增报告,2:继承报告"`
|
|
|
- Author string `description:"作者"`
|
|
|
- Content string `description:"内容"`
|
|
|
- ContentSub string `description:"内容前两个章节"`
|
|
|
- Stage int `description:"期数"`
|
|
|
- Trend string `description:"趋势观点"`
|
|
|
- Sort int `description:"排序: 数值越小越靠前"`
|
|
|
- IsEdit int `description:"是否已编辑 0-待编辑 1-已编辑"`
|
|
|
- PublishState int `description:"发布状态 1-待发布,2-已发布"`
|
|
|
- PublishTime time.Time `description:"发布时间"`
|
|
|
- VideoUrl string `description:"音频文件URL"`
|
|
|
- VideoName string `description:"音频文件名称"`
|
|
|
- VideoPlaySeconds string `description:"音频播放时长"`
|
|
|
- VideoSize string `description:"音频文件大小,单位M"`
|
|
|
- VideoKind int `description:"音频生成方式:1,手动上传,2:自动生成"`
|
|
|
- CreateTime string `description:"创建时间"`
|
|
|
- ModifyTime time.Time `description:"修改时间"`
|
|
|
- OriginalVideoUrl string `description:"原始音频文件URL"`
|
|
|
- ContentStruct string `description:"内容组件"`
|
|
|
- LastModifyAdminId int `description:"最后更新人ID"`
|
|
|
- LastModifyAdminName string `description:"最后更新人姓名"`
|
|
|
- ContentModifyTime time.Time `description:"内容更新时间"`
|
|
|
- ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
|
|
|
- ReportCreateTime time.Time `description:"报告时间创建时间"`
|
|
|
- VoiceGenerateType int `description:"音频生成方式,0:系统生成,1:人工上传"`
|
|
|
+ ReportChapterId int `gorm:"column:report_chapter_id;primaryKey;autoIncrement:false;not null" description:"报告章节ID"`
|
|
|
+ ReportId int `gorm:"column:report_id" description:"报告ID"`
|
|
|
+ ReportType string `gorm:"column:report_type" description:"报告类型 day-晨报 week-周报"`
|
|
|
+ ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
|
|
|
+ ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
|
|
|
+ TypeId int `gorm:"column:type_id" description:"品种ID"`
|
|
|
+ TypeName string `gorm:"column:type_name" description:"品种名称"`
|
|
|
+ Title string `gorm:"column:title" description:"标题"`
|
|
|
+ Abstract string `gorm:"column:abstract" description:"摘要"`
|
|
|
+ AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
|
|
|
+ Author string `gorm:"column:author" description:"作者"`
|
|
|
+ Content string `gorm:"column:content" description:"内容"`
|
|
|
+ ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
|
|
|
+ Stage int `gorm:"column:stage" description:"期数"`
|
|
|
+ Trend string `gorm:"column:trend" description:"趋势观点"`
|
|
|
+ Sort int `gorm:"column:sort" description:"排序: 数值越小越靠前"`
|
|
|
+ IsEdit int `gorm:"column:is_edit" description:"是否已编辑 0-待编辑 1-已编辑"`
|
|
|
+ PublishState int `gorm:"column:publish_state" description:"发布状态 1-待发布,2-已发布"`
|
|
|
+ PublishTime time.Time `gorm:"column:publish_time" description:"发布时间"`
|
|
|
+ VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
|
|
|
+ VideoName string `gorm:"column:video_name" description:"音频文件名称"`
|
|
|
+ VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
|
|
|
+ VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
|
|
|
+ VideoKind int `gorm:"column:video_kind" description:"音频生成方式:1,手动上传,2:自动生成"`
|
|
|
+ CreateTime string `gorm:"column:create_time" description:"创建时间"`
|
|
|
+ ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
|
|
|
+ OriginalVideoUrl string `gorm:"column:original_video_url" description:"原始音频文件URL"`
|
|
|
+ ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
|
|
|
+ LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
|
|
|
+ LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
|
|
|
+ ContentModifyTime time.Time `gorm:"column:content_modify_time" description:"内容更新时间"`
|
|
|
+ ReportLayout int8 `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
|
|
|
+ ReportCreateTime time.Time `gorm:"column:report_create_time" description:"报告时间创建时间"`
|
|
|
+ VoiceGenerateType int `gorm:"column:voice_generate_type" description:"音频生成方式,0:系统生成,1:人工上传"`
|
|
|
}
|
|
|
|
|
|
// ReportChapterItem 报告章节详情
|
|
|
type ReportChapterItem struct {
|
|
|
- ReportChapterId int `orm:"column(report_chapter_id);pk" description:"报告章节ID"`
|
|
|
- ReportId int `description:"报告ID"`
|
|
|
- ReportType string `description:"报告类型 day-晨报 week-周报"`
|
|
|
- ClassifyIdFirst int `description:"一级分类id"`
|
|
|
- ClassifyNameFirst string `description:"一级分类名称"`
|
|
|
- TypeId int `description:"品种ID"`
|
|
|
- TypeName string `description:"品种名称"`
|
|
|
- Title string `description:"标题"`
|
|
|
- Abstract string `description:"摘要"`
|
|
|
- AddType int `description:"新增方式:1:新增报告,2:继承报告"`
|
|
|
- Author string `description:"作者"`
|
|
|
- Content string `description:"内容"`
|
|
|
- ContentSub string `description:"内容前两个章节"`
|
|
|
- Stage int `description:"期数"`
|
|
|
- Trend string `description:"趋势观点"`
|
|
|
- Sort int `description:"排序: 数值越小越靠前"`
|
|
|
- IsEdit int `description:"是否已编辑 0-待编辑 1-已编辑"`
|
|
|
- PublishState int `description:"发布状态 1-待发布,2-已发布"`
|
|
|
- PublishTime string `description:"发布时间"`
|
|
|
- VideoUrl string `description:"音频文件URL"`
|
|
|
- VideoName string `description:"音频文件名称"`
|
|
|
- VideoPlaySeconds string `description:"音频播放时长"`
|
|
|
- VideoSize string `description:"音频文件大小,单位M"`
|
|
|
- VideoKind int `description:"音频生成方式:1,手动上传,2:自动生成"`
|
|
|
- CreateTime string `description:"创建时间"`
|
|
|
- ModifyTime string `description:"修改时间"`
|
|
|
- OriginalVideoUrl string `description:"原始音频文件URL"`
|
|
|
- ContentStruct string `description:"内容组件"`
|
|
|
- LastModifyAdminId int `description:"最后更新人ID"`
|
|
|
- LastModifyAdminName string `description:"最后更新人姓名"`
|
|
|
- ContentModifyTime string `description:"内容更新时间"`
|
|
|
- ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
|
|
|
- ReportCreateTime string `description:"报告时间创建时间"`
|
|
|
+ ReportChapterId int `gorm:"column:report_chapter_id;primaryKey;autoIncrement:false;not null" description:"报告章节ID"`
|
|
|
+ ReportId int `gorm:"column:report_id" description:"报告ID"`
|
|
|
+ ReportType string `gorm:"column:report_type" description:"报告类型 day-晨报 week-周报"`
|
|
|
+ ClassifyIdFirst int `gorm:"column:classify_id_first" description:"一级分类id"`
|
|
|
+ ClassifyNameFirst string `gorm:"column:classify_name_first" description:"一级分类名称"`
|
|
|
+ TypeId int `gorm:"column:type_id" description:"品种ID"`
|
|
|
+ TypeName string `gorm:"column:type_name" description:"品种名称"`
|
|
|
+ Title string `gorm:"column:title" description:"标题"`
|
|
|
+ Abstract string `gorm:"column:abstract" description:"摘要"`
|
|
|
+ AddType int `gorm:"column:add_type" description:"新增方式:1:新增报告,2:继承报告"`
|
|
|
+ Author string `gorm:"column:author" description:"作者"`
|
|
|
+ Content string `gorm:"column:content" description:"内容"`
|
|
|
+ ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
|
|
|
+ Stage int `gorm:"column:stage" description:"期数"`
|
|
|
+ Trend string `gorm:"column:trend" description:"趋势观点"`
|
|
|
+ Sort int `gorm:"column:sort" description:"排序: 数值越小越靠前"`
|
|
|
+ IsEdit int `gorm:"column:is_edit" description:"是否已编辑 0-待编辑 1-已编辑"`
|
|
|
+ PublishState int `gorm:"column:publish_state" description:"发布状态 1-待发布,2-已发布"`
|
|
|
+ PublishTime string `gorm:"column:publish_time" description:"发布时间"`
|
|
|
+ VideoUrl string `gorm:"column:video_url" description:"音频文件URL"`
|
|
|
+ VideoName string `gorm:"column:video_name" description:"音频文件名称"`
|
|
|
+ VideoPlaySeconds string `gorm:"column:video_play_seconds" description:"音频播放时长"`
|
|
|
+ VideoSize string `gorm:"column:video_size" description:"音频文件大小,单位M"`
|
|
|
+ VideoKind int `gorm:"column:video_kind" description:"音频生成方式:1,手动上传,2:自动生成"`
|
|
|
+ CreateTime string `gorm:"column:create_time" description:"创建时间"`
|
|
|
+ ModifyTime string `gorm:"column:modify_time" description:"修改时间"`
|
|
|
+ OriginalVideoUrl string `gorm:"column:original_video_url" description:"原始音频文件URL"`
|
|
|
+ ContentStruct string `gorm:"column:content_struct" description:"内容组件"`
|
|
|
+ LastModifyAdminId int `gorm:"column:last_modify_admin_id" description:"最后更新人ID"`
|
|
|
+ LastModifyAdminName string `gorm:"column:last_modify_admin_name" description:"最后更新人姓名"`
|
|
|
+ ContentModifyTime string `gorm:"column:content_modify_time" description:"内容更新时间"`
|
|
|
+ ReportLayout int8 `gorm:"column:report_layout" description:"报告布局,1:常规布局,2:智能布局。默认:1"`
|
|
|
+ ReportCreateTime string `gorm:"column:report_create_time" description:"报告时间创建时间"`
|
|
|
}
|
|
|
|
|
|
// ReportChapterItemResp
|
|
@@ -130,19 +130,19 @@ type ReportChapterResp struct {
|
|
|
|
|
|
// GetChapterListByReportId 根据ReportId获取章节列表
|
|
|
func GetChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE report_id = ? ORDER BY sort ASC`
|
|
|
- _, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetPublishedChapterListByReportId 根据ReportId获取已发布章节列表
|
|
|
func GetPublishedChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE report_id = ? AND publish_state = 2 ORDER BY sort ASC`
|
|
|
- _, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -186,10 +186,10 @@ type EditTickList struct {
|
|
|
|
|
|
// GetReportChapterInfoById 根据主键获取报告章节
|
|
|
func GetReportChapterInfoById(reportChapterId int) (item *ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
|
|
|
- err = o.Raw(sql, reportChapterId).QueryRow(&item)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, reportChapterId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -201,19 +201,19 @@ func GetReportChapterInfoById(reportChapterId int) (item *ReportChapter, err err
|
|
|
// @return item *ReportChapterItem
|
|
|
// @return err error
|
|
|
func GetReportChapterItemById(reportChapterId int) (item *ReportChapterItem, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ? `
|
|
|
- err = o.Raw(sql, reportChapterId).QueryRow(&item)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, reportChapterId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetLastPublishedReportChapter 获取上一篇已发表的晨周报章节
|
|
|
func GetLastPublishedReportChapter(typeId int, reportType string) (item *ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE publish_state = 2 AND type_id = ? AND report_type = ? ORDER BY report_chapter_id DESC limit 1 `
|
|
|
- err = o.Raw(sql, typeId, reportType).QueryRow(&item)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, typeId, reportType).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, typeId, reportType).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -224,21 +224,21 @@ func GetLastPublishedReportChapter(typeId int, reportType string) (item *ReportC
|
|
|
// @datetime 2024-06-04 15:14:41
|
|
|
// @return err error
|
|
|
func (chapterChapterInfo *ReportChapter) Add() (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- lastId, err := o.Insert(chapterChapterInfo)
|
|
|
- if err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- chapterChapterInfo.ReportChapterId = int(lastId)
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //lastId, err := o.Insert(chapterChapterInfo)
|
|
|
+ //if err != nil {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //chapterChapterInfo.ReportChapterId = int(lastId)
|
|
|
+ err = global.DmSQL["rddp"].Create(chapterChapterInfo).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateChapter 更新报表章节
|
|
|
func (chapterChapterInfo *ReportChapter) UpdateChapter(cols []string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Update(chapterChapterInfo, cols...)
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Update(chapterChapterInfo, cols...)
|
|
|
+ err = global.DmSQL["rddp"].Select(cols).Updates(chapterChapterInfo).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -277,16 +277,16 @@ func UpdateChapterAndTicker(reportInfo *Report, chapterInfo *ReportChapter, upda
|
|
|
|
|
|
// ReportChapterVideoList 报告章节音频列表
|
|
|
type ReportChapterVideoList struct {
|
|
|
- ReportId int `description:"报告ID"`
|
|
|
- ReportChapterId int `description:"报告章节ID"`
|
|
|
- VideoUrl string `description:"音频文件URL"`
|
|
|
- VideoName string `description:"音频文件名称"`
|
|
|
- VideoPlaySeconds string `description:"音频播放时长"`
|
|
|
+ ReportId int `gorm:"column:report_id"` //`description:"报告ID"`
|
|
|
+ ReportChapterId int `gorm:"column:report_chapter_id"` //`description:"报告章节ID"`
|
|
|
+ VideoUrl string `gorm:"column:video_url"` //`description:"音频文件URL"`
|
|
|
+ VideoName string `gorm:"column:video_name"` //`description:"音频文件名称"`
|
|
|
+ VideoPlaySeconds string `gorm:"column:video_play_seconds"` //`description:"音频播放时长"`
|
|
|
}
|
|
|
|
|
|
// GetReportChapterVideoList 获取报告章节音频列表
|
|
|
func GetReportChapterVideoList(reportId int) (list []*ReportChapterVideoList, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT
|
|
|
report_id,
|
|
|
report_chapter_id,
|
|
@@ -299,8 +299,8 @@ func GetReportChapterVideoList(reportId int) (list []*ReportChapterVideoList, er
|
|
|
report_id = ? AND publish_state = 2 AND video_url != ""
|
|
|
ORDER BY
|
|
|
report_chapter_id ASC `
|
|
|
- _, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -309,7 +309,7 @@ func GetReportChapterVideoListByReportIds(reportIds []int) (list []*ReportChapte
|
|
|
if len(reportIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT
|
|
|
report_id,
|
|
|
report_chapter_id,
|
|
@@ -322,8 +322,8 @@ func GetReportChapterVideoListByReportIds(reportIds []int) (list []*ReportChapte
|
|
|
report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) AND publish_state = 2 AND video_url != ""
|
|
|
ORDER BY
|
|
|
report_chapter_id ASC `
|
|
|
- _, err = o.Raw(sql, reportIds).QueryRows(&list)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, reportIds).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportIds).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -332,7 +332,7 @@ func GetReportChapterVideoListByChapterIds(chapterIds []int) (list []*ReportChap
|
|
|
if len(chapterIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT
|
|
|
report_id,
|
|
|
report_chapter_id,
|
|
@@ -345,7 +345,8 @@ func GetReportChapterVideoListByChapterIds(chapterIds []int) (list []*ReportChap
|
|
|
report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) AND publish_state = 2
|
|
|
ORDER BY
|
|
|
report_chapter_id ASC `
|
|
|
- _, err = o.Raw(sql, chapterIds).QueryRows(&list)
|
|
|
+ //_, err = o.Raw(sql, chapterIds).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -357,10 +358,10 @@ type PublishReportChapterReq struct {
|
|
|
|
|
|
// CountPublishedChapterNum 获取报告已发布的章节数
|
|
|
func CountPublishedChapterNum(reportId int) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT COUNT(1) AS ct FROM report_chapter WHERE report_id = ? AND publish_state = 2 `
|
|
|
- err = o.Raw(sql, reportId).QueryRow(&count)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, reportId).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -372,10 +373,10 @@ func CountPublishedChapterNum(reportId int) (count int, err error) {
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func CountUnPublishedChapterNum(reportId int) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT COUNT(1) AS ct FROM report_chapter WHERE report_id = ? AND publish_state = 1 `
|
|
|
- err = o.Raw(sql, reportId).QueryRow(&count)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, reportId).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -387,10 +388,10 @@ func CountUnPublishedChapterNum(reportId int) (count int, err error) {
|
|
|
// @return list []*ReportChapter
|
|
|
// @return err error
|
|
|
func GetUnPublishedChapterList(reportId int) (list []*ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT report_chapter_id,report_id,title FROM report_chapter WHERE report_id = ? AND publish_state = 1 ORDER BY sort ASC`
|
|
|
- _, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -399,9 +400,10 @@ func GetChapterListByChapterIds(chapterIds []int) (list []*ReportChapter, err er
|
|
|
if len(chapterIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ // o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) ORDER BY sort ASC`
|
|
|
- _, err = o.Raw(sql, chapterIds).QueryRows(&list)
|
|
|
+ //_, err = o.Raw(sql, chapterIds).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -410,9 +412,10 @@ func GetChapterSimpleListByChapterIds(chapterIds []int) (list []*ReportChapter,
|
|
|
if len(chapterIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT report_id, report_chapter_id, title, type_name, create_time, IF(publish_time,publish_time,create_time) as publish_time FROM report_chapter WHERE report_chapter_id IN (` + utils.GetOrmInReplace(len(chapterIds)) + `) ORDER BY publish_time desc, sort ASC`
|
|
|
- _, err = o.Raw(sql, chapterIds).QueryRows(&list)
|
|
|
+ // _, err = o.Raw(sql, chapterIds).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, chapterIds).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -421,25 +424,28 @@ func GetChapterSimpleListByReportIds(reportIds []int) (list []*ReportChapter, er
|
|
|
if len(reportIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT report_id, report_chapter_id, title, type_name, create_time, IF(publish_time,publish_time,create_time) as publish_time FROM report_chapter WHERE publish_state = 2 and report_id IN (` + utils.GetOrmInReplace(len(reportIds)) + `) ORDER BY publish_time desc, sort ASC`
|
|
|
- _, err = o.Raw(sql, reportIds).QueryRows(&list)
|
|
|
+ //_, err = o.Raw(sql, reportIds).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportIds).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateReportChapterTypeNameByTypeId 更新章节类型名称
|
|
|
func UpdateReportChapterTypeNameByTypeId(typeId int, typeName string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report_chapter SET type_name = ? WHERE type_id = ?`
|
|
|
- _, err = o.Raw(sql, typeName, typeId).Exec()
|
|
|
+ //_, err = o.Raw(sql, typeName, typeId).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, typeName, typeId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// CountReportChapterByTypeId 通过章节类型ID获取章节数
|
|
|
func CountReportChapterByTypeId(typeId int) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT COUNT(1) AS ct FROM report_chapter WHERE type_id = ?`
|
|
|
- err = o.Raw(sql, typeId).QueryRow(&count)
|
|
|
+ //err = o.Raw(sql, typeId).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, typeId).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -468,12 +474,12 @@ type EditReportChapterBaseInfoAndPermissionReq struct {
|
|
|
// @return list []int
|
|
|
// @return err error
|
|
|
func GetReportChapterIdList(reportId int) (list []int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT report_chapter_id FROM report_chapter
|
|
|
WHERE report_id = ?
|
|
|
ORDER BY report_chapter_id ASC `
|
|
|
- _, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, reportId).QueryRows(&list)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&list).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -495,9 +501,10 @@ type ReportChapterMoveReq struct {
|
|
|
// @return item *ReportChapter
|
|
|
// @return err error
|
|
|
func (chapterChapterInfo *ReportChapter) GetReportChapterById(reportChapterId int) (item *ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ // o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE report_chapter_id = ?`
|
|
|
- err = o.Raw(sql, reportChapterId).QueryRow(&item)
|
|
|
+ //err = o.Raw(sql, reportChapterId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportChapterId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -512,7 +519,7 @@ func (chapterChapterInfo *ReportChapter) GetReportChapterById(reportChapterId in
|
|
|
// @param updateSort string
|
|
|
// @return err error
|
|
|
func (chapterChapterInfo *ReportChapter) UpdateReportChapterSortByReportId(reportId, reportChapterId, nowSort int, updateSort string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
pars := make([]interface{}, 0)
|
|
|
sql := ` update report_chapter set sort = ` + updateSort + ` WHERE report_id = ? AND sort > ?`
|
|
|
pars = append(pars, reportId, nowSort)
|
|
@@ -522,8 +529,8 @@ func (chapterChapterInfo *ReportChapter) UpdateReportChapterSortByReportId(repor
|
|
|
pars = append(pars, reportChapterId, nowSort)
|
|
|
}
|
|
|
|
|
|
- _, err = o.Raw(sql, pars).Exec()
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql, pars).Exec()
|
|
|
+ err = global.DmSQL["rddp"].Exec(sql, pars).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -536,9 +543,10 @@ func (chapterChapterInfo *ReportChapter) UpdateReportChapterSortByReportId(repor
|
|
|
// @return item *ReportChapter
|
|
|
// @return err error
|
|
|
func (chapterChapterInfo *ReportChapter) GetFirstReportChapterByReportId(reportId int) (item *ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter WHERE 1 = 1 AND report_id = ? ORDER BY sort ASC, report_chapter_id ASC LIMIT 1`
|
|
|
- err = o.Raw(sql, reportId).QueryRow(&item)
|
|
|
+ //err = o.Raw(sql, reportId).QueryRow(&item)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -551,10 +559,10 @@ func (chapterChapterInfo *ReportChapter) GetFirstReportChapterByReportId(reportI
|
|
|
// @return maxSort int
|
|
|
// @return err error
|
|
|
func (chapterChapterInfo *ReportChapter) GetMaxSortByReportId(reportId int) (maxSort int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT max(sort) AS sort FROM report_chapter WHERE report_id = ?`
|
|
|
- err = o.Raw(sql, reportId).QueryRow(&maxSort)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, reportId).QueryRow(&maxSort)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, reportId).Scan(&maxSort).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -566,9 +574,9 @@ func (chapterChapterInfo *ReportChapter) GetMaxSortByReportId(reportId int) (max
|
|
|
// @param cols []string
|
|
|
// @return err error
|
|
|
func (chapterChapterInfo *ReportChapter) Update(cols []string) (err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- _, err = o.Update(chapterChapterInfo, cols...)
|
|
|
-
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //_, err = o.Update(chapterChapterInfo, cols...)
|
|
|
+ err = global.DmSQL["rddp"].Select(cols).Updates(chapterChapterInfo).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -580,10 +588,10 @@ type DelReportChapterReq struct {
|
|
|
|
|
|
// GetAllReportChapter 获取所有的报告章节
|
|
|
func GetAllReportChapter() (items []*ReportChapter, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report_chapter ORDER BY report_chapter_id asc `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
-
|
|
|
+ //_, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -596,12 +604,12 @@ func GetAllReportChapter() (items []*ReportChapter, err error) {
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func GetCountReportChapterByCondition(condition string, pars []interface{}) (count int, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
+ //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT COUNT(1) AS count FROM report_chapter WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
-
|
|
|
+ //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
+ err = global.DmSQL["rddp"].Raw(sql, pars).Scan(&count).Error
|
|
|
return
|
|
|
}
|