feat(sj_1.0.0): 通过客户端生成幂等ID

This commit is contained in:
dhb52 2024-04-22 22:21:49 +08:00
parent f37697c899
commit 6c81cb75db
5 changed files with 43 additions and 26 deletions

View File

@ -62,3 +62,12 @@ export function fetchBatchDeleteRetryTask(data: Api.RetryTask.BatchDeleteRetryTa
data data
}); });
} }
/** generate retryTask idempotent id */
export function fetchIdempotentIdGenerate(data: Api.RetryTask.GenerateRetryIdempotentIdVO) {
return request<string>({
url: '/retry-task/generate/idempotent-id',
method: 'post',
data
});
}

11
src/typings/api.d.ts vendored
View File

@ -679,6 +679,17 @@ declare namespace Api {
ids: string[]; ids: string[];
}; };
type GenerateRetryIdempotentIdVO = {
/** 组名称 */
groupName: string;
/** 场景名称 */
sceneName: string;
/** 执行参数 */
argsStr: string;
/** 执行器名称 */
executorName: string;
};
/** RetryTask search params */ /** RetryTask search params */
type RetryTaskSearchParams = CommonType.RecordNullable< type RetryTaskSearchParams = CommonType.RecordNullable<
Pick<Api.RetryTask.RetryTask, 'uniqueId' | 'groupName' | 'sceneName' | 'idempotentId' | 'bizNo' | 'retryStatus'> & Pick<Api.RetryTask.RetryTask, 'uniqueId' | 'groupName' | 'sceneName' | 'idempotentId' | 'bizNo' | 'retryStatus'> &

View File

@ -129,9 +129,6 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
width: 260, width: 260,
render: row => ( render: row => (
<div class="flex-center gap-8px"> <div class="flex-center gap-8px">
<NButton type="primary" ghost size="small" onClick={() => edit(row.id!)}>
{$t('common.edit')}
</NButton>
<NPopconfirm onPositiveClick={() => handleDelete(row.groupName!, row.id!)}> <NPopconfirm onPositiveClick={() => handleDelete(row.groupName!, row.id!)}>
{{ {{
default: () => $t('common.confirmDelete'), default: () => $t('common.confirmDelete'),
@ -211,9 +208,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
const { const {
drawerVisible, drawerVisible,
operateType, operateType,
editingData,
handleAdd, handleAdd,
handleEdit,
checkedRowKeys, checkedRowKeys,
onBatchDeleted, onBatchDeleted,
onDeleted onDeleted
@ -239,10 +234,6 @@ async function handleBatchDelete() {
onBatchDeleted(); onBatchDeleted();
} }
function edit(id: string) {
handleEdit(id);
}
function handleBatchAdd() { function handleBatchAdd() {
openBatchAddDrawer(); openBatchAddDrawer();
} }
@ -304,13 +295,8 @@ async function updateRetryTaskStatus(id: number, groupName: string, retryStatus:
:pagination="mobilePagination" :pagination="mobilePagination"
class="sm:h-full" class="sm:h-full"
/> />
<RetryTaskOperateDrawer <RetryTaskOperateDrawer v-model:visible="drawerVisible" :operate-type="operateType" @submitted="getData" />
v-model:visible="drawerVisible" <RetryTaskBatchAddDrawer v-model:visible="batchAddDrawerVisible" @submitted="getData" />
:operate-type="operateType"
:row-data="editingData"
@submitted="getData"
/>
<RetryTaskBatchAddDrawer v-model:visible="batchAddDrawerVisible" :row-data="editingData" @submitted="getData" />
</NCard> </NCard>
</div> </div>
</template> </template>

View File

@ -3,7 +3,12 @@ import { computed, onMounted, reactive, ref, watch } from 'vue';
import { useFormRules, useNaiveForm } from '@/hooks/common/form'; import { useFormRules, useNaiveForm } from '@/hooks/common/form';
import OperateDrawer from '@/components/common/operate-drawer.vue'; import OperateDrawer from '@/components/common/operate-drawer.vue';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { fetchAddRetryTask, fetchGetAllGroupNameList, fetchGetRetrySceneList } from '@/service/api'; import {
fetchAddRetryTask,
fetchGetAllGroupNameList,
fetchGetRetrySceneList,
fetchIdempotentIdGenerate
} from '@/service/api';
import { translateOptions, translateOptions2 } from '@/utils/common'; import { translateOptions, translateOptions2 } from '@/utils/common';
import { retryTaskStatusTypeOptions } from '@/constants/business'; import { retryTaskStatusTypeOptions } from '@/constants/business';
@ -113,12 +118,6 @@ async function handleSubmit() {
window.$message?.success($t('common.addSuccess')); window.$message?.success($t('common.addSuccess'));
} }
// if (props.operateType === 'edit') {
// const { ... } = model;
// fetchEditRetryTask({ ... });
// window.$message?.success($t('common.updateSuccess'));
// }
closeDrawer(); closeDrawer();
emit('submitted'); emit('submitted');
} }
@ -145,8 +144,20 @@ async function handleGroupNameUpdate(groupName: string) {
} }
} }
function setIdempotentId() { async function setIdempotentId() {
model.idempotentId = 'test'; const groupName = model.groupName;
const sceneName = model.sceneName;
const executorName = model.executorName;
const argsStr = model.argsStr;
const { data: idempotentId, error } = await fetchIdempotentIdGenerate({
groupName,
sceneName,
executorName,
argsStr
});
if (!error) {
model.idempotentId = idempotentId;
}
} }
onMounted(() => { onMounted(() => {

View File

@ -61,8 +61,8 @@ onMounted(() => {
v-model:value="model.groupName" v-model:value="model.groupName"
:placeholder="$t('page.retryTask.form.groupName')" :placeholder="$t('page.retryTask.form.groupName')"
:options="translateOptions2(groupNameList)" :options="translateOptions2(groupNameList)"
filterable
clearable clearable
filterable
@update:value="handleGroupNameUpdate" @update:value="handleGroupNameUpdate"
/> />
</NFormItemGi> </NFormItemGi>