-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.go
42 lines (40 loc) · 1.16 KB
/
list.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
38
39
40
41
42
package favoriteaction
import (
"context"
"github.com/PICOF/simple-tiktok/cmd/constant"
"github.com/PICOF/simple-tiktok/dal/operation"
"github.com/PICOF/simple-tiktok/kitex_gen/favorite"
"github.com/PICOF/simple-tiktok/kitex_gen/feed"
"github.com/cloudwego/kitex/pkg/klog"
)
func FavoriteList(ctx context.Context, request *favorite.LikeListRequest) (resp *favorite.LikeListResponse, err error) {
var list []operation.TVideoInfo
list, err = operation.GetFavoriteList(ctx, request.GetQueryId())
if err != nil {
klog.CtxErrorf(ctx, "Failed get favorite video list: %v", err)
code, msg := constant.Failed.GetInfo()
resp = &favorite.LikeListResponse{
StatusCode: code,
StatusMsg: &msg,
}
return
}
var info []*feed.VideoInfo
info, err = ConvertAllVideoInfo(ctx, request.GetUserId(), list)
if err != nil {
klog.CtxErrorf(ctx, "Failed to convert favorite list: %v", err)
code, msg := constant.Failed.GetInfo()
resp = &favorite.LikeListResponse{
StatusCode: code,
StatusMsg: &msg,
}
return
}
code, msg := constant.Success.GetInfo()
resp = &favorite.LikeListResponse{
StatusCode: code,
StatusMsg: &msg,
VideoList: info,
}
return
}