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
@@ -1,4 +1,4 @@
Name: juwan-api
Name: shop-api
Host: 0.0.0.0
Port: 8888
@@ -4,24 +4,34 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 接受邀请
func AcceptInvitationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.AcceptInvitationReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := shop.NewAcceptInvitationLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewAcceptInvitationLogic(ctx, svcCtx)
resp, err := l.AcceptInvitation(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,12 +4,17 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 新增店铺公告
@@ -21,7 +26,12 @@ func AddAnnouncementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
l := shop.NewAddAnnouncementLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewAddAnnouncementLogic(ctx, svcCtx)
resp, err := l.AddAnnouncement(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,12 +4,17 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 创建店铺
@@ -21,7 +26,12 @@ func CreateShopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
l := shop.NewCreateShopLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewCreateShopLogic(ctx, svcCtx)
resp, err := l.CreateShop(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,24 +4,34 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 删除店铺公告
func DeleteAnnouncementHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.DeleteAnnouncementReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := shop.NewDeleteAnnouncementLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewDeleteAnnouncementLogic(ctx, svcCtx)
resp, err := l.DeleteAnnouncement(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,12 +4,17 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 获取当前用户的店铺
@@ -21,7 +26,12 @@ func GetMyShopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
l := shop.NewGetMyShopLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewGetMyShopLogic(ctx, svcCtx)
resp, err := l.GetMyShop(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -6,16 +6,17 @@ package shop
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 获取店铺详情
func GetShopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.ShopIdReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
@@ -4,24 +4,34 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 获取收入统计
func GetShopIncomeStatsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.AcceptInvitationReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := shop.NewGetShopIncomeStatsLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewGetShopIncomeStatsLogic(ctx, svcCtx)
resp, err := l.GetShopIncomeStats(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -6,16 +6,17 @@ package shop
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 获取店长的店铺
func GetUserShopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.UserIdReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
@@ -4,12 +4,17 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 邀请打手
@@ -21,7 +26,12 @@ func InvitePlayerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
l := shop.NewInvitePlayerLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewInvitePlayerLogic(ctx, svcCtx)
resp, err := l.InvitePlayer(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,24 +4,34 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 拒绝邀请
func RejectInvitationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.AcceptInvitationReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := shop.NewRejectInvitationLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewRejectInvitationLogic(ctx, svcCtx)
resp, err := l.RejectInvitation(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,24 +4,34 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 移除打手
func RemovePlayerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.EmptyResp
var req types.InvitationReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := shop.NewRemovePlayerLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewRemovePlayerLogic(ctx, svcCtx)
resp, err := l.RemovePlayer(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,12 +4,17 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 更新店铺信息
@@ -21,7 +26,12 @@ func UpdateShopHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
l := shop.NewUpdateShopLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewUpdateShopLogic(ctx, svcCtx)
resp, err := l.UpdateShop(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -4,12 +4,17 @@
package shop
import (
"errors"
"juwan-backend/common/utils/contextj"
"juwan-backend/common/utils/httpj"
"juwan-backend/common/utils/responses"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"juwan-backend/app/shop/api/internal/logic/shop"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"github.com/zeromicro/go-zero/rest/httpx"
)
// 更新店铺模板
@@ -21,7 +26,12 @@ func UpdateShopTemplateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return
}
l := shop.NewUpdateShopTemplateLogic(r.Context(), svcCtx)
userId, err := httpj.GetUserIdFromHeader(r.Header)
if err != nil {
httpx.ErrorCtx(r.Context(), w, responses.NewErrorResp(403, errors.New("forbidden: user not authenticated")))
}
ctx := contextj.WithUserID(r.Context(), userId)
l := shop.NewUpdateShopTemplateLogic(ctx, svcCtx)
resp, err := l.UpdateShopTemplate(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
@@ -5,9 +5,12 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"time"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +31,44 @@ func NewAcceptInvitationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
func (l *AcceptInvitationLogic) AcceptInvitation(req *types.AcceptInvitationReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
AcceptInvitationLogic{}
return
userId, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
invitation, err := l.svcCtx.ShopRpc.GetShopInvitationsById(l.ctx, &pb.GetShopInvitationsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if invitation.ShopInvitations == nil {
return nil, errors.New("invitation not found")
}
if invitation.ShopInvitations.PlayerId != userId {
return nil, errors.New("bad request: invitation not found or not owned by user")
}
i, err := l.svcCtx.ShopRpc.UpdateShopInvitations(l.ctx, &pb.UpdateShopInvitationsReq{
Id: req.Id,
ShopId: invitation.ShopInvitations.ShopId,
PlayerId: userId,
Status: "accepted",
InvitedBy: invitation.ShopInvitations.InvitedBy,
CreatedAt: invitation.ShopInvitations.CreatedAt,
RespondedAt: time.Now().Unix(),
})
if err != nil {
return nil, err
}
_, err = l.svcCtx.ShopRpc.AddShopPlayers(l.ctx, &pb.AddShopPlayersReq{
ShopId: i.ShopInvitations.ShopId,
PlayerId: userId,
IsPrimary: false,
JoinedAt: time.Now().Unix(),
LeftAt: 0,
})
if err != nil {
return nil, err
}
_ = i
return &types.EmptyResp{}, nil
}
@@ -5,6 +5,9 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
@@ -28,7 +31,41 @@ func NewAddAnnouncementLogic(ctx context.Context, svcCtx *svc.ServiceContext) *A
}
func (l *AddAnnouncementLogic) AddAnnouncement(req *types.AnnouncementReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
userId, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
shop, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if shop.Shops == nil {
return nil, errors.New("shop not found")
}
if shop.Shops.OwnerId != userId {
return nil, contextj.ERRILLEGALUSER
}
shop.Shops.Announcements = append(shop.Shops.Announcements, req.Content)
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
Id: shop.Shops.Id,
OwnerId: shop.Shops.OwnerId,
Name: shop.Shops.Name,
Banner: shop.Shops.Banner,
Description: shop.Shops.Description,
Rating: shop.Shops.Rating,
TotalOrders: shop.Shops.TotalOrders,
PlayerCount: shop.Shops.PlayerCount,
CommissionType: shop.Shops.CommissionType,
CommissionValue: shop.Shops.CommissionValue,
AllowMultiShop: shop.Shops.AllowMultiShop,
AllowIndependentOrders: shop.Shops.AllowIndependentOrders,
DispatchMode: shop.Shops.DispatchMode,
Announcements: shop.Shops.Announcements,
TemplateConfig: shop.Shops.TemplateConfig,
})
if err != nil {
return nil, err
}
return
return &types.EmptyResp{}, nil
}
@@ -5,6 +5,10 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
@@ -28,7 +32,42 @@ func NewCreateShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Create
}
func (l *CreateShopLogic) CreateShop(req *types.CreateShopReq) (resp *types.ShopProfile, err error) {
// todo: add your logic here and delete this line
ownerID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
if req.Name == "" {
return nil, errors.New("name is required")
}
_, err = l.svcCtx.ShopRpc.AddShops(l.ctx, &pb.AddShopsReq{
OwnerId: ownerID,
Name: req.Name,
Description: req.Description,
Rating: "5",
TotalOrders: 0,
PlayerCount: 0,
CommissionType: req.CommissionType,
CommissionValue: req.CommissionValue,
AllowMultiShop: false,
AllowIndependentOrders: true,
DispatchMode: "manual",
Announcements: []string{},
TemplateConfig: `{}`,
})
if err != nil {
return nil, err
}
shop, err := getShopByOwnerID(l.ctx, l.svcCtx.ShopRpc, ownerID)
if err != nil {
return nil, err
}
if shop == nil {
return nil, errors.New("create shop failed")
}
return toShopProfile(shop), nil
return
}
@@ -5,9 +5,12 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +31,48 @@ func NewDeleteAnnouncementLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *DeleteAnnouncementLogic) DeleteAnnouncement(req *types.DeleteAnnouncementReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
return
shop, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if shop.Shops == nil {
return nil, errors.New("shop not found")
}
if shop.Shops.OwnerId != userID {
return nil, contextj.ERRILLEGALUSER
}
index := int(req.Index)
if index < 0 || index >= len(shop.Shops.Announcements) {
return nil, errors.New("announcement index out of range")
}
shop.Shops.Announcements = append(shop.Shops.Announcements[:index], shop.Shops.Announcements[index+1:]...)
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
Id: shop.Shops.Id,
OwnerId: shop.Shops.OwnerId,
Name: shop.Shops.Name,
Banner: shop.Shops.Banner,
Description: shop.Shops.Description,
Rating: shop.Shops.Rating,
TotalOrders: shop.Shops.TotalOrders,
PlayerCount: shop.Shops.PlayerCount,
CommissionType: shop.Shops.CommissionType,
CommissionValue: shop.Shops.CommissionValue,
AllowMultiShop: shop.Shops.AllowMultiShop,
AllowIndependentOrders: shop.Shops.AllowIndependentOrders,
DispatchMode: shop.Shops.DispatchMode,
Announcements: shop.Shops.Announcements,
TemplateConfig: shop.Shops.TemplateConfig,
})
if err != nil {
return nil, err
}
return &types.EmptyResp{}, nil
}
@@ -5,9 +5,11 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +30,19 @@ func NewGetMyShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMySh
}
func (l *GetMyShopLogic) GetMyShop(req *types.EmptyResp) (resp *types.ShopProfile, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
shop, err := getShopByOwnerID(l.ctx, l.svcCtx.ShopRpc, userID)
if err != nil {
return nil, err
}
if shop == nil {
return nil, errors.New("shop not found")
}
return toShopProfile(shop), nil
return
}
@@ -5,9 +5,12 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +31,28 @@ func NewGetShopIncomeStatsLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *GetShopIncomeStatsLogic) GetShopIncomeStats(req *types.AcceptInvitationReq) (resp *types.IncomeStatsResp, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
shop, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if shop.Shops == nil {
return nil, errors.New("shop not found")
}
if shop.Shops.OwnerId != userID {
return nil, contextj.ERRILLEGALUSER
}
return &types.IncomeStatsResp{
MonthlyIncome: "0",
PendingSettlement: "0",
TotalWithdrawn: "0",
TotalOrders: shop.Shops.TotalOrders,
CompletedOrders: shop.Shops.TotalOrders,
}, nil
return
}
@@ -5,6 +5,9 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
@@ -28,7 +31,13 @@ func NewGetShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetShopLo
}
func (l *GetShopLogic) GetShop(req *types.ShopIdReq) (resp *types.ShopProfile, err error) {
// todo: add your logic here and delete this line
result, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if result.Shops == nil {
return nil, errors.New("shop not found")
}
return toShopProfile(result.Shops), nil
return
}
@@ -5,6 +5,7 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
@@ -28,7 +29,13 @@ func NewGetUserShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUs
}
func (l *GetUserShopLogic) GetUserShop(req *types.UserIdReq) (resp *types.ShopProfile, err error) {
// todo: add your logic here and delete this line
shop, err := getShopByOwnerID(l.ctx, l.svcCtx.ShopRpc, req.Id)
if err != nil {
return nil, err
}
if shop == nil {
return nil, errors.New("shop not found")
}
return toShopProfile(shop), nil
return
}
@@ -0,0 +1,65 @@
package shop
import (
"context"
"encoding/json"
"strconv"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/app/shop/rpc/shopservice"
)
func toShopProfile(in *pb.Shops) *types.ShopProfile {
if in == nil {
return nil
}
var template any
if in.TemplateConfig != "" {
_ = json.Unmarshal([]byte(in.TemplateConfig), &template)
}
if template == nil {
template = map[string]any{}
}
ownerID := strconv.FormatInt(in.OwnerId, 10)
return &types.ShopProfile{
Id: strconv.FormatInt(in.Id, 10),
Owner: types.UserProfile{
Id: ownerID,
Username: "",
Nickname: "",
Avatar: "",
Role: "owner",
VerifiedRoles: []string{"owner"},
VerificationStatus: map[string]string{},
CreatedAt: "",
},
Name: in.Name,
Banner: in.Banner,
Description: in.Description,
Rating: in.Rating,
TotalOrders: in.TotalOrders,
PlayerCount: in.PlayerCount,
CommissionType: in.CommissionType,
CommissionValue: in.CommissionValue,
Announcements: in.Announcements,
TemplateConfig: template,
}
}
func getShopByOwnerID(ctx context.Context, rpc shopservice.ShopService, ownerID int64) (*pb.Shops, error) {
list, err := rpc.SearchShops(ctx, &pb.SearchShopsReq{
Page: 0,
Limit: 1,
OwnerId: ownerID,
})
if err != nil {
return nil, err
}
if len(list.Shops) == 0 {
return nil, nil
}
return list.Shops[0], nil
}
@@ -5,9 +5,13 @@ package shop
import (
"context"
"errors"
"time"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +32,33 @@ func NewInvitePlayerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Invi
}
func (l *InvitePlayerLogic) InvitePlayer(req *types.InvitationReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
return
shop, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if shop.Shops == nil {
return nil, errors.New("shop not found")
}
if shop.Shops.OwnerId != userID {
return nil, contextj.ERRILLEGALUSER
}
_, err = l.svcCtx.ShopRpc.AddShopInvitations(l.ctx, &pb.AddShopInvitationsReq{
ShopId: req.Id,
PlayerId: req.PlayerId,
Status: "pending",
InvitedBy: userID,
CreatedAt: time.Now().Unix(),
RespondedAt: 0,
})
if err != nil {
return nil, err
}
return &types.EmptyResp{}, nil
}
@@ -6,6 +6,8 @@ package shop
import (
"context"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
@@ -28,7 +30,33 @@ func NewListShopsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListSho
}
func (l *ListShopsLogic) ListShops(req *types.PageReq) (resp *types.ShopListResp, err error) {
// todo: add your logic here and delete this line
if req.Limit <= 0 {
req.Limit = 20
}
result, err := l.svcCtx.ShopRpc.SearchShops(l.ctx, &pb.SearchShopsReq{
Page: req.Offset / req.Limit,
Limit: req.Limit,
})
if err != nil {
return nil, err
}
items := make([]types.ShopProfile, 0, len(result.Shops))
for _, item := range result.Shops {
profile := toShopProfile(item)
if profile != nil {
items = append(items, *profile)
}
}
return &types.ShopListResp{
Items: items,
Meta: types.PageMeta{
Total: int64(len(items)),
Offset: req.Offset,
Limit: req.Limit,
},
}, nil
return
}
@@ -5,9 +5,13 @@ package shop
import (
"context"
"errors"
"time"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +32,34 @@ func NewRejectInvitationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
func (l *RejectInvitationLogic) RejectInvitation(req *types.AcceptInvitationReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
return
invitation, err := l.svcCtx.ShopRpc.GetShopInvitationsById(l.ctx, &pb.GetShopInvitationsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if invitation.ShopInvitations == nil {
return nil, errors.New("invitation not found")
}
if invitation.ShopInvitations.PlayerId != userID {
return nil, contextj.ERRILLEGALUSER
}
_, err = l.svcCtx.ShopRpc.UpdateShopInvitations(l.ctx, &pb.UpdateShopInvitationsReq{
Id: req.Id,
ShopId: invitation.ShopInvitations.ShopId,
PlayerId: invitation.ShopInvitations.PlayerId,
Status: "rejected",
InvitedBy: invitation.ShopInvitations.InvitedBy,
CreatedAt: invitation.ShopInvitations.CreatedAt,
RespondedAt: time.Now().Unix(),
})
if err != nil {
return nil, err
}
return &types.EmptyResp{}, nil
}
@@ -5,9 +5,13 @@ package shop
import (
"context"
"errors"
"time"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +32,31 @@ func NewRemovePlayerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Remo
}
func (l *RemovePlayerLogic) RemovePlayer(req *types.InvitationReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
return
shop, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if shop.Shops == nil {
return nil, errors.New("shop not found")
}
if shop.Shops.OwnerId != userID {
return nil, contextj.ERRILLEGALUSER
}
_, err = l.svcCtx.ShopRpc.UpdateShopPlayers(l.ctx, &pb.UpdateShopPlayersReq{
ShopId: req.Id,
PlayerId: req.PlayerId,
IsPrimary: false,
LeftAt: time.Now().Unix(),
})
if err != nil {
return nil, err
}
return &types.EmptyResp{}, nil
}
@@ -5,9 +5,12 @@ package shop
import (
"context"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -27,8 +30,69 @@ func NewUpdateShopLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Update
}
}
func (l *UpdateShopLogic) UpdateShop(req *types.ShopIdReq) (resp *types.ShopProfile, err error) {
// todo: add your logic here and delete this line
func (l *UpdateShopLogic) UpdateShop(req *types.UpdateShopReq) (resp *types.ShopProfile, err error) {
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
current, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if current.Shops == nil {
return nil, errors.New("shop not found")
}
if current.Shops.OwnerId != userID {
return nil, contextj.ERRILLEGALUSER
}
name := current.Shops.Name
if req.Name != "" {
name = req.Name
}
description := current.Shops.Description
if req.Description != "" {
description = req.Description
}
commissionType := current.Shops.CommissionType
if req.CommissionType != "" {
commissionType = req.CommissionType
}
commissionValue := current.Shops.CommissionValue
if req.CommissionValue != "" {
commissionValue = req.CommissionValue
}
dispatchMode := current.Shops.DispatchMode
if req.DispatchMode != "" {
dispatchMode = req.DispatchMode
}
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
Id: current.Shops.Id,
OwnerId: current.Shops.OwnerId,
Name: name,
Banner: current.Shops.Banner,
Description: description,
Rating: current.Shops.Rating,
TotalOrders: current.Shops.TotalOrders,
PlayerCount: current.Shops.PlayerCount,
CommissionType: commissionType,
CommissionValue: commissionValue,
AllowMultiShop: req.AllowMultiShop,
AllowIndependentOrders: req.AllowIndependentOrders,
DispatchMode: dispatchMode,
Announcements: current.Shops.Announcements,
TemplateConfig: current.Shops.TemplateConfig,
})
if err != nil {
return nil, err
}
updated, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
return toShopProfile(updated.Shops), nil
return
}
@@ -5,9 +5,13 @@ package shop
import (
"context"
"encoding/json"
"errors"
"juwan-backend/app/shop/api/internal/svc"
"juwan-backend/app/shop/api/internal/types"
"juwan-backend/app/shop/rpc/pb"
"juwan-backend/common/utils/contextj"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -28,7 +32,48 @@ func NewUpdateShopTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *UpdateShopTemplateLogic) UpdateShopTemplate(req *types.UpdateTemplateReq) (resp *types.EmptyResp, err error) {
// todo: add your logic here and delete this line
userID, err := contextj.UserIDFrom(l.ctx)
if err != nil {
return nil, err
}
shop, err := l.svcCtx.ShopRpc.GetShopsById(l.ctx, &pb.GetShopsByIdReq{Id: req.Id})
if err != nil {
return nil, err
}
if shop.Shops == nil {
return nil, errors.New("shop not found")
}
if shop.Shops.OwnerId != userID {
return nil, contextj.ERRILLEGALUSER
}
templateBytes, err := json.Marshal(map[string]any{"sections": req.Sections})
if err != nil {
return nil, errors.New("invalid sections")
}
_, err = l.svcCtx.ShopRpc.UpdateShops(l.ctx, &pb.UpdateShopsReq{
Id: shop.Shops.Id,
OwnerId: shop.Shops.OwnerId,
Name: shop.Shops.Name,
Banner: shop.Shops.Banner,
Description: shop.Shops.Description,
Rating: shop.Shops.Rating,
TotalOrders: shop.Shops.TotalOrders,
PlayerCount: shop.Shops.PlayerCount,
CommissionType: shop.Shops.CommissionType,
CommissionValue: shop.Shops.CommissionValue,
AllowMultiShop: shop.Shops.AllowMultiShop,
AllowIndependentOrders: shop.Shops.AllowIndependentOrders,
DispatchMode: shop.Shops.DispatchMode,
Announcements: shop.Shops.Announcements,
TemplateConfig: string(templateBytes),
})
if err != nil {
return nil, err
}
return &types.EmptyResp{}, nil
return
}
+19 -19
View File
@@ -13,10 +13,10 @@ type AnnouncementReq struct {
}
type CreateShopReq struct {
Name string `json:"name"`
Description string `json:"description"`
CommissionType string `json:"commissionType"`
CommissionValue float64 `json:"commissionValue"`
Name string `json:"name"`
Description string `json:"description"`
CommissionType string `json:"commissionType"`
CommissionValue string `json:"commissionValue"`
}
type DeleteAnnouncementReq struct {
@@ -28,11 +28,11 @@ type EmptyResp struct {
}
type IncomeStatsResp struct {
MonthlyIncome float64 `json:"monthlyIncome"`
PendingSettlement float64 `json:"pendingSettlement"`
TotalWithdrawn float64 `json:"totalWithdrawn"`
TotalOrders int64 `json:"totalOrders"`
CompletedOrders int64 `json:"completedOrders"`
MonthlyIncome string `json:"monthlyIncome"`
PendingSettlement string `json:"pendingSettlement"`
TotalWithdrawn string `json:"totalWithdrawn"`
TotalOrders int64 `json:"totalOrders"`
CompletedOrders int64 `json:"completedOrders"`
}
type InvitationReq struct {
@@ -66,11 +66,11 @@ type ShopProfile struct {
Name string `json:"name"`
Banner string `json:"banner,optional"`
Description string `json:"description"`
Rating float64 `json:"rating"`
Rating string `json:"rating"`
TotalOrders int64 `json:"totalOrders"`
PlayerCount int64 `json:"playerCount"`
CommissionType string `json:"commissionType"`
CommissionValue float64 `json:"commissionValue"`
CommissionValue string `json:"commissionValue"`
Announcements []string `json:"announcements"`
TemplateConfig interface{} `json:"templateConfig"`
}
@@ -82,14 +82,14 @@ type SimpleUser struct {
}
type UpdateShopReq struct {
Id int64 `path:"id"`
Name string `json:"name,optional"`
Description string `json:"description,optional"`
CommissionType string `json:"commissionType,optional"`
CommissionValue float64 `json:"commissionValue,optional"`
AllowMultiShop bool `json:"allowMultiShop,optional"`
AllowIndependentOrders bool `json:"allowIndependentOrders,optional"`
DispatchMode string `json:"dispatchMode,optional"`
Id int64 `path:"id"`
Name string `json:"name,optional"`
Description string `json:"description,optional"`
CommissionType string `json:"commissionType,optional"`
CommissionValue string `json:"commissionValue,optional"`
AllowMultiShop bool `json:"allowMultiShop,optional"`
AllowIndependentOrders bool `json:"allowIndependentOrders,optional"`
DispatchMode string `json:"dispatchMode,optional"`
}
type UpdateTemplateReq struct {
@@ -15,7 +15,7 @@ import (
"github.com/zeromicro/go-zero/rest"
)
var configFile = flag.String("f", "etc/juwan-api.yaml", "the config file")
var configFile = flag.String("f", "etc/shop-api.yaml", "the config file")
func main() {
flag.Parse()
+3 -1
View File
@@ -14,11 +14,13 @@ Prometheus:
# Target: k8s://juwan/<service name>.<namespace>:8080
SnowflakeRpcConf:
Target: k8s://juwan/snowflake-svc:8080
DB:
Master: "postgresql://${PD_USERNAME}:${DB_PASSWORD}@user-db-rw.juwan:${DB_PORT}/${DB_NAME}?sslmode=disable"
Slave: "postgresql://${PD_USERNAME}:${DB_PASSWORD}@user-db-ro.juwan:${DB_PORT}/${DB_NAME}?sslmode=disable"
Slaves: "postgresql://${PD_USERNAME}:${DB_PASSWORD}@user-db-ro.juwan:${DB_PORT}/${DB_NAME}?sslmode=disable"
CacheConf:
+11 -2
View File
@@ -42,17 +42,26 @@ func (l *AddShopsLogic) AddShops(in *pb.AddShopsReq) (*pb.AddShopsResp, error) {
return nil, errors.New("invalid template config")
}
rating, err := decimal.NewFromString(in.Rating)
if err != nil {
return nil, errors.New("invalid rating")
}
commissionValue, err := decimal.NewFromString(in.CommissionValue)
if err != nil {
return nil, errors.New("invalid commissionValue")
}
_, err = l.svcCtx.ShopModelRO.Shops.Create().
SetID(idResp.Id).
SetOwnerID(in.OwnerId).
SetName(in.Name).
SetBanner(in.Banner).
SetDescription(in.Description).
SetRating(decimal.NewFromFloat(in.Rating)).
SetRating(rating).
SetTotalOrders(int(in.TotalOrders)).
SetPlayerCount(int(in.PlayerCount)).
SetNillableCommissionType(&in.CommissionType).
SetCommissionValue(decimal.NewFromFloat(in.CommissionValue)).
SetCommissionValue(commissionValue).
SetAllowMultiShop(in.AllowMultiShop).
SetAllowIndependentOrders(in.AllowIndependentOrders).
SetDispatchMode(in.DispatchMode).
@@ -43,11 +43,11 @@ func (l *GetShopsByIdLogic) GetShopsById(in *pb.GetShopsByIdReq) (*pb.GetShopsBy
Id: shop.ID,
OwnerId: shop.OwnerID,
Name: shop.Name,
Rating: shop.Rating.InexactFloat64(),
Rating: shop.Rating.String(),
TotalOrders: int64(shop.TotalOrders),
PlayerCount: int64(shop.PlayerCount),
CommissionType: shop.CommissionType,
CommissionValue: shop.CommissionValue.InexactFloat64(),
CommissionValue: shop.CommissionValue.String(),
AllowMultiShop: shop.AllowMultiShop,
AllowIndependentOrders: shop.AllowIndependentOrders,
DispatchMode: shop.DispatchMode,
@@ -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
}
@@ -2,7 +2,12 @@ package logic
import (
"context"
"errors"
"juwan-backend/app/shop/rpc/internal/models/predicate"
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
"juwan-backend/app/shop/rpc/internal/svc"
"juwan-backend/app/shop/rpc/pb"
"time"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -22,5 +27,57 @@ func NewSearchShopPlayersLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *SearchShopPlayersLogic) SearchShopPlayers(in *pb.SearchShopPlayersReq) (*pb.SearchShopPlayersResp, error) {
if in.Limit <= 0 {
in.Limit = 20
}
if in.Limit > 1000 {
return nil, errors.New("limit too large")
}
preds := make([]predicate.ShopPlayers, 0, 8)
if in.ShopId > 0 {
preds = append(preds, shopplayers.ShopIDEQ(in.ShopId))
}
if in.PlayerId > 0 {
preds = append(preds, shopplayers.PlayerIDEQ(in.PlayerId))
}
if in.IsPrimary {
preds = append(preds, shopplayers.IsPrimaryEQ(true))
}
if in.JoinedAt > 0 {
preds = append(preds, shopplayers.JoinedAtGTE(time.Unix(in.JoinedAt, 0)))
}
if in.LeftAt > 0 {
preds = append(preds, shopplayers.LeftAtGTE(time.Unix(in.LeftAt, 0)))
}
query := l.svcCtx.ShopModelRO.ShopPlayers.Query()
if len(preds) > 0 {
query = query.Where(shopplayers.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 players failed, %s", err.Error())
return nil, errors.New("search shop players failed")
}
result := make([]*pb.ShopPlayers, 0, len(list))
for _, item := range list {
pbItem := &pb.ShopPlayers{
ShopId: item.ShopID,
PlayerId: item.PlayerID,
IsPrimary: item.IsPrimary,
JoinedAt: item.JoinedAt.Unix(),
}
if item.LeftAt != nil {
pbItem.LeftAt = item.LeftAt.Unix()
}
result = append(result, pbItem)
}
return &pb.SearchShopPlayersResp{ShopPlayers: result}, nil
}
@@ -2,9 +2,17 @@ package logic
import (
"context"
"errors"
"juwan-backend/app/shop/rpc/internal/models/predicate"
"juwan-backend/app/shop/rpc/internal/models/shops"
"time"
"juwan-backend/app/shop/rpc/internal/svc"
"juwan-backend/app/shop/rpc/pb"
"encoding/json"
"github.com/shopspring/decimal"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -23,5 +31,112 @@ func NewSearchShopsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Searc
}
func (l *SearchShopsLogic) SearchShops(in *pb.SearchShopsReq) (*pb.SearchShopsResp, error) {
if in.Limit <= 0 {
in.Limit = 20
}
if in.Limit > 1000 {
return nil, errors.New("limit too large")
}
preds := make([]predicate.Shops, 0, 12)
if in.Id > 0 {
preds = append(preds, shops.IDEQ(in.Id))
}
if in.OwnerId > 0 {
preds = append(preds, shops.OwnerIDEQ(in.OwnerId))
}
if in.Name != "" {
preds = append(preds, shops.NameContainsFold(in.Name))
}
if in.Description != "" {
preds = append(preds, shops.DescriptionContainsFold(in.Description))
}
if in.CommissionType != "" {
preds = append(preds, shops.CommissionTypeEQ(in.CommissionType))
}
if in.DispatchMode != "" {
preds = append(preds, shops.DispatchModeEQ(in.DispatchMode))
}
if in.Rating != "" {
rating, perr := decimal.NewFromString(in.Rating)
if perr != nil {
return nil, errors.New("invalid rating")
}
preds = append(preds, shops.RatingGTE(rating))
}
if in.CommissionValue != "" {
commissionValue, perr := decimal.NewFromString(in.CommissionValue)
if perr != nil {
return nil, errors.New("invalid commissionValue")
}
preds = append(preds, shops.CommissionValueGTE(commissionValue))
}
if in.TotalOrders > 0 {
preds = append(preds, shops.TotalOrdersGTE(int(in.TotalOrders)))
}
if in.PlayerCount > 0 {
preds = append(preds, shops.PlayerCountGTE(int(in.PlayerCount)))
}
if in.AllowMultiShop {
preds = append(preds, shops.AllowMultiShopEQ(true))
}
if in.AllowIndependentOrders {
preds = append(preds, shops.AllowIndependentOrdersEQ(true))
}
if in.CreatedAt > 0 {
preds = append(preds, shops.CreatedAtGTE(time.Unix(in.CreatedAt, 0)))
}
if in.UpdatedAt > 0 {
preds = append(preds, shops.UpdatedAtGTE(time.Unix(in.UpdatedAt, 0)))
}
query := l.svcCtx.ShopModelRO.Shops.Query()
if len(preds) > 0 {
query = query.Where(shops.And(preds...))
}
list, err := query.
Offset(int(in.Page * in.Limit)).
Limit(int(in.Limit)).
All(l.ctx)
if err != nil {
logx.Errorf("search shops failed, %s", err.Error())
return nil, errors.New("search shops failed")
}
result := make([]*pb.Shops, 0, len(list))
for _, item := range list {
templateConfigBytes, err := json.Marshal(item.TemplateConfig)
if err != nil {
logx.WithContext(l.ctx).Errorf("marshal template config failed: %v", err)
continue
}
pbItem := &pb.Shops{
Id: item.ID,
OwnerId: item.OwnerID,
Name: item.Name,
Rating: item.Rating.String(),
TotalOrders: int64(item.TotalOrders),
PlayerCount: int64(item.PlayerCount),
CommissionType: item.CommissionType,
CommissionValue: item.CommissionValue.String(),
AllowMultiShop: item.AllowMultiShop,
AllowIndependentOrders: item.AllowIndependentOrders,
DispatchMode: item.DispatchMode,
Announcements: item.Announcements,
TemplateConfig: string(templateConfigBytes),
CreatedAt: item.CreatedAt.Unix(),
UpdatedAt: item.UpdatedAt.Unix(),
}
if item.Banner != nil {
pbItem.Banner = *item.Banner
}
if item.Description != nil {
pbItem.Description = *item.Description
}
result = append(result, pbItem)
}
return &pb.SearchShopsResp{Shops: result}, nil
}
@@ -3,11 +3,11 @@ package logic
import (
"context"
"errors"
"time"
"juwan-backend/app/shop/rpc/internal/models/shopinvitations"
"juwan-backend/app/shop/rpc/internal/svc"
"juwan-backend/app/shop/rpc/pb"
"github.com/jinzhu/copier"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -26,5 +26,19 @@ func NewUpdateShopInvitationsLogic(ctx context.Context, svcCtx *svc.ServiceConte
}
func (l *UpdateShopInvitationsLogic) UpdateShopInvitations(in *pb.UpdateShopInvitationsReq) (*pb.UpdateShopInvitationsResp, error) {
update, err := l.svcCtx.ShopModelRW.ShopInvitations.UpdateOneID(in.Id).
Where(shopinvitations.PlayerIDEQ(in.PlayerId)).
SetStatus(in.Status).Save(l.ctx)
if err != nil {
logx.Errorf("failed to update shop invitation: %v", err)
return nil, errors.New("failed to update shop invitation")
}
resp := &pb.ShopInvitations{}
err = copier.Copy(resp, update)
if err != nil {
logx.Errorf("failed to copy update: %v", err)
return nil, errors.New("failed to update shop invitation")
}
return &pb.UpdateShopInvitationsResp{ShopInvitations: resp}, nil
}
@@ -3,7 +3,7 @@ package logic
import (
"context"
"errors"
"juwan-backend/app/shop/rpc/internal/models"
"juwan-backend/app/shop/rpc/internal/models/predicate"
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
"time"
@@ -28,5 +28,32 @@ func NewUpdateShopPlayersLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *UpdateShopPlayersLogic) UpdateShopPlayers(in *pb.UpdateShopPlayersReq) (*pb.UpdateShopPlayersResp, error) {
if in.ShopId <= 0 || in.PlayerId <= 0 {
return nil, errors.New("invalid shop_id or player_id")
}
preds := []predicate.ShopPlayers{
shopplayers.ShopIDEQ(in.ShopId),
shopplayers.PlayerIDEQ(in.PlayerId),
}
updater := l.svcCtx.ShopModelRW.ShopPlayers.Update().
Where(shopplayers.And(preds...)).
SetIsPrimary(in.IsPrimary)
if in.LeftAt > 0 {
t := time.Unix(in.LeftAt, 0)
updater = updater.SetLeftAt(t)
}
affected, err := updater.Save(l.ctx)
if err != nil {
logx.Errorf("update shop players failed, %s", err.Error())
return nil, errors.New("update shop players failed")
}
if affected == 0 {
return nil, errors.New("shop player not found")
}
return &pb.UpdateShopPlayersResp{}, nil
}
@@ -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
}
+17 -2
View File
@@ -1,16 +1,19 @@
package svc
import (
"fmt"
"juwan-backend/app/shop/rpc/internal/config"
"juwan-backend/app/shop/rpc/internal/models"
"juwan-backend/app/snowflake/rpc/snowflake"
"juwan-backend/common/redisx"
"juwan-backend/common/snowflakex"
"juwan-backend/pkg/adapter"
"strings"
"time"
"ariga.io/entcache"
"entgo.io/ent/dialect/sql"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/zeromicro/go-zero/core/logx"
)
@@ -40,10 +43,22 @@ func NewServiceContext(c config.Config) *ServiceContext {
RWDrv := entcache.NewDriver(RWConn, entcache.TTL(30*time.Second), entcache.Levels(adapter.NewRedisCache(redisCluster.Client)))
RODrv := entcache.NewDriver(ROConn, entcache.TTL(30*time.Second), entcache.Levels(adapter.NewRedisCache(redisCluster.Client)))
entLogFn := func(v ...any) {
logx.Infof("[ent][shop] %s", fmt.Sprint(v...))
}
rwModelOpts := []models.Option{models.Driver(RWDrv), models.Log(entLogFn)}
roModelOpts := []models.Option{models.Driver(RODrv), models.Log(entLogFn)}
if strings.EqualFold(c.Log.Level, "debug") {
rwModelOpts = append(rwModelOpts, models.Debug())
roModelOpts = append(roModelOpts, models.Debug())
}
return &ServiceContext{
Config: c,
Snowflake: snowflakex.NewClient(c.SnowflakeRpcConf),
ShopModelRO: models.NewClient(models.Driver(RODrv)),
ShopModelRW: models.NewClient(models.Driver(RWDrv)),
ShopModelRO: models.NewClient(roModelOpts...),
ShopModelRW: models.NewClient(rwModelOpts...),
}
}
+1 -1
View File
@@ -22,7 +22,7 @@ func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
conf.MustLoad(*configFile, &c, conf.UseEnv())
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
+88 -78
View File
@@ -327,9 +327,10 @@ func (x *UpdateShopInvitationsReq) GetRespondedAt() int64 {
}
type UpdateShopInvitationsResp struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
state protoimpl.MessageState `protogen:"open.v1"`
ShopInvitations *ShopInvitations `protobuf:"bytes,1,opt,name=shopInvitations,proto3" json:"shopInvitations,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *UpdateShopInvitationsResp) Reset() {
@@ -362,6 +363,13 @@ func (*UpdateShopInvitationsResp) Descriptor() ([]byte, []int) {
return file_shop_proto_rawDescGZIP(), []int{4}
}
func (x *UpdateShopInvitationsResp) GetShopInvitations() *ShopInvitations {
if x != nil {
return x.ShopInvitations
}
return nil
}
type DelShopInvitationsReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` //id
@@ -1295,11 +1303,11 @@ type Shops struct {
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` //name
Banner string `protobuf:"bytes,4,opt,name=banner,proto3" json:"banner,omitempty"` //banner
Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` //description
Rating float64 `protobuf:"fixed64,6,opt,name=rating,proto3" json:"rating,omitempty"` //rating
Rating string `protobuf:"bytes,6,opt,name=rating,proto3" json:"rating,omitempty"` //rating
TotalOrders int64 `protobuf:"varint,7,opt,name=totalOrders,proto3" json:"totalOrders,omitempty"` //totalOrders
PlayerCount int64 `protobuf:"varint,8,opt,name=playerCount,proto3" json:"playerCount,omitempty"` //playerCount
CommissionType string `protobuf:"bytes,9,opt,name=commissionType,proto3" json:"commissionType,omitempty"` //commissionType
CommissionValue float64 `protobuf:"fixed64,10,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
CommissionValue string `protobuf:"bytes,10,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
AllowMultiShop bool `protobuf:"varint,11,opt,name=allowMultiShop,proto3" json:"allowMultiShop,omitempty"` //allowMultiShop
AllowIndependentOrders bool `protobuf:"varint,12,opt,name=allowIndependentOrders,proto3" json:"allowIndependentOrders,omitempty"` //allowIndependentOrders
DispatchMode string `protobuf:"bytes,13,opt,name=dispatchMode,proto3" json:"dispatchMode,omitempty"` //dispatchMode
@@ -1376,11 +1384,11 @@ func (x *Shops) GetDescription() string {
return ""
}
func (x *Shops) GetRating() float64 {
func (x *Shops) GetRating() string {
if x != nil {
return x.Rating
}
return 0
return ""
}
func (x *Shops) GetTotalOrders() int64 {
@@ -1404,11 +1412,11 @@ func (x *Shops) GetCommissionType() string {
return ""
}
func (x *Shops) GetCommissionValue() float64 {
func (x *Shops) GetCommissionValue() string {
if x != nil {
return x.CommissionValue
}
return 0
return ""
}
func (x *Shops) GetAllowMultiShop() bool {
@@ -1466,11 +1474,11 @@ type AddShopsReq struct {
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` //name
Banner string `protobuf:"bytes,3,opt,name=banner,proto3" json:"banner,omitempty"` //banner
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` //description
Rating float64 `protobuf:"fixed64,5,opt,name=rating,proto3" json:"rating,omitempty"` //rating
Rating string `protobuf:"bytes,5,opt,name=rating,proto3" json:"rating,omitempty"` //rating
TotalOrders int64 `protobuf:"varint,6,opt,name=totalOrders,proto3" json:"totalOrders,omitempty"` //totalOrders
PlayerCount int64 `protobuf:"varint,7,opt,name=playerCount,proto3" json:"playerCount,omitempty"` //playerCount
CommissionType string `protobuf:"bytes,8,opt,name=commissionType,proto3" json:"commissionType,omitempty"` //commissionType
CommissionValue float64 `protobuf:"fixed64,9,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
CommissionValue string `protobuf:"bytes,9,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
AllowMultiShop bool `protobuf:"varint,10,opt,name=allowMultiShop,proto3" json:"allowMultiShop,omitempty"` //allowMultiShop
AllowIndependentOrders bool `protobuf:"varint,11,opt,name=allowIndependentOrders,proto3" json:"allowIndependentOrders,omitempty"` //allowIndependentOrders
DispatchMode string `protobuf:"bytes,12,opt,name=dispatchMode,proto3" json:"dispatchMode,omitempty"` //dispatchMode
@@ -1540,11 +1548,11 @@ func (x *AddShopsReq) GetDescription() string {
return ""
}
func (x *AddShopsReq) GetRating() float64 {
func (x *AddShopsReq) GetRating() string {
if x != nil {
return x.Rating
}
return 0
return ""
}
func (x *AddShopsReq) GetTotalOrders() int64 {
@@ -1568,11 +1576,11 @@ func (x *AddShopsReq) GetCommissionType() string {
return ""
}
func (x *AddShopsReq) GetCommissionValue() float64 {
func (x *AddShopsReq) GetCommissionValue() string {
if x != nil {
return x.CommissionValue
}
return 0
return ""
}
func (x *AddShopsReq) GetAllowMultiShop() bool {
@@ -1667,11 +1675,11 @@ type UpdateShopsReq struct {
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` //name
Banner string `protobuf:"bytes,4,opt,name=banner,proto3" json:"banner,omitempty"` //banner
Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"` //description
Rating float64 `protobuf:"fixed64,6,opt,name=rating,proto3" json:"rating,omitempty"` //rating
Rating string `protobuf:"bytes,6,opt,name=rating,proto3" json:"rating,omitempty"` //rating
TotalOrders int64 `protobuf:"varint,7,opt,name=totalOrders,proto3" json:"totalOrders,omitempty"` //totalOrders
PlayerCount int64 `protobuf:"varint,8,opt,name=playerCount,proto3" json:"playerCount,omitempty"` //playerCount
CommissionType string `protobuf:"bytes,9,opt,name=commissionType,proto3" json:"commissionType,omitempty"` //commissionType
CommissionValue float64 `protobuf:"fixed64,10,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
CommissionValue string `protobuf:"bytes,10,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
AllowMultiShop bool `protobuf:"varint,11,opt,name=allowMultiShop,proto3" json:"allowMultiShop,omitempty"` //allowMultiShop
AllowIndependentOrders bool `protobuf:"varint,12,opt,name=allowIndependentOrders,proto3" json:"allowIndependentOrders,omitempty"` //allowIndependentOrders
DispatchMode string `protobuf:"bytes,13,opt,name=dispatchMode,proto3" json:"dispatchMode,omitempty"` //dispatchMode
@@ -1748,11 +1756,11 @@ func (x *UpdateShopsReq) GetDescription() string {
return ""
}
func (x *UpdateShopsReq) GetRating() float64 {
func (x *UpdateShopsReq) GetRating() string {
if x != nil {
return x.Rating
}
return 0
return ""
}
func (x *UpdateShopsReq) GetTotalOrders() int64 {
@@ -1776,11 +1784,11 @@ func (x *UpdateShopsReq) GetCommissionType() string {
return ""
}
func (x *UpdateShopsReq) GetCommissionValue() float64 {
func (x *UpdateShopsReq) GetCommissionValue() string {
if x != nil {
return x.CommissionValue
}
return 0
return ""
}
func (x *UpdateShopsReq) GetAllowMultiShop() bool {
@@ -2045,11 +2053,11 @@ type SearchShopsReq struct {
Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` //name
Banner string `protobuf:"bytes,6,opt,name=banner,proto3" json:"banner,omitempty"` //banner
Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` //description
Rating float64 `protobuf:"fixed64,8,opt,name=rating,proto3" json:"rating,omitempty"` //rating
Rating string `protobuf:"bytes,8,opt,name=rating,proto3" json:"rating,omitempty"` //rating
TotalOrders int64 `protobuf:"varint,9,opt,name=totalOrders,proto3" json:"totalOrders,omitempty"` //totalOrders
PlayerCount int64 `protobuf:"varint,10,opt,name=playerCount,proto3" json:"playerCount,omitempty"` //playerCount
CommissionType string `protobuf:"bytes,11,opt,name=commissionType,proto3" json:"commissionType,omitempty"` //commissionType
CommissionValue float64 `protobuf:"fixed64,12,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
CommissionValue string `protobuf:"bytes,12,opt,name=commissionValue,proto3" json:"commissionValue,omitempty"` //commissionValue
AllowMultiShop bool `protobuf:"varint,13,opt,name=allowMultiShop,proto3" json:"allowMultiShop,omitempty"` //allowMultiShop
AllowIndependentOrders bool `protobuf:"varint,14,opt,name=allowIndependentOrders,proto3" json:"allowIndependentOrders,omitempty"` //allowIndependentOrders
DispatchMode string `protobuf:"bytes,15,opt,name=dispatchMode,proto3" json:"dispatchMode,omitempty"` //dispatchMode
@@ -2140,11 +2148,11 @@ func (x *SearchShopsReq) GetDescription() string {
return ""
}
func (x *SearchShopsReq) GetRating() float64 {
func (x *SearchShopsReq) GetRating() string {
if x != nil {
return x.Rating
}
return 0
return ""
}
func (x *SearchShopsReq) GetTotalOrders() int64 {
@@ -2168,11 +2176,11 @@ func (x *SearchShopsReq) GetCommissionType() string {
return ""
}
func (x *SearchShopsReq) GetCommissionValue() float64 {
func (x *SearchShopsReq) GetCommissionValue() string {
if x != nil {
return x.CommissionValue
}
return 0
return ""
}
func (x *SearchShopsReq) GetAllowMultiShop() bool {
@@ -2297,8 +2305,9 @@ const file_shop_proto_rawDesc = "" +
"\x06status\x18\x04 \x01(\tR\x06status\x12\x1c\n" +
"\tinvitedBy\x18\x05 \x01(\x03R\tinvitedBy\x12\x1c\n" +
"\tcreatedAt\x18\x06 \x01(\x03R\tcreatedAt\x12 \n" +
"\vrespondedAt\x18\a \x01(\x03R\vrespondedAt\"\x1b\n" +
"\x19UpdateShopInvitationsResp\"'\n" +
"\vrespondedAt\x18\a \x01(\x03R\vrespondedAt\"Z\n" +
"\x19UpdateShopInvitationsResp\x12=\n" +
"\x0fshopInvitations\x18\x01 \x01(\v2\x13.pb.ShopInvitationsR\x0fshopInvitations\"'\n" +
"\x15DelShopInvitationsReq\x12\x0e\n" +
"\x02id\x18\x01 \x01(\x03R\x02id\"\x18\n" +
"\x16DelShopInvitationsResp\"+\n" +
@@ -2361,12 +2370,12 @@ const file_shop_proto_rawDesc = "" +
"\x04name\x18\x03 \x01(\tR\x04name\x12\x16\n" +
"\x06banner\x18\x04 \x01(\tR\x06banner\x12 \n" +
"\vdescription\x18\x05 \x01(\tR\vdescription\x12\x16\n" +
"\x06rating\x18\x06 \x01(\x01R\x06rating\x12 \n" +
"\x06rating\x18\x06 \x01(\tR\x06rating\x12 \n" +
"\vtotalOrders\x18\a \x01(\x03R\vtotalOrders\x12 \n" +
"\vplayerCount\x18\b \x01(\x03R\vplayerCount\x12&\n" +
"\x0ecommissionType\x18\t \x01(\tR\x0ecommissionType\x12(\n" +
"\x0fcommissionValue\x18\n" +
" \x01(\x01R\x0fcommissionValue\x12&\n" +
" \x01(\tR\x0fcommissionValue\x12&\n" +
"\x0eallowMultiShop\x18\v \x01(\bR\x0eallowMultiShop\x126\n" +
"\x16allowIndependentOrders\x18\f \x01(\bR\x16allowIndependentOrders\x12\"\n" +
"\fdispatchMode\x18\r \x01(\tR\fdispatchMode\x12$\n" +
@@ -2379,11 +2388,11 @@ const file_shop_proto_rawDesc = "" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x16\n" +
"\x06banner\x18\x03 \x01(\tR\x06banner\x12 \n" +
"\vdescription\x18\x04 \x01(\tR\vdescription\x12\x16\n" +
"\x06rating\x18\x05 \x01(\x01R\x06rating\x12 \n" +
"\x06rating\x18\x05 \x01(\tR\x06rating\x12 \n" +
"\vtotalOrders\x18\x06 \x01(\x03R\vtotalOrders\x12 \n" +
"\vplayerCount\x18\a \x01(\x03R\vplayerCount\x12&\n" +
"\x0ecommissionType\x18\b \x01(\tR\x0ecommissionType\x12(\n" +
"\x0fcommissionValue\x18\t \x01(\x01R\x0fcommissionValue\x12&\n" +
"\x0fcommissionValue\x18\t \x01(\tR\x0fcommissionValue\x12&\n" +
"\x0eallowMultiShop\x18\n" +
" \x01(\bR\x0eallowMultiShop\x126\n" +
"\x16allowIndependentOrders\x18\v \x01(\bR\x16allowIndependentOrders\x12\"\n" +
@@ -2399,12 +2408,12 @@ const file_shop_proto_rawDesc = "" +
"\x04name\x18\x03 \x01(\tR\x04name\x12\x16\n" +
"\x06banner\x18\x04 \x01(\tR\x06banner\x12 \n" +
"\vdescription\x18\x05 \x01(\tR\vdescription\x12\x16\n" +
"\x06rating\x18\x06 \x01(\x01R\x06rating\x12 \n" +
"\x06rating\x18\x06 \x01(\tR\x06rating\x12 \n" +
"\vtotalOrders\x18\a \x01(\x03R\vtotalOrders\x12 \n" +
"\vplayerCount\x18\b \x01(\x03R\vplayerCount\x12&\n" +
"\x0ecommissionType\x18\t \x01(\tR\x0ecommissionType\x12(\n" +
"\x0fcommissionValue\x18\n" +
" \x01(\x01R\x0fcommissionValue\x12&\n" +
" \x01(\tR\x0fcommissionValue\x12&\n" +
"\x0eallowMultiShop\x18\v \x01(\bR\x0eallowMultiShop\x126\n" +
"\x16allowIndependentOrders\x18\f \x01(\bR\x16allowIndependentOrders\x12\"\n" +
"\fdispatchMode\x18\r \x01(\tR\fdispatchMode\x12$\n" +
@@ -2428,12 +2437,12 @@ const file_shop_proto_rawDesc = "" +
"\x04name\x18\x05 \x01(\tR\x04name\x12\x16\n" +
"\x06banner\x18\x06 \x01(\tR\x06banner\x12 \n" +
"\vdescription\x18\a \x01(\tR\vdescription\x12\x16\n" +
"\x06rating\x18\b \x01(\x01R\x06rating\x12 \n" +
"\x06rating\x18\b \x01(\tR\x06rating\x12 \n" +
"\vtotalOrders\x18\t \x01(\x03R\vtotalOrders\x12 \n" +
"\vplayerCount\x18\n" +
" \x01(\x03R\vplayerCount\x12&\n" +
"\x0ecommissionType\x18\v \x01(\tR\x0ecommissionType\x12(\n" +
"\x0fcommissionValue\x18\f \x01(\x01R\x0fcommissionValue\x12&\n" +
"\x0fcommissionValue\x18\f \x01(\tR\x0fcommissionValue\x12&\n" +
"\x0eallowMultiShop\x18\r \x01(\bR\x0eallowMultiShop\x126\n" +
"\x16allowIndependentOrders\x18\x0e \x01(\bR\x16allowIndependentOrders\x12\"\n" +
"\fdispatchMode\x18\x0f \x01(\tR\fdispatchMode\x12$\n" +
@@ -2509,47 +2518,48 @@ var file_shop_proto_goTypes = []any{
(*SearchShopsResp)(nil), // 32: pb.SearchShopsResp
}
var file_shop_proto_depIdxs = []int32{
0, // 0: pb.GetShopInvitationsByIdResp.shopInvitations:type_name -> pb.ShopInvitations
0, // 1: pb.SearchShopInvitationsResp.shopInvitations:type_name -> pb.ShopInvitations
11, // 2: pb.GetShopPlayersByIdResp.shopPlayers:type_name -> pb.ShopPlayers
11, // 3: pb.SearchShopPlayersResp.shopPlayers:type_name -> pb.ShopPlayers
22, // 4: pb.GetShopsByIdResp.shops:type_name -> pb.Shops
22, // 5: pb.SearchShopsResp.shops:type_name -> pb.Shops
1, // 6: pb.shopService.AddShopInvitations:input_type -> pb.AddShopInvitationsReq
3, // 7: pb.shopService.UpdateShopInvitations:input_type -> pb.UpdateShopInvitationsReq
5, // 8: pb.shopService.DelShopInvitations:input_type -> pb.DelShopInvitationsReq
7, // 9: pb.shopService.GetShopInvitationsById:input_type -> pb.GetShopInvitationsByIdReq
9, // 10: pb.shopService.SearchShopInvitations:input_type -> pb.SearchShopInvitationsReq
12, // 11: pb.shopService.AddShopPlayers:input_type -> pb.AddShopPlayersReq
14, // 12: pb.shopService.UpdateShopPlayers:input_type -> pb.UpdateShopPlayersReq
16, // 13: pb.shopService.DelShopPlayers:input_type -> pb.DelShopPlayersReq
18, // 14: pb.shopService.GetShopPlayersById:input_type -> pb.GetShopPlayersByIdReq
20, // 15: pb.shopService.SearchShopPlayers:input_type -> pb.SearchShopPlayersReq
23, // 16: pb.shopService.AddShops:input_type -> pb.AddShopsReq
25, // 17: pb.shopService.UpdateShops:input_type -> pb.UpdateShopsReq
27, // 18: pb.shopService.DelShops:input_type -> pb.DelShopsReq
29, // 19: pb.shopService.GetShopsById:input_type -> pb.GetShopsByIdReq
31, // 20: pb.shopService.SearchShops:input_type -> pb.SearchShopsReq
2, // 21: pb.shopService.AddShopInvitations:output_type -> pb.AddShopInvitationsResp
4, // 22: pb.shopService.UpdateShopInvitations:output_type -> pb.UpdateShopInvitationsResp
6, // 23: pb.shopService.DelShopInvitations:output_type -> pb.DelShopInvitationsResp
8, // 24: pb.shopService.GetShopInvitationsById:output_type -> pb.GetShopInvitationsByIdResp
10, // 25: pb.shopService.SearchShopInvitations:output_type -> pb.SearchShopInvitationsResp
13, // 26: pb.shopService.AddShopPlayers:output_type -> pb.AddShopPlayersResp
15, // 27: pb.shopService.UpdateShopPlayers:output_type -> pb.UpdateShopPlayersResp
17, // 28: pb.shopService.DelShopPlayers:output_type -> pb.DelShopPlayersResp
19, // 29: pb.shopService.GetShopPlayersById:output_type -> pb.GetShopPlayersByIdResp
21, // 30: pb.shopService.SearchShopPlayers:output_type -> pb.SearchShopPlayersResp
24, // 31: pb.shopService.AddShops:output_type -> pb.AddShopsResp
26, // 32: pb.shopService.UpdateShops:output_type -> pb.UpdateShopsResp
28, // 33: pb.shopService.DelShops:output_type -> pb.DelShopsResp
30, // 34: pb.shopService.GetShopsById:output_type -> pb.GetShopsByIdResp
32, // 35: pb.shopService.SearchShops:output_type -> pb.SearchShopsResp
21, // [21:36] is the sub-list for method output_type
6, // [6:21] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
0, // 0: pb.UpdateShopInvitationsResp.shopInvitations:type_name -> pb.ShopInvitations
0, // 1: pb.GetShopInvitationsByIdResp.shopInvitations:type_name -> pb.ShopInvitations
0, // 2: pb.SearchShopInvitationsResp.shopInvitations:type_name -> pb.ShopInvitations
11, // 3: pb.GetShopPlayersByIdResp.shopPlayers:type_name -> pb.ShopPlayers
11, // 4: pb.SearchShopPlayersResp.shopPlayers:type_name -> pb.ShopPlayers
22, // 5: pb.GetShopsByIdResp.shops:type_name -> pb.Shops
22, // 6: pb.SearchShopsResp.shops:type_name -> pb.Shops
1, // 7: pb.shopService.AddShopInvitations:input_type -> pb.AddShopInvitationsReq
3, // 8: pb.shopService.UpdateShopInvitations:input_type -> pb.UpdateShopInvitationsReq
5, // 9: pb.shopService.DelShopInvitations:input_type -> pb.DelShopInvitationsReq
7, // 10: pb.shopService.GetShopInvitationsById:input_type -> pb.GetShopInvitationsByIdReq
9, // 11: pb.shopService.SearchShopInvitations:input_type -> pb.SearchShopInvitationsReq
12, // 12: pb.shopService.AddShopPlayers:input_type -> pb.AddShopPlayersReq
14, // 13: pb.shopService.UpdateShopPlayers:input_type -> pb.UpdateShopPlayersReq
16, // 14: pb.shopService.DelShopPlayers:input_type -> pb.DelShopPlayersReq
18, // 15: pb.shopService.GetShopPlayersById:input_type -> pb.GetShopPlayersByIdReq
20, // 16: pb.shopService.SearchShopPlayers:input_type -> pb.SearchShopPlayersReq
23, // 17: pb.shopService.AddShops:input_type -> pb.AddShopsReq
25, // 18: pb.shopService.UpdateShops:input_type -> pb.UpdateShopsReq
27, // 19: pb.shopService.DelShops:input_type -> pb.DelShopsReq
29, // 20: pb.shopService.GetShopsById:input_type -> pb.GetShopsByIdReq
31, // 21: pb.shopService.SearchShops:input_type -> pb.SearchShopsReq
2, // 22: pb.shopService.AddShopInvitations:output_type -> pb.AddShopInvitationsResp
4, // 23: pb.shopService.UpdateShopInvitations:output_type -> pb.UpdateShopInvitationsResp
6, // 24: pb.shopService.DelShopInvitations:output_type -> pb.DelShopInvitationsResp
8, // 25: pb.shopService.GetShopInvitationsById:output_type -> pb.GetShopInvitationsByIdResp
10, // 26: pb.shopService.SearchShopInvitations:output_type -> pb.SearchShopInvitationsResp
13, // 27: pb.shopService.AddShopPlayers:output_type -> pb.AddShopPlayersResp
15, // 28: pb.shopService.UpdateShopPlayers:output_type -> pb.UpdateShopPlayersResp
17, // 29: pb.shopService.DelShopPlayers:output_type -> pb.DelShopPlayersResp
19, // 30: pb.shopService.GetShopPlayersById:output_type -> pb.GetShopPlayersByIdResp
21, // 31: pb.shopService.SearchShopPlayers:output_type -> pb.SearchShopPlayersResp
24, // 32: pb.shopService.AddShops:output_type -> pb.AddShopsResp
26, // 33: pb.shopService.UpdateShops:output_type -> pb.UpdateShopsResp
28, // 34: pb.shopService.DelShops:output_type -> pb.DelShopsResp
30, // 35: pb.shopService.GetShopsById:output_type -> pb.GetShopsByIdResp
32, // 36: pb.shopService.SearchShops:output_type -> pb.SearchShopsResp
22, // [22:37] is the sub-list for method output_type
7, // [7:22] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_shop_proto_init() }