banner_img.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. )
  6. type CygxBannerImgResp struct {
  7. ImgId int `orm:"column(img_id);pk"`
  8. IndexImg string `description:"小程序封面图"`
  9. Img1 string `description:"图片1"`
  10. Img2 string `description:"图片2"`
  11. Img3 string `description:"图片3"`
  12. Img4 string `description:"图片4"`
  13. CreateTime string `description:"创建时间"`
  14. ModifyTime string `description:"更改时间"`
  15. }
  16. type CygxBannerImgListResp struct {
  17. Paging *paging.PagingItem `description:"分页数据"`
  18. List []*CygxBannerImgResp
  19. }
  20. // 获取数量
  21. func GetCygxBannerImgCount(condition string, pars []interface{}) (count int, err error) {
  22. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_banner_img as art WHERE 1= 1 `
  23. if condition != "" {
  24. sqlCount += condition
  25. }
  26. o := orm.NewOrmUsingDB("hz_cygx")
  27. err = o.Raw(sqlCount, pars).QueryRow(&count)
  28. return
  29. }
  30. // 列表
  31. func GetCygxBannerImgList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxBannerImgResp, err error) {
  32. o := orm.NewOrmUsingDB("hz_cygx")
  33. sql := `SELECT * FROM cygx_banner_img as art WHERE 1= 1 `
  34. if condition != "" {
  35. sql += condition
  36. }
  37. sql += ` LIMIT ?,? `
  38. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  39. return
  40. }
  41. // 通过ID获取详情
  42. func GetCygxBannerImgDetail(imgId int) (item *CygxBannerImgResp, err error) {
  43. o := orm.NewOrmUsingDB("hz_cygx")
  44. sql := `SELECT * FROM cygx_banner_img WHERE img_id=? `
  45. err = o.Raw(sql, imgId).QueryRow(&item)
  46. return
  47. }