Skip to content

Commit

Permalink
fix: 修复点赞数量
Browse files Browse the repository at this point in the history
  • Loading branch information
fuqihao.foliet committed Dec 22, 2023
1 parent 2b2b1e1 commit 648a1b0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
9 changes: 3 additions & 6 deletions biz/domain/service/cat_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"context"

genbasic "github.com/xh-polaris/service-idl-gen-go/kitex_gen/basic"

"github.com/google/wire"
Expand Down Expand Up @@ -35,18 +36,14 @@ func (s *CatImageDomainService) LoadLikeCount(ctx context.Context, image *core_a
TargetId: image.Id,
Type: genuser.LikeType_CatPhoto,
PaginationOptions: &genbasic.PaginationOptions{
Page: nil,
Limit: lo.ToPtr(int64(0)),
LastToken: nil,
Backward: nil,
Offset: nil,
Limit: lo.ToPtr(int64(0)),
},
})
if err != nil {
log.CtxError(ctx, "[LoadLikeCount] fail, err=%v", err)
return err
}
image.Likes = lo.ToPtr(int64(len(rpcResp.UserIds)))
image.Likes = lo.ToPtr(rpcResp.GetTotal())
return nil
}

Expand Down
9 changes: 3 additions & 6 deletions biz/domain/service/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"context"

genbasic "github.com/xh-polaris/service-idl-gen-go/kitex_gen/basic"

"github.com/google/wire"
Expand Down Expand Up @@ -71,18 +72,14 @@ func (s *CommentDomainService) LoadLikeCount(ctx context.Context, comment *core_
TargetId: comment.Id,
Type: genuser.LikeType_Comment,
PaginationOptions: &genbasic.PaginationOptions{
Page: nil,
Limit: lo.ToPtr(int64(0)),
LastToken: nil,
Backward: nil,
Offset: nil,
Limit: lo.ToPtr(int64(0)),
},
})
if err != nil {
log.CtxError(ctx, "[LoadLikeCount] fail, err=%v", err)
return err
}
comment.LikeCount = lo.ToPtr(int64(len(rpcResp.UserIds)))
comment.LikeCount = lo.ToPtr(rpcResp.GetTotal())
return nil
}

Expand Down
9 changes: 3 additions & 6 deletions biz/domain/service/moment.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"context"
"errors"

genbasic "github.com/xh-polaris/service-idl-gen-go/kitex_gen/basic"

"github.com/google/wire"
Expand Down Expand Up @@ -100,17 +101,13 @@ func (s *MomentDomainService) LoadLikeCount(ctx context.Context, moment *core_ap
TargetId: moment.Id,
Type: genuser.LikeType_Moment,
PaginationOptions: &genbasic.PaginationOptions{
Page: nil,
Limit: lo.ToPtr(int64(0)),
LastToken: nil,
Backward: nil,
Offset: nil,
Limit: lo.ToPtr(int64(0)),
},
})
if err != nil {
return err
}
moment.LikeCount = lo.ToPtr(int64(len(rpcResp.UserIds)))
moment.LikeCount = lo.ToPtr(rpcResp.GetTotal())
return nil
}

Expand Down
9 changes: 3 additions & 6 deletions biz/domain/service/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package service
import (
"context"
"errors"

genbasic "github.com/xh-polaris/service-idl-gen-go/kitex_gen/basic"

"github.com/google/wire"
Expand Down Expand Up @@ -66,17 +67,13 @@ func (s *PostDomainService) LoadLikeCount(ctx context.Context, post *core_api.Po
TargetId: post.Id,
Type: genuser.LikeType_Post,
PaginationOptions: &genbasic.PaginationOptions{
Page: nil,
Limit: lo.ToPtr(int64(0)),
LastToken: nil,
Backward: nil,
Offset: nil,
Limit: lo.ToPtr(int64(0)),
},
})
if err != nil {
return err
}
post.Likes = lo.ToPtr(int64(len(rpcResp.UserIds)))
post.Likes = lo.ToPtr(rpcResp.GetTotal())
return nil
}

Expand Down

0 comments on commit 648a1b0

Please sign in to comment.