(isMobile bool, status ...bool)
| 247 | } |
| 248 | |
| 249 | func (m *AdsCont) Lists(isMobile bool, status ...bool) (ads []AdsCont) { |
| 250 | var ( |
| 251 | positions []AdsPosition |
| 252 | pids []interface{} |
| 253 | tablePosition = NewAdsPosition() |
| 254 | tableAds = NewAdsCont() |
| 255 | ) |
| 256 | o := orm.NewOrm() |
| 257 | o.QueryTable(tablePosition).Filter("is_mobile", isMobile).All(&positions) |
| 258 | for _, p := range positions { |
| 259 | pids = append(pids, p.Id) |
| 260 | } |
| 261 | |
| 262 | q := o.QueryTable(tableAds).Filter("pid__in", pids...) |
| 263 | if len(status) > 0 { |
| 264 | q = q.Filter("status", status[0]) |
| 265 | } |
| 266 | q.All(&ads) |
| 267 | layout := "2006-01-02" |
| 268 | for idx, ad := range ads { |
| 269 | ad.StartTime = time.Unix(int64(ad.Start), 0).Format(layout) |
| 270 | ad.EndTime = time.Unix(int64(ad.End), 0).Format(layout) |
| 271 | ads[idx] = ad |
| 272 | } |
| 273 | return |
| 274 | } |
| 275 | |
| 276 | func GetAdsCode(positionIdentify string, isMobile bool) (code string) { |
| 277 | if beego.AppConfig.String("runmode") == "dev" { |
nothing calls this directly
no test coverage detected