go-common/app/interface/main/creative/http/web_ad.go

38 lines
762 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package http
import (
"go-common/library/ecode"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/metadata"
"strconv"
)
// webAdGameList fn
func webAdGameList(c *bm.Context) {
ip := metadata.String(c, metadata.RemoteIP)
params := c.Request.Form
_, ok := c.Get("mid")
if !ok {
c.JSON(nil, ecode.NoLogin)
return
}
pnStr := params.Get("pn")
psStr := params.Get("ps")
pn, err := strconv.Atoi(pnStr)
if err != nil || pn <= 0 {
pn = 1
}
ps, err := strconv.Atoi(psStr)
if err != nil || ps <= 0 || ps > 20 {
ps = 20
}
keywordStr := params.Get("keyword")
letterStr := params.Get("letter")
data, err := adSvc.GameList(c, keywordStr, letterStr, pn, ps, ip)
if err != nil {
c.JSON(nil, err)
return
}
c.JSON(data, nil)
}