Files
juwan-backend/app/community/rpc/internal/logic/getPostLikesByIdLogic.go
T
wwweww 19cc7a778c Refactor: Remove deprecated gRPC service files and implement new API structure
- Deleted old gRPC service definitions in `game_grpc.pb.go` and `public.go`.
- Added new API server implementations for objectstory, player, and shop services.
- Introduced configuration files for new APIs in `etc/*.yaml`.
- Created main entry points for each service in `objectstory.go`, `player.go`, and `shop.go`.
- Removed unused user update handler and user API files.
- Added utility functions for context management and HTTP header parsing.
- Introduced PostgreSQL backup configuration in `backup/postgreSql.yaml`.
2026-02-28 18:35:56 +08:00

45 lines
948 B
Go

package logic
import (
"context"
"errors"
"juwan-backend/app/community/rpc/internal/svc"
"juwan-backend/app/community/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type GetPostLikesByIdLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetPostLikesByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPostLikesByIdLogic {
return &GetPostLikesByIdLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *GetPostLikesByIdLogic) GetPostLikesById(in *pb.GetPostLikesByIdReq) (*pb.GetPostLikesByIdResp, error) {
if in.GetId() <= 0 {
return nil, errors.New("id is required")
}
store := l.svcCtx.Store
store.Mu.RLock()
defer store.Mu.RUnlock()
for _, like := range store.PostLikes {
if like.GetPostId() == in.GetId() {
cp := *like
return &pb.GetPostLikesByIdResp{PostLikes: &cp}, nil
}
}
return nil, errors.New("post like not found")
}