package data_manage import ( "github.com/beego/beego/v2/client/orm" "time" ) // GetLatestContractListByProductId 获取最新的续约合同ids func GetLatestContractListByProductId(productId int) (contractIds []string, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT article_id FROM cygx_research_summary WHERE product_id=? AND contract_type="续约合同" GROUP BY create_time DESC,company_id ` _, err = o.Raw(sql, productId).QueryRows(&contractIds) return } type CygxResearchSummaryLog struct { ArticleSunId int `orm:"column(article_sun_id);pk"description:"子级报告id"` ArticleId int `description:"父级报告Id"` Type string `description:"类型'SDBG:深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP:事件点评,’BZCHJH:本周晨会精华’"` Sort string `description:"排序"` ChartPermissionId int `description:"行业ID"` ChartPermissionSort string `description:"行业排序"` CreateTime time.Time `description:"创建时间"` Body string `description:"内容"` ReportLink string `description:"报告链接"` LinkArticleId int `description:"报告ID链接"` } 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:"销售/管理员姓名"` } func AddCygxResearchSummaryOrm(item *CygxResearchSummary) (newArtId int64, err error) { o := orm.NewOrm() newArtId, err = o.Insert(item) if err != nil { return } return } func AddCygxResearchSummaryLogOrm(items []*CygxResearchSummaryLog) (newArtId int64, err error) { o := orm.NewOrm() newArtId, err = o.InsertMulti(1, items) if err != nil { return } return } type CygxRSlChartPermission struct { ChartPermissionId int `description:"行业ID"` ChartPermissionSort string `description:"行业排序"` List []*AddCygxResearchSummaryLog } type AddCygxResearchSummaryLog struct { Body string `description:"内容"` ReportLink string `description:"报告链接"` ChartPermissionSort string `description:"行业排序"` } type CygxArticleSubjectList struct { ArticleId int `description:"报告id"` SubjectName string `description:"标的名称"` } //文章标的列表 func GetArticleSubjectList(articleId string) (items []*CygxArticleSubjectList, err error) { if articleId == "" { articleId = "0" } o := orm.NewOrm() sql := ` SELECT GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '#' ) AS subject_name, sg.article_id FROM cygx_industrial_article_group_subject AS sg LEFT JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = sg.industrial_subject_id WHERE sg.article_id IN (` + articleId + `) GROUP BY sg.article_id` _, err = o.Raw(sql).QueryRows(&items) return }