go-common/app/interface/openplatform/article/http/archive.go

35 lines
795 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package http
import (
"go-common/app/interface/openplatform/article/conf"
"go-common/app/service/main/archive/api"
"go-common/library/ecode"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/metadata"
"go-common/library/xstr"
)
func archives(c *bm.Context) {
var (
err error
aids []int64
arcs map[int64]*api.Arc
params = c.Request.Form
ip = metadata.String(c, metadata.RemoteIP)
)
idsStr := params.Get("ids")
if aids, err = xstr.SplitInts(idsStr); err != nil || len(aids) < 1 || len(aids) > conf.Conf.Article.MaxArchives {
c.JSON(nil, ecode.RequestErr)
return
}
if arcs, err = artSrv.Archives(c, aids, ip); err != nil {
c.JSON(nil, err)
return
}
if len(arcs) == 0 {
c.JSON(nil, ecode.NothingFound)
return
}
c.JSON(arcs, err)
}