fix(接口测试): 修复导入的接口没有日志的缺陷

--bug=1037852 --user=王孝刚 【接口测试】接口定义,导入swagger接口没有日志
https://www.tapd.cn/55049933/s/1484561
This commit is contained in:
wxg0103 2024-03-30 16:32:37 +08:00 committed by Craftsman
parent 6e41a8e16e
commit 68afead5d5
9 changed files with 60 additions and 89 deletions

View File

@ -327,7 +327,7 @@ public class ApiDefinitionImportUtilService {
project.getOrganizationId(), project.getOrganizationId(),
v.getId(), v.getId(),
request.getUserId(), request.getUserId(),
OperationLogType.IMPORT.name(), OperationLogType.UPDATE.name(),
OperationLogModule.API_TEST_MANAGEMENT_DEFINITION, OperationLogModule.API_TEST_MANAGEMENT_DEFINITION,
v.getName()); v.getName());
dto.setHistory(true); dto.setHistory(true);
@ -376,6 +376,7 @@ public class ApiDefinitionImportUtilService {
dto.setPath("/api/definition/import"); dto.setPath("/api/definition/import");
dto.setMethod(HttpMethodConstants.POST.name()); dto.setMethod(HttpMethodConstants.POST.name());
dto.setOriginalValue(JSON.toJSONBytes(apiDefinitionDTO)); dto.setOriginalValue(JSON.toJSONBytes(apiDefinitionDTO));
operationLogs.add(dto);
ApiDefinitionCaseDTO apiDefinitionCaseDTO = new ApiDefinitionCaseDTO(); ApiDefinitionCaseDTO apiDefinitionCaseDTO = new ApiDefinitionCaseDTO();
BeanUtils.copyBean(apiDefinitionCaseDTO, t); BeanUtils.copyBean(apiDefinitionCaseDTO, t);

View File

@ -46,7 +46,7 @@
</div> </div>
</a-radio> </a-radio>
<a-radio :value="RequestExtractResultMatchingRule.SPECIFIC"> <a-radio :value="RequestExtractResultMatchingRule.SPECIFIC">
<div class="flex items-center"> <div class="flex items-center text-[14px]">
{{ t('apiTestDebug.specifyMatch') }} {{ t('apiTestDebug.specifyMatch') }}
<a-tooltip :content="t('apiTestDebug.specifyMatchTip')" :content-style="{ maxWidth: '400px' }"> <a-tooltip :content="t('apiTestDebug.specifyMatchTip')" :content-style="{ maxWidth: '400px' }">
<icon-question-circle <icon-question-circle

View File

@ -1577,8 +1577,9 @@
} }
onBeforeMount(() => { onBeforeMount(() => {
if (props.isCase) return; if (!props.isCase) {
initLocalConfig(); initLocalConfig();
}
}); });
onMounted(() => { onMounted(() => {

View File

@ -153,28 +153,22 @@
const shareTime = ref<string>(''); const shareTime = ref<string>('');
async function getTime() { async function getTime() {
const res = await getShareTime(appStore.currentProjectId); try {
const match = res.match(/^(\d+)([MYHD])$/); const res = await getShareTime(appStore.currentProjectId);
if (match) { const match = res.match(/^(\d+)([MYHD])$/);
const value = parseInt(match[1], 10); // if (match) {
const type = match[2]; // const value = parseInt(match[1], 10);
switch (type) { const type = match[2];
case 'M': const translations = {
shareTime.value = value + t('msTimeSelector.month'); M: t('msTimeSelector.month'),
break; Y: t('msTimeSelector.year'),
case 'Y': H: t('msTimeSelector.hour'),
shareTime.value = value + t('msTimeSelector.year'); D: t('msTimeSelector.day'),
break; };
case 'H': shareTime.value = value + (translations[type] || translations.D);
shareTime.value = value + t('msTimeSelector.hour');
break;
case 'D':
shareTime.value = value + t('msTimeSelector.day');
break;
default:
shareTime.value = 24 + t('msTimeSelector.hour');
break;
} }
} catch (error) {
console.log(error);
} }
} }
onMounted(() => { onMounted(() => {

View File

@ -108,7 +108,7 @@
import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import { MsTableColumn } from '@/components/pure/ms-table/type'; import { MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import CaseReportDrawer from '@/views/api-test/report/component/caseReportDrawer.vue'; import CaseReportDrawer from '@/views/api-test/management/components/management/case/caseReportDrawer.vue';
import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue'; import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue';
import { getApiCaseExecuteHistory } from '@/api/modules/api-test/management'; import { getApiCaseExecuteHistory } from '@/api/modules/api-test/management';

View File

@ -33,7 +33,7 @@
<template #content> <template #content>
<a-doption> <a-doption>
<span>{{ t('report.detail.api.copyLink') }}</span <span>{{ t('report.detail.api.copyLink') }}</span
><span>{{ t('report.detail.api.copyLinkTimeEnd', { time: shareTime }) }}</span> ><span>{{ t('report.detail.api.copyLinkTimeEnd', { time: props.shareTime }) }}</span>
</a-doption> </a-doption>
</template> </template>
</a-dropdown> </a-dropdown>
@ -84,6 +84,7 @@
tableData: any[]; tableData: any[];
pagination: MsPaginationI; pagination: MsPaginationI;
pageChange: (page: number) => Promise<void>; pageChange: (page: number) => Promise<void>;
shareTime: string;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -180,35 +181,6 @@
console.log(error); console.log(error);
} }
} }
const shareTime = ref<string>('');
async function getTime() {
const res = await getShareTime(appStore.currentProjectId);
const match = res.match(/^(\d+)([MYHD])$/);
if (match) {
const value = parseInt(match[1], 10); //
const type = match[2]; //
switch (type) {
case 'M':
shareTime.value = value + t('msTimeSelector.month');
break;
case 'Y':
shareTime.value = value + t('msTimeSelector.year');
break;
case 'H':
shareTime.value = value + t('msTimeSelector.hour');
break;
case 'D':
shareTime.value = value + t('msTimeSelector.day');
break;
default:
shareTime.value = 24 + t('msTimeSelector.hour');
break;
}
}
}
onMounted(() => {
getTime();
});
// //
function loadedReport(detail: ReportDetail) { function loadedReport(detail: ReportDetail) {

View File

@ -33,7 +33,7 @@
<template #content> <template #content>
<a-doption> <a-doption>
<span>{{ t('report.detail.api.copyLink') }}</span <span>{{ t('report.detail.api.copyLink') }}</span
><span>{{ t('report.detail.api.copyLinkTimeEnd', { time: shareTime }) }}</span> ><span>{{ t('report.detail.api.copyLinkTimeEnd', { time: props.shareTime }) }}</span>
</a-doption> </a-doption>
</template> </template>
</a-dropdown> </a-dropdown>
@ -87,6 +87,7 @@
pagination: MsPaginationI; pagination: MsPaginationI;
pageChange: (page: number) => Promise<void>; pageChange: (page: number) => Promise<void>;
isShare?: boolean; isShare?: boolean;
shareTime?: string;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
@ -189,36 +190,6 @@
console.log(error); console.log(error);
} }
} }
const shareTime = ref<string>('');
async function getTime() {
const res = await getShareTime(appStore.currentProjectId);
const match = res.match(/^(\d+)([MYHD])$/);
if (match) {
const value = parseInt(match[1], 10); //
const type = match[2]; //
switch (type) {
case 'M':
shareTime.value = value + t('msTimeSelector.month');
break;
case 'Y':
shareTime.value = value + t('msTimeSelector.year');
break;
case 'H':
shareTime.value = value + t('msTimeSelector.hour');
break;
case 'D':
shareTime.value = value + t('msTimeSelector.day');
break;
default:
shareTime.value = 24 + t('msTimeSelector.hour');
break;
}
}
}
onMounted(() => {
getTime();
});
/** /**
* 导出 * 导出
*/ */

View File

@ -141,6 +141,7 @@
:page-change="propsEvent.pageChange" :page-change="propsEvent.pageChange"
:pagination="propsRes.msPagination!" :pagination="propsRes.msPagination!"
:show-type="showType" :show-type="showType"
:share-time="shareTime"
/> />
<CaseReportDrawer <CaseReportDrawer
v-model:visible="showCaseDetailDrawer" v-model:visible="showCaseDetailDrawer"
@ -150,6 +151,7 @@
:page-change="propsEvent.pageChange" :page-change="propsEvent.pageChange"
:pagination="propsRes.msPagination!" :pagination="propsRes.msPagination!"
:show-type="activeCaseReportType" :show-type="activeCaseReportType"
:share-time="shareTime"
/> />
</div> </div>
</template> </template>
@ -169,7 +171,13 @@
import ReportDetailDrawer from './reportDetailDrawer.vue'; import ReportDetailDrawer from './reportDetailDrawer.vue';
import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue'; import ExecutionStatus from '@/views/api-test/report/component/reportStatus.vue';
import { reportBathDelete, reportDelete, reportList, reportRename } from '@/api/modules/api-test/report'; import {
getShareTime,
reportBathDelete,
reportDelete,
reportList,
reportRename,
} from '@/api/modules/api-test/report';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal'; import useModal from '@/hooks/useModal';
import { useTableStore } from '@/store'; import { useTableStore } from '@/store';
@ -472,6 +480,30 @@
} }
} }
const shareTime = ref<string>('');
async function getTime() {
try {
const res = await getShareTime(appStore.currentProjectId);
const match = res.match(/^(\d+)([MYHD])$/);
if (match) {
const value = parseInt(match[1], 10);
const type = match[2];
const translations = {
M: t('msTimeSelector.month'),
Y: t('msTimeSelector.year'),
H: t('msTimeSelector.hour'),
D: t('msTimeSelector.day'),
};
shareTime.value = value + (translations[type] || translations.D);
}
} catch (error) {
console.log(error);
}
}
onMounted(() => {
getTime();
});
watch( watch(
() => props.moduleType, () => props.moduleType,
(val) => { (val) => {

View File

@ -96,7 +96,7 @@
import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type'; import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import ExecutionStatus from './executionStatus.vue'; import ExecutionStatus from './executionStatus.vue';
import CaseReportDrawer from '@/views/api-test/report/component/caseReportDrawer.vue'; import CaseReportDrawer from '@/views/api-test/management/components/management/case/caseReportDrawer.vue';
import ReportDetailDrawer from '@/views/api-test/report/component/reportDetailDrawer.vue'; import ReportDetailDrawer from '@/views/api-test/report/component/reportDetailDrawer.vue';
import { import {