industrial_subject.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type CygxIndustrialSubject struct {
  6. IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"`
  7. IndustrialManagementId int `description:"产业id"`
  8. SubjectName string `description:"标的名称"`
  9. CreateTime string `description:"创建时间"`
  10. Source int `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"`
  11. }
  12. type IndustrialSubjectByArticle struct {
  13. IndustrialSubjectId int `description:"标的id"`
  14. IndustrialManagementId int `description:"产业id"`
  15. SubjectName string `description:"标的名称"`
  16. IndustryName string `description:"产业名称"`
  17. ArticleId int `description:"文章ID"`
  18. }
  19. // 获取标的列表
  20. func GetCygxIndustrialSubjectListCondition(condition string, pars []interface{}) (items []*CygxIndustrialSubject, err error) {
  21. o := orm.NewOrm()
  22. sql := `SELECT *
  23. FROM
  24. cygx_industrial_subject WHERE 1 = 1 ` + condition
  25. _, err = o.Raw(sql, pars).QueryRows(&items)
  26. return
  27. }
  28. // 获取标的列表
  29. func GetArticleGroupSubjectList(pars []interface{}, condition string) (items []*IndustrialSubjectByArticle, err error) {
  30. o := orm.NewOrm()
  31. sql := `SELECT
  32. s.subject_name,
  33. s.industrial_subject_id,
  34. s.industrial_management_id,
  35. g.article_id
  36. FROM
  37. cygx_industrial_article_group_subject AS g
  38. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = g.industrial_subject_id
  39. WHERE
  40. 1 = 1 ` + condition
  41. _, err = o.Raw(sql, pars).QueryRows(&items)
  42. return
  43. }