-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed_service.go
37 lines (32 loc) · 877 Bytes
/
feed_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Code generated by hertz generator.
package tiktokapi
import (
"context"
"github.com/PICOF/simple-tiktok/cmd/api/biz/rpc/feed"
"github.com/PICOF/simple-tiktok/cmd/api/biz/model/tiktokapi"
"github.com/cloudwego/hertz/pkg/app"
"github.com/cloudwego/hertz/pkg/protocol/consts"
)
// GetVideoList .
// @router /douyin/feed/ [GET]
func GetVideoList(ctx context.Context, c *app.RequestContext) {
var err error
var req tiktokapi.FeedRequest
err = c.BindAndValidate(&req)
if err != nil {
c.String(consts.StatusBadRequest, err.Error())
return
}
resp, err := feed.GetVideoList(ctx, &req, c.GetInt64("user_id"))
if err != nil {
msg := "请求远程服务时出错"
c.JSON(consts.StatusInternalServerError, tiktokapi.FeedResponse{
StatusCode: -1,
StatusMsg: &msg,
NextTime: nil,
VideoList: nil,
})
} else {
c.JSON(consts.StatusOK, resp)
}
}