提交openapi单元测试代码

调整接口管理的字段位置
授权管理删掉无用配置
授权管理编辑改为重置生成ak sk功能
授权页面应该改成跟角色授权类型的效果
This commit is contained in:
xlh12306
2025-05-16 23:12:28 +08:00
parent 9aea5de668
commit fb188a83a1
14 changed files with 211 additions and 47 deletions

View File

@ -9,7 +9,7 @@ enum Api {
edit='/openapi/auth/edit',
apiList= '/openapi/list',
genAKSK = '/openapi/auth/genAKSK',
permissionList='/openapi/permission/list',
permissionList='/openapi/permission/getOpenApi',
permissionAdd='/openapi/permission/add',
deleteOne = '/openapi/auth/delete',
deleteBatch = '/openapi/auth/deleteBatch',

View File

@ -33,7 +33,7 @@ export const columns: BasicColumn[] = [
{
title: '关联系统用户名',
align: "center",
dataIndex: 'systemUserId_dictText',
dataIndex: 'createBy',
},
];
@ -43,7 +43,7 @@ export const superQuerySchema = {
name: {title: '授权名称',order: 0,view: 'text', type: 'string',},
ak: {title: 'AK',order: 1,view: 'text', type: 'string',},
sk: {title: 'SK',order: 2,view: 'text', type: 'string',},
createBy: {title: '创建人',order: 3,view: 'text', type: 'string',},
createBy: {title: '关联系统用户名',order: 3,view: 'text', type: 'string',},
createTime: {title: '创建时间',order: 4,view: 'datetime', type: 'string',},
systemUserId: {title: '关联系统用户名',order: 5,view: 'text', type: 'string',},
// systemUserId: {title: '关联系统用户名',order: 5,view: 'text', type: 'string',},
};

View File

@ -11,9 +11,9 @@
</a-form-item>
</a-col>
<a-col :lg="6">
<a-form-item name="systemUserId">
<a-form-item name="createBy">
<template #label><span title="关联系统用户名">关联系统用户名</span></template>
<JSearchSelect dict="sys_user,username,id" v-model:value="queryParam.systemUserId" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>
<JSearchSelect dict="sys_user,username,username" v-model:value="queryParam.createBy" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>
<!-- <a-input placeholder="请输入关联系统用户名" v-model:value="queryParam.systemUserId" allow-clear ></a-input>-->
</a-form-item>
</a-col>
@ -62,6 +62,7 @@
<template v-slot:bodyCell="{ column, record, index, text }">
</template>
</BasicTable>
<!-- 表单区域 -->
<OpenApiAuthModal ref="registerModal" @success="handleSuccess"></OpenApiAuthModal>
<AuthModal ref="authModal" @success="handleSuccess"></AuthModal>
@ -73,11 +74,19 @@
import { BasicTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns, superQuerySchema } from './OpenApiAuth.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './OpenApiAuth.api';
import {
list,
deleteOne,
batchDelete,
getImportUrl,
getExportUrl,
getGenAKSK
} from "./OpenApiAuth.api";
import OpenApiAuthModal from './components/OpenApiAuthModal.vue'
import AuthModal from './components/AuthModal.vue'
import { useUserStore } from '/@/store/modules/user';
import JSearchSelect from "../../components/Form/src/jeecg/components/JSearchSelect.vue";
import { saveOrUpdate } from "@/views/openapi/OpenApi.api";
const formRef = ref();
const queryParam = reactive<any>({});
@ -157,8 +166,22 @@
*/
function handleEdit(record: Recordable) {
registerModal.value.disableSubmit = false;
registerModal.value.authDrawerOpen = true;
registerModal.value.edit(record);
}
/**
* 重置事件
* @param record
*/
async function handleReset(record: Recordable) {
const AKSKObj = await getGenAKSK({});
record.ak = AKSKObj[0];
record.sk = AKSKObj[1];
saveOrUpdate(record,true);
// handleSuccess;
}
/**
* 详情
@ -200,8 +223,12 @@
auth: 'openapi:open_api_auth:edit'
},
{
label: '编辑',
onClick: handleEdit.bind(null, record),
label: '重置',
popConfirm: {
title: '是否重置AK,SK',
confirm: handleReset.bind(null, record),
placement: 'topLeft',
},
auth: 'openapi:open_api_auth:edit'
},
];

View File

@ -33,7 +33,7 @@
},
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource,setSelectedRowKeys }, { rowSelection, selectedRowKeys,selectedRows }] =
tableContext;
const props = defineProps({
@ -85,13 +85,18 @@
formData.apiAuthId = record.id;
// 获取当前已授权的项目
getPermissionList({ apiAuthId: record.id }).then((res) => {
if (res && res.length > 0) {
let list = res.result.records || res.result;
if (res.length > 0) {
let list = res;
let ids = [];
list.forEach((item) => {
if(item.ifCheckBox == "1"){
selectedRowKeys.value.push(item.id)
selectedRows.value.push(item)
setSelectedRowKeys(selectedRowKeys.value);
}
ids.push(item.apiId);
});
selectedRowKeys.value = ids;
// selectedRowKeys.value = ids;
formData.apiIdList = ids;
}
});
@ -102,8 +107,8 @@
* 提交数据
*/
async function submitForm() {
if(selectedRowKeys.value.length === 0)
return emit('ok');
// if(selectedRowKeys.value.length === 0)
// return emit('ok');
try {
// 触发表单验证
await validate();
@ -131,6 +136,7 @@
if (res.success) {
createMessage.success(res.message);
emit('ok');
cleanData()
} else {
createMessage.warning(res.message);
}
@ -139,11 +145,16 @@
confirmLoading.value = false;
});
}
const cleanData = () => {
selectedRows.value = []
selectedRowKeys.value = []
}
defineExpose({
add,
edit,
submitForm,
cleanData
});
</script>

