package models import ( "github.com/beego/beego/v2/client/orm" ) type CygxBannerResp struct { BannerId int `description:"BannerId等于0新增,大于零修改"` ImgId int `description:"cygx_banner_img主键ID"` IndexImg string `description:"小程序封面图"` ListType string `description:"ABC哪一列"` BannerTypeName string `description:"添加类型名称"` Title string `description:"标题"` Link string `description:"链接地址"` Subtitle string `description:"副标题"` BannerUrlResp *BannerUrlResp `description:"跳转地址"` } type CygxBannerIdReq struct { BannerId int `description:"BannerId"` } type GetCygxBannerImgRespDetailResp struct { Detail *CygxBannerResp } // 通过ID获取详情 func GetCygxBannerDetail(banneId int) (item *CygxBannerResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_banner WHERE banner_id=? ` err = o.Raw(sql, banneId).QueryRow(&item) return } // 获取数量 func GetCygxBannerCount(condition string, pars []interface{}) (count int, err error) { sqlCount := ` SELECT COUNT(1) AS count FROM cygx_banner as art WHERE 1= 1 ` if condition != "" { sqlCount += condition } o := orm.NewOrm() err = o.Raw(sqlCount, pars).QueryRow(&count) return } // 列表 func GetCygxBannerList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxBannerResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_banner as art WHERE 1= 1 ` if condition != "" { sql += condition } sql += ` LIMIT ?,? ` _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items) return } type CygxBannerListResp struct { List []*CygxBannerResp } type CygxBannerImgResp struct { ImgId int `description:"图片ID"` IndexImg string `description:"小程序封面图"` } type BannerUrlResp struct { ChartPermissionId int `description:"行业id"` SourceId int `description:"资源ID"` Type int `description:"类型:1普通文本,2:文章、3:活动、4:产业、5:关于我们、6:产品内测"` Body string `description:"内容"` Path string `description:"小程序路径"` } type BannerUrlYxResp struct { IndexImg string `description:"小程序封面图"` Path string `description:"小程序路径"` } type BannerUrlYxListResp struct { ListA []*BannerUrlYxResp ListB []*BannerUrlYxResp } // 列表 func GetCygxBannerImgList() (items []*CygxBannerImgResp, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_banner_img as art WHERE 1= 1 ` _, err = o.Raw(sql).QueryRows(&items) return }