|
@@ -121,13 +121,13 @@ public class ModuleGenerateIntrospector {
|
|
|
params.put("insertSQL", insertSQL);
|
|
|
if (StringUtils.isNotBlank(criteria)) {
|
|
|
// 修改
|
|
|
- String updateSQL = "UPDATE " + tableName + " SET ";
|
|
|
+ String updateSQL = "UPDATE " + tableName + " <set>\n<if test=\"";
|
|
|
for (Entry<String, String> entry : fieldPropMapping.entrySet()) {
|
|
|
- updateSQL += (entry.getKey() + " = #{" + entry.getValue() + "},");
|
|
|
+ updateSQL += entry.getValue() + " != null\">\n" + (entry.getKey() + " = #{" + entry.getValue() + "},\n</if>\n<if test=\"");
|
|
|
}
|
|
|
// 删除最后一个“,”
|
|
|
- updateSQL = updateSQL.substring(0, updateSQL.length() - 1);
|
|
|
- updateSQL += (" WHERE " + criteria);
|
|
|
+ updateSQL = updateSQL.substring(0, updateSQL.length() - 10);
|
|
|
+ updateSQL += ("</set> WHERE " + criteria);
|
|
|
params.put("updateSQL", updateSQL);
|
|
|
// 根据主键查询
|
|
|
String querySingleSQL = queryBaseSQL + " WHERE " + criteria;
|