zhouqi_article_map.go 1014 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. ArticleUpdateTime string `description:"对应文章的更新时间"`
  9. }
  10. // 获取周期下面的一级分类
  11. func GetCygxZhouqiArticleMapFirst() (items []*CygxZhouqiArticleMap, err error) {
  12. o := orm.NewOrm()
  13. sql := `SELECT
  14. category_id,
  15. match_type_name,
  16. article_update_time
  17. FROM
  18. cygx_zhouqi_article_map
  19. WHERE
  20. hidden = 0
  21. AND parent_id = 0
  22. ORDER BY
  23. sort DESC `
  24. _, err = o.Raw(sql).QueryRows(&items)
  25. return
  26. }
  27. // 根据父级分类ID获取下面的子分类
  28. func GetCygxZhouqiArticleMapByParentId(parentId int) (items []*CygxZhouqiArticleMap, err error) {
  29. o := orm.NewOrm()
  30. sql := `SELECT
  31. category_id,
  32. match_type_name,
  33. article_update_time
  34. FROM
  35. cygx_zhouqi_article_map
  36. WHERE
  37. parent_id = ? `
  38. _, err = o.Raw(sql, parentId).QueryRows(&items)
  39. return
  40. }