banner.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. BannerTypeName string `description:"添加类型名称"`
  11. Title string `description:"标题"`
  12. Link string `description:"链接地址"`
  13. Subtitle string `description:"副标题"`
  14. BannerUrlResp *BannerUrlResp `description:"跳转地址"`
  15. }
  16. type CygxBannerIdReq struct {
  17. BannerId int `description:"BannerId"`
  18. }
  19. type GetCygxBannerImgRespDetailResp struct {
  20. Detail *CygxBannerResp
  21. }
  22. // 通过ID获取详情
  23. func GetCygxBannerDetail(banneId int) (item *CygxBannerResp, err error) {
  24. o := orm.NewOrm()
  25. sql := `SELECT * FROM cygx_banner WHERE banner_id=? `
  26. err = o.Raw(sql, banneId).QueryRow(&item)
  27. return
  28. }
  29. // 获取数量
  30. func GetCygxBannerCount(condition string, pars []interface{}) (count int, err error) {
  31. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_banner as art WHERE 1= 1 `
  32. if condition != "" {
  33. sqlCount += condition
  34. }
  35. o := orm.NewOrm()
  36. err = o.Raw(sqlCount, pars).QueryRow(&count)
  37. return
  38. }
  39. // 列表
  40. func GetCygxBannerList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxBannerResp, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT * FROM cygx_banner as art WHERE 1= 1 `
  43. if condition != "" {
  44. sql += condition
  45. }
  46. sql += ` LIMIT ?,? `
  47. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  48. return
  49. }
  50. type CygxBannerListResp struct {
  51. List []*CygxBannerResp
  52. }
  53. type CygxBannerImgResp struct {
  54. ImgId int `description:"图片ID"`
  55. IndexImg string `description:"小程序封面图"`
  56. }
  57. type BannerUrlResp struct {
  58. ChartPermissionId int `description:"行业id"`
  59. SourceId int `description:"资源ID"`
  60. Type int `description:"类型:1普通文本,2:文章、3:活动、4:产业、5:关于我们、6:产品内测"`
  61. Body string `description:"内容"`
  62. Path string `description:"小程序路径"`
  63. }
  64. type BannerUrlYxResp struct {
  65. IndexImg string `description:"小程序封面图"`
  66. Path string `description:"小程序路径"`
  67. }
  68. type BannerUrlYxListResp struct {
  69. ListA []*BannerUrlYxResp
  70. ListB []*BannerUrlYxResp
  71. }
  72. // 列表
  73. func GetCygxBannerImgList() (items []*CygxBannerImgResp, err error) {
  74. o := orm.NewOrm()
  75. sql := `SELECT * FROM cygx_banner_img as art WHERE 1= 1 `
  76. _, err = o.Raw(sql).QueryRows(&items)
  77. return
  78. }