123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 |
- package models
- import (
- "eta/eta_hub/utils"
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "html"
- "strings"
- "time"
- )
- // 报告状态
- const (
- ReportStateUnpublished = 1 // 未发布
- ReportStatePublished = 2 // 已发布
- ReportStateWaitSubmit = 3 // 待提交
- ReportStateWaitApprove = 4 // 审批中
- ReportStateRefused = 5 // 已驳回
- ReportStatePass = 6 // 已通过
- )
- // 报告操作
- const (
- ReportOperateAdd = 1 // 新增报告
- ReportOperateEdit = 2 // 编辑报告
- ReportOperatePublish = 3 // 发布报告
- ReportOperateCancelPublish = 4 // 取消发布报告
- ReportOperateSubmitApprove = 5 // 提交审批
- ReportOperateCancelApprove = 6 // 撤回审批
- )
- // 报告类型
- const (
- ReportTypeChinese = 1 // 中文研报
- ReportTypeEnglish = 2 // 英文研报
- ReportTypeSmart = 3 // 智能研报
- )
- type Report struct {
- Id int `orm:"column(id)" description:"报告Id"`
- AddType int `json:"-" description:"新增方式:1:新增报告,2:继承报告"`
- ClassifyIdFirst int `description:"一级分类id"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类id"`
- ClassifyNameSecond string `description:"二级分类名称"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- State int `description:"状态:1-未提交 2-待审核 3-驳回 4-审核"`
- Stage int `description:"期数"`
- MsgIsSend int `json:"-" description:"消息是否已发送,0:否,1:是"`
- ThsMsgIsSend int `json:"-" description:"客户群消息是否已发送,0:否,1:是"`
- Content string `description:"内容"`
- VideoUrl string `description:"音频文件URL"`
- VideoName string `description:"音频文件名称"`
- VideoPlaySeconds string `description:"音频播放时长"`
- VideoSize string `description:"音频文件大小,单位M"`
- ContentSub string `json:"-" description:"内容前两个章节"`
- ReportCode string `description:"报告唯一编码"`
- ReportVersion int `json:"-" description:"1:旧版,2:新版"`
- HasChapter int `json:"-" description:"是否有章节 0-否 1-是"`
- ChapterType string `json:"-" description:"章节类型 day-晨报 week-周报"`
- OldReportId int `json:"-" description:"research_report表ID, 大于0则表示该报告为老后台同步过来的"`
- MsgSendTime time.Time `json:"-" description:"模版消息发送时间"`
- AdminId int `description:"创建者账号"`
- AdminRealName string `description:"创建者姓名"`
- ApproveTime time.Time `description:"审批时间"`
- PublishTime time.Time `description:"发布时间"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- // eta1.8.3(研报改版)相关内容
- ContentStruct string `description:"内容组件"`
- LastModifyAdminId int `description:"最后更新人ID"`
- LastModifyAdminName string `description:"最后更新人姓名"`
- ContentModifyTime time.Time `description:"内容更新时间"`
- Pv int `description:"pv"`
- Uv int `description:"uv"`
- HeadImg string `description:"报告头图地址"`
- EndImg string `description:"报告尾图地址"`
- HeadStyle string `description:"版头样式"`
- EndStyle string `description:"版尾样式"`
- CanvasColor string `description:"画布颜色"`
- NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
- HeadResourceId int `description:"版头资源ID"`
- EndResourceId int `description:"版尾资源ID"`
- ClassifyIdThird int `description:"三级分类id"`
- ClassifyNameThird string `description:"三级分类名称"`
- CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
- ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
- IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
- ReportCreateTime time.Time `description:"报告时间创建时间"`
- DetailImgUrl string `description:"报告详情长图地址"`
- DetailPdfUrl string `description:"报告详情PDF地址"`
- }
- type ReportListResp struct {
- List []*ReportItem
- Paging *paging.PagingItem `description:"分页数据"`
- }
- func GetReportListCount(condition string, pars []interface{}, companyType string) (count int, err error) {
- //产品权限
- companyTypeSqlStr := ``
- if companyType == "ficc" {
- companyTypeSqlStr = " AND classify_id_first != 40 "
- } else if companyType == "权益" {
- companyTypeSqlStr = " AND classify_id_first = 40 "
- }
- oRddp := orm.NewOrmUsingDB("rddp")
- sql := `SELECT COUNT(1) AS count FROM report WHERE 1=1 ` + companyTypeSqlStr
- if condition != "" {
- sql += condition
- }
- err = oRddp.Raw(sql, pars).QueryRow(&count)
- return
- }
- func GetReportList(condition string, pars []interface{}, startSize, pageSize int) (items []*Report, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM report WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- sql += `ORDER BY FIELD(state,3,1,4,5,6,2), modify_time DESC LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // PublishReport 发布报告
- func PublishReport(reportIds []int) (err error) {
- if len(reportIds) == 0 {
- return
- }
- o := orm.NewOrmUsingDB("rddp")
- sql := `UPDATE report SET state=2,publish_time=now(),modify_time=NOW() WHERE id IN (` + utils.GetOrmInReplace(len(reportIds)) + `)`
- _, err = o.Raw(sql).Exec()
- return
- }
- // PublishCancleReport 取消发布报告
- func PublishCancleReport(reportIds int, publishTimeNullFlag bool) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- var sql string
- if publishTimeNullFlag {
- sql = ` UPDATE report SET state=1, publish_time=null, pre_publish_time=null, pre_msg_send=0 WHERE id =?`
- } else {
- sql = ` UPDATE report SET state=1, pre_publish_time=null, pre_msg_send=0 WHERE id =?`
- }
- _, err = o.Raw(sql, reportIds).Exec()
- return
- }
- // 删除报告
- func DeleteReport(reportIds int) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` DELETE FROM report WHERE id =? `
- _, err = o.Raw(sql, reportIds).Exec()
- return
- }
- type ReportDetail struct {
- Id int `orm:"column(id)" description:"报告Id"`
- AddType int `description:"新增方式:1:新增报告,2:继承报告"`
- ClassifyIdFirst int `description:"一级分类id"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类id"`
- ClassifyNameSecond string `description:"二级分类名称"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- CreateTime string `description:"创建时间"`
- ModifyTime string `description:"修改时间"`
- State int `description:"状态:1-未提交 2-待审核 3-驳回 4-审核"`
- PublishTime string `description:"发布时间"`
- PrePublishTime string `description:"预发布时间"`
- Stage int `description:"期数"`
- MsgIsSend int `json:"-" description:"消息是否已发送,0:否,1:是"`
- PreMsgSend int `json:"-" description:"定时发布成功后是否立即推送模版消息:0否,1是"`
- Content string `description:"内容"`
- VideoUrl string `description:"音频文件URL"`
- VideoName string `description:"音频文件名称"`
- VideoPlaySeconds string `description:"音频播放时长"`
- ContentSub string `json:"-" description:"内容前两个章节"`
- ThsMsgIsSend int `json:"-" description:"客户群消息是否已发送,0:否,1:是"`
- HasChapter int `json:"-" description:"是否有章节 0-否 1-是"`
- ChapterType string `json:"-" description:"章节类型 day-晨报 week-周报"`
- }
- func GetReportById(reportId int) (item *Report, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM report WHERE id=?`
- err = o.Raw(sql, reportId).QueryRow(&item)
- return
- }
- func GetReportStage(classifyIdFirst, classifyIdSecond int) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ``
- if classifyIdSecond > 0 {
- sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? "
- o.Raw(sql, classifyIdSecond).QueryRow(&count)
- } else {
- sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? "
- o.Raw(sql, classifyIdFirst).QueryRow(&count)
- }
- return
- }
- func GetReportStageEdit(classifyIdFirst, classifyIdSecond, reportId int) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ``
- if classifyIdSecond > 0 {
- sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_second=? AND id<>? "
- o.Raw(sql, classifyIdSecond, reportId).QueryRow(&count)
- } else {
- sql = "SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first=? AND id<>? "
- o.Raw(sql, classifyIdFirst, reportId).QueryRow(&count)
- }
- return
- }
- type PublishReq struct {
- ReportIds string `description:"报告id,多个用英文逗号隔开"`
- State int `description:"状态:1-未提交 2-待审核 3-驳回 4-审核"`
- }
- type PublishCancelReq struct {
- ReportIds int `description:"报告id"`
- }
- type DeleteReq struct {
- ReportIds int `description:"报告id"`
- }
- type AddReq struct {
- AddType int `description:"新增方式:1:新增报告,2:继承报告"`
- ClassifyIdFirst int `description:"一级分类id"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类id"`
- ClassifyNameSecond string `description:"二级分类名称"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- State int `description:"状态:1:未发布,2:已发布"`
- Content string `description:"内容"`
- CreateTime string `description:"创建时间"`
- ReportVersion int `description:"1:旧版,2:新版"`
- }
- type PrePublishReq struct {
- ReportId int `description:"报告id"`
- PrePublishTime string `description:"预发布时间"`
- PreMsgSend int `description:"定时发布成功后是否立即推送模版消息:0否,1是"`
- }
- type AddResp struct {
- ReportId int64 `description:"报告id"`
- 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"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类id"`
- ClassifyNameSecond string `description:"二级分类名称"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- State int `description:"状态:1:未发布,2:已发布"`
- Content string `description:"内容"`
- CreateTime string `description:"创建时间"`
- }
- type EditResp struct {
- ReportId int64 `description:"报告id"`
- ReportCode string `description:"报告code"`
- }
- func EditReport(item *Report, reportId int64) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `UPDATE report
- SET
- classify_id_first =?,
- classify_name_first = ?,
- classify_id_second = ?,
- classify_name_second = ?,
- title = ?,
- abstract = ?,
- author = ?,
- frequency = ?,
- state = ?,
- content = ?,
- content_sub = ?,
- stage =?,
- 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()
- return
- }
- type ReportDetailReq struct {
- ReportId int `description:"报告id"`
- }
- type ClassifyIdDetailReq struct {
- ClassifyIdFirst int `description:"报告一级分类id"`
- ClassifyIdSecond int `description:"报告二级分类id"`
- }
- type SendTemplateMsgReq struct {
- ReportId int `description:"报告id"`
- }
- 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()
- return
- }
- func EditReportContent(reportId int, content, contentSub string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
- _, err = o.Raw(sql, content, contentSub, reportId).Exec()
- return
- }
- func AddReportSaveLog(reportId, adminId int, content, contentSub, adminName string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` INSERT INTO report_save_log(report_id, content,content_sub,admin_id,admin_name) VALUES (?,?,?,?,?) `
- _, err = o.Raw(sql, reportId, content, contentSub, adminId, adminName).Exec()
- return
- }
- type SaveReportContentResp struct {
- ReportId int `description:"报告id"`
- }
- 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()
- 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()
- }
- return
- }
- // GetDayWeekReportStage 获取晨报周报期数
- func GetDayWeekReportStage(classifyIdFirst int, yearStart time.Time) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := " SELECT MAX(stage) AS max_stage FROM report WHERE classify_id_first = ? AND create_time > ? "
- o.Raw(sql, classifyIdFirst, yearStart).QueryRow(&count)
- return
- }
- // 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)
- return
- }
- // 发布报告
- func PublishReportById(reportId, state int, publishTime time.Time) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `UPDATE report SET state = ?, publish_time = ?, pre_publish_time = null, pre_msg_send=0, modify_time = NOW() WHERE id = ? `
- _, err = o.Raw(sql, state, publishTime, reportId).Exec()
- return
- }
- 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()
- 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()
- 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()
- 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()
- return
- }
- // 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, ",")
- }
- sql := `SELECT ` + fields + ` FROM report WHERE 1=1 `
- sql += condition
- order := ` ORDER BY modify_time DESC`
- if orderRule != `` {
- order = orderRule
- }
- sql += order
- if isPage {
- sql += ` LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- } else {
- _, err = o.Raw(sql, pars).QueryRows(&items)
- }
- return
- }
- type ElasticReportDetail struct {
- ReportId int `description:"报告ID"`
- ReportChapterId int `description:"报告章节ID"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- BodyContent string `description:"内容"`
- PublishTime string `description:"发布时间"`
- PublishState int `description:"状态:1-未提交 2-待审核 3-驳回 4-审核"`
- Author string `description:"作者"`
- ClassifyIdFirst int `description:"一级分类ID"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类ID"`
- ClassifyNameSecond string `description:"二级分类名称"`
- ClassifyId int `description:"最小单元的分类ID"`
- ClassifyName string `description:"最小单元的分类名称"`
- Categories string `description:"关联的品种名称(包括品种别名)"`
- StageStr string `description:"报告期数"`
- }
- type ReportItem struct {
- Id int `description:"报告Id"`
- ReportCode string `description:"报告唯一编码"`
- ClassifyIdFirst int `description:"一级分类id"`
- ClassifyNameFirst string `description:"一级分类名称"`
- ClassifyIdSecond int `description:"二级分类id"`
- ClassifyNameSecond string `description:"二级分类名称"`
- Title string `description:"标题"`
- Abstract string `description:"摘要"`
- Author string `description:"作者"`
- Frequency string `description:"频度"`
- State int `description:"状态:1:未发布;2:已发布;3-待提交;4-待审批;5-已驳回;6-已通过"`
- Stage int `description:"期数"`
- Content string `description:"内容"`
- VideoUrl string `description:"音频文件URL"`
- VideoName string `description:"音频文件名称"`
- VideoPlaySeconds string `description:"音频播放时长"`
- VideoSize string `description:"音频文件大小,单位M"`
- AdminId int `description:"创建者账号"`
- AdminRealName string `description:"创建者姓名"`
- PublishTime string `description:"发布时间"`
- ApproveTime string `description:"审批时间"`
- CreateTime string `description:"创建时间"`
- ModifyTime string `description:"修改时间"`
- // eta1.8.3(研报改版)相关内容
- //ContentStruct string `description:"内容组件"`
- //LastModifyAdminId int `description:"最后更新人ID"`
- //LastModifyAdminName string `description:"最后更新人姓名"`
- ContentModifyTime string `description:"内容更新时间"`
- //Pv int `description:"pv"`
- //Uv int `description:"uv"`
- HeadImg string `description:"报告头图地址"`
- EndImg string `description:"报告尾图地址"`
- HeadStyle string `description:"版头样式"`
- EndStyle string `description:"版尾样式"`
- CanvasColor string `description:"画布颜色"`
- NeedSplice int `description:"是否拼接版头版位的标记,主要是为了兼容历史报告。0-不需要 1-需要"`
- //HeadResourceId int `description:"版头资源ID"`
- //EndResourceId int `description:"版尾资源ID"`
- ClassifyIdThird int `description:"三级分类id"`
- ClassifyNameThird string `description:"三级分类名称"`
- //CollaborateType int8 `description:"协作方式,1:个人,2:多人协作。默认:1"`
- ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
- IsPublicPublish int8 `description:"是否公开发布,1:是,2:否"`
- ReportCreateTime string `description:"报告时间创建时间"`
- ChapterList []*ReportChapterItem `description:"章节列表"`
- HasChapter int `description:"是否有章节 0-否 1-是"`
- DetailImgUrl string `description:"报告详情长图地址"`
- DetailPdfUrl string `description:"报告详情PDF地址"`
- }
- func FormatReport2Item(origin *Report, chapterList []*ReportChapterItem) (item *ReportItem) {
- if origin == nil {
- return
- }
- item = new(ReportItem)
- item.Id = origin.Id
- item.ReportCode = origin.ReportCode
- item.ClassifyIdFirst = origin.ClassifyIdFirst
- item.ClassifyNameFirst = origin.ClassifyNameFirst
- item.ClassifyIdSecond = origin.ClassifyIdSecond
- item.ClassifyNameSecond = origin.ClassifyNameSecond
- item.Title = origin.Title
- item.Abstract = origin.Abstract
- item.Author = origin.Author
- item.Frequency = origin.Frequency
- item.State = origin.State
- item.Stage = origin.Stage
- item.Content = html.UnescapeString(origin.Content)
- item.VideoUrl = origin.VideoUrl
- item.VideoName = origin.VideoName
- item.VideoPlaySeconds = origin.VideoPlaySeconds
- item.VideoSize = origin.VideoSize
- item.AdminId = origin.AdminId
- item.AdminRealName = origin.AdminRealName
- item.PublishTime = utils.TimeTransferString(utils.FormatDateTime, origin.PublishTime)
- item.ApproveTime = utils.TimeTransferString(utils.FormatDateTime, origin.ApproveTime)
- item.CreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.CreateTime)
- item.ModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ModifyTime)
- // eta1.8.3(研报改版)相关内容
- item.HeadImg = origin.HeadImg
- item.EndImg = origin.EndImg
- item.HeadStyle = origin.HeadStyle
- item.EndStyle = origin.EndStyle
- item.CanvasColor = origin.CanvasColor
- item.NeedSplice = origin.NeedSplice
- item.ClassifyIdThird = origin.ClassifyIdThird
- item.ClassifyNameThird = origin.ClassifyNameThird
- item.ReportLayout = origin.ReportLayout
- item.IsPublicPublish = origin.IsPublicPublish
- item.ContentModifyTime = utils.TimeTransferString(utils.FormatDateTime, origin.ContentModifyTime)
- item.ReportCreateTime = utils.TimeTransferString(utils.FormatDateTime, origin.ReportCreateTime)
- item.ChapterList = chapterList
- item.HasChapter = origin.HasChapter
- item.DetailImgUrl = origin.DetailImgUrl
- item.DetailPdfUrl = origin.DetailPdfUrl
- return
- }
- // ReportApproveReq 报告审批请求体
- type ReportApproveReq struct {
- ReportId int `description:"报告ID"`
- Pass bool `description:"是否通过审批"`
- }
- // UpdateReport 更新报告
- func (m *Report) UpdateReport(cols []string) (err error) {
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Update(m, cols...)
- return
- }
- // 获取分类列表
- func GetClassifyList(startSize, pageSize int, keyWord, companyType string) (items []*ClassifyList, err error) {
- sql := ``
- companyTypeSqlStr := ``
- if companyType == "ficc" {
- companyTypeSqlStr = " AND id != 40 AND parent_id != 40 "
- } else if companyType == "权益" {
- companyTypeSqlStr = " AND (id = 40 or parent_id = 40) "
- }
- pars := make([]interface{}, 0)
- if keyWord != "" {
- sql = `SELECT * FROM (
- SELECT * FROM classify
- WHERE parent_id=0 ` + companyTypeSqlStr + ` AND classify_name LIKE ?
- UNION
- SELECT * FROM classify
- WHERE id IN( SELECT parent_id FROM classify
- WHERE parent_id>0 ` + companyTypeSqlStr + ` AND classify_name LIKE ? )
- )AS t
- ORDER BY sort ASC,create_time ASC
- LIMIT ?,? `
- pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
- } else {
- sql = `SELECT * FROM classify WHERE parent_id=0 ` + companyTypeSqlStr
- sql += ` ORDER BY sort ASC, create_time ASC LIMIT ?,? `
- }
- pars = append(pars, startSize, pageSize)
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Raw(sql, pars...).QueryRows(&items)
- return
- }
- func GetClassifyListCount(keyWord, companyType string) (count int, err error) {
- sqlCount := ``
- companyTypeSqlStr := ``
- if companyType == "ficc" {
- companyTypeSqlStr = " AND id != 40 AND parent_id != 40 "
- } else if companyType == "权益" {
- companyTypeSqlStr = " AND (id = 40 or parent_id = 40) "
- }
- pars := make([]interface{}, 0)
- if keyWord != "" {
- sqlCount = `SELECT COUNT(1) AS count FROM (
- SELECT * FROM classify
- WHERE parent_id=0 ` + companyTypeSqlStr + ` AND classify_name LIKE ?
- UNION
- SELECT * FROM classify
- WHERE id IN(SELECT parent_id FROM classify
- WHERE parent_id>0 ` + companyTypeSqlStr + ` AND classify_name LIKE ? )
- )AS t `
- pars = utils.GetLikeKeywordPars(pars, keyWord, 2)
- } else {
- sqlCount = `SELECT COUNT(1) AS count FROM classify WHERE parent_id=0 ` + companyTypeSqlStr
- }
- o := orm.NewOrmUsingDB("rddp")
- err = o.Raw(sqlCount, pars...).QueryRow(&count)
- return
- }
- // GetClassifyListByKeywordV2
- // @Description: 获取分类列表
- // @author: Roc
- // @datetime 2024-06-19 09:49:33
- // @param keyWord string
- // @param enabled int
- // @return items []*ClassifyList
- // @return err error
- func GetClassifyListByKeywordV2(keyWord string, enabled int) (items []*ClassifyListV2, err error) {
- sql := ``
- pars := make([]interface{}, 0)
- sql = `SELECT * FROM classify WHERE 1=1 `
- if enabled == 1 {
- sql += ` AND enabled = 1 `
- }
- if keyWord != `` {
- sql += ` AND classify_name LIKE ? `
- pars = utils.GetLikeKeywordPars(pars, keyWord, 1)
- }
- sql += ` ORDER BY sort ASC, create_time ASC`
- o := orm.NewOrmUsingDB("rddp")
- _, err = o.Raw(sql, pars...).QueryRows(&items)
- return
- }
|