Merge branch 'master' of https://gitea.qinmian.online/2112A-ONE/muyu-source
commit
625e309944
|
@ -40,6 +40,19 @@ public class DataValueController {
|
||||||
return Result.success(dataValueList);
|
return Result.success(dataValueList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据基础表ID和SQL语句查询数据
|
||||||
|
*
|
||||||
|
* @param dataValueModel 基础表ID和sql语句
|
||||||
|
* @return DataValue{kltv}
|
||||||
|
*/
|
||||||
|
@PostMapping("/addTableValue")
|
||||||
|
@Operation(summary = "根据基础表ID和SQL语句新增数据", description = "根据基础表ID和SQL语句新增数据")
|
||||||
|
public Result addTableValue(@RequestBody DataValueModel dataValueModel) {
|
||||||
|
Integer i = dataValueService.addTableValue(dataValueModel);
|
||||||
|
return Result.success(i);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据基础表ID和表名查询数据
|
* 根据基础表ID和表名查询数据
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,4 +18,6 @@ public interface DataValueService extends IService<DataValue> {
|
||||||
List<DataValue> findTableValue(DataValueModel dataValueModel);
|
List<DataValue> findTableValue(DataValueModel dataValueModel);
|
||||||
|
|
||||||
List<DataValue> findTableValueByTableName(Long basicId, String tableName);
|
List<DataValue> findTableValueByTableName(Long basicId, String tableName);
|
||||||
|
|
||||||
|
Integer addTableValue(DataValueModel dataValueModel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,4 +121,20 @@ public class DataValueServiceImpl extends ServiceImpl<DataValueMapper, DataValue
|
||||||
mysqlPool.closeConn();
|
mysqlPool.closeConn();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer addTableValue(DataValueModel dataValueModel) {
|
||||||
|
MysqlQuery mysqlQuery = new MysqlQuery();
|
||||||
|
mysqlQuery.setDataSourceId(String.valueOf(dataValueModel.getBasicId()));
|
||||||
|
DataSource dataSource = dataSourceService.getById(dataValueModel.getBasicId());
|
||||||
|
MysqlPool mysqlPool = new MysqlPool(dataSource);
|
||||||
|
mysqlPool.init();
|
||||||
|
Connection conn = mysqlPool.getConn();
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = conn.prepareStatement(dataValueModel.getSql());
|
||||||
|
return preparedStatement.executeUpdate();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue