industrial_activity_group_management.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxIndustrialActivityGroupManagement struct {
  7. Id int `orm:"column(id);pk" description:"主键ID"`
  8. ActivityId int `description:"活动ID"`
  9. IndustrialManagementId int `description:"cygx_industrial_management表的主键ID"`
  10. Source int `description:"来源,1 活动,2专项调研"`
  11. CreateTime time.Time `description:"创建时间"`
  12. }
  13. type CygxIndustrialActivityGroupSubject struct {
  14. Id int `orm:"column(id);pk" description:"主键ID"`
  15. ActivityId int `description:"活动ID"`
  16. IndustrialSubjectId int `description:"cygx_industrial_subject表的文章ID"`
  17. Source int `description:"来源,1 活动,2专项调研"`
  18. CreateTime time.Time `description:"创建时间"`
  19. }
  20. // GetActivityIndustryRelationList 获取活动与产业关联列表
  21. func GetActivityIndustryRelationList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
  22. sql := `SELECT
  23. a.activity_id,
  24. b.industrial_management_id
  25. FROM
  26. cygx_activity AS a
  27. JOIN cygx_industrial_activity_group_management AS b ON a.activity_id = b.activity_id
  28. WHERE
  29. 1 = 1 AND b.source = 1 `
  30. if condition != `` {
  31. sql += condition
  32. }
  33. _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
  34. return
  35. }
  36. // 列表
  37. func GetIndustrialActivityGroupManagementList(activityId int) (items []*IndustrialManagementRep, err error) {
  38. o := orm.NewOrm()
  39. sql := `SELECT
  40. m.chart_permission_id,
  41. m.industrial_management_id,
  42. m.industry_name
  43. FROM
  44. cygx_industrial_activity_group_management AS am
  45. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
  46. WHERE
  47. am.activity_id = ? AND am.source = 1`
  48. _, err = o.Raw(sql, activityId).QueryRows(&items)
  49. return
  50. }