提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.api.tenant; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
c39abc
|
4 |
import com.iailab.module.infra.api.db.DataSourceConfigServiceApi; |
潘 |
5 |
import com.iailab.module.system.api.tenant.dto.TenantDataSourceConfigRespDTO; |
|
6 |
import com.iailab.module.system.convert.tenant.TenantConvert; |
|
7 |
import com.iailab.module.system.dal.dataobject.tenant.TenantDO; |
e7c126
|
8 |
import com.iailab.module.system.service.tenant.TenantService; |
H |
9 |
import org.springframework.validation.annotation.Validated; |
|
10 |
import org.springframework.web.bind.annotation.RestController; |
|
11 |
|
|
12 |
import javax.annotation.Resource; |
|
13 |
import java.util.List; |
|
14 |
|
|
15 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
16 |
|
|
17 |
@RestController // 提供 RESTful API 接口,给 Feign 调用 |
|
18 |
@Validated |
|
19 |
public class TenantApiImpl implements TenantApi { |
|
20 |
|
|
21 |
@Resource |
|
22 |
private TenantService tenantService; |
|
23 |
|
c39abc
|
24 |
@Resource |
潘 |
25 |
private DataSourceConfigServiceApi dataSourceConfigServiceApi; |
|
26 |
|
e7c126
|
27 |
@Override |
H |
28 |
public CommonResult<List<Long>> getTenantIdList() { |
|
29 |
return success(tenantService.getTenantIdList()); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public CommonResult<Boolean> validTenant(Long id) { |
|
34 |
tenantService.validTenant(id); |
|
35 |
return success(true); |
|
36 |
} |
|
37 |
|
c39abc
|
38 |
@Override |
潘 |
39 |
public TenantDataSourceConfigRespDTO getTenantDataSourceConfig(Long tenantId) { |
|
40 |
// 获得租户信息 |
|
41 |
TenantDO tenant = tenantService.getTenant(tenantId); |
|
42 |
if (tenant == null) { |
|
43 |
return null; |
|
44 |
} |
|
45 |
// 获得租户的数据源配置 |
|
46 |
return TenantConvert.INSTANCE.convert( |
|
47 |
dataSourceConfigServiceApi.getDataSourceConfig(tenant.getDataSourceConfigId())); |
|
48 |
} |
e7c126
|
49 |
} |