package com.hxzkappboot.controller;
|
import com.hxzkappboot.config.DynamicDataSourceService;
|
import com.hxzkappboot.pojo.DatabaseConfig;
|
import com.hxzkappboot.util.R;
|
import com.hxzkappboot.util.StatusCode;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.sql.SQLException;
|
|
@RestController
|
public class DatabaseConfigController {
|
|
@Autowired
|
private DynamicDataSourceService dynamicDataSourceService;
|
|
@PutMapping("/api/wx/updatedatasource")
|
public R updateDatabaseUrl(@RequestBody DatabaseConfig newConfig) throws SQLException {
|
// R response ;
|
//
|
// response = new R(StatusCode.Success);
|
// response.setData(dynamicDataSourceService.changeDatabaseUrl(newConfig.getUrl(), newConfig.getUsername(), newConfig.getPassword()));
|
return dynamicDataSourceService.changeDatabaseUrl(newConfig.getUrl(), newConfig.getUsername(), newConfig.getPassword());
|
// return "Data source URL updated successfully";
|
}
|
}
|