package models import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "strconv" "time" ) type Tactics struct { ArticleId int `description:"文章id"` Title string `description:"标题"` TitleEn string `description:"英文标题"` UpdateFrequency string `description:"更新周期"` PublishDate time.Time `description:"发布时间"` PublishStatus int `description:"发布状态"` Department string `description:"作者"` Body string `description:"内容"` Abstract string `description:"摘要"` Annotation string `description:"注解"` CategoryName string `description:"分类"` SubCategoryName string `description:"子级分类"` CategoryId int `description:"分类id"` CreateDate string `description:"创建日期"` } func GetTacticsList(endDate string) (list []*Tactics, err error) { o := orm.NewOrmUsingDB("tactics") sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id FROM article_articleinfo AS a INNER JOIN article_content AS b ON a.id=b.article_id INNER JOIN article_category AS c ON a.id=c.article_id INNER JOIN article_categoryinfo AS d ON c.category_id=d.id WHERE a.publish_status=1 AND a.publish_date>=? AND d.id IN (28,32,45,57,62,72,74,79,84,86,88,90,93,95,96,98) AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) ` _, err = o.Raw(sql, endDate).QueryRows(&list) return } func GetTacticsListAll() (list []*Tactics, err error) { o := orm.NewOrmUsingDB("tactics") sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id FROM article_articleinfo AS a INNER JOIN article_content AS b ON a.id=b.article_id INNER JOIN article_category AS c ON a.id=c.article_id INNER JOIN article_categoryinfo AS d ON c.category_id=d.id WHERE a.publish_status=1 AND d.id IN (28,32,45,57,62,72,74,79,84,86,88,90,93,95,96,98) AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) ` //IN(85,71) _, err = o.Raw(sql).QueryRows(&list) return } func GetCygxArticleListAll() (list []*Tactics, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_article ` _, err = o.Raw(sql).QueryRows(&list) return } type Tactics2 struct { ArticleId int `description:"文章id"` Title string `description:"标题"` TitleEn string `description:"英文标题"` UpdateFrequency string `description:"更新周期"` PublishDate time.Time `description:"发布时间"` PublishStatus int `description:"发布状态"` Department string `description:"作者"` Body string `description:"内容"` Abstract string `description:"摘要"` Annotation string `description:"注解"` CategoryName string `description:"分类"` SubCategoryName string `description:"子级分类"` CategoryId int `description:"分类id"` CategoryIdTwo int `description:"分类id"` CreateDate string `description:"创建日期"` IsClass int `description:"是否归类,1是,0否"` IsSummary int `description:"是否是纪要库,1是,0否"` IsReport int `description:"是否属于报告,1是,0否"` ReportType int `description:"报告类型,1行业报告,2产业报告,0无"` Stock string `description:"个股标签"` FieldName string `description:"产业标签"` File string `description:"Pdf下载链接"` TypeName string `description:"策略平台报告类型"` UpdateDate string `description:"策略平台报告更新时间"` CeLueFieldId int `description:"策略平台领域ID"` Cover string `description:"封面图片"` } func GetTacticsList2(endDate string) (list []*Tactics2, err error) { o := orm.NewOrmUsingDB("tactics") sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id FROM article_articleinfo AS a INNER JOIN article_content AS b ON a.id=b.article_id INNER JOIN article_category AS c ON a.id=c.article_id INNER JOIN article_categoryinfo AS d ON c.category_id=d.id WHERE a.publish_status=1 AND a.publish_date>=? AND d.id IN (7,9,11,28,32,45,51,52,57,62,64,65,66,67,69,71,72,74,79,80,84,85,86,87,88,89,90,93,95,96,98,100,102)` //AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) ` //IN(85,71) _, err = o.Raw(sql, endDate).QueryRows(&list) return } func GetTacticsListAll2() (list []*Tactics2, err error) { o := orm.NewOrmUsingDB("tactics") sql := `SELECT a.*,b.body,b.abstract,b.annotation,b.article_id,d.category_name,d.sub_category_name,c.category_id FROM article_articleinfo AS a INNER JOIN article_content AS b ON a.id=b.article_id INNER JOIN article_category AS c ON a.id=c.article_id INNER JOIN article_categoryinfo AS d ON c.category_id=d.id WHERE a.publish_status=1 AND d.id IN (7,9,11,28,32,45,51,52,57,62,64,65,66,67,69,71,72,74,79,80,84,85,86,87,88,89,90,93,95,96,98,100) ` //AND a.id NOT IN (3454,3456,3457,3459,2449,2450,2453,2454,2459,2530,2583,2663,2670,2699,2715,2732,2748,2759,2399,2356,2870,3173,2978,2826,3470) ` //IN(85,71) _, err = o.Raw(sql).QueryRows(&list) return } type TacticsListResp struct { Paging *paging.PagingItem MatchTypeName string `description:"匹配类型"` ChartPermissionId int `description:"行业ID"` CategoryImgUrlPc string `description:"图片"` IsShowAbstract bool `description:"是否展示摘要"` List []*ReportArticle } func GetReportTacticsList(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*ReportArticle, err error) { o := orm.NewOrm() sql := ` SELECT * ,(SELECT COUNT(1) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id=a.article_id) AS readnum FROM cygx_article AS a WHERE a.publish_status=1 ` if condition != "" { sql += condition } sql += ` ORDER BY publish_date DESC LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } type TimeLineReportListResp struct { Paging *paging.PagingItem MatchTypeName string `description:"匹配类型"` CategoryImgUrlPc string `description:"图片"` List []*TimeLineReportItem }