This commit is contained in:
六如
2024-12-03 22:58:44 +08:00
parent 77b52508bb
commit c407261bd7
7 changed files with 86 additions and 4 deletions

View File

@@ -122,17 +122,23 @@ public class IsvInfoService implements LambdaService<IsvInfo, IsvInfoMapper> {
public IsvKeysDTO getKeys(Long isvId) { public IsvKeysDTO getKeys(Long isvId) {
IsvKeys isvKeys = isvKeysService.get(IsvKeys::getIsvId, isvId); IsvKeys isvKeys = isvKeysService.get(IsvKeys::getIsvId, isvId);
IsvKeysDTO isvKeysDTO;
if (isvKeys == null) { if (isvKeys == null) {
IsvKeysDTO isvKeysDTO = new IsvKeysDTO(); isvKeysDTO = new IsvKeysDTO();
isvKeysDTO.setIsvId(isvId); isvKeysDTO.setIsvId(isvId);
isvKeysDTO.setKeyFormat(RSATool.KeyFormat.PKCS8.getValue()); isvKeysDTO.setKeyFormat(RSATool.KeyFormat.PKCS8.getValue());
isvKeysDTO.setPublicKeyIsv(""); isvKeysDTO.setPublicKeyIsv("");
isvKeysDTO.setPrivateKeyIsv(""); isvKeysDTO.setPrivateKeyIsv("");
isvKeysDTO.setPublicKeyPlatform(""); isvKeysDTO.setPublicKeyPlatform("");
isvKeysDTO.setPrivateKeyPlatform(""); isvKeysDTO.setPrivateKeyPlatform("");
return isvKeysDTO; } else {
isvKeysDTO = CopyUtil.copyBean(isvKeys, IsvKeysDTO::new);
} }
return CopyUtil.copyBean(isvKeys, IsvKeysDTO::new);
IsvInfo isvInfo = this.getById(isvId);
isvKeysDTO.setAppId(isvInfo.getAppId());
return isvKeysDTO;
} }
/** /**

View File

@@ -8,6 +8,8 @@ import lombok.Data;
@Data @Data
public class IsvKeysDTO { public class IsvKeysDTO {
private String appId;
private Long isvId; private Long isvId;
/** /**

View File

@@ -0,0 +1,21 @@
/**
* 下载文件
*
* @param filename 文件名称,带后缀,如:aa.txt
* @param text 文件内容
*/
export function downloadText(filename, text) {
const element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(text)
);
element.setAttribute("download", filename);
element.style.display = "none";
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}

View File

@@ -21,6 +21,7 @@ import {
dlgKeysShow, dlgKeysShow,
showKeysFormColumns, showKeysFormColumns,
showKeysFormData, showKeysFormData,
downloadIsvKey,
viewKeys viewKeys
} from "./showKeys"; } from "./showKeys";
import { import {
@@ -98,8 +99,12 @@ import {
v-model="showKeysFormData" v-model="showKeysFormData"
:dialog="{ title: '秘钥 - 标识☆分配给开发者' }" :dialog="{ title: '秘钥 - 标识☆分配给开发者' }"
:form="{ group: showKeysFormColumns, labelPosition: 'right' }" :form="{ group: showKeysFormColumns, labelPosition: 'right' }"
@confirm="downloadIsvKey"
> >
<template #dialog-footer="{ handleCancel }"> <template #dialog-footer="{ handleCancel }">
<el-button type="success" @click="downloadIsvKey">
下载开发者秘钥
</el-button>
<el-button type="primary" @click="handleCancel">关闭</el-button> <el-button type="primary" @click="handleCancel">关闭</el-button>
</template> </template>
</PlusDialogForm> </PlusDialogForm>

View File

@@ -2,10 +2,12 @@ import { ref } from "vue";
import type { PlusFormGroupRow } from "plus-pro-components"; import type { PlusFormGroupRow } from "plus-pro-components";
import { api } from "@/api/isvList"; import { api } from "@/api/isvList";
import { KeyFormatEnum } from "@/model/enums"; import { KeyFormatEnum } from "@/model/enums";
import { downloadText } from "@/utils/file";
// 弹窗显示 // 弹窗显示
export const dlgKeysShow = ref(false); export const dlgKeysShow = ref(false);
export const showKeysFormData = ref<any>({ export const showKeysFormData = ref<any>({
appId: "",
keyFormat: KeyFormatEnum.PKCS8, keyFormat: KeyFormatEnum.PKCS8,
publicKeyIsv: "", publicKeyIsv: "",
privateKeyIsv: "", privateKeyIsv: "",
@@ -17,6 +19,15 @@ export const showKeysFormColumns: PlusFormGroupRow[] = [
{ {
title: "基本信息", title: "基本信息",
columns: [ columns: [
{
label: "AppId",
prop: "appId",
labelWidth: 100,
valueType: "text",
fieldProps: {
disabled: true
}
},
{ {
label: "秘钥格式", label: "秘钥格式",
prop: "keyFormat", prop: "keyFormat",
@@ -107,3 +118,23 @@ export const viewKeys = (row: any) => {
dlgKeysShow.value = true; dlgKeysShow.value = true;
}); });
}; };
const downloadTemplate = `AppID:
{appId}
开发者私钥:
{privateKeyIsv}
平台公钥:
{publicKeyPlatform}
`;
export const downloadIsvKey = () => {
let text = downloadTemplate
.replace("{appId}", showKeysFormData.value.appId)
.replace("{privateKeyIsv}", showKeysFormData.value.privateKeyIsv)
.replace("{publicKeyPlatform}", showKeysFormData.value.publicKeyPlatform);
downloadText(`key_${new Date().getTime()}.txt`, text);
};

View File

@@ -11,6 +11,8 @@ export const apiModules = ref([]);
export const dataNodeType = ref("Object"); export const dataNodeType = ref("Object");
export const requestParamsExample = ref({}); export const requestParamsExample = ref({});
export const responseParamsExample = ref({}); export const responseParamsExample = ref({});
export const defaultExpandedKeys = ref([]);
export const currentNodeKey = ref(0);
export const docAppId = ref(0); export const docAppId = ref(0);
export const docAppList = ref([]); export const docAppList = ref([]);
@@ -234,6 +236,16 @@ function loadDocTree(id) {
}; };
docApi.listDocTree(params).then(resp => { docApi.listDocTree(params).then(resp => {
docTree.value = resp.data; docTree.value = resp.data;
// 默认展开并选中第一个
if (docTree.value?.length > 0) {
defaultExpandedKeys.value.push(docTree.value[0].docId);
const children = docTree.value[0]?.children;
if (children && children.length > 0) {
const firstNode = children[0];
currentNodeKey.value = firstNode.docId;
handleNodeClick(firstNode);
}
}
}); });
} }

View File

@@ -15,7 +15,9 @@ import {
showUrl, showUrl,
showProdUrl, showProdUrl,
showSandBoxUrl, showSandBoxUrl,
showDoc showDoc,
defaultExpandedKeys,
currentNodeKey
} from "./index"; } from "./index";
import { ApiParamTable } from "@/components/ApiParamTable"; import { ApiParamTable } from "@/components/ApiParamTable";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
@@ -45,6 +47,9 @@ const defaultProps = {
<el-tree <el-tree
:data="docTree" :data="docTree"
:props="defaultProps" :props="defaultProps"
node-key="docId"
:default-expanded-keys="defaultExpandedKeys"
:current-node-key="currentNodeKey"
style="margin-top: 10px" style="margin-top: 10px"
highlight-current highlight-current
@node-click="handleNodeClick" @node-click="handleNodeClick"