修复: GET /v1/admin/promo/price/list 字段不匹配导致 400
前端发 rule_id/subscribe_id (均可选), 后端 API 定义为 promo_rule_id (required), 直接返回 "PromoRuleId is a required field"。 对齐前端约定 (与 usage/list 命名一致): - API: promo_rule_id(required) → rule_id + subscribe_id, 均可选 - model.QueryPriceList: 改为接 PriceFilter, 按条件过滤 - 同步 fake mock 与校验测试签名
This commit is contained in:
@@ -54,7 +54,7 @@ func (fakePromoModel) DeletePrice(context.Context, int64) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakePromoModel) QueryPriceList(context.Context, int64, int, int) (int64, []*promomodel.SubscribePromo, error) {
|
||||
func (fakePromoModel) QueryPriceList(context.Context, promomodel.PriceFilter) (int64, []*promomodel.SubscribePromo, error) {
|
||||
return 0, nil, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package promo
|
||||
import (
|
||||
"context"
|
||||
|
||||
promomodel "github.com/perfect-panel/server/internal/model/promo"
|
||||
"github.com/perfect-panel/server/internal/svc"
|
||||
"github.com/perfect-panel/server/internal/types"
|
||||
"github.com/perfect-panel/server/pkg/logger"
|
||||
@@ -25,7 +26,12 @@ func NewGetPriceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetP
|
||||
}
|
||||
|
||||
func (l *GetPriceListLogic) GetPriceList(req *types.GetPromoPriceListRequest) (*types.GetPromoPriceListResponse, error) {
|
||||
total, list, err := l.svcCtx.PromoModel.QueryPriceList(l.ctx, req.PromoRuleId, int(req.Page), int(req.Size))
|
||||
total, list, err := l.svcCtx.PromoModel.QueryPriceList(l.ctx, promomodel.PriceFilter{
|
||||
Page: int(req.Page),
|
||||
Size: int(req.Size),
|
||||
RuleId: req.RuleId,
|
||||
SubscribeId: req.SubscribeId,
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorw("[GetPromoPriceList] Database Error", logger.Field("error", err.Error()))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get promo price list error: %v", err.Error())
|
||||
|
||||
Reference in New Issue
Block a user