增加租户的数据源配置
This commit is contained in:
parent
1b563fecaa
commit
3efcc4bc62
|
@ -3,13 +3,14 @@ package cn.iocoder.yudao.module.infra.controller.admin.db;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCreateReqVO;
|
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigRespVO;
|
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigRespVO;
|
||||||
|
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigSimpleRespVO;
|
||||||
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
|
import cn.iocoder.yudao.module.infra.controller.admin.db.vo.DataSourceConfigUpdateReqVO;
|
||||||
import cn.iocoder.yudao.module.infra.convert.db.DataSourceConfigConvert;
|
import cn.iocoder.yudao.module.infra.convert.db.DataSourceConfigConvert;
|
||||||
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
import cn.iocoder.yudao.module.infra.dal.dataobject.db.DataSourceConfigDO;
|
||||||
import cn.iocoder.yudao.module.infra.service.db.DataSourceConfigService;
|
import cn.iocoder.yudao.module.infra.service.db.DataSourceConfigService;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -70,4 +71,11 @@ public class DataSourceConfigController {
|
||||||
return success(DataSourceConfigConvert.INSTANCE.convertList(list));
|
return success(DataSourceConfigConvert.INSTANCE.convertList(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list-all-simple")
|
||||||
|
@Operation(summary = "获取数据源配置精简信息列表", description = "主要用于前端的下拉选项")
|
||||||
|
public CommonResult<List<DataSourceConfigSimpleRespVO>> getSimpleDataSourceConfigList() {
|
||||||
|
List<DataSourceConfigDO> list = dataSourceConfigService.getDataSourceConfigList();
|
||||||
|
return success(DataSourceConfigConvert.INSTANCE.convertList02(list));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package cn.iocoder.yudao.module.infra.controller.admin.db.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 数据源配置的精简 Response VO")
|
||||||
|
@Data
|
||||||
|
public class DataSourceConfigSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键编号", required = true, example = "1024")
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@Schema(description = "数据源名称", required = true, example = "test")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
}
|
|
@ -30,4 +30,6 @@ public interface DataSourceConfigConvert {
|
||||||
|
|
||||||
DataSourceConfigRespDTO convert02(DataSourceConfigDO bean);
|
DataSourceConfigRespDTO convert02(DataSourceConfigDO bean);
|
||||||
|
|
||||||
|
List<DataSourceConfigSimpleRespVO> convertList02(List<DataSourceConfigDO> list);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class TenantApiImpl implements TenantApi {
|
||||||
}
|
}
|
||||||
// 获得租户的数据源配置
|
// 获得租户的数据源配置
|
||||||
return TenantConvert.INSTANCE.convert(
|
return TenantConvert.INSTANCE.convert(
|
||||||
dataSourceConfigServiceApi.getDataSourceConfig(tenant.getDatasourceConfigId()));
|
dataSourceConfigServiceApi.getDataSourceConfig(tenant.getDataSourceConfigId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,4 +43,8 @@ public class TenantBaseVO {
|
||||||
@NotNull(message = "账号数量不能为空")
|
@NotNull(message = "账号数量不能为空")
|
||||||
private Integer accountCount;
|
private Integer accountCount;
|
||||||
|
|
||||||
|
@Schema(description = "数据源配置编号", required = true, example = "4096")
|
||||||
|
@NotNull(message = "数据源配置编号不能为空")
|
||||||
|
private Long dataSourceConfigId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,6 @@ public class TenantDO extends BaseDO {
|
||||||
*
|
*
|
||||||
* 关联 DataSourceConfigDO 的 id 字段
|
* 关联 DataSourceConfigDO 的 id 字段
|
||||||
*/
|
*/
|
||||||
private Long datasourceConfigId;
|
private Long dataSourceConfigId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptUpdateRe
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
|
import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
|
||||||
import cn.iocoder.yudao.module.system.enums.dept.DeptIdEnum;
|
import cn.iocoder.yudao.module.system.enums.dept.DeptIdEnum;
|
||||||
import cn.iocoder.yudao.module.system.mq.producer.dept.DeptProducer;
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
|
@ -41,3 +41,11 @@ export function getDataSourceConfigList() {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取数据源配置精简信息列表
|
||||||
|
export function getSimpleDataSourceConfigList() {
|
||||||
|
return request({
|
||||||
|
url: '/infra/data-source-config/list-all-simple',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getSchemaTableList, createCodegenList } from "@/api/infra/codegen";
|
import { getSchemaTableList, createCodegenList } from "@/api/infra/codegen";
|
||||||
import {getDataSourceConfigList} from "@/api/infra/dataSourceConfig";
|
import { getSimpleDataSourceConfigList } from "@/api/infra/dataSourceConfig";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -65,7 +66,7 @@ export default {
|
||||||
show() {
|
show() {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
// 加载数据源
|
// 加载数据源
|
||||||
getDataSourceConfigList().then(response => {
|
getSimpleDataSourceConfigList().then(response => {
|
||||||
this.dataSourceConfigs = response.data;
|
this.dataSourceConfigs = response.data;
|
||||||
this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id;
|
this.queryParams.dataSourceConfigId = this.dataSourceConfigs[0].id;
|
||||||
// 加载表列表
|
// 加载表列表
|
||||||
|
|
|
@ -45,25 +45,30 @@
|
||||||
<el-table v-loading="loading" :data="list">
|
<el-table v-loading="loading" :data="list">
|
||||||
<el-table-column label="租户编号" align="center" prop="id" />
|
<el-table-column label="租户编号" align="center" prop="id" />
|
||||||
<el-table-column label="租户名" align="center" prop="name" />
|
<el-table-column label="租户名" align="center" prop="name" />
|
||||||
<el-table-column label="租户套餐" align="center" prop="packageId">
|
<el-table-column label="租户套餐" align="center" prop="packageId" width="100">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-tag v-if="scope.row.packageId === 0" type="danger">系统租户</el-tag>
|
<el-tag v-if="scope.row.packageId === 0" type="danger">系统租户</el-tag>
|
||||||
<el-tag v-else> {{getPackageName(scope.row.packageId)}} </el-tag>
|
<el-tag v-else> {{ getPackageName(scope.row.packageId )}} </el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="联系人" align="center" prop="contactName" />
|
<el-table-column label="联系人" align="center" prop="contactName" />
|
||||||
<el-table-column label="联系手机" align="center" prop="contactMobile" />
|
<el-table-column label="联系手机" align="center" prop="contactMobile" width="120" />
|
||||||
<el-table-column label="账号额度" align="center" prop="accountCount">
|
<el-table-column label="账号额度" align="center" prop="accountCount">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-tag> {{scope.row.accountCount}} </el-tag>
|
<el-tag> {{scope.row.accountCount}} </el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="过期时间" align="center" prop="expireTime" width="180">
|
<el-table-column label="过期时间" align="center" prop="expireTime" width="180" >
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<span>{{ parseTime(scope.row.expireTime) }}</span>
|
<span>{{ parseTime(scope.row.expireTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="绑定域名" align="center" prop="domain" width="180" />
|
<el-table-column label="绑定域名" align="center" prop="domain" width="180" />
|
||||||
|
<el-table-column label="数据源" align="center" prop="dataSourceConfigId" width="100" >
|
||||||
|
<template v-slot="scope">
|
||||||
|
<el-tag type="success"> {{ getDataSourceConfigName(scope.row.dataSourceConfigId )}} </el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="租户状态" align="center" prop="status">
|
<el-table-column label="租户状态" align="center" prop="status">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
|
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
|
||||||
|
@ -74,7 +79,7 @@
|
||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="110">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
||||||
v-hasPermi="['system:tenant:update']">修改</el-button>
|
v-hasPermi="['system:tenant:update']">修改</el-button>
|
||||||
|
@ -120,6 +125,12 @@
|
||||||
<el-form-item label="绑定域名" prop="domain">
|
<el-form-item label="绑定域名" prop="domain">
|
||||||
<el-input v-model="form.domain" placeholder="请输入绑定域名" />
|
<el-input v-model="form.domain" placeholder="请输入绑定域名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="数据源" prop="dataSourceConfigId">
|
||||||
|
<el-select v-model="form.dataSourceConfigId" placeholder="请选择数据源" clearable>
|
||||||
|
<el-option v-for="config in dataSourceConfigs"
|
||||||
|
:key="config.id" :label="config.name" :value="config.id"/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="租户状态" prop="status">
|
<el-form-item label="租户状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
|
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
|
||||||
|
@ -139,6 +150,7 @@
|
||||||
import { createTenant, updateTenant, deleteTenant, getTenant, getTenantPage, exportTenantExcel } from "@/api/system/tenant";
|
import { createTenant, updateTenant, deleteTenant, getTenant, getTenantPage, exportTenantExcel } from "@/api/system/tenant";
|
||||||
import { CommonStatusEnum } from '@/utils/constants'
|
import { CommonStatusEnum } from '@/utils/constants'
|
||||||
import {getTenantPackageList} from "@/api/system/tenantPackage";
|
import {getTenantPackageList} from "@/api/system/tenantPackage";
|
||||||
|
import {getSimpleDataSourceConfigList} from "@/api/infra/dataSourceConfig";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Tenant",
|
name: "Tenant",
|
||||||
|
@ -183,7 +195,12 @@ export default {
|
||||||
accountCount: [{ required: true, message: "账号额度不能为空", trigger: "blur" }],
|
accountCount: [{ required: true, message: "账号额度不能为空", trigger: "blur" }],
|
||||||
expireTime: [{ required: true, message: "过期时间不能为空", trigger: "blur" }],
|
expireTime: [{ required: true, message: "过期时间不能为空", trigger: "blur" }],
|
||||||
domain: [{ required: true, message: "绑定域名不能为空", trigger: "blur" }],
|
domain: [{ required: true, message: "绑定域名不能为空", trigger: "blur" }],
|
||||||
}
|
username: [{ required: true, message: "账号不能为空", trigger: "blur" }],
|
||||||
|
password: [{ required: true, message: "密码不能为空", trigger: "blur" }],
|
||||||
|
datasourceConfigId: [{ required: true, message: "数据源不能为空", trigger: "blur" }],
|
||||||
|
},
|
||||||
|
// 数据源配置
|
||||||
|
dataSourceConfigs: [],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -192,6 +209,10 @@ export default {
|
||||||
getTenantPackageList().then(response => {
|
getTenantPackageList().then(response => {
|
||||||
this.packageList = response.data;
|
this.packageList = response.data;
|
||||||
})
|
})
|
||||||
|
// 获得数据源配置列表
|
||||||
|
getSimpleDataSourceConfigList().then(response => {
|
||||||
|
this.dataSourceConfigs = response.data;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询列表 */
|
/** 查询列表 */
|
||||||
|
@ -221,6 +242,7 @@ export default {
|
||||||
expireTime: undefined,
|
expireTime: undefined,
|
||||||
domain: undefined,
|
domain: undefined,
|
||||||
status: CommonStatusEnum.ENABLE,
|
status: CommonStatusEnum.ENABLE,
|
||||||
|
dataSourceConfigId: 0, // 默认 0 为 master 主数据源
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
|
@ -306,6 +328,15 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '未知套餐';
|
return '未知套餐';
|
||||||
|
},
|
||||||
|
/** 套餐名格式化 */
|
||||||
|
getDataSourceConfigName(dataSourceConfigId) {
|
||||||
|
for (const item of this.dataSourceConfigs) {
|
||||||
|
if (item.id === dataSourceConfigId) {
|
||||||
|
return item.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '未知数据源';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue