123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- 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:"创建时间"`
- }
- // 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
- }
- type IndustrialDepartmentListResp struct {
- IndustrialManagementId int `description:"产业Id"`
- IndustryName string `description:"产业名称"`
- DepartmentId int `description:"作者Id"`
- List []*IndustrialDepartmentListResp
- }
- // 作者文章所关联的产业列表
- func GetIndustrialDepartmentList() (items []*IndustrialDepartmentListResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- m.industrial_management_id,
- m.industry_name,
- d.department_id
- FROM
- cygx_article_department AS d
- INNER JOIN cygx_article AS a ON d.department_id = a.department_id
- INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
- INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
- WHERE
- 1 = 1
- AND a.article_type_id > 0
- AND publish_status = 1
- GROUP BY
- a.article_id
- ORDER BY
- a.publish_date DESC`
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type CygxIndustrialArticleGroupManagementResp struct {
- ArticleId int `description:"文章ID"`
- IndustrialManagementId int `description:"cygx_industrial_management表的主键ID"`
- PublishDate time.Time `description:"发布时间"`
- }
- // GetCygxIndustrialArticleGroupManagement 获取产业关联的所有文章
- func GetCygxIndustrialArticleGroupManagement(condition string, pars []interface{}) (list []*CygxIndustrialArticleGroupManagementResp, err error) {
- sql := `SELECT
- mg.industrial_management_id,
- a.article_id,
- a.publish_date
- FROM
- cygx_industrial_article_group_management AS mg
- INNER JOIN cygx_article AS a ON a.article_id = mg.article_id
- WHERE
- 1 = 1
- AND a.publish_status = 1 `
- if condition != `` {
- sql += condition
- }
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
|