add video command body

This commit is contained in:
Jay
2018-12-18 16:50:38 +08:00
parent 9628bdfca3
commit 1c35860c17
3 changed files with 10 additions and 3 deletions
+1 -3
View File
@@ -2,7 +2,6 @@ package model
import (
"database/sql"
"math/rand"
"time"
)
@@ -29,8 +28,7 @@ func GetRandomLotteryByType(t string) (p *Lottery, err error) {
// GetRandomLotteryByTypeAndLimit -
func GetRandomLotteryByTypeAndLimit(t string, limit int) (p []*Lottery, err error) {
offset := rand.Intn(10)
err = x.Select(&p, `select * from "public"."lottery" where "type" = $1 order by random() offset $2 limit $3`, t, offset, limit)
err = x.Select(&p, `select * from "public"."lottery" where "type" = $1 offset floor(random() * (select count(*) as c from "public"."lottery" where "type" = $2)) limit $3`, t, t, limit)
if err == sql.ErrNoRows {
return nil, nil
}