123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- package cygx
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type CygxResearchSummary struct {
- ArticleId int `orm:"column(article_id);pk"description:"报告id"`
- Title string `description:"标题"`
- Department string `description:"作者"`
- Abstract string `description:"摘要"`
- PublishStatus int `description:"发布状态,1已发布,0未发布"`
- PublishDate time.Time `description:"发布时间"`
- CreateTime time.Time `description:"创建时间"`
- LastUpdatedTime time.Time `description:"最后一次更新时间"`
- Periods string `description:"期数"`
- HavePublish int `description:"是否发布过,1是,0否"`
- AdminId int `description:"销售/管理员ID"`
- AdminName string `description:"销售/管理员姓名"`
- }
- type CygxResearchSummaryRep struct {
- ArticleId int `orm:"column(article_id);pk"description:"报告id"`
- Title string `description:"标题"`
- Department string `description:"作者"`
- Abstract string `description:"摘要"`
- PublishStatus int `description:"发布状态,1已发布,0未发布"`
- PublishDate string `description:"发布时间"`
- CreateTime string `description:"创建时间"`
- LastUpdatedTime string `description:"最后一次更新时间"`
- Periods string `description:"期数"`
- HavePublish int `description:"是否发布过,1是,0否"`
- Pv int `description:"PV"`
- Uv int `description:"Uv"`
- AdminId int `description:"销售/管理员ID"`
- AdminName string `description:"销售/管理员姓名"`
- VisibleRange int `description:"设置可见范围1全部,0内部"`
- IsSendWxMsg int `description:"是否推送过微信模版消息,1是,0否"`
- }
- type CygxResearchSummaryListRep struct {
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxResearchSummaryRep
- }
- type AddCygxResearchSummary struct {
- ArticleId int `description:"报告Id ,传0时新增,大于0时修改"`
- Title string `description:"标题"`
- Department string `description:"作者"`
- Abstract string `description:"摘要"`
- DoType int `description:"操作方式,1发布,0保存"`
- PublishDate string `description:"发布时间"`
- Content *CygxRSlFirstList `description:"内容"`
- }
- type DetailCygxResearchSummaryRep struct {
- ArticleId int `description:"报告Id ,传0时新增,大于0时修改"`
- Title string `description:"标题"`
- Department string `description:"作者"`
- Abstract string `description:"摘要"`
- PublishDate string `description:"发布时间"`
- PublishStatus int `description:"发布状态,1已发布,0未发布"`
- SortSdbg string `description:"深度报告排序"`
- ListSdbg []*CygxRSlChartPermissionIco `description:"类型——’SDBG:深度报告片篇’"`
- SortCydyjy string `description:"产业调研纪要排序"`
- ListCydyjy []*CygxRSlChartPermissionIco `description:"类型——’CYDYJY:产业调研纪要’"`
- SortSjdp string `description:"事件点评排序"`
- ListSsgs []*CygxRSlChartPermissionIco `description:"类型——’SSGS:上市公司调研纪要篇’"`
- SortSsgs string `description:"上市公司调研纪要篇排序"`
- ListSjdp []*AddCygxResearchSummaryLog `description:"类型——’SJDP:事件点评"`
- SortBzchjh string `description:"本周晨会精华排序"`
- ListBzchjh []*CygxRSlChartPermissionIco `description:"类型——’BZCHJH:本周晨会精华’"`
- SortYanx string `description:"研选排序"`
- ListYanx []*CygxRSlChartPermissionIco `description:"类型——’YANX:研选’"`
- }
- type DetailCygxResearchSummaryTmpRep struct {
- Title string `description:"标题"`
- Department string `description:"作者"`
- Abstract string `description:"摘要"`
- PublishDate string `description:"发布时间"`
- SortSdbg string `description:"深度报告排序"`
- ListSdbg []*CygxRSlChartPermissionIcoTmp `description:"类型——’SDBG:深度报告片篇’"`
- SortCydyjy string `description:"产业调研纪要排序"`
- ListCydyjy []*CygxRSlChartPermissionIcoTmp `description:"类型——’CYDYJY:产业调研纪要’"`
- SortSjdp string `description:"事件点评排序"`
- ListSjdp []*AddCygxResearchSummaryLog `description:"类型——’SJDP:事件点评"`
- SortBzchjh string `description:"本周晨会精华排序"`
- ListBzchjh []*CygxRSlChartPermissionIcoTmp `description:"类型——’BZCHJH:本周晨会精华’"`
- SortSsgs string `description:"上市公司调研纪要篇排序"`
- ListSsgs []*CygxRSlChartPermissionIcoTmp `description:"类型——’SSGS:上市公司调研纪要篇’"`
- SortYanx string `description:"研选排序"`
- ListYanx []*CygxRSlChartPermissionIcoTmp `description:"类型——’YANX:研选’"`
- }
- type ResearchSummaryId struct {
- ArticleId int `description:"报告Id"`
- }
- // 添加
- func AddCygxResearchSummaryOrm(itme *CygxResearchSummary, items []*CygxResearchSummaryLog) (newArtId int64, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- fmt.Println(err)
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- newArtId, err = to.Insert(itme)
- if err != nil {
- return
- }
- for _, v := range items {
- v.ArticleId = int(newArtId)
- _, err = to.Insert(v)
- if err != nil {
- return
- }
- }
- return
- }
- // 编辑
- func UpdateCygxResearchSummaryOrm(item *CygxResearchSummary, items []*CygxResearchSummaryLog) (newId int64, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- fmt.Println(err)
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- articleId := item.ArticleId
- sql := `UPDATE cygx_research_summary SET title=?, department=? ,abstract = ?,publish_status = ?,publish_date = ?,last_updated_time = ?,periods = ?,admin_id =? ,admin_name =?,have_publish = ? WHERE article_id=?`
- _, err = to.Raw(sql, item.Title, item.Department, item.Abstract, item.PublishStatus, item.PublishDate, item.LastUpdatedTime, item.Periods, item.AdminId, item.AdminName, item.HavePublish, articleId).Exec()
- if err != nil {
- return
- }
- sql = ` DELETE FROM cygx_research_summary_log WHERE article_id = ?`
- _, err = to.Raw(sql, articleId).Exec()
- if err != nil {
- return
- }
- for _, v := range items {
- v.ArticleId = articleId
- newId, err = to.Insert(v)
- if err != nil {
- return
- }
- }
- return
- }
- // 获取数量
- func GetCygxResearchSummary(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_research_summary as rs WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrmUsingDB("hz_cygx")
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 通过纪要ID获取活动详情
- func GetCygxResearchSummaryInfoById(articleId int) (item *CygxResearchSummaryRep, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT * FROM cygx_research_summary WHERE article_id=?`
- err = o.Raw(sql, articleId).QueryRow(&item)
- return
- }
- // 删除数据
- func DeleteCygxResearchSummary(articleId int) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- fmt.Println(err)
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- sql := ` DELETE FROM cygx_research_summary WHERE article_id=? `
- _, err = to.Raw(sql, articleId).Exec()
- if err != nil {
- return
- }
- sql = ` DELETE FROM cygx_research_summary_log WHERE article_id = ?`
- _, err = to.Raw(sql, articleId).Exec()
- return
- }
- // 列表
- func GetResearchSummaryList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResearchSummaryRep, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT *,
- (SELECT COUNT(1) FROM cygx_report_history_record AS h WHERE h.article_id=rs.article_id AND report_type = 'bzyjhz' AND h.company_id != 16) AS pv,
- (SELECT COUNT(DISTINCT user_id) FROM cygx_report_history_record AS h WHERE h.article_id=rs.article_id AND report_type = 'bzyjhz' AND h.company_id != 16 ) AS uv
- FROM cygx_research_summary as rs WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` ORDER BY rs.publish_date DESC LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // 修改发布状态
- func ResearchSummaryPublishAndCancel(item *CygxResearchSummaryRep) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `UPDATE cygx_research_summary SET publish_status=? , last_updated_time= ?, periods= ? ,admin_id =? ,admin_name =? ,have_publish = 1 WHERE article_id=? `
- _, err = o.Raw(sql, item.PublishStatus, time.Now(), item.Periods, item.AdminId, item.AdminName, item.ArticleId).Exec()
- return
- }
- // 修改可见范围
- func ResearchSummaryVisibleRange(item *CygxResearchSummaryRep) (err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `UPDATE cygx_research_summary SET is_send_wx_msg = 1, visible_range=? , last_updated_time= ?,admin_id =? ,admin_name =? WHERE article_id=? `
- _, err = o.Raw(sql, item.VisibleRange, time.Now(), item.AdminId, item.AdminName, item.ArticleId).Exec()
- return
- }
- type DetailCygxResearchSummaryTmpRepS struct {
- List []*CygxRSlChartPermissionIcoTmps `description:"类型——’SDBG:深度报告片篇’"`
- }
- type CygxRSlChartPermissionIcoTmps struct {
- ChartPermissionId int `description:"行业ID"`
- ChartPermissionName string `description:"行业名称"`
- List []string
- //List make([]string, 0)
- }
- // 列表
- func GetResearchSummarylogListFirst(articleId int) (items []*ResearchSummaryChartPermission, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT l.*
- FROM cygx_research_summary_log AS l
- WHERE l.article_id = ?
- GROUP BY l.type
- ORDER BY l.sort ASC`
- _, err = o.Raw(sql, articleId).QueryRows(&items)
- return
- }
- type ResearchSummaryChartPermission struct {
- ListName string `description:"列表名称"`
- IcoLink string `orm:"column(image_url)"description:"图标链接"`
- Type string `description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- List []*CygxResearchSummaryLogSecond
- }
- type CygxResearchSummaryLogSecond struct {
- PermissionName string `description:"行业名称"`
- ChartPermissionId int `description:"行业ID"`
- IcoLink string `orm:"column(image_url)"description:"图标链接"`
- List []*CygxResearchSummaryLogThird
- }
- type CygxResearchSummaryLogThird struct {
- Body string `description:"内容"`
- }
- // 列表
- func GetResearchSummarylogSonListSecond(articleId int, artType string) (items []*CygxResearchSummaryLogSecond, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT l.*
- FROM
- cygx_research_summary_log AS l
- WHERE l.article_id = ? AND l.type =?
- GROUP BY l.chart_permission_id
- ORDER BY l.chart_permission_sort ASC`
- _, err = o.Raw(sql, articleId, artType).QueryRows(&items)
- return
- }
- // 列表
- func GetResearchSummarylogSonListThird(articleId, chartPermissionId int, artType string) (items []*CygxResearchSummaryLogThird, err error) {
- o := orm.NewOrmUsingDB("hz_cygx")
- sql := `SELECT l.link_article_id,l.body ,a.video_url
- FROM cygx_research_summary_log AS l
- LEFT JOIN cygx_article as a ON a.article_id = l.link_article_id
- WHERE l.article_id = ? AND l.type =? AND l.chart_permission_id = ?
- ORDER BY l.chart_permission_sort ASC `
- _, err = o.Raw(sql, articleId, artType, chartPermissionId).QueryRows(&items)
- return
- }
|