article_type.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxArticleType struct {
  7. ArticleTypeId int `orm:"column(article_type_id);pk";description:"文章类型ID"`
  8. ArticleTypeName string `description:"类型名称"`
  9. Sort int `description:"排序字段"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ModifyTime time.Time `description:"最后修改时间"`
  12. IsSendEs int `description:"这种报告类型是否同步到Es"`
  13. YanxPermissionId int `description:"研选类型所对应的ID"`
  14. YanxPermissionName string `description:"研选类型所对应的名称"`
  15. IcoLink string `description:"图标链接地址"`
  16. IcoLinkM string `description:"移动端图标链接地址"`
  17. IsShowLinkButton int `description:"这种报告类型是否展示查看报告链接"`
  18. ButtonStyle string `description:"按钮展示样式"`
  19. }
  20. type CygxArticleTypeResp struct {
  21. ArticleTypeId int `description:"文章类型ID"`
  22. ArticleTypeName string `description:"类型名称"`
  23. ButtonStyle string `description:"按钮展示样式"`
  24. }
  25. type CygxArticleTypeListResp struct {
  26. List []*CygxArticleTypeResp
  27. }
  28. // 详情
  29. func GetCygxArticleTypeDetailById(activityTypeId int) (item *CygxArticleType, err error) {
  30. o := orm.NewOrm()
  31. sql := `SELECT * FROM cygx_article_type WHERE article_type_id = ? `
  32. err = o.Raw(sql, activityTypeId).QueryRow(&item)
  33. return
  34. }
  35. // 获取数量
  36. func GetCygxArticleTypeCount(condition string) (count int, err error) {
  37. o := orm.NewOrm()
  38. sqlCount := `SELECT COUNT(1) AS count FROM cygx_article_type WHERE 1=1 ` + condition
  39. err = o.Raw(sqlCount).QueryRow(&count)
  40. return
  41. }
  42. // 报告类型列表
  43. func GetCygxArticleTypeList() (items []*CygxArticleType, err error) {
  44. o := orm.NewOrm()
  45. sql := `SELECT * FROM cygx_article_type ORDER BY sort DESC`
  46. _, err = o.Raw(sql).QueryRows(&items)
  47. return
  48. }
  49. // 报告类型列表
  50. func GetCygxArticleTypeListCondition(condition string) (items []*CygxArticleType, err error) {
  51. o := orm.NewOrm()
  52. sql := `SELECT * FROM cygx_article_type WHERE 1=1 ` + condition + ` ORDER BY sort DESC`
  53. _, err = o.Raw(sql).QueryRows(&items)
  54. return
  55. }
  56. func GetArticleTypeInfo(activityTypeId int) (item *CygxArticleType, err error) {
  57. o := orm.NewOrm()
  58. sql := `SELECT * FROM cygx_article_type WHERE article_type_id=? `
  59. err = o.Raw(sql, activityTypeId).QueryRow(&item)
  60. return
  61. }