|
@@ -89,6 +89,7 @@ public class MysqlJdbcServiceImpl extends MysqlJdbcDaoImpl implements JdbcServic
|
|
if(obj == null){
|
|
if(obj == null){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ Long userId = SessionContext.getSession().getUserId();
|
|
Result<TableInfo> tableInfo = tableService.get(tableName);
|
|
Result<TableInfo> tableInfo = tableService.get(tableName);
|
|
if(!tableInfo.isSuccess()){
|
|
if(!tableInfo.isSuccess()){
|
|
throw new RuntimeException("找不到表:"+tableName);
|
|
throw new RuntimeException("找不到表:"+tableName);
|
|
@@ -100,11 +101,13 @@ public class MysqlJdbcServiceImpl extends MysqlJdbcDaoImpl implements JdbcServic
|
|
}
|
|
}
|
|
obj.computeIfAbsent("updatedAt", k -> new Date());
|
|
obj.computeIfAbsent("updatedAt", k -> new Date());
|
|
obj.computeIfAbsent("createdAt", k -> new Date());
|
|
obj.computeIfAbsent("createdAt", k -> new Date());
|
|
|
|
+ obj.computeIfAbsent("createdBy", k -> userId);
|
|
// List<String> columns = columnInfos.stream().map(columnInfo -> columnInfo.getColumnName()).collect(Collectors.toList());
|
|
// List<String> columns = columnInfos.stream().map(columnInfo -> columnInfo.getColumnName()).collect(Collectors.toList());
|
|
List<String> columns = columnInfos.stream().filter(
|
|
List<String> columns = columnInfos.stream().filter(
|
|
columnInfo -> obj.containsKey(StringUtil.toFieldColumn(columnInfo.getColumnName()))
|
|
columnInfo -> obj.containsKey(StringUtil.toFieldColumn(columnInfo.getColumnName()))
|
|
|| "updated_at".equals(columnInfo.getColumnName())
|
|
|| "updated_at".equals(columnInfo.getColumnName())
|
|
|| "created_at".equals(columnInfo.getColumnName())
|
|
|| "created_at".equals(columnInfo.getColumnName())
|
|
|
|
+ || "created_by".equals(columnInfo.getColumnName())
|
|
).map(ColumnInfo::getColumnName).collect(Collectors.toList());
|
|
).map(ColumnInfo::getColumnName).collect(Collectors.toList());
|
|
List<String> args = columns.stream().map(columnInfo -> "?").collect(Collectors.toList());
|
|
List<String> args = columns.stream().map(columnInfo -> "?").collect(Collectors.toList());
|
|
String sql = StrUtil.format("insert into {} ({}) values ({})",table.getTableName(),StringUtil.concatStr(columns,","),StringUtil.concatStr(args,","));
|
|
String sql = StrUtil.format("insert into {} ({}) values ({})",table.getTableName(),StringUtil.concatStr(columns,","),StringUtil.concatStr(args,","));
|