😎修复租户从库处理错误

This commit is contained in:
zuohuaijun 2024-09-06 17:52:22 +08:00
parent 943b776fa2
commit f7e01cf58f
3 changed files with 14 additions and 5 deletions

View File

@ -80,6 +80,7 @@ public class SysTenantService : IDynamicApiController, ITransient
DbType = u.DbType,
Connection = u.Connection,
ConfigId = u.ConfigId,
SlaveConnections = u.SlaveConnections,
OrderNo = u.OrderNo,
Remark = u.Remark,
Status = u.Status,
@ -118,7 +119,7 @@ public class SysTenantService : IDynamicApiController, ITransient
if (isExist) throw Oops.Oh(ErrorCodeEnum.D1301);
// 从库配置判断
if (!string.IsNullOrWhiteSpace(input.SlaveConnections) && !JSON.IsValid(input.SlaveConnections))
if (input.TenantType == TenantTypeEnum.Db && (string.IsNullOrWhiteSpace(input.SlaveConnections) || !JSON.IsValid(input.SlaveConnections, true)))
throw Oops.Oh(ErrorCodeEnum.D1302);
switch (input.TenantType)
@ -329,7 +330,7 @@ public class SysTenantService : IDynamicApiController, ITransient
throw Oops.Oh(ErrorCodeEnum.D3004);
}
// 从库配置判断
if (!string.IsNullOrWhiteSpace(input.SlaveConnections) && !JSON.IsValid(input.SlaveConnections))
if (input.TenantType == TenantTypeEnum.Db && (string.IsNullOrWhiteSpace(input.SlaveConnections) || !JSON.IsValid(input.SlaveConnections, true)))
throw Oops.Oh(ErrorCodeEnum.D1302);
await _sysTenantRep.AsUpdateable(input.Adapt<TenantOutput>()).IgnoreColumns(true).ExecuteCommandAsync();

View File

@ -97,9 +97,17 @@
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
<el-form-item label="从库连接串">
<template v-slot:label>
<div>
从库连接串
<el-tooltip raw-content content='格式:[{"HitRate":10, "ConnectionString":"xxx"},{"HitRate":10, "ConnectionString":"xxx"}]' placement="top">
<SvgIcon name="fa fa-question-circle-o" :size="16" style="vertical-align: middle" />
</el-tooltip>
</div>
</template>
<el-input
v-model="state.ruleForm.slaveConnections"
placeholder="格式:[{'HitRate':10, 'ConnectionString':'xxx'},{'HitRate':10, 'ConnectionString':'xxx'}]"
placeholder='格式:[{"HitRate":10, "ConnectionString":"xxx"},{"HitRate":10, "ConnectionString":"xxx"}]'
clearable
type="textarea"
:disabled="state.ruleForm.tenantType == 0 && state.ruleForm.tenantType != undefined"

View File

@ -152,10 +152,10 @@ const options = useVxeTable<TenantOutput>(
{ field: 'dbType', title: '数据库类型', minWidth: 120, showOverflow: 'tooltip', slots: { default: 'row_dbType' } },
{ field: 'configId', title: '数据库标识', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'connection', title: '数据库连接', minWidth: 300, showOverflow: 'tooltip' },
{ field: 'slaveConnections', title: '从库连接', showOverflow: 'tooltip' },
{ field: 'slaveConnections', title: '从库连接', minWidth: 300, showOverflow: 'tooltip' },
{ field: 'orderNo', title: '排序', width: 80, showOverflow: 'tooltip' },
{ field: '', title: '修改记录', width: 100, showOverflow: 'tooltip', slots: { default: 'row_record' } },
{ title: '操作', fixed: 'right', width: 430, showOverflow: true, slots: { default: 'row_buttons' } },
{ title: '操作', fixed: 'right', width: 400, showOverflow: true, slots: { default: 'row_buttons' } },
],
},
// vxeGrid()vxe-table