View File

@ -1,14 +1,29 @@
<template>
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<AuthForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AuthForm>
</j-modal>
<!-- <j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">-->
<div style="position: relative;">
<a-drawer
v-model:open="authDrawerOpen"
class="custom-class"
root-class-name="root-class-name"
:root-style="{ color: 'blue' }"
style="color: red"
title="Basic Drawer"
placement="right"
:width="800"
@after-open-change="authDrawerOpenChange"
>
<AuthForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AuthForm>
<a-button type="primary" style="position: absolute;bottom: 2%;right: 2%" @click="handleOk">确定</a-button>
</a-drawer>
</div>
<!-- </j-modal>-->
</template>
<script lang="ts" setup>
import { ref, nextTick, defineExpose } from 'vue';
import AuthForm from './AuthForm.vue'
import AuthForm from './AuthForm.vue';
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
const title = ref<string>('');
const width = ref<number>(800);
const visible = ref<boolean>(false);
@ -16,6 +31,12 @@
const registerForm = ref();
const emit = defineEmits(['register', 'success']);
const authDrawerOpen = ref(false);
const authDrawerOpenChange = (val: any) => {
if(!val)
registerForm.value.cleanData()
};
/**
* 新增
*/
@ -26,7 +47,7 @@
registerForm.value.add();
});
}
/**
* 授权
* @param record
@ -34,11 +55,12 @@
function edit(record) {
title.value = disableSubmit.value ? '详情' : '授权';
visible.value = true;
authDrawerOpen.value = true;
nextTick(() => {
registerForm.value.edit(record);
});
}
/**
* 确定按钮点击事件
*/
@ -59,6 +81,7 @@
*/
function handleCancel() {
visible.value = false;
authDrawerOpen.value = false;
}
defineExpose({

View File

@ -19,11 +19,11 @@
<a-input v-model:value="formData.sk" placeholder="请输入SK" disabled allow-clear ></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="关联系统用户名" v-bind="validateInfos.systemUserId" id="OpenApiAuthForm-systemUserId" name="systemUserId">
<JSearchSelect dict="sys_user,username,id" v-model:value="formData.systemUserId" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>
</a-form-item>
</a-col>
<!-- <a-col :span="24">-->
<!-- <a-form-item label="关联系统用户名" v-bind="validateInfos.systemUserId" id="OpenApiAuthForm-systemUserId" name="systemUserId">-->
<!-- <JSearchSelect dict="sys_user,username,id" v-model:value="formData.systemUserId" placeholder="请输入关联系统用户名" allow-clear ></JSearchSelect>-->
<!-- </a-form-item>-->
<!-- </a-col>-->
</a-row>
</a-form>
</template>

View File

@ -1,5 +1,5 @@
<template>
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<j-modal :title="title" :width="width" :maxHeight="200" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
<OpenApiAuthForm ref="registerForm" @ok="submitCallback" :title="title" :formDisabled="disableSubmit" :formBpm="false"></OpenApiAuthForm>
</j-modal>
</template>