This commit is contained in:
2026-02-01 19:15:52 +08:00
parent e30e69f8b8
commit 5942de22ad
4 changed files with 30 additions and 16 deletions

View File

@@ -53,6 +53,25 @@ func ProcessQueryParams(QueryParams string, target *map[string]interface{}, key
return nil
}
// ensureQueryParamsIDCard 确保 target 中 id_card 非空,缺则用 fallbackId 填充(同一次报告多次进入分数一致)
func ensureQueryParamsIDCard(target *map[string]interface{}, fallbackId string) {
if target == nil {
return
}
if *target == nil {
*target = make(map[string]interface{})
}
v, ok := (*target)["id_card"]
if !ok {
(*target)["id_card"] = fallbackId
return
}
s, _ := v.(string)
if s == "" {
(*target)["id_card"] = fallbackId
}
}
func UpdateFeatureAndProductFeature(ctx context.Context, svcCtx *svc.ServiceContext, productID string, target *[]types.QueryItem) error {
for i := len(*target) - 1; i >= 0; i-- {
queryItem := &(*target)[i]
@@ -103,6 +122,8 @@ func BuildEncryptedQuery(ctx context.Context, svcCtx *svc.ServiceContext, queryM
if processParamsErr != nil {
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 报告参数处理失败: %v", processParamsErr)
}
// 保证 query_params 中始终有 id_card供前端评分 ±10 等逻辑使用(代理/自己查看报告等模式)
ensureQueryParamsIDCard(&query.QueryParams, "fallback_"+queryModel.Id)
processErr := ProcessQueryData(queryModel.QueryData, &query.QueryData, key)
if processErr != nil {
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 报告结果处理失败: %v", processErr)