fix: some api bug
This commit is contained in:
@@ -5,6 +5,9 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"juwan-backend/app/users/rpc/usercenter"
|
||||
"juwan-backend/common/utils/contextj"
|
||||
|
||||
"juwan-backend/app/users/api/internal/svc"
|
||||
"juwan-backend/app/users/api/internal/types"
|
||||
@@ -29,6 +32,19 @@ func NewFollowUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Follow
|
||||
|
||||
func (l *FollowUserLogic) FollowUser(req *types.FollowUserReq) (resp *types.EmptyResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
userId, err := contextj.UserIDFrom(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.New("unauthorized")
|
||||
}
|
||||
|
||||
return
|
||||
_, err = l.svcCtx.UserRpc.AddUserFollows(l.ctx, &usercenter.AddUserFollowsReq{
|
||||
FollowerId: userId,
|
||||
FolloweeId: req.Id,
|
||||
CreatedAt: 0,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("add user follow err: %v", err)
|
||||
return nil, errors.New("failed to follow user")
|
||||
}
|
||||
return &types.EmptyResp{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user