package models import ( "github.com/beego/beego/v2/client/orm" ) type IndustrialSubjectByArticle struct { IndustrialSubjectId int `description:"标的id"` IndustrialManagementId int `description:"产业id"` SubjectName string `description:"标的名称"` IndustryName string `description:"产业名称"` ArticleId int `description:"文章ID"` } type SubjectArticlGroupList struct { SubjectName string `description:"标的名称"` ArticleId int `description:"cygx_article表的文章ID"` IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"` } type CygxIndustrialSubject struct { IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"` IndustrialManagementId int `description:"产业id"` SubjectName string `description:"标的名称"` CreateTime string `description:"创建时间"` Source int `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"` } // 获取标的列表 func GetArticleGroupSubjectList(pars []interface{}, condition string) (items []*IndustrialSubjectByArticle, err error) { o := orm.NewOrm() sql := `SELECT s.subject_name, s.industrial_subject_id, s.industrial_management_id, g.article_id FROM cygx_industrial_article_group_subject AS g INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = g.industrial_subject_id 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 GetcygxIndustrialSubject(industrialManagementId int) (items []*IndustrialSubject, err error) { o := orm.NewOrm() sql := `SELECT subject_name,industrial_subject_id FROM cygx_industrial_subject WHERE industrial_management_id = ?` _, err = o.Raw(sql, industrialManagementId).QueryRows(&items) return } // GetCygxIndustrialSubjectList 获取标的列表 func GetCygxIndustrialSubjectListCondition(condition string, pars []interface{}) (items []*CygxIndustrialSubject, err error) { sql := `SELECT * FROM cygx_industrial_subject WHERE 1 = 1 ` if condition != `` { sql += condition } _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items) return }