fei.wang
2025-04-18 321a74059773cfecc01d6313f7c2e2d45545d6d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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";
    }
}