mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2026-01-21 01:01:05 -05:00
Normalize platform names to remove hyphens across import and API layers
Changes all platform references from hyphenated format (AR-15, AR-10, AR-9, AK-47) to non-hyphenated format (AR15, AR10, AR9, AK47) for consistency across: - Import logic (MerchantFeedImportServiceImpl): Updated inferPlatform() method and default fallbacks - API endpoints (ProductController, BuilderBootstrapController): Updated default parameter values - Platform normalization: Updated BuilderBootstrapController.normalizePlatform() to strip hyphens instead of adding them This ensures platform keys are consistent throughout the system and match the canonical format expected by the catalog and builder components. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ public class BuilderBootstrapController {
|
||||
*/
|
||||
@GetMapping("/bootstrap")
|
||||
public BuilderBootstrapDto bootstrap(
|
||||
@RequestParam(defaultValue = "AR-15") String platform
|
||||
@RequestParam(defaultValue = "AR15") String platform
|
||||
) {
|
||||
final String platformNorm = normalizePlatform(platform);
|
||||
|
||||
@@ -86,11 +86,11 @@ public class BuilderBootstrapController {
|
||||
}
|
||||
|
||||
private String normalizePlatform(String platform) {
|
||||
if (platform == null) return "AR-15";
|
||||
if (platform == null) return "AR15";
|
||||
String p = platform.trim();
|
||||
if (p.isEmpty()) return "AR-15";
|
||||
// normalize to AR-15 / AR-10 style
|
||||
return p.toUpperCase(Locale.ROOT).replace('_', '-');
|
||||
if (p.isEmpty()) return "AR15";
|
||||
// normalize to AR15 / AR10 style (uppercase, no hyphens)
|
||||
return p.toUpperCase(Locale.ROOT).replace("-", "").replace("_", "");
|
||||
}
|
||||
|
||||
public record BuilderBootstrapDto(
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ProductController {
|
||||
key = "#platform + '::' + (#partRoles == null ? 'ALL' : #partRoles) + '::' + #priceSort + '::' + #pageable.pageNumber + '::' + #pageable.pageSize"
|
||||
)
|
||||
public Page<ProductSummaryDto> getProducts(
|
||||
@RequestParam(defaultValue = "AR-15") String platform,
|
||||
@RequestParam(defaultValue = "AR15") String platform,
|
||||
@RequestParam(required = false, name = "partRoles") List<String> partRoles,
|
||||
@RequestParam(name = "priceSort", defaultValue = "price_asc") String priceSort,
|
||||
@PageableDefault(size = 50) Pageable pageable
|
||||
|
||||
@@ -254,7 +254,7 @@ public class MerchantFeedImportServiceImpl implements MerchantFeedImportService
|
||||
|
||||
String finalPlatform = resolvedPlatform != null
|
||||
? resolvedPlatform
|
||||
: (basePlatform != null ? basePlatform : "AR-15");
|
||||
: (basePlatform != null ? basePlatform : "AR15");
|
||||
|
||||
p.setPlatform(finalPlatform);
|
||||
}
|
||||
@@ -669,12 +669,12 @@ public class MerchantFeedImportServiceImpl implements MerchantFeedImportService
|
||||
coalesce(trimOrNull(row.subCategory()), "")
|
||||
).toLowerCase(Locale.ROOT);
|
||||
|
||||
if (blob.contains("ar-15") || blob.contains("ar15")) return "AR-15";
|
||||
if (blob.contains("ar-10") || blob.contains("ar10") || blob.contains("lr-308") || blob.contains("lr308")) return "AR-10";
|
||||
if (blob.contains("ar-9") || blob.contains("ar9")) return "AR-9";
|
||||
if (blob.contains("ak-47") || blob.contains("ak47") || blob.contains("ak ")) return "AK-47";
|
||||
if (blob.contains("ar-15") || blob.contains("ar15")) return "AR15";
|
||||
if (blob.contains("ar-10") || blob.contains("ar10") || blob.contains("lr-308") || blob.contains("lr308")) return "AR10";
|
||||
if (blob.contains("ar-9") || blob.contains("ar9")) return "AR9";
|
||||
if (blob.contains("ak-47") || blob.contains("ak47") || blob.contains("ak ")) return "AK47";
|
||||
|
||||
return "AR-15"; // safe default
|
||||
return "AR15"; // safe default
|
||||
}
|
||||
|
||||
public MerchantFeedImportServiceImpl(
|
||||
|
||||
Reference in New Issue
Block a user