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.
44 lines
1.1 KiB
44 lines
1.1 KiB
2 months ago
|
package pack
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/TremblingV5/DouTok/applications/user/dal/model"
|
||
|
"github.com/TremblingV5/DouTok/applications/user/misc"
|
||
|
"github.com/TremblingV5/DouTok/applications/user/rpc"
|
||
|
"github.com/TremblingV5/DouTok/kitex_gen/relation"
|
||
|
"github.com/TremblingV5/DouTok/kitex_gen/user"
|
||
|
)
|
||
|
|
||
|
func PackUserResp(code int32, msg string, u *model.User) (resp *user.DouyinUserResponse, err error) {
|
||
|
resp = &user.DouyinUserResponse{
|
||
|
StatusCode: code,
|
||
|
StatusMsg: msg,
|
||
|
}
|
||
|
|
||
|
userResp, err := rpc.GetFollowCount(context.Background(), &relation.DouyinRelationCountRequest{
|
||
|
UserId: int64(u.ID),
|
||
|
})
|
||
|
|
||
|
if err != nil {
|
||
|
resp.StatusCode = int32(misc.SystemErr.ErrCode)
|
||
|
resp.StatusMsg = misc.SystemErr.ErrMsg
|
||
|
return resp, err
|
||
|
}
|
||
|
|
||
|
info := user.User{
|
||
|
Id: int64(u.ID),
|
||
|
Name: u.UserName,
|
||
|
Avatar: u.Avatar,
|
||
|
BackgroundImage: u.BackgroundImage,
|
||
|
Signature: u.Signature,
|
||
|
FollowCount: userResp.FollowCount,
|
||
|
FollowerCount: userResp.FollowerCount,
|
||
|
IsFollow: true,
|
||
|
}
|
||
|
|
||
|
resp.User = &info
|
||
|
|
||
|
return resp, nil
|
||
|
}
|