fix: 修复批量更新问题

This commit is contained in:
2025-04-16 15:05:45 +08:00
parent 62ae719a72
commit a9bdf4ce61

View File

@@ -798,7 +798,7 @@ public class BaseMapperImpl implements BaseMapper {
String key = entry.getKey(); String key = entry.getKey();
Object value = entry.getValue(); Object value = entry.getValue();
if (!key.equals(pkName) && value != null && !(value instanceof String && ((String) value).isEmpty())) { if (!key.equals(pkName) && value != null && !(value instanceof String && ((String) value).isEmpty())) {
sql.append("`").append(key).append("`").append(" = #{item").append(index).append("_").append(key).append("}, "); sql.append(key).append(" = #{item").append(index).append("_").append(key).append("}, ");
paramMap.put("item" + index + "_" + key, value); paramMap.put("item" + index + "_" + key, value);
hasSetClause = true; hasSetClause = true;
} }
@@ -810,7 +810,7 @@ public class BaseMapperImpl implements BaseMapper {
// 如果没有要更新的字段,跳过这条记录 // 如果没有要更新的字段,跳过这条记录
continue; continue;
} }
sql.append(" WHERE ").append("`").append(pkName).append("`").append(" = #{item").append(index).append("_").append(pkName).append("};"); sql.append(" WHERE ").append(pkName).append(" = #{item").append(index).append("_").append(pkName).append("};");
paramMap.put("item" + index + "_" + pkName, item.get(pkName)); paramMap.put("item" + index + "_" + pkName, item.get(pkName));
index++; index++;
} }