Skip to content

Commit

Permalink
feat: 租户连接字符串添加删除功能
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJunZzz committed May 22, 2024
1 parent 341fea5 commit 0050ccc
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ public class DeleteConnectionStringInput
/// 连接字符串名称
/// </summary>
public string Name { get; set; }

/// <summary>
/// 租户id
/// </summary>
public Guid TenantId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,15 @@ public async Task AddOrUpdateConnectionStringAsync(AddOrUpdateConnectionStringIn

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);
Expand Down
10 changes: 10 additions & 0 deletions vben28/src/services/ServiceProxies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9299,6 +9299,8 @@ export interface IDateTimeFormatDto {
export class DeleteConnectionStringInput implements IDeleteConnectionStringInput {
/** 连接字符串名称 */
name!: string | undefined;
/** 租户id */
tenantId!: string;

constructor(data?: IDeleteConnectionStringInput) {
if (data) {
Expand All @@ -9312,6 +9314,7 @@ export class DeleteConnectionStringInput implements IDeleteConnectionStringInput
init(_data?: any) {
if (_data) {
this.name = _data["name"];
this.tenantId = _data["tenantId"];
}
}

Expand All @@ -9325,13 +9328,16 @@ export class DeleteConnectionStringInput implements IDeleteConnectionStringInput
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["name"] = this.name;
data["tenantId"] = this.tenantId;
return data;
}
}

export interface IDeleteConnectionStringInput {
/** 连接字符串名称 */
name: string | undefined;
/** 租户id */
tenantId: string;
}

export class DeleteDataDictionaryDetailInput implements IDeleteDataDictionaryDetailInput {
Expand Down Expand Up @@ -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) {
Expand All @@ -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"];
}
}
Expand All @@ -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;
}
Expand All @@ -11345,6 +11354,7 @@ export interface IFindTenantResultDto {
success: boolean;
tenantId: string | undefined;
name: string | undefined;
normalizedName: string | undefined;
isActive: boolean;
}

Expand Down
46 changes: 43 additions & 3 deletions vben28/src/views/tenants/EditConnectionString.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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: {
Expand All @@ -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',
},
});
Expand All @@ -68,14 +90,32 @@ 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,
registerModal,
submit,
registerCreateConnectionStringModal,
reload,
handlerOpenCreateConnectionStringModal
handlerOpenCreateConnectionStringModal,
handleDelete
};
},
});
Expand Down
11 changes: 10 additions & 1 deletion vben28/src/views/tenants/Tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
}

0 comments on commit 0050ccc

Please sign in to comment.