json转换fix

This commit is contained in:
litianxiang
2026-06-01 16:54:06 +08:00
parent 7994f4f2cd
commit b01acc5f7b
2 changed files with 6 additions and 6 deletions

View File

@@ -81,13 +81,13 @@ public class ListingMallServiceImpl extends ServiceImpl<ListingMallMapper, Listi
String cat = dto.getCategories().get(i);
if (i == 0) {
wrapper.apply(
"JSON_CONTAINS(product_category, {0}, '$')",
"\"" + cat + "\""
"JSON_CONTAINS(product_category, JSON_QUOTE({0}), '$')",
cat
);
} else {
wrapper.or().apply(
"JSON_CONTAINS(product_category, {0}, '$')",
"\"" + cat + "\""
"JSON_CONTAINS(product_category, JSON_QUOTE({0}), '$')",
cat
);
}
}

View File

@@ -19,7 +19,7 @@
<if test="dto.categories != null and dto.categories.size() > 0">
AND (
<foreach collection="dto.categories" item="cat" separator=" OR ">
JSON_CONTAINS(soi.product_category, #{cat})
JSON_CONTAINS(soi.product_category, JSON_QUOTE(#{cat}))
</foreach>
)
</if>
@@ -42,7 +42,7 @@
<if test="dto.categories != null and dto.categories.size() > 0">
AND (
<foreach collection="dto.categories" item="cat" separator=" OR ">
JSON_CONTAINS(soi.product_category, #{cat})
JSON_CONTAINS(soi.product_category, JSON_QUOTE(#{cat}))
</foreach>
)
</if>