| | |
| | | package com.iailab.module.system.api.tenant; |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.system.api.tenant.dto.TenantDataSourceConfigRespDTO; |
| | | import com.iailab.module.system.enums.ApiConstants; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | |
| | | @Parameter(name = "id", description = "租户编号", required = true, example = "1024") |
| | | CommonResult<Boolean> validTenant(@RequestParam("id") Long id); |
| | | |
| | | @GetMapping(PREFIX + "/data-source") |
| | | @Operation(summary = "获得租户的数据源配置") |
| | | @Parameter(name = "tenantId", description = "租户编号", required = true, example = "1024") |
| | | TenantDataSourceConfigRespDTO getTenantDataSourceConfig(@RequestParam("tenantId") Long tenantId); |
| | | |
| | | } |
对比新文件 |
| | |
| | | package com.iailab.module.system.api.tenant.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 多租户的数据源配置 Response DTO |
| | | * |
| | | * @author 芋道源码 |
| | | */ |
| | | @Data |
| | | public class TenantDataSourceConfigRespDTO { |
| | | |
| | | /** |
| | | * 连接名 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 数据源连接 |
| | | */ |
| | | private String url; |
| | | /** |
| | | * 用户名 |
| | | */ |
| | | private String username; |
| | | /** |
| | | * 密码 |
| | | */ |
| | | private String password; |
| | | |
| | | } |
| | |
| | | `package_id` bigint NOT NULL COMMENT '租户套餐编号', |
| | | `expire_time` datetime NOT NULL COMMENT '过期时间', |
| | | `account_count` int NOT NULL COMMENT '账号数量', |
| | | `data_source_config_id` bigint DEFAULT NULL COMMENT '数据源配置的编号', |
| | | `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '创建者', |
| | | `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', |
| | | `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', |
| | |
| | | package com.iailab.module.system.api.tenant; |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.infra.api.db.DataSourceConfigServiceApi; |
| | | import com.iailab.module.system.api.tenant.dto.TenantDataSourceConfigRespDTO; |
| | | import com.iailab.module.system.convert.tenant.TenantConvert; |
| | | import com.iailab.module.system.dal.dataobject.tenant.TenantDO; |
| | | import com.iailab.module.system.service.tenant.TenantService; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | |
| | | @Resource |
| | | private TenantService tenantService; |
| | | |
| | | @Resource |
| | | private DataSourceConfigServiceApi dataSourceConfigServiceApi; |
| | | |
| | | @Override |
| | | public CommonResult<List<Long>> getTenantIdList() { |
| | | return success(tenantService.getTenantIdList()); |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @Override |
| | | public TenantDataSourceConfigRespDTO getTenantDataSourceConfig(Long tenantId) { |
| | | // 获得租户信息 |
| | | TenantDO tenant = tenantService.getTenant(tenantId); |
| | | if (tenant == null) { |
| | | return null; |
| | | } |
| | | // 获得租户的数据源配置 |
| | | return TenantConvert.INSTANCE.convert( |
| | | dataSourceConfigServiceApi.getDataSourceConfig(tenant.getDataSourceConfigId())); |
| | | } |
| | | } |
| | |
| | | package com.iailab.module.system.convert.tenant; |
| | | |
| | | import com.iailab.module.infra.api.db.dto.DataSourceConfigRespDTO; |
| | | import com.iailab.module.system.api.tenant.dto.TenantDataSourceConfigRespDTO; |
| | | import com.iailab.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; |
| | | import com.iailab.module.system.controller.admin.user.vo.user.UserSaveReqVO; |
| | | import org.mapstruct.Mapper; |
| | |
| | | return reqVO; |
| | | } |
| | | |
| | | TenantDataSourceConfigRespDTO convert(DataSourceConfigRespDTO bean); |
| | | |
| | | } |
| | |
| | | * 账号数量 |
| | | */ |
| | | private Integer accountCount; |
| | | /** |
| | | * 数据源配置编号 |
| | | * |
| | | * 多租户采用“分库”方案时,通过该字段配置所在数据源 |
| | | * |
| | | * 关联 DataSourceConfigDO 的 id 字段 |
| | | */ |
| | | private Long dataSourceConfigId; |
| | | |
| | | } |
| | |
| | | package com.iailab.module.system.framework.rpc.config; |
| | | |
| | | import com.iailab.module.infra.api.config.ConfigApi; |
| | | import com.iailab.module.infra.api.db.DataSourceConfigServiceApi; |
| | | import com.iailab.module.infra.api.file.FileApi; |
| | | import com.iailab.module.infra.api.websocket.WebSocketSenderApi; |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration(proxyBeanMethods = false) |
| | | @EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, ConfigApi.class}) |
| | | @EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, DataSourceConfigServiceApi.class, ConfigApi.class}) |
| | | public class RpcConfiguration { |
| | | } |