|
|
|
@ -1,17 +1,24 @@
|
|
|
|
|
package com.op.energy.base.controller;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
|
|
|
|
|
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
|
|
|
|
|
import com.op.common.core.domain.R;
|
|
|
|
|
import com.op.common.core.utils.bean.BeanUtils;
|
|
|
|
|
import com.op.common.core.utils.poi.ExcelUtil;
|
|
|
|
|
import com.op.common.core.web.controller.BaseController;
|
|
|
|
|
import com.op.common.core.web.domain.AjaxResult;
|
|
|
|
|
import com.op.common.datasource.creator.DynamicDatasourceCreator;
|
|
|
|
|
import com.op.common.log.annotation.Log;
|
|
|
|
|
import com.op.common.log.enums.BusinessType;
|
|
|
|
|
import com.op.common.security.annotation.RequiresPermissions;
|
|
|
|
|
import com.op.energy.base.domain.BaseBuildInfo;
|
|
|
|
|
import com.op.energy.base.domain.Ztree;
|
|
|
|
|
import com.op.energy.base.service.IBaseBuildInfoService;
|
|
|
|
|
import com.op.system.api.domain.DataSourcePropertyDTO;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -26,7 +33,10 @@ import java.util.List;
|
|
|
|
|
public class BaseBuildInfoController extends BaseController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IBaseBuildInfoService baseBuildInfoService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private DynamicDatasourceCreator dynamicDatasourceCreator;
|
|
|
|
|
@Resource
|
|
|
|
|
private DynamicRoutingDataSource dynamicRoutingDataSource;
|
|
|
|
|
/**
|
|
|
|
|
* 查询建筑信息管理列表
|
|
|
|
|
*/
|
|
|
|
@ -97,5 +107,19 @@ public class BaseBuildInfoController extends BaseController {
|
|
|
|
|
List<Ztree> ztrees = baseBuildInfoService.selectBaseBuildInfoTree();
|
|
|
|
|
return ztrees;
|
|
|
|
|
}
|
|
|
|
|
@PostMapping("/addDatasource")
|
|
|
|
|
public R addDatasource(@RequestBody DataSourcePropertyDTO dto){
|
|
|
|
|
DataSourceProperty dataSourceProperty = new DataSourceProperty();
|
|
|
|
|
BeanUtils.copyProperties(dto,dataSourceProperty);
|
|
|
|
|
dynamicDatasourceCreator.createDynamicDataSource(dataSourceProperty);
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/removeDatasource")
|
|
|
|
|
public R removeDatasource(@RequestBody DataSourcePropertyDTO dto){
|
|
|
|
|
DataSourceProperty dataSourceProperty = new DataSourceProperty();
|
|
|
|
|
BeanUtils.copyProperties(dto,dataSourceProperty);
|
|
|
|
|
dynamicRoutingDataSource.removeDataSource(dataSourceProperty.getPoolName());
|
|
|
|
|
return R.ok();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|