feat(codegen): 支持动态数据源切换功能

- 在GenTableController的export方法中添加DynamicDataSourceContextHolder支持
- 实现根据table参数动态切换数据源功能
This commit is contained in:
PIGCLOUD committed 2025-12-29 14:53:41 +08:00
1 parent 5a324b75c9
commit e959811fa2
1 file changed
+3
@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.codegen.controller;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.codegen.entity.GenTable;
@@ -179,6 +180,8 @@ public class GenTableController {
@ResponseExcel
@GetMapping("/export")
public List<GenTable> export(GenTable table) {
// 切换至对应数据源
DynamicDataSourceContextHolder.push(table.getDsName());
return tableService.list(Wrappers.query(table));
}