This commit is contained in:
六如
2024-10-19 20:27:16 +08:00
parent 17bc2d5ca8
commit 0cbadbeda8
25 changed files with 487 additions and 118 deletions

View File

@@ -8,9 +8,20 @@ const apiUrl: any = createUrl({
update: "/isv/update",
del: "/isv/delete",
getKeys: "/isv/getKeys",
updateStatus: "/isv/updateStatus"
updateStatus: "/isv/updateStatus",
createKeys: "/isv/createKeys",
updateKeys: "/isv/updateKeys"
});
/*
private String publicKey;
private String privateKey;
*/
export interface KeyStore {
publicKey: string;
privateKey: string;
}
/**
* 接口管理
*/
@@ -27,34 +38,51 @@ export const api: any = {
* @param data 表单内容
*/
add(data: object) {
return http.post<Result, any>(apiUrl.add, { data });
return http.post<Result<any>, any>(apiUrl.add, { data });
},
/**
* 修改
* @param data 表单内容
*/
update(data: object) {
return http.post<Result, any>(apiUrl.update, { data });
return http.post<Result<any>, any>(apiUrl.update, { data });
},
/**
* 删除
* @param data 表单内容
*/
del(data: object) {
return http.post<Result, any>(apiUrl.del, { data });
return http.post<Result<any>, any>(apiUrl.del, { data });
},
/**
* 查看秘钥
* @param params
*/
viewKeys(params: object) {
return http.get<Result, any>(apiUrl.getKeys, { params });
return http.get<Result<any>, any>(apiUrl.getKeys, { params });
},
/**
* 修改状态
* @param data 表单内容
*/
updateStatus(data: object) {
return http.post<Result, any>(apiUrl.updateStatus, { data });
return http.post<Result<any>, any>(apiUrl.updateStatus, { data });
},
/**
* 创建秘钥
* @param keyFormat 秘钥格式1PKCS8(JAVA适用)2PKCS1(非JAVA适用)
*/
createKeys(keyFormat): Promise<Result<KeyStore>> {
const data = {
keyFormat: keyFormat
};
return http.post<Result<KeyStore>, any>(apiUrl.createKeys, { data });
},
/**
* 修改秘钥
* @param data 表单内容
*/
updateKeys(data: object): Promise<Result<KeyStore>> {
return http.post<Result<any>, any>(apiUrl.updateKeys, { data });
}
};

View File

@@ -26,27 +26,27 @@ export const api: any = {
* @param data 表单内容
*/
add(data: object) {
return http.post<Result, any>(apiUrl.add, { data });
return http.post<Result<any>, any>(apiUrl.add, { data });
},
/**
* 修改
* @param data 表单内容
*/
update(data: object) {
return http.post<Result, any>(apiUrl.update, { data });
return http.post<Result<any>, any>(apiUrl.update, { data });
},
/**
* 删除
* @param data 表单内容
*/
del(data: object) {
return http.post<Result, any>(apiUrl.del, { data });
return http.post<Result<any>, any>(apiUrl.del, { data });
},
/**
* 修改状态
* @param data 表单内容
*/
updateStatus(data: object) {
return http.post<Result, any>(apiUrl.updateStatus, { data });
return http.post<Result<any>, any>(apiUrl.updateStatus, { data });
}
};

View File

@@ -25,20 +25,20 @@ export const api: any = {
* @param data 表单内容
*/
add(data: object) {
return http.post<Result, any>(apiUrl.add, { data });
return http.post<Result<any>, any>(apiUrl.add, { data });
},
/**
* 修改
* @param data 表单内容
*/
update(data: object) {
return http.post<Result, any>(apiUrl.update, { data });
return http.post<Result<any>, any>(apiUrl.update, { data });
},
/**
* 删除
* @param data 表单内容
*/
del(data: object) {
return http.post<Result, any>(apiUrl.del, { data });
return http.post<Result<any>, any>(apiUrl.del, { data });
}
};

View File

