industrial_article_group_subject.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxIndustrialArticleGroupSubject struct {
  7. Id int `orm:"column(id);pk" description:"主键ID"`
  8. CygxArticleId int `description:"cygx_article表的主键ID"`
  9. ArticleId int `description:"cygx_article表的文章ID"`
  10. IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"`
  11. CreateTime time.Time `description:"创建时间"`
  12. }
  13. type SubjectArticlGroupList struct {
  14. SubjectName string `description:"标的名称"`
  15. ArticleId int `description:"cygx_article表的文章ID"`
  16. IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"`
  17. }
  18. // 列表
  19. func GetSubjectArticleGroupManagementList(condition string, pars []interface{}) (items []*CygxIndustrialArticleGroupSubject, err error) {
  20. o := orm.NewOrm()
  21. sql := `SELECT
  22. *
  23. FROM
  24. cygx_industrial_article_group_subject AS ag
  25. WHERE
  26. 1 =1 ` + condition
  27. _, err = o.Raw(sql, pars).QueryRows(&items)
  28. return
  29. }
  30. // 列表
  31. func GetSubjectArticlGroupList(condition string, pars []interface{}) (items []*SubjectArticlGroupList, err error) {
  32. o := orm.NewOrm()
  33. sql := `SELECT
  34. s.subject_name,
  35. s.industrial_subject_id,
  36. ag.article_id
  37. FROM
  38. cygx_industrial_article_group_subject AS ag
  39. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id
  40. WHERE 1= 1 ` + condition
  41. _, err = o.Raw(sql, pars).QueryRows(&items)
  42. return
  43. }
  44. // 标的列表
  45. func GetIndustrialArticleGroupSubjectListByHz(IndustrialManagementId int) (items []*IndustrialSubject, err error) {
  46. o := orm.NewOrm()
  47. sql := `SELECT
  48. i.*
  49. FROM
  50. cygx_industrial_subject AS i
  51. INNER JOIN cygx_industrial_article_group_subject AS sg ON sg.industrial_subject_id = i.industrial_subject_id
  52. INNER JOIN cygx_article AS a ON a.article_id = sg.article_id
  53. WHERE
  54. i.industrial_management_id = ?
  55. AND a.article_type_id = 0
  56. GROUP BY
  57. i.industrial_subject_id `
  58. _, err = o.Raw(sql, IndustrialManagementId).QueryRows(&items)
  59. return
  60. }
  61. // 列表
  62. func GetSubjectArticleGroupManagementListByArtcileId(articleId int) (items []*SubjectActivityGroupManagementRep, err error) {
  63. o := orm.NewOrm()
  64. sql := `SELECT
  65. s.subject_name,
  66. s.industrial_subject_id
  67. FROM
  68. cygx_industrial_article_group_subject AS ag
  69. INNER JOIN cygx_industrial_subject AS s ON s.industrial_subject_id = ag.industrial_subject_id
  70. WHERE
  71. ag.article_id = ?`
  72. _, err = o.Raw(sql, articleId).QueryRows(&items)
  73. return
  74. }