article_data.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type CygxArticleDataResp struct {
  6. ArticleId int `description:"文章id"`
  7. Stock string `description:"文章个股标签"`
  8. Cover string `description:"封面图片,公司logo"`
  9. }
  10. type ArticleDataLogoResp struct {
  11. ArticleId int `description:"文章id"`
  12. Cover string `description:"封面图片,公司logo"`
  13. ComapnyList []*ComapnyNameResp `description:"公司名称"`
  14. }
  15. type ArticleDataLogoListResp struct {
  16. List []*ArticleDataLogoResp
  17. }
  18. type ComapnyNameResp struct {
  19. ComapnyName string `description:"公司民称"`
  20. }
  21. // 列表
  22. func CygxArticleDataList(condition string, pars []interface{}) (items []*CygxArticleDataResp, err error) {
  23. o := orm.NewOrm()
  24. sql := `SELECT
  25. a.article_id,
  26. a.stock,
  27. d.cover
  28. FROM
  29. cygx_article AS a
  30. INNER JOIN cygx_article_data AS d ON d.article_id = a.article_id
  31. WHERE
  32. 1 = 1
  33. AND a.publish_status = 1
  34. `
  35. if condition != "" {
  36. sql += condition
  37. }
  38. _, err = o.Raw(sql, pars).QueryRows(&items)
  39. return
  40. }
  41. // 获取文章封面
  42. func CygxCygxArticleDataDetail(articleId int) (item *CygxArticleDataResp, err error) {
  43. o := orm.NewOrm()
  44. sql := `SELECT * FROM cygx_article_data WHERE article_id = ? LIMIT 1 `
  45. err = o.Raw(sql, articleId).QueryRow(&item)
  46. return
  47. }