@@ -1,3 +1,8 @@
export enum YesOrNoEnum {
NO = 0,
YES = 1
}
export enum StatusEnum {
ENABLE = 1,
DISABLE = 2
@@ -7,3 +12,8 @@ export enum KeyFormatEnum {
PKCS8 = 1,
PKCS1 = 2
}
export enum RegSource {
SYS = 1,
CUSTOM = 2
}

View File

@@ -1,6 +1,6 @@
export interface Result {
export interface Result<T> {
success: boolean;
data: object;
data: T;
msg: "";
code: "";
}

View File

@@ -24,3 +24,14 @@
.html-weakness {
filter: invert(80%);
}
.grow {
.el-card {
--el-card-padding: 18px !important;
border: 0 !important;
border-radius: 0;
}
.main-content {
margin: 0 !important;
}
}

View File

@@ -16,6 +16,9 @@ import { useUserStoreHook } from "@/store/modules/user";
import { ElMessage } from "element-plus";
export const baseUrl = (url: string) => {
if (!url) {
throw new Error("url不能为空");
}
if (url.startsWith("/")) {
url = url.substring(1);
}

View File

@@ -56,6 +56,7 @@ import {
labelWidth: '100px',
labelPosition: 'right'
}"
:hasErrorTip="false"
@confirm="handleSave"
/>
</el-card>

View File

@@ -282,7 +282,7 @@ export const handlePaginationChange = (_pageInfo: PageInfo): void => {
};
// 查询
const search = async () => {
export const search = async () => {
try {
const { data } = await doSearch();
tableData.value = data.list;

View File

@@ -25,8 +25,14 @@ import {
} from "./showKeys";
import {
dlgKeysSetting,
handleUpdateKeys,
resetIsvKeys,
resetPlatformKeys,
restIsvKeysLoading,
resetPlatformKeysLoading,
settingKeysFormColumns,
settingKeysFormData
settingKeysFormData,
settingKeysFormRules
} from "@/views/isv/list/isvKeys";
</script>
<template>
@@ -84,17 +90,9 @@ import {
<PlusDialogForm
v-model:visible="dlgKeysShow"
v-model="showKeysFormData"
:dialog="{ title: '秘钥' }"
:dialog="{ title: '秘钥 - 标识☆分配给开发者' }"
:form="{ group: showKeysFormColumns, labelPosition: 'right' }"
>
<template #plus-field-privateKeyIsv>
<el-input
v-model="showKeysFormData.privateKeyIsv"
readonly
placeholder=""
/>
<el-button style="margin-top: 20px">重置ISV秘钥</el-button>
</template>
<template #dialog-footer="{ handleCancel }">
<el-button type="primary" @click="handleCancel">关闭</el-button>
</template>
@@ -103,19 +101,32 @@ import {
<PlusDialogForm
v-model:visible="dlgKeysSetting"
v-model="settingKeysFormData"
:dialog="{ title: '秘钥' }"
:form="{ group: settingKeysFormColumns, labelPosition: 'right' }"
:dialog="{ title: '秘钥 - 标识☆分配给开发者' }"
:form="{
group: settingKeysFormColumns,
rules: settingKeysFormRules,
labelPosition: 'right'
}"
:hasErrorTip="false"
@confirm="handleUpdateKeys"
>
<template #plus-field-privateKeyIsv>
<el-input
v-model="showKeysFormData.privateKeyIsv"
readonly
placeholder=""
/>
<el-button style="margin-top: 20px">重置ISV秘钥</el-button>
<template #plus-field-restIsvKeys>
<el-button
type="primary"
:loading="restIsvKeysLoading"
@click="resetIsvKeys"
>
重置ISV秘钥
</el-button>
</template>
<template #dialog-footer="{ handleCancel }">
<el-button type="primary" @click="handleCancel">关闭</el-button>
<template #plus-field-restPlatformKeys>
<el-button
type="primary"
:loading="resetPlatformKeysLoading"
@click="resetPlatformKeys"
>
重置平台秘钥
</el-button>
</template>
</PlusDialogForm>
</el-card>

View File

@@ -1,21 +1,51 @@
import { ref } from "vue";
import type { PlusFormGroupRow } from "plus-pro-components";
import { CreditCard } from "@element-plus/icons-vue";
import { api } from "@/api/isvList";
import { KeyFormatEnum } from "@/model/enums";
import { ElMessage } from "element-plus";
import { search } from "./index";
// 弹窗显示
export const dlgKeysSetting = ref(false);
export const settingKeysFormData = ref<any>({
isvId: 0,
keyFormat: KeyFormatEnum.PKCS8,
publicKeyIsv: "",
privateKeyIsv: "",
publicKeyPlatform: "",
privateKeyPlatform: ""
});
export const settingKeysFormRules = {
publicKeyIsv: [{ required: true, message: "不能为空" }],
privateKeyIsv: [{ required: true, message: "不能为空" }],
publicKeyPlatform: [{ required: true, message: "不能为空" }],
privateKeyPlatform: [{ required: true, message: "不能为空" }]
};
// 表单内容
export const settingKeysFormColumns: PlusFormGroupRow[] = [
{
title: "ISV公私钥 - 标识☆分配给开发者",
icon: CreditCard,
title: "基本信息",
columns: [
{
label: "秘钥格式",
prop: "keyFormat",
labelWidth: 100,
valueType: "radio",
options: [
{
label: "PKCS8(Java适用)",
value: KeyFormatEnum.PKCS8
},
{
label: "PKCS1(非Java适用)",
value: KeyFormatEnum.PKCS1
}
]
}
]
},
{
title: "ISV公私钥",
columns: [
{
label: "ISV公钥",
@@ -39,12 +69,18 @@ export const settingKeysFormColumns: PlusFormGroupRow[] = [
placeholder: "",
autosize: { minRows: 2, maxRows: 4 }
}
},
{
labelWidth: 100,
prop: "restIsvKeys",
renderLabel: () => {
return "";
}
}
]
},
{
title: "平台公私钥 - 标识☆分配给开发者",
icon: CreditCard,
title: "平台公私钥",
columns: [
{
label: "☆平台公钥",
@@ -67,6 +103,13 @@ export const settingKeysFormColumns: PlusFormGroupRow[] = [
placeholder: "",
autosize: { minRows: 2, maxRows: 4 }
}
},
{
labelWidth: 100,
prop: "restPlatformKeys",
renderLabel: () => {
return "";
}
}
]
}
@@ -81,3 +124,36 @@ export const settingKeys = (row: any) => {
dlgKeysSetting.value = true;
});
};
export const restIsvKeysLoading = ref(false);
export const resetIsvKeys = () => {
restIsvKeysLoading.value = true;
api.createKeys(settingKeysFormData.value.keyFormat).then(resp => {
restIsvKeysLoading.value = false;
const data = resp.data;
settingKeysFormData.value.publicKeyIsv = data.publicKey;
settingKeysFormData.value.privateKeyIsv = data.privateKey;
});
};
export const resetPlatformKeysLoading = ref(false);
export const resetPlatformKeys = () => {
resetPlatformKeysLoading.value = true;
api.createKeys(settingKeysFormData.value.keyFormat).then(resp => {
resetPlatformKeysLoading.value = false;
const data = resp.data;
settingKeysFormData.value.publicKeyPlatform = data.publicKey;
settingKeysFormData.value.privateKeyPlatform = data.privateKey;
});
};
export const handleUpdateKeys = () => {
api.updateKeys(settingKeysFormData.value).then(() => {
ElMessage({
message: "保存成功",
type: "success"
});
dlgKeysSetting.value = false;
search();
});
};

View File

@@ -1,11 +1,12 @@
import { ref } from "vue";
import type { PlusFormGroupRow } from "plus-pro-components";
import { CreditCard } from "@element-plus/icons-vue";
import { api } from "@/api/isvList";
import { KeyFormatEnum } from "@/model/enums";
// 弹窗显示
export const dlgKeysShow = ref(false);
export const showKeysFormData = ref<any>({
keyFormat: KeyFormatEnum.PKCS8,
publicKeyIsv: "",
privateKeyIsv: "",
publicKeyPlatform: "",
@@ -14,8 +15,31 @@ export const showKeysFormData = ref<any>({
// 表单内容
export const showKeysFormColumns: PlusFormGroupRow[] = [
{
title: "ISV公私钥 - 标识☆分配给开发者",
icon: CreditCard,
title: "基本信息",
columns: [
{
label: "秘钥格式",
prop: "keyFormat",
labelWidth: 100,
valueType: "radio",
options: [
{
label: "PKCS8(Java适用)",
value: KeyFormatEnum.PKCS8
},
{
label: "PKCS1(非Java适用)",
value: KeyFormatEnum.PKCS1
}
],
fieldProps: {
disabled: true
}
}
]
},
{
title: "ISV公私钥",
columns: [
{
label: "ISV公钥",
@@ -44,8 +68,7 @@ export const showKeysFormColumns: PlusFormGroupRow[] = [
]
},
{
title: "平台公私钥 - 标识☆分配给开发者",
icon: CreditCard,
title: "平台公私钥",
columns: [
{
label: "☆平台公钥",

View File

@@ -1,13 +1,12 @@
import { computed, ref } from "vue";
import {
type ButtonsCallBackParams,
type FieldValues,
type PageInfo,
type PlusColumn,
useTable
} from "plus-pro-components";
import { ElMessage } from "element-plus";
import { StatusEnum } from "@/model/enums";
import { RegSource, StatusEnum, YesOrNoEnum } from "@/model/enums";
import { api } from "@/api/serveApi";
const isAdd = ref(false);
@@ -64,11 +63,17 @@ pageInfo.value.pageSize = 10;
export const tableColumns: PlusColumn[] = [
{
label: "应用名称",
prop: "application"
prop: "application",
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "接口名称",
prop: "apiName"
prop: "apiName",
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "版本号",
@@ -77,7 +82,17 @@ export const tableColumns: PlusColumn[] = [
},
{
label: "接口描述",
prop: "description"
prop: "description",
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "备注",
prop: "remark",
tableColumnProps: {
showOverflowTooltip: true
}
},
{
label: "需要授权",
@@ -87,8 +102,7 @@ export const tableColumns: PlusColumn[] = [
options: [
{
label: "否",
value: 0,
color: "red"
value: 0
},
{
label: "是",
@@ -105,8 +119,7 @@ export const tableColumns: PlusColumn[] = [
options: [
{
label: "否",
value: 0,
color: "red"
value: 0
},
{
label: "是",
@@ -115,6 +128,24 @@ export const tableColumns: PlusColumn[] = [
}
]
},
{
label: "注册来源",
prop: "regSource",
width: 100,
valueType: "select",
options: [
{
label: "系统",
value: 1,
color: "blue"
},
{
label: "手动",
value: 2,
color: "green"
}
]
},
{
label: "状态",
prop: "status",
@@ -135,7 +166,13 @@ export const tableColumns: PlusColumn[] = [
},
{
label: "添加时间",
prop: "addTime"
prop: "addTime",
width: 160
},
{
label: "修改时间",
prop: "updateTime",
width: 160
}
];
// 表格按钮定义
@@ -195,40 +232,48 @@ export const dlgTitle = ref("");
const editFormDataGen = () => {
return {
application: "",
apiName: "",
apiVersion: "",
status: 1,
isPermission: 0,
description: "",
regSource: 1,
isNeedToken: 0
};
};
export const editFormData = ref<FieldValues>(editFormDataGen());
export const editFormData = ref<any>(editFormDataGen());
export const editFormRules = {
application: [{ required: true, message: "请输入应用名称" }],
apiName: [{ required: true, message: "请输入接口名称" }],
apiVersion: [{ required: true, message: "请输入版本号" }],
description: [{ required: true, message: "请输入接口描述" }]
};
export const isCustomRegSource = computed(() => {
return editFormData.value.regSource === RegSource.CUSTOM;
});
// 表单内容
export const editFormColumns: PlusColumn[] = [
{
label: "应用名称",
prop: "application",
valueType: "copy"
valueType: "text"
},
{
label: "接口名称",
prop: "apiName",
valueType: "copy"
valueType: "text"
},
{
label: "版本号",
prop: "apiVersion",
valueType: "copy"
valueType: "text"
},
{
label: "接口描述",
prop: "description",
valueType: "copy"
valueType: "text"
},
{
label: "备注",
@@ -247,12 +292,12 @@ export const editFormColumns: PlusColumn[] = [
options: [
{
label: "否",
value: 0,
value: YesOrNoEnum.NO,
color: "red"
},
{
label: "是",
value: 1,
value: YesOrNoEnum.YES,
color: "green"
}
]
@@ -264,12 +309,12 @@ export const editFormColumns: PlusColumn[] = [
options: [
{
label: "否",
value: 0,
value: YesOrNoEnum.NO,
color: "red"
},
{
label: "是",
value: 1,
value: YesOrNoEnum.YES,
color: "green"
}
]
@@ -281,12 +326,12 @@ export const editFormColumns: PlusColumn[] = [
options: [
{
label: "禁用",
value: 0,
value: StatusEnum.DISABLE,
color: "red"
},
{
label: "启用",
value: 1,
value: StatusEnum.ENABLE,
color: "green"
}
]

View File

@@ -10,6 +10,7 @@ import {
handlePaginationChange,
handleSave,
handleSearch,
isCustomRegSource,
pageInfo,
searchFormColumns,
searchFormData,
@@ -40,6 +41,7 @@ import {
pageSizeList: [10, 20, 50, 100],
align: 'right'
}"
adaptive
@paginationChange="handlePaginationChange"
>
<template #title>
@@ -56,7 +58,49 @@ import {
labelWidth: '100px',
labelPosition: 'right'
}"
:hasErrorTip="false"
@confirm="handleSave"
/>
>
<template #plus-field-application>
<el-input
v-if="isCustomRegSource"
v-model="editFormData.application"
placeholder="请输入所属应用"
/>
<span v-else>
{{ editFormData.application }}
</span>
</template>
<template #plus-field-apiName>
<el-input
v-if="isCustomRegSource"
v-model="editFormData.apiName"
placeholder="请输入接口名称,如:goods.get"
/>
<span v-else>
{{ editFormData.apiName }}
</span>
</template>
<template #plus-field-apiVersion>
<el-input
v-if="isCustomRegSource"
v-model="editFormData.apiVersion"
placeholder="请输入接口版本,如:1.0"
/>
<span v-else>
{{ editFormData.apiVersion }}
</span>
</template>
<template #plus-field-description>
<el-input
v-if="isCustomRegSource"
v-model="editFormData.description"
placeholder="请输入接口描述"
/>
<span v-else>
{{ editFormData.description }}
</span>
</template>
</PlusDialogForm>
</el-card>
</template>