|
@@ -6,7 +6,6 @@ import (
|
|
|
"eta_gn/eta_api/global"
|
|
|
"eta_gn/eta_api/utils"
|
|
|
"fmt"
|
|
|
- "github.com/beego/beego/v2/client/orm"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"gorm.io/gorm"
|
|
|
"strings"
|
|
@@ -168,12 +167,10 @@ type ReportListResp struct {
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func GetReportListCountV1(condition string, pars []interface{}) (count int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT COUNT(1) AS count FROM report as a WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
@@ -189,15 +186,12 @@ 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) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
-
|
|
|
sql := `SELECT * FROM report as a WHERE 1=1 `
|
|
|
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 ?,?`
|
|
|
- //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
pars = append(pars, startSize)
|
|
|
pars = append(pars, pageSize)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
@@ -215,10 +209,7 @@ func GetReportPvUvByReportIdList(reportIdList []int) (items []ReportPvUv, err er
|
|
|
if num <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
-
|
|
|
sql := `SELECT report_id, COUNT(1) as pv_total,COUNT(DISTINCT user_id) as uv_total FROM report_view_record WHERE report_id in (` + utils.GetOrmInReplace(num) + `) GROUP BY report_id`
|
|
|
- //_, err = o.Raw(sql, reportIdList).QueryRows(&items)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, reportIdList).Find(&items).Error
|
|
|
return
|
|
|
}
|
|
@@ -232,7 +223,6 @@ func GetReportPvUvByReportIdList(reportIdList []int) (items []ReportPvUv, err er
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func GetReportListCountByGrant(condition string, pars []interface{}) (count int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT a.id FROM report as a
|
|
|
JOIN report_grant b on a.id=b.report_id
|
|
|
WHERE 1=1 `
|
|
@@ -242,7 +232,6 @@ func GetReportListCountByGrant(condition string, pars []interface{}) (count int,
|
|
|
sql += " GROUP BY a.id "
|
|
|
|
|
|
sql = `SELECT COUNT(1) AS count FROM (` + sql + `) d`
|
|
|
- //err = o.Raw(sql, pars).QueryRow(&count)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
@@ -258,8 +247,6 @@ 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) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
-
|
|
|
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 FROM report as a JOIN report_grant b on a.id = b.report_id WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
@@ -275,7 +262,6 @@ func GetReportListByGrant(condition string, pars []interface{}, startSize, pageS
|
|
|
WHEN 6 THEN 5
|
|
|
ELSE 6
|
|
|
END, a.modify_time DESC LIMIT ?,?`
|
|
|
- //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
pars = append(pars, startSize)
|
|
|
pars = append(pars, pageSize)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
@@ -283,35 +269,29 @@ func GetReportListByGrant(condition string, pars []interface{}, startSize, pageS
|
|
|
}
|
|
|
|
|
|
func GetReportListCount(condition string, pars []interface{}) (count int, err error) {
|
|
|
- //oRddp := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT COUNT(1) AS count FROM report WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- //err = oRddp.Raw(sql, pars).QueryRow(&count)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// PublishCancelReport 取消发布报告
|
|
|
func PublishCancelReport(reportId, state int, publishTimeNullFlag bool, lastModifyAdminId int, lastModifyAdminName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
var sql string
|
|
|
if publishTimeNullFlag {
|
|
|
sql = ` UPDATE report SET state=?, publish_time=null, pre_publish_time=null, pre_msg_send=0,last_modify_admin_id=?,last_modify_admin_name=?,modify_time = NOW() WHERE id =?`
|
|
|
} else {
|
|
|
sql = ` UPDATE report SET state=?, pre_publish_time=null, pre_msg_send=0,last_modify_admin_id=?,last_modify_admin_name=?,modify_time = NOW() WHERE id =?`
|
|
|
}
|
|
|
- // _, err = o.Raw(sql, state, lastModifyAdminId, lastModifyAdminName, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, state, lastModifyAdminId, lastModifyAdminName, reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 删除报告
|
|
|
func DeleteReport(reportIds int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` DELETE FROM report WHERE id =? `
|
|
|
- //_, err = o.Raw(sql, reportIds).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, reportIds).Error
|
|
|
return
|
|
|
}
|
|
@@ -421,9 +401,7 @@ func GetSimpleReportByIds(reportIds []int) (list []*Report, err error) {
|
|
|
if len(reportIds) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT id, title, report_code FROM report WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
|
|
|
- //_, err = o.Raw(sql, reportIds).QueryRows(&list)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, reportIds).Find(&list).Error
|
|
|
return
|
|
|
}
|
|
@@ -438,7 +416,6 @@ func GetSimpleReportByIds(reportIds []int) (list []*Report, err error) {
|
|
|
// @return count int
|
|
|
// @return err error
|
|
|
func GetReportStage(classifyIdFirst, classifyIdSecond, classifyIdThird int) (count int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
classifyId := classifyIdThird
|
|
|
if classifyId <= 0 {
|
|
|
classifyId = classifyIdSecond
|
|
@@ -460,7 +437,6 @@ func GetReportStage(classifyIdFirst, classifyIdSecond, classifyIdThird int) (cou
|
|
|
} else {
|
|
|
sql += " AND classify_id_first = ? "
|
|
|
}
|
|
|
- //o.Raw(sql, yearStart, classifyId).QueryRow(&count)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, yearStart, classifyId).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
@@ -520,12 +496,6 @@ type AddResp struct {
|
|
|
ReportCode string `description:"报告code"`
|
|
|
}
|
|
|
|
|
|
-func AddReport(item *Report) (lastId int64, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- lastId, err = o.Insert(item)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
type EditReq struct {
|
|
|
ReportId int64 `description:"报告id"`
|
|
|
ClassifyIdFirst int `description:"一级分类id"`
|
|
@@ -560,7 +530,6 @@ type EditResp struct {
|
|
|
}
|
|
|
|
|
|
func EditReport(item *Report, reportId int64) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report
|
|
|
SET
|
|
|
classify_id_first =?,
|
|
@@ -578,16 +547,12 @@ func EditReport(item *Report, reportId int64) (err error) {
|
|
|
create_time = ?,
|
|
|
modify_time = ?
|
|
|
WHERE id = ? `
|
|
|
- //_, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
|
|
|
- // item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
|
|
|
item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func (m *Report) Update(cols []string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- //_, err = o.Update(m, cols...)
|
|
|
err = global.DmSQL["rddp"].Select(cols).Updates(m).Error
|
|
|
return
|
|
|
}
|
|
@@ -602,15 +567,12 @@ type ClassifyIdDetailReq struct {
|
|
|
}
|
|
|
|
|
|
func GetReportDetailByClassifyId(classifyIdFirst, classifyIdSecond int) (item *Report, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` SELECT * FROM report WHERE 1=1 `
|
|
|
if classifyIdSecond > 0 {
|
|
|
sql = sql + ` AND classify_id_second=? ORDER BY stage DESC LIMIT 1`
|
|
|
- //err = o.Raw(sql, classifyIdSecond).QueryRow(&item)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, classifyIdSecond).First(&item).Error
|
|
|
} else {
|
|
|
sql = sql + ` AND classify_id_first=? ORDER BY stage DESC LIMIT 1`
|
|
|
- //err = o.Raw(sql, classifyIdFirst).QueryRow(&item)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, classifyIdFirst).First(&item).Error
|
|
|
}
|
|
|
return
|
|
@@ -628,7 +590,6 @@ type SendTemplateMsgResp struct {
|
|
|
}
|
|
|
|
|
|
func ModifyReportMsgIsSend(reportId int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
report, err := GetReportById(reportId)
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -636,15 +597,12 @@ func ModifyReportMsgIsSend(reportId int) (err error) {
|
|
|
if report.MsgIsSend == 0 {
|
|
|
sql := `UPDATE report SET msg_is_send = 1, msg_send_time=NOW() WHERE id = ? `
|
|
|
err = global.DmSQL["rddp"].Exec(sql, reportId).Error
|
|
|
- //_, err = o.Raw(sql, reportId).Exec()
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? `
|
|
|
- //_, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Error
|
|
|
return
|
|
|
}
|
|
@@ -660,9 +618,7 @@ func ModifyReportVideo(reportId int, videoUrl, videoName, videoSize string, play
|
|
|
// @param playSeconds float64
|
|
|
// @return err error
|
|
|
func ModifyReportVideoByNoVideo(reportId int, videoUrl, videoName, videoSize string, playSeconds float64) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET video_url=?,video_name=?,video_play_seconds=?,video_size=? WHERE id=? AND video_url=''`
|
|
|
- //_, err = o.Raw(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, videoUrl, videoName, playSeconds, videoSize, reportId).Error
|
|
|
return
|
|
|
}
|
|
@@ -692,14 +648,6 @@ type ReportItem struct {
|
|
|
ContentSub string `gorm:"column:content_sub" description:"内容前两个章节"`
|
|
|
}
|
|
|
|
|
|
-func GetReportItemById(reportId int) (item *ReportItem, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := `SELECT * FROM report WHERE id=?`
|
|
|
- //err = o.Raw(sql, reportId).QueryRow(&item)
|
|
|
- err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
type SaveReportContent struct {
|
|
|
Content string `description:"内容"`
|
|
|
ReportId int `description:"报告id"`
|
|
@@ -716,28 +664,12 @@ type SaveReportContent struct {
|
|
|
}
|
|
|
|
|
|
func AddReportSaveLog(reportId, adminId int, content, contentSub, contentStruct, canvasColor, adminName string, headResourceId, endResourceId int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := ` INSERT INTO report_save_log(report_id, content,content_sub,content_struct,canvas_color,head_resource_id,end_resource_id,admin_id,admin_name) VALUES (?,?,?,?,?,?,?,?,?) `
|
|
|
- //_, err = o.Raw(sql, reportId, content, contentSub, contentStruct, canvasColor, headResourceId, endResourceId, adminId, adminName).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, reportId, content, contentSub, contentStruct, canvasColor, headResourceId, endResourceId, adminId, adminName).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func MultiAddReportChaptersSaveLog(items []*ReportChapter, adminId int, adminRealName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- //p, err := o.Raw(`INSERT INTO report_save_log(report_id, report_chapter_id, content, content_sub,content_struct,admin_id, admin_name) VALUES (?,?,?,?,?,?,?)`).Prepare()
|
|
|
- //if err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
- //defer func() {
|
|
|
- // _ = p.Close()
|
|
|
- //}()
|
|
|
- //for _, v := range items {
|
|
|
- // _, err = p.Exec(v.ReportId, v.ReportChapterId, v.Content, v.ContentSub, v.ContentStruct, adminId, adminRealName)
|
|
|
- // if err != nil {
|
|
|
- // return
|
|
|
- // }
|
|
|
- //}
|
|
|
tx := global.DmSQL["rddp"].Begin()
|
|
|
for _, v := range items {
|
|
|
err = tx.Exec(`INSERT INTO report_save_log(report_id, report_chapter_id, content, content_sub,content_struct,admin_id, admin_name) VALUES (?,?,?,?,?,?,?)`, v.ReportId, v.ReportChapterId, v.Content, v.ContentSub, v.ContentStruct, adminId, adminRealName).Error
|
|
@@ -755,18 +687,14 @@ type SaveReportContentResp struct {
|
|
|
}
|
|
|
|
|
|
func ModifyReportCode(reportId int64, reportCode string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET report_code=? WHERE id=? `
|
|
|
- //_, err = o.Raw(sql, reportCode, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, reportCode, reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ModifyReportThsMsgIsSend(item *ReportDetail) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
if item.ThsMsgIsSend == 0 {
|
|
|
sql := `UPDATE report SET ths_msg_is_send = 1 WHERE id = ? `
|
|
|
- //_, err = o.Raw(sql, item.Id).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, item.Id).Error
|
|
|
}
|
|
|
return
|
|
@@ -791,17 +719,13 @@ type SaveDayWeekReportReq struct {
|
|
|
|
|
|
// GetReportByReportId 主键获取报告
|
|
|
func GetReportByReportId(reportId int) (item *Report, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT * FROM report WHERE id = ?`
|
|
|
- //err = o.Raw(sql, reportId).QueryRow(&item)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// DeleteDayWeekReportAndChapter 删除晨周报及章节
|
|
|
func DeleteDayWeekReportAndChapter(reportId int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- //to, err := o.Begin()
|
|
|
to := global.DmSQL["rddp"].Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -812,16 +736,10 @@ func DeleteDayWeekReportAndChapter(reportId int) (err error) {
|
|
|
}()
|
|
|
|
|
|
sql := ` DELETE FROM report WHERE id = ? LIMIT 1 `
|
|
|
- //if _, err = to.Raw(sql, reportId).Exec(); err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
if err = to.Exec(sql, reportId).Error; err != nil {
|
|
|
return
|
|
|
}
|
|
|
sql = ` DELETE FROM report_chapter WHERE report_id = ? `
|
|
|
- //if _, err = to.Raw(sql, reportId).Exec(); err != nil {
|
|
|
- // return
|
|
|
- //}
|
|
|
if err = to.Exec(sql, reportId).Error; err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -830,8 +748,6 @@ func DeleteDayWeekReportAndChapter(reportId int) (err error) {
|
|
|
|
|
|
// UpdateReport 更新报告
|
|
|
func (reportInfo *Report) UpdateReport(cols []string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- //_, err = o.Update(reportInfo, cols...)
|
|
|
err = global.DmSQL["rddp"].Select(cols).Updates(reportInfo).Error
|
|
|
return
|
|
|
}
|
|
@@ -881,8 +797,6 @@ type ElasticReportDetail struct {
|
|
|
|
|
|
// PublishReportAndChapter 发布报告及章节
|
|
|
func PublishReportAndChapter(reportInfo *Report, isPublishReport bool, cols []string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- //to, err := o.Begin()
|
|
|
to := global.DmSQL["rddp"].Begin()
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
@@ -893,7 +807,6 @@ func PublishReportAndChapter(reportInfo *Report, isPublishReport bool, cols []st
|
|
|
}()
|
|
|
// 更新报告
|
|
|
if isPublishReport {
|
|
|
- // _, err = to.Update(reportInfo, cols...)
|
|
|
err = to.Select(cols).Updates(reportInfo).Error
|
|
|
if err != nil {
|
|
|
return
|
|
@@ -902,36 +815,20 @@ func PublishReportAndChapter(reportInfo *Report, isPublishReport bool, cols []st
|
|
|
|
|
|
// 发布该报告的所有章节
|
|
|
sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? `
|
|
|
- //_, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id).Exec()
|
|
|
err = to.Exec(sql, reportInfo.PublishTime, reportInfo.Id).Error
|
|
|
- // 发布章节
|
|
|
- //if len(publishIds) > 0 {
|
|
|
- // sql := ` UPDATE report_chapter SET publish_state = 2, publish_time = ? WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(publishIds)) + `) `
|
|
|
- // _, err = to.Raw(sql, reportInfo.PublishTime, reportInfo.Id, publishIds).Exec()
|
|
|
- //}
|
|
|
-
|
|
|
- //if len(unPublishIds) > 0 {
|
|
|
- // sql := ` UPDATE report_chapter SET publish_state = 1, publish_time = NULL, is_edit = 0 WHERE report_id = ? AND report_chapter_id IN (` + utils.GetOrmInReplace(len(unPublishIds)) + `) `
|
|
|
- // _, err = to.Raw(sql, reportInfo.Id, unPublishIds).Exec()
|
|
|
- //}
|
|
|
-
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// PublishReportById 发布报告
|
|
|
func PublishReportById(reportId int, publishTime time.Time, lastModifyAdminId int, lastModifyAdminName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET state = 2, publish_time = ?, pre_publish_time=null, pre_msg_send=0, modify_time = NOW(),last_modify_admin_id=?,last_modify_admin_name=? WHERE id = ? `
|
|
|
- //_, err = o.Raw(sql, publishTime, lastModifyAdminId, lastModifyAdminName, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, publishTime, lastModifyAdminId, lastModifyAdminName, reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// ResetReportById 重置报告状态
|
|
|
func ResetReportById(reportId, state int, lastModifyAdminId int, lastModifyAdminName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET state = ?, pre_publish_time = null, pre_msg_send = 0, modify_time = NOW(),last_modify_admin_id=?,last_modify_admin_name=? WHERE id = ?`
|
|
|
- //_, err = o.Raw(sql, state, lastModifyAdminId, lastModifyAdminName, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, state, lastModifyAdminId, lastModifyAdminName, reportId).Error
|
|
|
return
|
|
|
}
|
|
@@ -969,16 +866,12 @@ type YbPcSuncode struct {
|
|
|
|
|
|
// GetYbPcSunCode 获取太阳码
|
|
|
func GetYbPcSunCode(scene, page string) (item *YbPcSuncode, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("weekly")
|
|
|
sql := `SELECT * FROM yb_pc_suncode WHERE scene = ? AND code_page = ? `
|
|
|
- //err = o.Raw(sql, scene, page).QueryRow(&item)
|
|
|
err = global.DmSQL["weekly"].Raw(sql, scene, page).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func AddYbPcSunCode(item *YbPcSuncode) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("weekly")
|
|
|
- //_, err = o.Insert(item)
|
|
|
err = global.DmSQL["weekly"].Create(item).Error
|
|
|
return
|
|
|
}
|
|
@@ -992,35 +885,27 @@ type YbSuncodePars struct {
|
|
|
}
|
|
|
|
|
|
func AddYbSuncodePars(item *YbSuncodePars) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("weekly")
|
|
|
- //_, err = o.Insert(item)
|
|
|
err = global.DmSQL["weekly"].Create(item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateReportSecondClassifyNameByClassifyId 更新报告分类名称字段
|
|
|
func UpdateReportSecondClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := " UPDATE report SET classify_name_second = ? WHERE classify_id_second = ? "
|
|
|
- //_, err = o.Raw(sql, classifyName, classifyId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, classifyName, classifyId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateReportFirstClassifyNameByClassifyId 更新报告分类一级名称字段
|
|
|
func UpdateReportFirstClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := " UPDATE report SET classify_name_first = ? WHERE classify_id_first = ? "
|
|
|
- //_, err = o.Raw(sql, classifyName, classifyId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, classifyName, classifyId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateReportThirdClassifyNameByClassifyId 更新报告的三级分类名称字段
|
|
|
func UpdateReportThirdClassifyNameByClassifyId(classifyId int, classifyName string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := " UPDATE report SET classify_name_third = ? WHERE classify_id_third = ? "
|
|
|
- //_, err = o.Raw(sql, classifyName, classifyId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, classifyName, classifyId).Error
|
|
|
return
|
|
|
}
|
|
@@ -1028,13 +913,10 @@ func UpdateReportThirdClassifyNameByClassifyId(classifyId int, classifyName stri
|
|
|
// ModifyReportAuthor 更改报告作者
|
|
|
func ModifyReportAuthor(condition string, pars []interface{}, authorName string) (count int, err error) {
|
|
|
//产品权限
|
|
|
- //oRddp := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE english_report set author = ? WHERE 1=1 `
|
|
|
if condition != "" {
|
|
|
sql += condition
|
|
|
}
|
|
|
- //err = oRddp.Raw(sql, authorName, pars).QueryRow(&count)
|
|
|
- //err = global.DmSQL["rddp"].Raw(sql, utils.ForwardPars(pars, authorName)...).Scan(&count).Error
|
|
|
result := global.DmSQL["rddp"].Raw(sql, utils.ForwardPars(pars, authorName)...)
|
|
|
count = int(result.RowsAffected)
|
|
|
err = result.Error
|
|
@@ -1042,31 +924,25 @@ func ModifyReportAuthor(condition string, pars []interface{}, authorName string)
|
|
|
}
|
|
|
|
|
|
func UpdateReportPublishTime(reportId int, videoNameDate string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql1 := ` UPDATE report SET publish_time = NOW() WHERE id = ? `
|
|
|
- //_, err = o.Raw(sql1, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql1, reportId).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
//修改音频标题
|
|
|
sql2 := ` UPDATE report SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE id = ? and (video_name !='' and video_name is not null)`
|
|
|
- //_, err = o.Raw(sql2, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql2, reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func UpdateReportChapterPublishTime(reportId int, videoNameDate string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql1 := ` UPDATE report_chapter SET publish_time = NOW() WHERE report_id = ? `
|
|
|
- //_, err = o.Raw(sql1, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql1, reportId).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
//修改音频标题
|
|
|
sql2 := ` UPDATE report_chapter SET video_name=CONCAT(SUBSTRING_INDEX(video_name,"(",1),"` + videoNameDate + `") WHERE report_id = ? and (video_name !='' and video_name is not null)`
|
|
|
- //_, err = o.Raw(sql2, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql2, reportId).Error
|
|
|
return
|
|
|
}
|
|
@@ -1092,7 +968,6 @@ type MarkReportItem struct {
|
|
|
|
|
|
// GetReportByCondition 获取报告
|
|
|
func GetReportByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string, isPage bool, startSize, pageSize int) (items []*Report, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
fields := `*`
|
|
|
if len(fieldArr) > 0 {
|
|
|
fields = strings.Join(fieldArr, ",")
|
|
@@ -1106,10 +981,8 @@ func GetReportByCondition(condition string, pars []interface{}, fieldArr []strin
|
|
|
sql += order
|
|
|
if isPage {
|
|
|
sql += ` LIMIT ?,?`
|
|
|
- //_, err = o.Raw(sql, pars...).QueryRows(&items)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
|
} else {
|
|
|
- //_, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, pars...).Find(&items).Error
|
|
|
}
|
|
|
return
|
|
@@ -1117,9 +990,7 @@ func GetReportByCondition(condition string, pars []interface{}, fieldArr []strin
|
|
|
|
|
|
// SetPrePublishReportById 设置定时发布
|
|
|
func SetPrePublishReportById(reportId int, prePublishTime string, preMsgSend int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET pre_publish_time=?, pre_msg_send=? WHERE id = ? and state = 1 `
|
|
|
- //_, err = o.Raw(sql, prePublishTime, preMsgSend, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, prePublishTime, preMsgSend, reportId).Error
|
|
|
return
|
|
|
}
|
|
@@ -1135,25 +1006,20 @@ type ReportCancelApproveReq struct {
|
|
|
}
|
|
|
|
|
|
func (m *Report) GetItemById(id int) (item *Report, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT * FROM report WHERE id = ? LIMIT 1`
|
|
|
- //err = o.Raw(sql, id).QueryRow(&item)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, id).First(&item).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// GetReportStateCount 获取指定状态的报告数量
|
|
|
func GetReportStateCount(state int) (count int, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `SELECT COUNT(1) AS count FROM report WHERE state = ?`
|
|
|
- //err = o.Raw(sql, state).QueryRow(&count)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, state).Scan(&count).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdateReportsStateByCond 批量更新报告状态
|
|
|
func UpdateReportsStateByCond(classifyFirstId, classifySecondId, classifyThirdId, oldState, newState int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
cond := ``
|
|
|
if classifyFirstId > 0 {
|
|
|
cond += fmt.Sprintf(` AND classify_id_first = %d`, classifyFirstId)
|
|
@@ -1165,7 +1031,6 @@ func UpdateReportsStateByCond(classifyFirstId, classifySecondId, classifyThirdId
|
|
|
cond += fmt.Sprintf(` AND classify_id_third = %d`, classifyThirdId)
|
|
|
}
|
|
|
sql := fmt.Sprintf(`UPDATE report SET state = ?, pre_publish_time = NULL WHERE state = ? %s`, cond)
|
|
|
- //_, err = o.Raw(sql, newState, oldState).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, newState, oldState).Error
|
|
|
return
|
|
|
}
|
|
@@ -1175,17 +1040,14 @@ func UpdateReportsStateBySecondIds(oldState, newState int, secondIds []int) (err
|
|
|
if len(secondIds) <= 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
// (有审批流的)未发布->待提交
|
|
|
sql := fmt.Sprintf(`UPDATE report SET state = ?, pre_publish_time = NULL WHERE state = ? AND classify_id_second IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
|
|
|
- //_, err = o.Raw(sql, newState, oldState, secondIds).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, newState, oldState, secondIds).Error
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
// (无审批流的)待提交->未发布
|
|
|
sql = fmt.Sprintf(`UPDATE report SET state = ?, pre_publish_time = NULL WHERE state = ? AND classify_id_second NOT IN (%s)`, utils.GetOrmInReplace(len(secondIds)))
|
|
|
- //_, err = o.Raw(sql, oldState, newState, secondIds).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, oldState, newState, secondIds).Error
|
|
|
return
|
|
|
}
|
|
@@ -1198,26 +1060,20 @@ type GetReportPdfUrlReq struct {
|
|
|
}
|
|
|
|
|
|
func ModifyReportPdfUrl(reportId int, detailPdfUrl string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET detail_pdf_url=? WHERE id=? `
|
|
|
- //_, err = o.Raw(sql, detailPdfUrl, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, detailPdfUrl, reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
func ModifyReportImgUrl(reportId int, detailImgUrl string) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET detail_img_url=? WHERE id=? `
|
|
|
- //_, err = o.Raw(sql, detailImgUrl, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, detailImgUrl, reportId).Error
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// UpdatePdfUrlReportById 清空pdf相关字段
|
|
|
func UpdatePdfUrlReportById(reportId int) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
sql := `UPDATE report SET detail_img_url = '',detail_pdf_url='',modify_time=NOW() WHERE id = ? `
|
|
|
- //_, err = o.Raw(sql, reportId).Exec()
|
|
|
err = global.DmSQL["rddp"].Exec(sql, reportId).Error
|
|
|
return
|
|
|
}
|
|
@@ -1229,8 +1085,6 @@ func UpdatePdfUrlReportById(reportId int) (err error) {
|
|
|
// @param items []*Report
|
|
|
// @return err error
|
|
|
func InsertMultiReport(items []*Report) (err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
- //_, err = o.InsertMulti(500, items)
|
|
|
err = global.DmSQL["rddp"].CreateInBatches(items, utils.MultiAddNum).Error
|
|
|
return
|
|
|
}
|
|
@@ -1250,10 +1104,7 @@ type ReportLayout struct {
|
|
|
// @return item ReportLayout
|
|
|
// @return err error
|
|
|
func GetReportLayoutByReportId(reportId int) (item ReportLayout, err error) {
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
-
|
|
|
sql := `SELECT id, report_layout FROM report WHERE id = ? `
|
|
|
- //err = o.Raw(sql, reportId).QueryRow(&item)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, reportId).First(&item).Error
|
|
|
return
|
|
|
}
|
|
@@ -1262,13 +1113,11 @@ func GetReportFieldsByIds(ids []int, fields []string) (items []*Report, err erro
|
|
|
if len(ids) == 0 {
|
|
|
return
|
|
|
}
|
|
|
- //o := orm.NewOrmUsingDB("rddp")
|
|
|
field := " * "
|
|
|
if len(fields) > 0 {
|
|
|
field = fmt.Sprintf(" %s ", strings.Join(fields, ","))
|
|
|
}
|
|
|
sql := fmt.Sprintf(`SELECT %s FROM report WHERE id IN (%s)`, field, utils.GetOrmInReplace(len(ids)))
|
|
|
- //_, err = o.Raw(sql, ids).QueryRows(&items)
|
|
|
err = global.DmSQL["rddp"].Raw(sql, ids).Find(&items).Error
|
|
|
return
|
|
|
}
|