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`.
This commit is contained in:
@@ -2,8 +2,12 @@ package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"juwan-backend/app/shop/rpc/internal/models/predicate"
|
||||
"juwan-backend/app/shop/rpc/internal/models/shopinvitations"
|
||||
"juwan-backend/app/shop/rpc/internal/svc"
|
||||
"juwan-backend/app/shop/rpc/pb"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
@@ -23,6 +27,65 @@ func NewSearchShopInvitationsLogic(ctx context.Context, svcCtx *svc.ServiceConte
|
||||
}
|
||||
|
||||
func (l *SearchShopInvitationsLogic) SearchShopInvitations(in *pb.SearchShopInvitationsReq) (*pb.SearchShopInvitationsResp, error) {
|
||||
// TODO: implement search logic based on the provided criteria in the request
|
||||
return &pb.SearchShopInvitationsResp{}, nil
|
||||
if in.Limit <= 0 {
|
||||
in.Limit = 20
|
||||
}
|
||||
if in.Limit > 1000 {
|
||||
return nil, errors.New("limit too large")
|
||||
}
|
||||
|
||||
preds := make([]predicate.ShopInvitations, 0, 8)
|
||||
if in.Id > 0 {
|
||||
preds = append(preds, shopinvitations.IDEQ(in.Id))
|
||||
}
|
||||
if in.ShopId > 0 {
|
||||
preds = append(preds, shopinvitations.ShopIDEQ(in.ShopId))
|
||||
}
|
||||
if in.PlayerId > 0 {
|
||||
preds = append(preds, shopinvitations.PlayerIDEQ(in.PlayerId))
|
||||
}
|
||||
if in.Status != "" {
|
||||
preds = append(preds, shopinvitations.StatusEQ(in.Status))
|
||||
}
|
||||
if in.InvitedBy > 0 {
|
||||
preds = append(preds, shopinvitations.InvitedByEQ(in.InvitedBy))
|
||||
}
|
||||
if in.CreatedAt > 0 {
|
||||
preds = append(preds, shopinvitations.CreatedAtGTE(time.Unix(in.CreatedAt, 0)))
|
||||
}
|
||||
if in.RespondedAt > 0 {
|
||||
preds = append(preds, shopinvitations.RespondedAtGTE(time.Unix(in.RespondedAt, 0)))
|
||||
}
|
||||
|
||||
query := l.svcCtx.ShopModelRO.ShopInvitations.Query()
|
||||
if len(preds) > 0 {
|
||||
query = query.Where(shopinvitations.And(preds...))
|
||||
}
|
||||
|
||||
list, err := query.
|
||||
Offset(int(in.Page * in.Limit)).
|
||||
Limit(int(in.Limit)).
|
||||
All(l.ctx)
|
||||
if err != nil {
|
||||
logx.Errorf("search shop invitations failed, %s", err.Error())
|
||||
return nil, errors.New("search shop invitations failed")
|
||||
}
|
||||
|
||||
result := make([]*pb.ShopInvitations, 0, len(list))
|
||||
for _, item := range list {
|
||||
pbItem := &pb.ShopInvitations{
|
||||
Id: item.ID,
|
||||
ShopId: item.ShopID,
|
||||
PlayerId: item.PlayerID,
|
||||
Status: item.Status,
|
||||
InvitedBy: item.InvitedBy,
|
||||
CreatedAt: item.CreatedAt.Unix(),
|
||||
}
|
||||
if item.RespondedAt != nil {
|
||||
pbItem.RespondedAt = item.RespondedAt.Unix()
|
||||
}
|
||||
result = append(result, pbItem)
|
||||
}
|
||||
|
||||
return &pb.SearchShopInvitationsResp{ShopInvitations: result}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user