banner.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type CygxBannerResp struct {
  6. BannerId int `description:"BannerId等于0新增,大于零修改"`
  7. ImgId int `description:"cygx_banner_img主键ID"`
  8. IndexImg string `description:"小程序封面图"`
  9. ListType string `description:"ABC哪一列"`
  10. Title string `description:"标题"`
  11. Link string `description:"链接地址"`
  12. Subtitle string `description:"副标题"`
  13. BannerUrlResp *BannerUrlResp `description:"跳转地址"`
  14. }
  15. type CygxBannerIdReq struct {
  16. BannerId int `description:"BannerId"`
  17. }
  18. type GetCygxBannerImgRespDetailResp struct {
  19. Detail *CygxBannerResp
  20. }
  21. // 通过ID获取详情
  22. func GetCygxBannerDetail(banneId int) (item *CygxBannerResp, err error) {
  23. o := orm.NewOrm()
  24. sql := `SELECT * FROM cygx_banner WHERE banner_id=? `
  25. err = o.Raw(sql, banneId).QueryRow(&item)
  26. return
  27. }
  28. // 获取数量
  29. func GetCygxBannerCount(condition string, pars []interface{}) (count int, err error) {
  30. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_banner as art WHERE 1= 1 `
  31. if condition != "" {
  32. sqlCount += condition
  33. }
  34. o := orm.NewOrm()
  35. err = o.Raw(sqlCount, pars).QueryRow(&count)
  36. return
  37. }
  38. // 列表
  39. func GetCygxBannerList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxBannerResp, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT * FROM cygx_banner as art WHERE 1= 1 `
  42. if condition != "" {
  43. sql += condition
  44. }
  45. sql += ` LIMIT ?,? `
  46. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  47. return
  48. }
  49. type CygxBannerListResp struct {
  50. ListA []*CygxBannerResp
  51. ListB []*CygxBannerResp
  52. ListC []*CygxBannerResp
  53. }
  54. type CygxBannerImgResp struct {
  55. ImgId int `description:"图片ID"`
  56. IndexImg string `description:"小程序封面图"`
  57. Img1 string `description:"图片1"`
  58. Img2 string `description:"图片2"`
  59. Img3 string `description:"图片3"`
  60. Img4 string `description:"图片4"`
  61. }
  62. type BannerUrlResp struct {
  63. ChartPermissionId int `description:"行业id"`
  64. SourceId int `description:"资源ID"`
  65. Type int `description:"类型:1普通文本,2:文章、3:活动、4:产业、5:关于我们"`
  66. Body string `description:"内容"`
  67. }
  68. type BannerUrlYxListResp struct {
  69. ListA []*BannerUrlYxResp
  70. ListB []*BannerUrlYxResp
  71. ListC []*BannerUrlYxResp
  72. }
  73. // 列表
  74. func GetCygxBannerImgList() (items []*CygxBannerImgResp, err error) {
  75. o := orm.NewOrm()
  76. sql := `SELECT * FROM cygx_banner_img as art WHERE 1= 1 `
  77. _, err = o.Raw(sql).QueryRows(&items)
  78. return
  79. }
  80. type BannerUrlYxResp struct {
  81. IndexImg string `description:"小程序封面图"`
  82. Path string `description:"小程序路径"`
  83. Title string `description:"标题"`
  84. TitleColor string `description:"标题颜色"`
  85. Describe string `description:"描述"`
  86. DescribeColor string `description:"描述颜色"`
  87. }
  88. type BannerUrHomeListResp struct {
  89. ListA []*BannerUrlYxResp
  90. ListB []*BannerUrlYxResp
  91. }