zhouqi_article_map.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type CygxZhouqiArticleMap struct {
  6. CategoryId int `description:"产业Id"`
  7. MatchTypeName string `description:"行业名称"`
  8. SeriesName string `description:"系列名称"`
  9. ArticleUpdateTime string `description:"对应文章的更新时间"`
  10. }
  11. // 获取周期下面的一级分类
  12. func GetCygxZhouqiArticleMapFirst() (items []*CygxZhouqiArticleMap, err error) {
  13. o := orm.NewOrm()
  14. sql := `SELECT
  15. category_id,
  16. match_type_name,
  17. series_name,
  18. article_update_time
  19. FROM
  20. cygx_zhouqi_article_map
  21. WHERE
  22. hidden = 0
  23. AND parent_id = 0
  24. ORDER BY
  25. sort DESC `
  26. _, err = o.Raw(sql).QueryRows(&items)
  27. return
  28. }
  29. // 根据父级分类ID获取下面的子分类
  30. func GetCygxZhouqiArticleMapByParentId(parentId int) (items []*CygxZhouqiArticleMap, err error) {
  31. o := orm.NewOrm()
  32. sql := `SELECT
  33. category_id,
  34. match_type_name,
  35. series_name,
  36. article_update_time
  37. FROM
  38. cygx_zhouqi_article_map
  39. WHERE
  40. parent_id = ? `
  41. _, err = o.Raw(sql, parentId).QueryRows(&items)
  42. return
  43. }