You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
935 B
38 lines
935 B
package dao |
|
|
|
import ( |
|
"context" |
|
"net/url" |
|
"strconv" |
|
|
|
"go-common/app/interface/main/player/model" |
|
"go-common/library/ecode" |
|
"go-common/library/net/metadata" |
|
|
|
"github.com/pkg/errors" |
|
) |
|
|
|
const _viewPointsURI = "/x/internal/creative/video/viewpoints" |
|
|
|
// ViewPoints get view points data from creative. |
|
func (d *Dao) ViewPoints(c context.Context, aid, cid int64) (points []*model.Points, err error) { |
|
params := url.Values{} |
|
params.Set("aid", strconv.FormatInt(aid, 10)) |
|
params.Set("cid", strconv.FormatInt(cid, 10)) |
|
var res struct { |
|
Code int `json:"code"` |
|
Data struct { |
|
Points []*model.Points `json:"points"` |
|
} `json:"data"` |
|
} |
|
ip := metadata.String(c, metadata.RemoteIP) |
|
if err = d.client.Get(c, d.viewPointsURL, ip, params, &res); err != nil { |
|
return |
|
} |
|
if res.Code != ecode.OK.Code() { |
|
err = errors.Wrap(ecode.Int(res.Code), d.viewPointsURL+"?"+params.Encode()) |
|
return |
|
} |
|
points = res.Data.Points |
|
return |
|
}
|
|
|