Browse Source

feat: 租户连接字符串添加删除功能

pull/131/head
WangJunZzz 2 years ago
parent
commit
0050cccfc8
  1. 5
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Tenants/Dtos/DeleteConnectionStringInput.cs
  2. 11
      aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Tenants/VoloTenantAppService.cs
  3. 10
      vben28/src/services/ServiceProxies.ts
  4. 46
      vben28/src/views/tenants/EditConnectionString.vue
  5. 11
      vben28/src/views/tenants/Tenant.ts

5
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application.Contracts/Tenants/Dtos/DeleteConnectionStringInput.cs

@ -6,4 +6,9 @@ public class DeleteConnectionStringInput
/// 连接字符串名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 租户id
/// </summary>
public Guid TenantId { get; set; }
}

11
aspnet-core/modules/BasicManagement/src/Lion.AbpPro.BasicManagement.Application/Tenants/VoloTenantAppService.cs

@ -122,18 +122,15 @@ namespace Lion.AbpPro.BasicManagement.Tenants
public async Task DeleteConnectionStringAsync(DeleteConnectionStringInput input)
{
if (!CurrentTenant.Id.HasValue)
{
throw new BusinessException(BasicManagementErrorCodes.TenantNotExist);
}
var tenant = await _tenantRepository.FindAsync(CurrentTenant.Id.Value, true);
var tenant = await _tenantRepository.FindAsync(input.TenantId, true);
if (tenant == null)
{
throw new BusinessException(BasicManagementErrorCodes.TenantNotExist);
}
var connectionString = tenant.ConnectionStrings.FirstOrDefault(e => e.Value == input.Name);
var connectionString = tenant.ConnectionStrings.FirstOrDefault(e => e.Name == input.Name);
if (connectionString != null)
{
tenant.RemoveConnectionString(input.Name);

10
vben28/src/services/ServiceProxies.ts

@ -9299,6 +9299,8 @@ export interface IDateTimeFormatDto {
export class DeleteConnectionStringInput implements IDeleteConnectionStringInput {
/** 连接字符串名称 */
name!: string | undefined;
/** 租户id */
tenantId!: string;
constructor(data?: IDeleteConnectionStringInput) {
if (data) {
@ -9312,6 +9314,7 @@ export class DeleteConnectionStringInput implements IDeleteConnectionStringInput
init(_data?: any) {
if (_data) {
this.name = _data["name"];
this.tenantId = _data["tenantId"];
}
}
@ -9325,6 +9328,7 @@ export class DeleteConnectionStringInput implements IDeleteConnectionStringInput
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["name"] = this.name;
data["tenantId"] = this.tenantId;
return data;
}
}
@ -9332,6 +9336,8 @@ export class DeleteConnectionStringInput implements IDeleteConnectionStringInput
export interface IDeleteConnectionStringInput {
/** 连接字符串名称 */
name: string | undefined;
/** 租户id */
tenantId: string;
}
export class DeleteDataDictionaryDetailInput implements IDeleteDataDictionaryDetailInput {
@ -11304,6 +11310,7 @@ export class FindTenantResultDto implements IFindTenantResultDto {
success!: boolean;
tenantId!: string | undefined;
name!: string | undefined;
normalizedName!: string | undefined;
isActive!: boolean;
constructor(data?: IFindTenantResultDto) {
@ -11320,6 +11327,7 @@ export class FindTenantResultDto implements IFindTenantResultDto {
this.success = _data["success"];
this.tenantId = _data["tenantId"];
this.name = _data["name"];
this.normalizedName = _data["normalizedName"];
this.isActive = _data["isActive"];
}
}
@ -11336,6 +11344,7 @@ export class FindTenantResultDto implements IFindTenantResultDto {
data["success"] = this.success;
data["tenantId"] = this.tenantId;
data["name"] = this.name;
data["normalizedName"] = this.normalizedName;
data["isActive"] = this.isActive;
return data;
}
@ -11345,6 +11354,7 @@ export interface IFindTenantResultDto {
success: boolean;
tenantId: string | undefined;
name: string | undefined;
normalizedName: string | undefined;
isActive: boolean;
}

46
vben28/src/views/tenants/EditConnectionString.vue

@ -9,6 +9,18 @@
{{ t('common.createOrUpdateText') }}
</a-button>
</template>
<template #action="{ record }">
<TableAction :actions="[
{
icon: 'ant-design:minus-outlined',
auth: 'AbpTenantManagement.Tenants.Delete',
label: t('common.delText'),
onClick: handleDelete.bind(null, record),
},
]" />
</template>
</BasicTable>
<CreateConnectionString @register="registerCreateConnectionStringModal" @reload="reload"
@ -19,11 +31,12 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { updateConnectionStringFormSchema, editConnectionStringtableColumns, pageConnectionStringAsync } from '/@/views/tenants/Tenant';
import { updateConnectionStringFormSchema, editConnectionStringtableColumns, pageConnectionStringAsync, deleteConnectionString } from '/@/views/tenants/Tenant';
import { useI18n } from '/@/hooks/web/useI18n';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import CreateConnectionString from './CreateConnectionString.vue';
import { useModal } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
export default defineComponent({
name: 'EditTenant',
components: {
@ -46,7 +59,16 @@ export default defineComponent({
showTableSetting: true,
bordered: true,
canResize: true,
showIndexColumn: true
showIndexColumn: true,
actionColumn: {
title: t('common.action'),
dataIndex: 'action',
slots: {
customRender: 'action',
},
width: 350,
fixed: 'right',
},
});
@ -68,6 +90,23 @@ export default defineComponent({
const submit = async () => {
closeModal();
};
const { createConfirm } = useMessage();
//
const handleDelete = async (record: Recordable) => {
console.log(record);
console.log(getForm().getFieldsValue().id);
let msg = t('common.askDelete');
createConfirm({
iconType: 'warning',
title: t('common.tip'),
content: msg,
onOk: async () => {
await deleteConnectionString(getForm().getFieldsValue().id, record.name);
await reload();
},
});
};
return {
t,
registerTable,
@ -75,7 +114,8 @@ export default defineComponent({
submit,
registerCreateConnectionStringModal,
reload,
handlerOpenCreateConnectionStringModal
handlerOpenCreateConnectionStringModal,
handleDelete
};
},
});

11
vben28/src/views/tenants/Tenant.ts

@ -2,7 +2,7 @@ import { FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
import { TenantsServiceProxy, PagingTenantInput, IdInput, PageTenantConnectionStringInput, FeaturesServiceProxy, GetFeatureListResultInput,UpdateFeatureInput,UpdateFeaturesDto, UpdateFeatureDto} from '/@/services/ServiceProxies';
import { TenantsServiceProxy, PagingTenantInput, IdInput, PageTenantConnectionStringInput, FeaturesServiceProxy, GetFeatureListResultInput,UpdateFeatureInput,UpdateFeaturesDto, DeleteConnectionStringInput} from '/@/services/ServiceProxies';
export const searchFormSchema: FormSchema[] = [
{
field: 'filter',
@ -191,3 +191,12 @@ export async function updateTenantFeatureListAsync(tenantId, params) {
request.updateFeaturesDto.features=params;
return await _featuresServiceProxy.update(request);
}
export async function deleteConnectionString(id, name) {
const _tenantsServiceProxy = new TenantsServiceProxy();
const request = new DeleteConnectionStringInput();
request.name=name;
request.tenantId=id;
return await _tenantsServiceProxy.deleteConnectionString(request);
}

Loading…
Cancel
Save