Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.alibaba.cloud.ai.dataagent.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import org.springframework.format.annotation.DateTimeFormat;

Expand Down Expand Up @@ -45,10 +45,10 @@ public class Datasource {

private String username;

@JsonIgnore
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password;

@JsonIgnore
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String connectionUrl;

private String status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public Datasource createDatasource(Datasource datasource) {

@Override
public Datasource updateDatasource(Integer id, Datasource datasource) {
Datasource existingDatasource = datasourceMapper.selectById(id);
if (existingDatasource == null) {
throw new RuntimeException("Datasource not found with id: " + id);
}

// Regenerate connection URL
DatasourceTypeHandler handler = datasourceTypeHandlerRegistry.getRequired(datasource.getType());
String connectionUrl = handler.resolveConnectionUrl(datasource);
Expand All @@ -124,11 +129,11 @@ public Datasource updateDatasource(Integer id, Datasource datasource) {
datasource.setId(id);

if (datasource.getPassword() == null) {
datasource.setPassword("");
datasource.setPassword(existingDatasource.getPassword());
}

if (datasource.getUsername() == null) {
datasource.setUsername("");
datasource.setUsername(existingDatasource.getUsername());
}

datasourceMapper.updateById(datasource);
Expand Down
Loading