package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxIndustrialArticleGroupSubject struct { Id int `orm:"column(id);pk" description:"主键ID"` CygxArticleId int `description:"cygx_article表的主键ID"` ArticleId int `description:"cygx_article表的文章ID"` IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"` CreateTime time.Time `description:"创建时间"` } type SubjectArticlGroupList struct { SubjectName string `description:"标的名称"` ArticleId int `description:"cygx_article表的文章ID"` IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"` } // 列表 func GetSubjectArticleGroupManagementList(condition string, pars []interface{}) (items []*CygxIndustrialArticleGroupSubject, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_industrial_article_group_subject AS ag WHERE 1 =1 ` + condition _, err = o.Raw(sql, pars).QueryRows(&items) return } // 列表 func GetSubjectArticlGroupList(condition string, pars []interface{}) (items []*SubjectArticlGroupList, err error) { o := orm.NewOrm() sql := `SELECT s.subject_name, s.industrial_subject_id, ag.article_id FROM cygx_industrial_article_group_subject AS ag INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id WHERE 1= 1 ` + condition _, err = o.Raw(sql, pars).QueryRows(&items) return } // 标的列表 func GetIndustrialArticleGroupSubjectListByHz(IndustrialManagementId int) (items []*IndustrialSubject, err error) { o := orm.NewOrm() sql := `SELECT i.* FROM cygx_industrial_subject AS i INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.industrial_subject_id = i.industrial_subject_id INNER JOIN cygx_article AS a ON a.article_id = sg.article_id WHERE i.industrial_management_id = ? AND a.article_type_id = 0 GROUP BY i.industrial_subject_id ` _, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items) return } // 列表 func GetSubjectArticleGroupManagementListByArtcileId(articleId int) (items []*SubjectActivityGroupManagementRep, err error) { o := orm.NewOrm() sql := `SELECT s.subject_name, s.industrial_subject_id FROM cygx_industrial_article_group_subject AS ag INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id WHERE ag.article_id = ?` _, err = o.Raw(sql, articleId).QueryRows(&items) return }