123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxIndustrialArticleGroupManagement struct {
- Id int `orm:"column(id);pk" description:"主键ID"`
- CygxArticleId int `description:"cygx_article表id"`
- ArticleId int `description:"文章ID"`
- IndustrialManagementId int `description:"cygx_industrial_management表的主键ID"`
- Source int `description:"来源,1 活动,2专项调研"`
- CreateTime time.Time `description:"创建时间"`
- }
- // IndustryArtCount 产业文章数
- type IndustryArtCount struct {
- ArtNum int `json:"art_num" description:"文章数"`
- IndustrialManagementId int `json:"industrial_management_id" description:"产业ID"`
- }
- // GetIndustryArtCountByCondition 获取产业文章关联的文章数
- func GetIndustryArtCountByCondition(condition string, pars []interface{}) (list []*IndustryArtCount, err error) {
- sql := `SELECT
- COUNT(1) AS art_num,
- agm.industrial_management_id
- FROM
- cygx_industrial_article_group_management AS agm
- JOIN cygx_industrial_management AS man ON man.industrial_management_id = agm.industrial_management_id
- WHERE
- 1 = 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY agm.industrial_management_id`
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
- // IndustryArticleMinMaxPublishTime 产业文章最大最小发布时间
- type IndustryArticleMinMaxPublishTime struct {
- IndustrialManagementId int `description:"产业ID"`
- MinPublishTime time.Time `description:"文章最小发布时间"`
- MaxPublishTime time.Time `description:"文章最大发布时间"`
- }
- // GetIndustryArticleMinMaxPublishTime 获取产业文章最大最小发布时间
- func GetIndustryArticleMinMaxPublishTime(condition string, pars []interface{}) (list []*IndustryArticleMinMaxPublishTime, err error) {
- sql := `SELECT
- a.industrial_management_id,
- MIN(b.publish_date) AS min_publish_time,
- MAX(b.publish_date) AS max_publish_time
- FROM
- cygx_industrial_article_group_management AS a
- JOIN cygx_article AS b ON a.article_id = b.article_id
- WHERE
- 1 = 1`
- if condition != `` {
- sql += condition
- }
- sql += `GROUP BY a.industrial_management_id`
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
- // GetIndustrialArticleGroupManagementList 查询产业
- func GetIndustrialArticleGroupManagementList(condition string, pars []interface{}) (list []*CygxIndustrialArticleGroupManagement, err error) {
- sql := `SELECT
- *
- FROM
- cygx_industrial_article_group_management AS a
- WHERE
- 1 = 1 `
- if condition != `` {
- sql += condition
- }
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
- // 列表
- func GetIndustrialArticleGroupManagementListByArticleId(articleId int) (items []*CygxIndustrialArticleGroupManagement, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- m.chart_permission_id,
- m.industrial_management_id,
- m.industry_name
- FROM
- cygx_industrial_article_group_management AS am
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
- WHERE
- am.article_id = ?`
- _, err = o.Raw(sql, articleId).QueryRows(&items)
- return
- }
|