Skip to content

Commit

Permalink
code review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
“v_kkhuang” committed Jan 6, 2025
1 parent b8f08de commit 8eef9b1
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,63 @@ public Message queryDataSource(
"Fail to query page of data source[查询数据源失败]");
}

@ApiOperation(
value = "queryDataSourceWithConnectParms",
notes = "query datasource",
response = Message.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "system", dataType = "String"),
@ApiImplicitParam(name = "name", dataType = "Long"),
@ApiImplicitParam(name = "typeId", dataType = "Long"),
@ApiImplicitParam(name = "identifies", dataType = "String"),
@ApiImplicitParam(name = "currentPage", dataType = "Integer"),
@ApiImplicitParam(name = "pageSize", dataType = "Integer")
})
@RequestMapping(value = "/info/connect-params", method = RequestMethod.GET)
public Message queryDataSourceWithConnectParms(
@RequestParam(value = "system", required = false) String createSystem,
@RequestParam(value = "name", required = false) String dataSourceName,
@RequestParam(value = "typeId", required = false) Long dataSourceTypeId,
@RequestParam(value = "identifies", required = false) String identifies,
@RequestParam(value = "currentPage", required = false) Integer currentPage,
@RequestParam(value = "pageSize", required = false) Integer pageSize,
HttpServletRequest request) {
return RestfulApiHelper.doAndResponse(
() -> {
String permissionUser = ModuleUserUtils.getOperationUser(request, "queryDataSourceWithConnectParms");

DataSourceVo dataSourceVo =
new DataSourceVo(dataSourceName, dataSourceTypeId, identifies, createSystem);
dataSourceVo.setCurrentPage(null != currentPage ? currentPage : 1);
dataSourceVo.setPageSize(null != pageSize ? pageSize : 10);

if (AuthContext.isAdministrator(permissionUser)) {
permissionUser = null;
}
dataSourceVo.setPermissionUser(permissionUser);
PageInfo<DataSource> pageInfo =
dataSourceInfoService.queryDataSourceInfoPage(dataSourceVo);
List<DataSource> queryList = pageInfo.getList();
for (DataSource dataSource : queryList) {
DataSource dataSourceConnect =
dataSourceInfoService.getDataSourceInfoForConnect(dataSource.getDataSourceName());
if (dataSourceConnect == null) {
return Message.error("No Exists The DataSource [不存在该数据源]");
}
Map<String, Object> connectParams = dataSourceConnect.getConnectParams();
List<DataSourceParamKeyDefinition> keyDefinitionList =
dataSourceRelateService.getKeyDefinitionsByType(
dataSourceConnect.getDataSourceTypeId());
if (!AESUtils.LINKIS_DATASOURCE_AES_SWITCH.getValue()) {
RestfulApiHelper.decryptPasswordKey(keyDefinitionList, connectParams);
}
dataSource.setConnectParams(connectParams);
}
return Message.ok().data("queryList", queryList).data("totalPage", pageInfo.getTotal());
},
"Fail to query page of data source[查询数据源失败]");
}

@ApiOperation(
value = "encryptDatasourcePassword",
notes = "encrypt datasource password",
Expand Down

0 comments on commit 8eef9b1

Please sign in to comment.