This commit is contained in:
2026-06-18 21:16:02 +08:00
parent 9685d34187
commit 3a5a0d0028
36 changed files with 1566 additions and 66 deletions

View File

@@ -96,6 +96,7 @@ type ApiApplicationServiceImpl struct {
subscriptionService *product_services.ProductSubscriptionService
balanceAlertService finance_services.BalanceAlertService
subordinateRepo subordinate_repositories.SubordinateRepository
queryWhitelistSvc services.QueryWhitelistService
}
func NewApiApplicationService(
@@ -116,6 +117,7 @@ func NewApiApplicationService(
exportManager *export.ExportManager,
balanceAlertService finance_services.BalanceAlertService,
subordinateRepo subordinate_repositories.SubordinateRepository,
queryWhitelistSvc services.QueryWhitelistService,
) ApiApplicationService {
service := &ApiApplicationServiceImpl{
apiCallService: apiCallService,
@@ -135,6 +137,7 @@ func NewApiApplicationService(
subscriptionService: subscriptionService,
balanceAlertService: balanceAlertService,
subordinateRepo: subordinateRepo,
queryWhitelistSvc: queryWhitelistSvc,
}
return service
@@ -367,6 +370,12 @@ func extractParentAccessID(params map[string]interface{}) (string, bool) {
// callExternalApi 同步调用外部API
func (s *ApiApplicationServiceImpl) callExternalApi(ctx context.Context, cmd *commands.ApiCallCommand, validation *dto.ApiCallValidationResult) (string, error) {
// 查询白名单拦截:命中则返回「查询为空」,不调用上游、不扣费
if s.queryWhitelistSvc != nil &&
s.queryWhitelistSvc.ShouldReturnEmpty(ctx, validation.GetUserID(), cmd.ApiName, validation.RequestParams) {
return "", ErrQueryEmpty
}
// 创建CallContext
callContext := &processors.CallContext{
ContractCode: validation.ContractCode,