package logic import ( "context" "errors" "juwan-backend/app/community/rpc/internal/models/commentlikes" "juwan-backend/app/community/rpc/internal/svc" "juwan-backend/app/community/rpc/pb" "github.com/zeromicro/go-zero/core/logx" ) type GetCommentLikesByIdLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewGetCommentLikesByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCommentLikesByIdLogic { return &GetCommentLikesByIdLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } func (l *GetCommentLikesByIdLogic) GetCommentLikesById(in *pb.GetCommentLikesByIdReq) (*pb.GetCommentLikesByIdResp, error) { if in.GetId() <= 0 { return nil, errors.New("id is required") } like, err := l.svcCtx.CommunityModelRO.CommentLikes.Query(). Where(commentlikes.CommentIDEQ(in.GetId())). First(l.ctx) if err != nil { return nil, errors.New("comment like not found") } return &pb.GetCommentLikesByIdResp{CommentLikes: entCommentLikeToPb(like)}, nil }