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:
wwweww
2026-02-28 18:35:56 +08:00
parent d2f33b4b96
commit 19cc7a778c
349 changed files with 42548 additions and 1453 deletions
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"errors"
"juwan-backend/app/shop/rpc/internal/models/shops"
"time"
"juwan-backend/app/shop/rpc/internal/svc"
@@ -28,5 +29,74 @@ func NewUpdateShopsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
}
func (l *UpdateShopsLogic) UpdateShops(in *pb.UpdateShopsReq) (*pb.UpdateShopsResp, error) {
updater := l.svcCtx.ShopModelRW.Shops.UpdateOneID(in.Id)
if in.OwnerId > 0 {
updater = updater.SetOwnerID(in.OwnerId)
}
if in.Name != "" {
updater = updater.SetName(in.Name)
}
if in.Banner != "" {
updater = updater.SetBanner(in.Banner)
}
if in.Description != "" {
updater = updater.SetDescription(in.Description)
}
if in.Rating != "" {
rating, perr := decimal.NewFromString(in.Rating)
if perr != nil {
return nil, errors.New("invalid rating")
}
updater = updater.SetRating(rating)
}
if in.TotalOrders > 0 {
updater = updater.SetTotalOrders(int(in.TotalOrders))
}
if in.PlayerCount > 0 {
updater = updater.SetPlayerCount(int(in.PlayerCount))
}
if in.CommissionType != "" {
updater = updater.SetCommissionType(in.CommissionType)
}
if in.CommissionValue != "" {
commissionValue, perr := decimal.NewFromString(in.CommissionValue)
if perr != nil {
return nil, errors.New("invalid commissionValue")
}
updater = updater.SetCommissionValue(commissionValue)
}
if in.DispatchMode != "" {
updater = updater.SetDispatchMode(in.DispatchMode)
}
updater = updater.
SetAllowMultiShop(in.AllowMultiShop).
SetAllowIndependentOrders(in.AllowIndependentOrders)
if len(in.Announcements) > 0 {
updater = updater.SetAnnouncements(in.Announcements)
}
if in.TemplateConfig != "" {
var templateConfig map[string]interface{}
err := json.Unmarshal([]byte(in.TemplateConfig), &templateConfig)
if err != nil {
logx.WithContext(l.ctx).Errorf("invalid template config: %v", err)
return nil, errors.New("invalid template config")
}
updater = updater.SetTemplateConfig(templateConfig)
}
if in.UpdatedAt > 0 {
updater = updater.SetUpdatedAt(time.Unix(in.UpdatedAt, 0))
}
_, err := updater.Where(shops.IDEQ(in.Id)).Save(l.ctx)
if err != nil {
logx.WithContext(l.ctx).Errorf("update shops failed: %v", err)
return nil, errors.New("update shops failed")
}
return &pb.UpdateShopsResp{}, nil
}