industrial_subject.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type IndustrialSubjectByArticle struct {
  6. IndustrialSubjectId int `description:"标的id"`
  7. IndustrialManagementId int `description:"产业id"`
  8. SubjectName string `description:"标的名称"`
  9. IndustryName string `description:"产业名称"`
  10. ArticleId int `description:"文章ID"`
  11. }
  12. type SubjectArticlGroupList struct {
  13. SubjectName string `description:"标的名称"`
  14. ArticleId int `description:"cygx_article表的文章ID"`
  15. IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"`
  16. }
  17. type CygxIndustrialSubject struct {
  18. IndustrialSubjectId int `orm:"column(industrial_subject_id);pk" description:"标的id"`
  19. IndustrialManagementId int `description:"产业id"`
  20. SubjectName string `description:"标的名称"`
  21. CreateTime string `description:"创建时间"`
  22. Source int `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"`
  23. }
  24. // 获取标的列表
  25. func GetArticleGroupSubjectList(pars []interface{}, condition string) (items []*IndustrialSubjectByArticle, err error) {
  26. o := orm.NewOrm()
  27. sql := `SELECT
  28. s.subject_name,
  29. s.industrial_subject_id,
  30. s.industrial_management_id,
  31. g.article_id
  32. FROM
  33. cygx_industrial_article_group_subject AS g
  34. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = g.industrial_subject_id
  35. WHERE
  36. 1 = 1 ` + condition
  37. _, err = o.Raw(sql, pars).QueryRows(&items)
  38. return
  39. }
  40. // 列表
  41. func GetSubjectArticlGroupList(condition string, pars []interface{}) (items []*SubjectArticlGroupList, err error) {
  42. o := orm.NewOrm()
  43. sql := `SELECT
  44. s.subject_name,
  45. s.industrial_subject_id,
  46. ag.article_id
  47. FROM
  48. cygx_industrial_article_group_subject AS ag
  49. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id
  50. WHERE 1= 1 ` + condition
  51. _, err = o.Raw(sql, pars).QueryRows(&items)
  52. return
  53. }
  54. func GetcygxIndustrialSubject(industrialManagementId int) (items []*IndustrialSubject, err error) {
  55. o := orm.NewOrm()
  56. sql := `SELECT subject_name,industrial_subject_id FROM cygx_industrial_subject WHERE industrial_management_id = ?`
  57. _, err = o.Raw(sql, industrialManagementId).QueryRows(&items)
  58. return
  59. }
  60. // GetCygxIndustrialSubjectList 获取标的列表
  61. func GetCygxIndustrialSubjectListCondition(condition string, pars []interface{}) (items []*CygxIndustrialSubject, err error) {
  62. sql := `SELECT * FROM cygx_industrial_subject WHERE 1 = 1 `
  63. if condition != `` {
  64. sql += condition
  65. }
  66. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&items)
  67. return
  68. }