mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-01 08:52:11 +08:00
Error modifying environment
This commit is contained in:
@ -7,6 +7,7 @@ import ai.chat2db.spi.model.KeyValue;
|
||||
import ai.chat2db.spi.model.SSHInfo;
|
||||
import ai.chat2db.spi.model.SSLInfo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@ -101,4 +102,10 @@ public class DataSourceCreateParam {
|
||||
* @see ai.chat2db.server.domain.api.enums.DataSourceKindEnum
|
||||
*/
|
||||
private String kind;
|
||||
|
||||
/**
|
||||
* 环境id
|
||||
*/
|
||||
@NotNull
|
||||
private Long environmentId;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ public interface DataSourceService {
|
||||
* @return
|
||||
* @throws ai.chat2db.server.tools.common.exception.DataNotFoundException
|
||||
*/
|
||||
DataResult<DataSource> queryExistent(@NotNull Long id);
|
||||
DataResult<DataSource> queryExistent(@NotNull Long id, DataSourceSelector selector);
|
||||
|
||||
/**
|
||||
* 克隆连接
|
||||
|
@ -45,6 +45,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -117,7 +118,7 @@ public class DataSourceServiceImpl implements DataSourceService {
|
||||
|
||||
@Override
|
||||
public DataResult<Long> updateWithPermission(DataSourceUpdateParam param) {
|
||||
DataSource dataSource = queryExistent(param.getId()).getData();
|
||||
DataSource dataSource = queryExistent(param.getId(), null).getData();
|
||||
PermissionUtils.checkOperationPermission(dataSource.getUserId());
|
||||
|
||||
DataSourceDO dataSourceDO = dataSourceConverter.param2do(param);
|
||||
@ -129,7 +130,7 @@ public class DataSourceServiceImpl implements DataSourceService {
|
||||
@Override
|
||||
public ActionResult deleteWithPermission(Long id) {
|
||||
|
||||
DataSource dataSource = queryExistent(id).getData();
|
||||
DataSource dataSource = queryExistent(id, null).getData();
|
||||
PermissionUtils.checkOperationPermission(dataSource.getUserId());
|
||||
|
||||
dataSourceMapper.deleteById(id);
|
||||
@ -143,17 +144,20 @@ public class DataSourceServiceImpl implements DataSourceService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataResult<DataSource> queryExistent(Long id) {
|
||||
public DataResult<DataSource> queryExistent(Long id, DataSourceSelector selector) {
|
||||
DataResult<DataSource> dataResult = queryById(id);
|
||||
if (dataResult.getData() == null) {
|
||||
throw new DataNotFoundException();
|
||||
}
|
||||
|
||||
fillData(Lists.newArrayList(dataResult.getData()), selector);
|
||||
|
||||
return dataResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataResult<Long> copyByIdWithPermission(Long id) {
|
||||
DataSource dataSource = queryExistent(id).getData();
|
||||
DataSource dataSource = queryExistent(id, null).getData();
|
||||
PermissionUtils.checkOperationPermission(dataSource.getUserId());
|
||||
|
||||
DataSourceDO dataSourceDO = dataSourceMapper.selectById(id);
|
||||
|
@ -184,7 +184,7 @@ public class DataSourceController {
|
||||
*/
|
||||
@GetMapping("/datasource/{id}")
|
||||
public DataResult<DataSourceVO> queryById(@PathVariable("id") Long id) {
|
||||
DataResult<DataSource> dataResult = dataSourceService.queryById(id);
|
||||
DataResult<DataSource> dataResult = dataSourceService.queryExistent(id, DATA_SOURCE_SELECTOR);
|
||||
DataSourceVO dataSourceVO = dataSourceWebConverter.dto2vo(dataResult.getData());
|
||||
if (StringUtils.isNotBlank(dataSourceVO.getUser())) {
|
||||
dataSourceVO.setAuthenticationType("1");
|
||||
|
@ -101,6 +101,11 @@ public class DataSourceVO {
|
||||
*/
|
||||
private DriverConfig driverConfig;
|
||||
|
||||
/**
|
||||
* 环境id
|
||||
*/
|
||||
private Long environmentId;
|
||||
|
||||
/**
|
||||
* 环境
|
||||
*/
|
||||
|
Reference in New Issue
Block a user