fix: unify user ID type to string and rename service to users-api

This commit is contained in:
zetaloop
2026-04-22 22:03:49 +08:00
parent 59256897e9
commit b3db04c9cc
11 changed files with 59 additions and 28 deletions
@@ -6,6 +6,8 @@ package user
import (
"context"
"errors"
"strconv"
"juwan-backend/app/users/rpc/usercenter"
"juwan-backend/common/utils/contextj"
@@ -31,15 +33,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")
}
followeeId, err := strconv.ParseInt(req.Id, 10, 64)
if err != nil {
return nil, errors.New("invalid user id")
}
_, err = l.svcCtx.UserRpc.AddUserFollows(l.ctx, &usercenter.AddUserFollowsReq{
FollowerId: userId,
FolloweeId: req.Id,
FolloweeId: followeeId,
CreatedAt: 0,
})
if err != nil {