mirror of
https://gitee.com/JavaLionLi/plus-ui.git
synced 2026-09-13 07:43:43 +08:00
Pre Merge pull request !272 from 美妙/devA_hzy
This commit is contained in:
commit
3ac35695fd
23
src/api/biz/apiTest/index.ts
Normal file
23
src/api/biz/apiTest/index.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 测试 fetchVideoSearchV2
|
||||
*/
|
||||
export const fetchVideoSearchV2 = (data: Record<string, any>) => {
|
||||
return request({
|
||||
url: '/biz/apiTest/fetchVideoSearchV2',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 测试 fetchVideoComments
|
||||
*/
|
||||
export const fetchVideoComments = (data: Record<string, any>) => {
|
||||
return request({
|
||||
url: '/biz/apiTest/fetchVideoComments',
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
};
|
||||
41
src/api/biz/definition/index.ts
Normal file
41
src/api/biz/definition/index.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { DefinitionForm, DefinitionQuery, DefinitionVO } from '@/api/biz/definition/types';
|
||||
|
||||
export function listDefinition(query?: DefinitionQuery): AxiosPromise<DefinitionVO[]> {
|
||||
return request({
|
||||
url: '/biz/definition/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
export function getDefinition(apiId: string | number): AxiosPromise<DefinitionVO> {
|
||||
return request({
|
||||
url: '/biz/definition/' + apiId,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
export function addDefinition(data: DefinitionForm) {
|
||||
return request({
|
||||
url: '/biz/definition',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
export function updateDefinition(data: DefinitionForm) {
|
||||
return request({
|
||||
url: '/biz/definition',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
export function delDefinition(apiId: string | number | Array<string | number>) {
|
||||
return request({
|
||||
url: '/biz/definition/' + apiId,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
39
src/api/biz/definition/types.ts
Normal file
39
src/api/biz/definition/types.ts
Normal file
@ -0,0 +1,39 @@
|
||||
export interface DefinitionVO {
|
||||
apiId: string | number;
|
||||
platformId: string | number;
|
||||
platformName: string;
|
||||
baseUrl: string;
|
||||
apiCode: string;
|
||||
apiName: string;
|
||||
apiUri: string;
|
||||
fullUrl: string;
|
||||
requestMethod: string;
|
||||
pointsCost: number;
|
||||
timeout: number;
|
||||
contentType: string;
|
||||
status: string;
|
||||
remark: string;
|
||||
createTime: string;
|
||||
}
|
||||
|
||||
export interface DefinitionForm extends BaseEntity {
|
||||
apiId?: string | number;
|
||||
platformId?: string | number;
|
||||
apiCode?: string;
|
||||
apiName?: string;
|
||||
apiUri?: string;
|
||||
requestMethod?: string;
|
||||
pointsCost?: number;
|
||||
timeout?: number;
|
||||
contentType?: string;
|
||||
status?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface DefinitionQuery extends PageQuery {
|
||||
platformId?: string | number;
|
||||
apiCode?: string;
|
||||
apiName?: string;
|
||||
requestMethod?: string;
|
||||
status?: string;
|
||||
}
|
||||
18
src/api/biz/invokeRecord/index.ts
Normal file
18
src/api/biz/invokeRecord/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { InvokeRecordQuery, InvokeRecordVO } from '@/api/biz/invokeRecord/types';
|
||||
|
||||
export function listInvokeRecord(query?: InvokeRecordQuery): AxiosPromise<InvokeRecordVO[]> {
|
||||
return request({
|
||||
url: '/biz/invokeRecord/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
export function getInvokeRecord(recordId: string | number): AxiosPromise<InvokeRecordVO> {
|
||||
return request({
|
||||
url: '/biz/invokeRecord/' + recordId,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
25
src/api/biz/invokeRecord/types.ts
Normal file
25
src/api/biz/invokeRecord/types.ts
Normal file
@ -0,0 +1,25 @@
|
||||
export interface InvokeRecordVO {
|
||||
recordId: string | number;
|
||||
tenantId?: string;
|
||||
platformCode: string;
|
||||
platformName: string;
|
||||
apiCode: string;
|
||||
apiName: string;
|
||||
userName: string;
|
||||
requestTime: string;
|
||||
requestMethod: string;
|
||||
pointsCost: number;
|
||||
bizCode: number;
|
||||
httpStatus: number;
|
||||
elapsedMs: number;
|
||||
requestParams?: string;
|
||||
requestUrl?: string;
|
||||
}
|
||||
|
||||
export interface InvokeRecordQuery extends PageQuery {
|
||||
platformCode?: string;
|
||||
apiCode?: string;
|
||||
userName?: string;
|
||||
beginRequestTime?: string;
|
||||
endRequestTime?: string;
|
||||
}
|
||||
63
src/api/biz/platform/index.ts
Normal file
63
src/api/biz/platform/index.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import request from '@/utils/request';
|
||||
import { AxiosPromise } from 'axios';
|
||||
import { PlatformForm, PlatformOptionVO, PlatformQuery, PlatformVO } from '@/api/biz/platform/types';
|
||||
|
||||
export function listPlatform(query?: PlatformQuery): AxiosPromise<PlatformVO[]> {
|
||||
return request({
|
||||
url: '/biz/platform/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
export function getPlatform(platformId: string | number): AxiosPromise<PlatformVO> {
|
||||
return request({
|
||||
url: '/biz/platform/' + platformId,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
export function optionselectPlatform(): AxiosPromise<PlatformOptionVO[]> {
|
||||
return request({
|
||||
url: '/biz/platform/optionselect',
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
export function addPlatform(data: PlatformForm) {
|
||||
return request({
|
||||
url: '/biz/platform',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
export function updatePlatform(data: PlatformForm) {
|
||||
return request({
|
||||
url: '/biz/platform',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
export function delPlatform(platformId: string | number | Array<string | number>) {
|
||||
return request({
|
||||
url: '/biz/platform/' + platformId,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
export function changePlatformStatus(platformId: string | number, status: string) {
|
||||
return request({
|
||||
url: '/biz/platform/changeStatus',
|
||||
method: 'put',
|
||||
data: { platformId, status }
|
||||
});
|
||||
}
|
||||
|
||||
export function resetPlatformSecret(platformId: string | number) {
|
||||
return request({
|
||||
url: '/biz/platform/resetSecret/' + platformId,
|
||||
method: 'put'
|
||||
});
|
||||
}
|
||||
42
src/api/biz/platform/types.ts
Normal file
42
src/api/biz/platform/types.ts
Normal file
@ -0,0 +1,42 @@
|
||||
export interface PlatformVO {
|
||||
platformId: string | number;
|
||||
platformCode: string;
|
||||
platformName: string;
|
||||
baseUrl: string;
|
||||
appKey: string;
|
||||
appSecret: string;
|
||||
token: string;
|
||||
tokenExpireTime: string;
|
||||
authType: string;
|
||||
status: string;
|
||||
remark: string;
|
||||
createTime: string;
|
||||
}
|
||||
|
||||
export interface PlatformOptionVO {
|
||||
platformId: string | number;
|
||||
platformCode: string;
|
||||
platformName: string;
|
||||
baseUrl: string;
|
||||
}
|
||||
|
||||
export interface PlatformForm extends BaseEntity {
|
||||
platformId?: string | number;
|
||||
platformCode?: string;
|
||||
platformName?: string;
|
||||
baseUrl?: string;
|
||||
appKey?: string;
|
||||
appSecret?: string;
|
||||
token?: string;
|
||||
tokenExpireTime?: string;
|
||||
authType?: string;
|
||||
status?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface PlatformQuery extends PageQuery {
|
||||
platformCode?: string;
|
||||
platformName?: string;
|
||||
authType?: string;
|
||||
status?: string;
|
||||
}
|
||||
102
src/api/linkflow/org/index.ts
Normal file
102
src/api/linkflow/org/index.ts
Normal file
@ -0,0 +1,102 @@
|
||||
import request from '@/utils/request';
|
||||
import { TenantDetailVO, TenantDetailQuery, TenantDetailForm } from './types';
|
||||
import { AxiosPromise } from 'axios';
|
||||
|
||||
// 查询LinkFlow租户列表
|
||||
export function listLinkflowTenant(query: TenantDetailQuery): AxiosPromise<TenantDetailVO[]> {
|
||||
return request({
|
||||
url: '/linkflow/tenant/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
// 查询租户详情
|
||||
export function getLinkflowTenant(tenantId: string | number): AxiosPromise<TenantDetailVO> {
|
||||
return request({
|
||||
url: '/linkflow/tenant/' + tenantId,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 新增租户
|
||||
export function addLinkflowTenant(data: TenantDetailForm) {
|
||||
return request({
|
||||
url: '/linkflow/tenant',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 修改租户
|
||||
export function updateLinkflowTenant(data: TenantDetailForm) {
|
||||
return request({
|
||||
url: '/linkflow/tenant',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
}
|
||||
|
||||
// 切换业务状态
|
||||
export function changeOrgStatus(tenantId: string, orgStatus: string) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/changeOrgStatus',
|
||||
method: 'put',
|
||||
data: { tenantId, orgStatus }
|
||||
});
|
||||
}
|
||||
|
||||
// 删除租户
|
||||
export function delLinkflowTenant(ids: string | number | Array<string | number>) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/' + ids,
|
||||
method: 'delete'
|
||||
});
|
||||
}
|
||||
|
||||
// 导出租户
|
||||
export function exportLinkflowTenant(data: any) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/export',
|
||||
method: 'post',
|
||||
data: data,
|
||||
responseType: 'blob'
|
||||
});
|
||||
}
|
||||
|
||||
// ========== 通知相关 ==========
|
||||
|
||||
// 查询通知列表(tenantId 可选,后端自动兜底)
|
||||
export function listNotifications(tenantId?: string) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/notifications',
|
||||
method: 'get',
|
||||
params: tenantId ? { tenantId } : {}
|
||||
});
|
||||
}
|
||||
|
||||
// 标记已读
|
||||
export function markNotificationRead(id: number | string) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/notifications/' + id + '/read',
|
||||
method: 'put'
|
||||
});
|
||||
}
|
||||
|
||||
// 全部已读
|
||||
export function markAllNotificationsRead(tenantId?: string) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/notifications/readAll',
|
||||
method: 'put',
|
||||
params: tenantId ? { tenantId } : {}
|
||||
});
|
||||
}
|
||||
|
||||
// 未读数量
|
||||
export function getUnreadCount(tenantId?: string) {
|
||||
return request({
|
||||
url: '/linkflow/tenant/notifications/unreadCount',
|
||||
method: 'get',
|
||||
params: tenantId ? { tenantId } : {}
|
||||
});
|
||||
}
|
||||
64
src/api/linkflow/org/types.ts
Normal file
64
src/api/linkflow/org/types.ts
Normal file
@ -0,0 +1,64 @@
|
||||
export interface TenantDetailVO extends BaseEntity {
|
||||
id: number | string;
|
||||
tenantId: string;
|
||||
companyName: string;
|
||||
contactUserName: string;
|
||||
contactPhone: string;
|
||||
domain: string;
|
||||
packageId: number | string;
|
||||
packageName: string;
|
||||
expireTime: string;
|
||||
accountCount: number;
|
||||
status: string;
|
||||
// lf_tenant_ext 字段
|
||||
extId: number | string;
|
||||
monthlyQuota: number;
|
||||
usedQuota: number;
|
||||
platformCount: number;
|
||||
orgStatus: string;
|
||||
remark: string;
|
||||
// 管理员信息
|
||||
phonenumber: string;
|
||||
// 计算字段
|
||||
quotaUsageRate: number;
|
||||
daysToExpire: number;
|
||||
}
|
||||
|
||||
export interface TenantDetailQuery extends PageQuery {
|
||||
companyName?: string;
|
||||
contactUserName?: string;
|
||||
orgStatus?: string;
|
||||
packageId?: number | string;
|
||||
}
|
||||
|
||||
export interface TenantDetailForm {
|
||||
id?: number | string | undefined;
|
||||
tenantId?: string | undefined;
|
||||
companyName: string;
|
||||
contactUserName: string;
|
||||
contactPhone: string;
|
||||
domain?: string;
|
||||
packageId: number | string;
|
||||
expireTime: string;
|
||||
accountCount: number;
|
||||
// 新增租户时需要(RuoYi 创建租户同时创建管理员用户)
|
||||
username?: string;
|
||||
password?: string;
|
||||
phonenumber?: string;
|
||||
// lf_tenant_ext
|
||||
extId?: number | string | undefined;
|
||||
monthlyQuota: number;
|
||||
platformCount: number;
|
||||
remark?: string;
|
||||
orgStatus?: string;
|
||||
}
|
||||
|
||||
export interface NotificationVO {
|
||||
id: number | string;
|
||||
tenantId: string;
|
||||
type: string;
|
||||
title: string;
|
||||
content: string;
|
||||
isRead: string;
|
||||
createTime: string;
|
||||
}
|
||||
39
src/api/linkflow/quota/index.ts
Normal file
39
src/api/linkflow/quota/index.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import request from '@/utils/request';
|
||||
import { QuotaVO, QuotaQuery } from './types';
|
||||
import { AxiosPromise } from 'axios';
|
||||
|
||||
// 查询配额列表
|
||||
export function listQuota(query: QuotaQuery): AxiosPromise<QuotaVO[]> {
|
||||
return request({
|
||||
url: '/linkflow/quota/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
// 查询单个租户配额
|
||||
export function getQuota(tenantId: string | number): AxiosPromise<QuotaVO> {
|
||||
return request({
|
||||
url: '/linkflow/quota/' + tenantId,
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
// 调整配额
|
||||
export function adjustQuota(tenantId: string, newMonthlyQuota: number) {
|
||||
return request({
|
||||
url: '/linkflow/quota/adjust',
|
||||
method: 'put',
|
||||
params: { tenantId, newMonthlyQuota }
|
||||
});
|
||||
}
|
||||
|
||||
// 导出配额
|
||||
export function exportQuota(data: any) {
|
||||
return request({
|
||||
url: '/linkflow/quota/export',
|
||||
method: 'post',
|
||||
data: data,
|
||||
responseType: 'blob'
|
||||
});
|
||||
}
|
||||
2
src/api/linkflow/quota/types.ts
Normal file
2
src/api/linkflow/quota/types.ts
Normal file
@ -0,0 +1,2 @@
|
||||
// 配额 VO 复用 TenantDetailVO(包含配额使用率等计算字段)
|
||||
export type { TenantDetailVO as QuotaVO, TenantDetailQuery as QuotaQuery } from '../org/types';
|
||||
@ -47,6 +47,8 @@
|
||||
</el-popover>
|
||||
</div>
|
||||
</el-tooltip>
|
||||
<!-- LinkFlow 系统通知 -->
|
||||
<lf-notification />
|
||||
<el-tooltip content="Github" effect="dark" placement="bottom">
|
||||
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
|
||||
</el-tooltip>
|
||||
@ -102,6 +104,7 @@ import { getTenantList } from '@/api/login';
|
||||
import { dynamicClear, dynamicTenant } from '@/api/system/tenant';
|
||||
import { TenantVO } from '@/api/types';
|
||||
import notice from './notice/index.vue';
|
||||
import LfNotification from '@/components/LfNotification/index.vue';
|
||||
import router from '@/router';
|
||||
import { ElMessageBoxOptions } from 'element-plus/es/components/message-box/src/message-box.type';
|
||||
import { NavTypeEnum } from '@/enums/NavTypeEnum';
|
||||
|
||||
332
src/views/biz/apiDefinition/index.vue
Normal file
332
src/views/biz/apiDefinition/index.vue
Normal file
@ -0,0 +1,332 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="search">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="85px">
|
||||
<el-form-item label="接口名称" prop="apiName">
|
||||
<el-input v-model="queryParams.apiName" placeholder="请输入接口名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="所属平台" prop="platformId">
|
||||
<el-select v-model="queryParams.platformId" placeholder="请选择平台" clearable>
|
||||
<el-option
|
||||
v-for="item in platformOptions"
|
||||
:key="item.platformId"
|
||||
:label="item.platformName + ' (' + item.platformCode + ')'"
|
||||
:value="item.platformId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="请求方式" prop="requestMethod">
|
||||
<el-select v-model="queryParams.requestMethod" placeholder="请求方式" clearable>
|
||||
<el-option v-for="dict in biz_request_method" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="状态" clearable>
|
||||
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:definition:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:definition:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:definition:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:definition:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="definitionList" border @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="接口编码" align="center" prop="apiCode" min-width="120" />
|
||||
<el-table-column label="接口名称" align="center" prop="apiName" min-width="120" />
|
||||
<el-table-column label="平台名称" align="center" prop="platformName" min-width="120" />
|
||||
<el-table-column label="完整地址" align="center" prop="fullUrl" min-width="240" show-overflow-tooltip />
|
||||
<el-table-column label="请求方式" align="center" prop="requestMethod" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="biz_request_method" :value="scope.row.requestMethod" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="消耗积分" align="center" prop="pointsCost" width="90" />
|
||||
<el-table-column label="状态" align="center" prop="status" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button v-hasPermi="['biz:definition:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button v-hasPermi="['biz:definition:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="dialog.visible" :title="dialog.title" width="650px" append-to-body>
|
||||
<el-form ref="definitionFormRef" :model="form" :rules="rules" label-width="110px">
|
||||
<el-form-item label="所属平台" prop="platformId">
|
||||
<el-select v-model="form.platformId" placeholder="请选择平台" @change="handlePlatformChange">
|
||||
<el-option
|
||||
v-for="item in platformOptions"
|
||||
:key="item.platformId"
|
||||
:label="item.platformName + ' (' + item.platformCode + ')'"
|
||||
:value="item.platformId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="接口编码" prop="apiCode">
|
||||
<el-input v-model="form.apiCode" :disabled="!!form.apiId" placeholder="请输入接口编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="接口名称" prop="apiName">
|
||||
<el-input v-model="form.apiName" placeholder="请输入接口名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="访问URI" prop="apiUri">
|
||||
<el-input v-model="form.apiUri" placeholder="/v1/user/query" @input="updateFullUrlPreview" />
|
||||
</el-form-item>
|
||||
<el-form-item label="完整地址预览">
|
||||
<el-input :model-value="fullUrlPreview" readonly placeholder="选择平台并填写URI后自动生成" />
|
||||
</el-form-item>
|
||||
<el-form-item label="请求方式" prop="requestMethod">
|
||||
<el-select v-model="form.requestMethod" placeholder="请选择请求方式">
|
||||
<el-option v-for="dict in biz_request_method" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="消耗积分" prop="pointsCost">
|
||||
<el-input-number v-model="form.pointsCost" :min="0" controls-position="right" />
|
||||
</el-form-item>
|
||||
<el-form-item label="超时(秒)" prop="timeout">
|
||||
<el-input-number v-model="form.timeout" :min="1" controls-position="right" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Content-Type" prop="contentType">
|
||||
<el-select v-model="form.contentType" placeholder="请选择Content-Type" allow-create filterable default-first-option>
|
||||
<el-option label="application/json" value="application/json" />
|
||||
<el-option label="application/x-www-form-urlencoded" value="application/x-www-form-urlencoded" />
|
||||
<el-option label="multipart/form-data" value="multipart/form-data" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="dict in sys_normal_disable" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="BizApiDefinition" lang="ts">
|
||||
import { optionselectPlatform } from '@/api/biz/platform';
|
||||
import { PlatformOptionVO } from '@/api/biz/platform/types';
|
||||
import { addDefinition, delDefinition, getDefinition, listDefinition, updateDefinition } from '@/api/biz/definition';
|
||||
import { DefinitionForm, DefinitionQuery, DefinitionVO } from '@/api/biz/definition/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const dictData = proxy?.useDict('sys_normal_disable', 'biz_request_method') ?? {};
|
||||
const { sys_normal_disable, biz_request_method } = toRefs<any>(reactive(dictData));
|
||||
|
||||
const definitionList = ref<DefinitionVO[]>([]);
|
||||
const platformOptions = ref<PlatformOptionVO[]>([]);
|
||||
const fullUrlPreview = ref('');
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const definitionFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: DefinitionForm = {
|
||||
apiId: undefined,
|
||||
platformId: undefined,
|
||||
apiCode: undefined,
|
||||
apiName: undefined,
|
||||
apiUri: undefined,
|
||||
requestMethod: 'GET',
|
||||
pointsCost: 0,
|
||||
timeout: 30,
|
||||
contentType: 'application/json',
|
||||
status: '0',
|
||||
remark: undefined
|
||||
};
|
||||
|
||||
const data = reactive<PageData<DefinitionForm, DefinitionQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
platformId: undefined,
|
||||
apiName: undefined,
|
||||
requestMethod: undefined,
|
||||
status: undefined
|
||||
},
|
||||
rules: {
|
||||
platformId: [{ required: true, message: '所属平台不能为空', trigger: 'change' }],
|
||||
apiCode: [{ required: true, message: '接口编码不能为空', trigger: 'blur' }],
|
||||
apiName: [{ required: true, message: '接口名称不能为空', trigger: 'blur' }],
|
||||
apiUri: [{ required: true, message: '访问URI不能为空', trigger: 'blur' }],
|
||||
requestMethod: [{ required: true, message: '请求方式不能为空', trigger: 'change' }],
|
||||
pointsCost: [{ required: true, message: '消耗积分不能为空', trigger: 'blur' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
const buildFullUrl = (baseUrl?: string, apiUri?: string) => {
|
||||
if (!baseUrl || !apiUri) {
|
||||
return '';
|
||||
}
|
||||
const base = baseUrl.trim().replace(/\/+$/, '');
|
||||
let uri = apiUri.trim();
|
||||
if (!uri.startsWith('/')) {
|
||||
uri = '/' + uri;
|
||||
}
|
||||
return base + uri;
|
||||
};
|
||||
|
||||
const updateFullUrlPreview = () => {
|
||||
const platform = platformOptions.value.find((item) => item.platformId === form.value.platformId);
|
||||
fullUrlPreview.value = buildFullUrl(platform?.baseUrl, form.value.apiUri);
|
||||
};
|
||||
|
||||
const loadPlatformOptions = async () => {
|
||||
try {
|
||||
const res = await optionselectPlatform();
|
||||
platformOptions.value = res.data ?? [];
|
||||
} catch {
|
||||
platformOptions.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await listDefinition(queryParams.value);
|
||||
definitionList.value = res.rows ?? [];
|
||||
total.value = res.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
fullUrlPreview.value = '';
|
||||
definitionFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
const handleSelectionChange = (selection: DefinitionVO[]) => {
|
||||
ids.value = selection.map((item) => item.apiId);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
const handlePlatformChange = () => {
|
||||
updateFullUrlPreview();
|
||||
};
|
||||
|
||||
const handleAdd = async () => {
|
||||
reset();
|
||||
await loadPlatformOptions();
|
||||
dialog.visible = true;
|
||||
dialog.title = '新增接口定义';
|
||||
};
|
||||
|
||||
const handleUpdate = async (row?: DefinitionVO) => {
|
||||
reset();
|
||||
await loadPlatformOptions();
|
||||
const apiId = row?.apiId || ids.value[0];
|
||||
const res = await getDefinition(apiId);
|
||||
Object.assign(form.value, res.data);
|
||||
updateFullUrlPreview();
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改接口定义';
|
||||
};
|
||||
|
||||
const submitForm = () => {
|
||||
definitionFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.apiId) {
|
||||
await updateDefinition(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addDefinition(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleDelete = async (row?: DefinitionVO) => {
|
||||
const apiIds = row?.apiId || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除接口编号为"' + apiIds + '"的数据项?');
|
||||
await delDefinition(apiIds);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
const handleExport = () => {
|
||||
proxy?.download('biz/definition/export', { ...queryParams.value }, `definition_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await loadPlatformOptions();
|
||||
await getList();
|
||||
});
|
||||
</script>
|
||||
192
src/views/biz/apiTest/index.vue
Normal file
192
src/views/biz/apiTest/index.vue
Normal file
@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<span class="font-bold">接口测试</span>
|
||||
<span class="ml-2 text-gray-400 text-sm">调用 IBizDouyinSearchService,JSON 作为方法入参</span>
|
||||
</template>
|
||||
|
||||
<el-form label-width="100px">
|
||||
<el-form-item label="测试方法">
|
||||
<el-radio-group v-model="method">
|
||||
<el-radio label="fetchVideoSearchV2">fetchVideoSearchV2(视频搜索)</el-radio>
|
||||
<el-radio label="fetchVideoComments">fetchVideoComments(视频评论)</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="JSON 参数">
|
||||
<el-input
|
||||
v-model="jsonParams"
|
||||
type="textarea"
|
||||
:rows="14"
|
||||
placeholder="请输入 JSON 对象,例如: { "keyword": "CPU", "cursor": 0 }"
|
||||
spellcheck="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" :loading="loading" icon="VideoPlay" v-hasPermi="['biz:apiTest:invoke']" @click="handleInvoke">
|
||||
执行
|
||||
</el-button>
|
||||
<el-button icon="Document" @click="fillSample">填充示例</el-button>
|
||||
<el-button icon="Refresh" @click="clearResult">清空结果</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-if="persistSummary" shadow="never" class="mt-[10px]">
|
||||
<template #header>
|
||||
<span class="font-bold">落库结果</span>
|
||||
</template>
|
||||
<el-alert
|
||||
v-if="persistSummary.error"
|
||||
type="warning"
|
||||
:title="String(persistSummary.error)"
|
||||
show-icon
|
||||
:closable="false"
|
||||
class="mb-2"
|
||||
/>
|
||||
<el-descriptions v-else :column="3" border size="small">
|
||||
<el-descriptions-item v-for="(val, key) in persistSummary" :key="key" :label="String(key)">
|
||||
{{ val }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="mt-[10px]">
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="font-bold">响应结果</span>
|
||||
<el-tag v-if="elapsedMs !== null" type="info" size="small">耗时 {{ elapsedMs }} ms</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="!responseText" class="text-gray-400 text-sm py-8 text-center">执行后将在此展示接口返回 JSON</div>
|
||||
<pre v-else class="response-pre">{{ responseText }}</pre>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="ApiTest" lang="ts">
|
||||
import { fetchVideoComments, fetchVideoSearchV2 } from '@/api/biz/apiTest';
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
type TestMethod = 'fetchVideoSearchV2' | 'fetchVideoComments';
|
||||
|
||||
const SAMPLE_PARAMS: Record<TestMethod, string> = {
|
||||
fetchVideoSearchV2: JSON.stringify(
|
||||
{
|
||||
keyword: 'CPU',
|
||||
cursor: 0
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
fetchVideoComments: JSON.stringify(
|
||||
{
|
||||
aweme_id: '7448118827402972455',
|
||||
count: 20
|
||||
},
|
||||
null,
|
||||
2
|
||||
)
|
||||
};
|
||||
|
||||
const method = ref<TestMethod>('fetchVideoSearchV2');
|
||||
const jsonParams = ref(SAMPLE_PARAMS.fetchVideoSearchV2);
|
||||
const responseText = ref('');
|
||||
const persistSummary = ref<Record<string, unknown> | null>(null);
|
||||
const loading = ref(false);
|
||||
const elapsedMs = ref<number | null>(null);
|
||||
|
||||
watch(method, (val) => {
|
||||
jsonParams.value = SAMPLE_PARAMS[val];
|
||||
responseText.value = '';
|
||||
persistSummary.value = null;
|
||||
elapsedMs.value = null;
|
||||
});
|
||||
|
||||
const parseParams = (): Record<string, any> => {
|
||||
const text = jsonParams.value?.trim();
|
||||
if (!text) {
|
||||
return {};
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
throw new Error('参数必须是 JSON 对象');
|
||||
}
|
||||
return parsed;
|
||||
} catch (e: any) {
|
||||
throw new Error('JSON 格式错误:' + (e?.message || '无法解析'));
|
||||
}
|
||||
};
|
||||
|
||||
const formatResponse = (data: unknown): string => {
|
||||
try {
|
||||
return JSON.stringify(data, null, 2);
|
||||
} catch {
|
||||
return String(data);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvoke = async () => {
|
||||
let params: Record<string, any>;
|
||||
try {
|
||||
params = parseParams();
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e.message);
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
const start = Date.now();
|
||||
try {
|
||||
const res =
|
||||
method.value === 'fetchVideoSearchV2'
|
||||
? await fetchVideoSearchV2(params)
|
||||
: await fetchVideoComments(params);
|
||||
elapsedMs.value = Date.now() - start;
|
||||
const payload = res.data as Record<string, unknown>;
|
||||
persistSummary.value = (payload?.persist as Record<string, unknown>) ?? null;
|
||||
responseText.value = formatResponse(payload);
|
||||
if (persistSummary.value?.error) {
|
||||
ElMessage.warning('接口调用成功,但落库未执行:' + persistSummary.value.error);
|
||||
} else if (persistSummary.value) {
|
||||
ElMessage.success('调用成功,落库已完成');
|
||||
} else {
|
||||
ElMessage.success('调用成功');
|
||||
}
|
||||
} catch (e: any) {
|
||||
elapsedMs.value = Date.now() - start;
|
||||
responseText.value = e?.message || '请求失败';
|
||||
ElMessage.error('调用失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const fillSample = () => {
|
||||
jsonParams.value = SAMPLE_PARAMS[method.value];
|
||||
};
|
||||
|
||||
const clearResult = () => {
|
||||
responseText.value = '';
|
||||
persistSummary.value = null;
|
||||
elapsedMs.value = null;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.response-pre {
|
||||
margin: 0;
|
||||
padding: 12px;
|
||||
background: var(--el-fill-color-light);
|
||||
border-radius: 4px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
max-height: 600px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
177
src/views/biz/invokeRecord/index.vue
Normal file
177
src/views/biz/invokeRecord/index.vue
Normal file
@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="search">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="85px">
|
||||
<el-form-item label="平台编码" prop="platformCode">
|
||||
<el-input v-model="queryParams.platformCode" placeholder="请输入平台编码" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="接口编码" prop="apiCode">
|
||||
<el-input v-model="queryParams.apiCode" placeholder="请输入接口编码" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="请求用户" prop="userName">
|
||||
<el-input v-model="queryParams.userName" placeholder="请输入用户名" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="请求时间">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="datetimerange"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
range-separator="-"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:invokeRecord:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="recordList" border>
|
||||
<el-table-column label="平台编码" align="center" prop="platformCode" min-width="100" />
|
||||
<el-table-column label="平台名称" align="center" prop="platformName" min-width="120" />
|
||||
<el-table-column label="接口编码" align="center" prop="apiCode" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="接口名称" align="center" prop="apiName" min-width="120" />
|
||||
<el-table-column label="请求用户" align="center" prop="userName" width="100" />
|
||||
<el-table-column label="请求时间" align="center" prop="requestTime" width="160" />
|
||||
<el-table-column label="请求方式" align="center" prop="requestMethod" width="90" />
|
||||
<el-table-column label="消耗积分" align="center" prop="pointsCost" width="90" />
|
||||
<el-table-column label="业务code" align="center" prop="bizCode" width="90" />
|
||||
<el-table-column label="HTTP状态" align="center" prop="httpStatus" width="90" />
|
||||
<el-table-column label="耗时(ms)" align="center" prop="elapsedMs" width="90" />
|
||||
<el-table-column label="操作" align="center" width="80" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="详情" placement="top">
|
||||
<el-button v-hasPermi="['biz:invokeRecord:query']" link type="primary" icon="View" @click="handleDetail(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="detailDialog.visible" title="调用记录详情" width="700px" append-to-body>
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="平台">{{ detailDialog.data.platformName }} ({{ detailDialog.data.platformCode }})</el-descriptions-item>
|
||||
<el-descriptions-item label="接口">{{ detailDialog.data.apiName }} ({{ detailDialog.data.apiCode }})</el-descriptions-item>
|
||||
<el-descriptions-item label="请求用户">{{ detailDialog.data.userName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="请求时间">{{ detailDialog.data.requestTime }}</el-descriptions-item>
|
||||
<el-descriptions-item label="请求方式">{{ detailDialog.data.requestMethod }}</el-descriptions-item>
|
||||
<el-descriptions-item label="消耗积分">{{ detailDialog.data.pointsCost }}</el-descriptions-item>
|
||||
<el-descriptions-item label="业务code">{{ detailDialog.data.bizCode }}</el-descriptions-item>
|
||||
<el-descriptions-item label="HTTP状态">{{ detailDialog.data.httpStatus }}</el-descriptions-item>
|
||||
<el-descriptions-item label="耗时">{{ detailDialog.data.elapsedMs }} ms</el-descriptions-item>
|
||||
<el-descriptions-item label="请求URL">{{ detailDialog.data.requestUrl || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="请求参数">
|
||||
<pre class="json-pre">{{ formatJson(detailDialog.data.requestParams) }}</pre>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="InvokeRecord" lang="ts">
|
||||
import { listInvokeRecord, getInvokeRecord } from '@/api/biz/invokeRecord';
|
||||
import { InvokeRecordQuery, InvokeRecordVO } from '@/api/biz/invokeRecord/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
|
||||
const recordList = ref<InvokeRecordVO[]>([]);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const total = ref(0);
|
||||
const dateRange = ref<[string, string]>();
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
|
||||
const queryParams = ref<InvokeRecordQuery>({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
platformCode: undefined,
|
||||
apiCode: undefined,
|
||||
userName: undefined
|
||||
});
|
||||
|
||||
const detailDialog = reactive<{ visible: boolean; data: Partial<InvokeRecordVO> }>({
|
||||
visible: false,
|
||||
data: {}
|
||||
});
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const params = { ...queryParams.value };
|
||||
if (dateRange.value) {
|
||||
params.beginRequestTime = dateRange.value[0];
|
||||
params.endRequestTime = dateRange.value[1];
|
||||
}
|
||||
const res = await listInvokeRecord(params);
|
||||
recordList.value = res.rows ?? [];
|
||||
total.value = res.total ?? 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
dateRange.value = undefined;
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
const handleDetail = async (row: InvokeRecordVO) => {
|
||||
const res = await getInvokeRecord(row.recordId);
|
||||
detailDialog.data = res.data ?? row;
|
||||
detailDialog.visible = true;
|
||||
};
|
||||
|
||||
const handleExport = () => {
|
||||
const params = { ...queryParams.value };
|
||||
if (dateRange.value) {
|
||||
params.beginRequestTime = dateRange.value[0];
|
||||
params.endRequestTime = dateRange.value[1];
|
||||
}
|
||||
proxy?.download('biz/invokeRecord/export', params, `invoke_record_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
const formatJson = (jsonStr?: string) => {
|
||||
if (!jsonStr) return '-';
|
||||
try {
|
||||
return JSON.stringify(JSON.parse(jsonStr), null, 2);
|
||||
} catch {
|
||||
return jsonStr;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.json-pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
291
src/views/biz/platform/index.vue
Normal file
291
src/views/biz/platform/index.vue
Normal file
@ -0,0 +1,291 @@
|
||||
<template>
|
||||
<div class="p-2">
|
||||
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||
<div v-show="showSearch" class="search">
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="85px">
|
||||
<el-form-item label="平台名称" prop="platformName">
|
||||
<el-input v-model="queryParams.platformName" placeholder="请输入平台名称" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="平台编码" prop="platformCode">
|
||||
<el-input v-model="queryParams.platformCode" placeholder="请输入平台编码" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="状态" clearable>
|
||||
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:platform:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:platform:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()">修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:platform:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()">删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-hasPermi="['biz:platform:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar v-model:show-search="showSearch" @query-table="getList"></right-toolbar>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" :data="platformList" border @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="平台编码" align="center" prop="platformCode" min-width="100" />
|
||||
<el-table-column label="平台名称" align="center" prop="platformName" min-width="120" />
|
||||
<el-table-column label="请求地址" align="center" prop="baseUrl" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="AppKey" align="center" prop="appKey" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="AppSecret" align="center" prop="appSecret" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="Token" align="center" prop="token" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="认证方式" align="center" prop="authType" width="120">
|
||||
<template #default="scope">
|
||||
<dict-tag :options="biz_auth_type" :value="scope.row.authType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" align="center" width="80">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button v-hasPermi="['biz:platform:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button v-hasPermi="['biz:platform:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" :total="total" @pagination="getList" />
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="dialog.visible" :title="dialog.title" width="600px" append-to-body>
|
||||
<el-form ref="platformFormRef" :model="form" :rules="rules" label-width="110px">
|
||||
<el-form-item label="平台编码" prop="platformCode">
|
||||
<el-input v-model="form.platformCode" :disabled="!!form.platformId" placeholder="请输入平台编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="平台名称" prop="platformName">
|
||||
<el-input v-model="form.platformName" placeholder="请输入平台名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="请求地址" prop="baseUrl">
|
||||
<el-input v-model="form.baseUrl" placeholder="https://api.example.com" />
|
||||
</el-form-item>
|
||||
<el-form-item label="认证方式" prop="authType">
|
||||
<el-radio-group v-model="form.authType">
|
||||
<el-radio v-for="dict in biz_auth_type" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="AppKey" prop="appKey">
|
||||
<el-input v-model="form.appKey" placeholder="请输入AppKey" />
|
||||
</el-form-item>
|
||||
<el-form-item label="AppSecret" prop="appSecret">
|
||||
<el-input v-model="form.appSecret" type="password" show-password placeholder="请输入AppSecret" />
|
||||
<el-button v-if="form.platformId" class="ml-2" type="warning" plain @click="handleResetSecret">重置</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="Token" prop="token">
|
||||
<el-input v-model="form.token" type="password" show-password placeholder="请输入Token" />
|
||||
</el-form-item>
|
||||
<el-form-item label="Token过期时间" prop="tokenExpireTime">
|
||||
<el-date-picker v-model="form.tokenExpireTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择Token过期时间" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio v-for="dict in sys_normal_disable" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="BizPlatform" lang="ts">
|
||||
import {
|
||||
addPlatform,
|
||||
changePlatformStatus,
|
||||
delPlatform,
|
||||
getPlatform,
|
||||
listPlatform,
|
||||
resetPlatformSecret,
|
||||
updatePlatform
|
||||
} from '@/api/biz/platform';
|
||||
import { PlatformForm, PlatformQuery, PlatformVO } from '@/api/biz/platform/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
const { sys_normal_disable, biz_auth_type } = toRefs<any>(proxy?.useDict('sys_normal_disable', 'biz_auth_type'));
|
||||
|
||||
const platformList = ref<PlatformVO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref<Array<string | number>>([]);
|
||||
const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const platformFormRef = ref<ElFormInstance>();
|
||||
|
||||
const dialog = reactive<DialogOption>({
|
||||
visible: false,
|
||||
title: ''
|
||||
});
|
||||
|
||||
const initFormData: PlatformForm = {
|
||||
platformId: undefined,
|
||||
platformCode: undefined,
|
||||
platformName: undefined,
|
||||
baseUrl: undefined,
|
||||
appKey: undefined,
|
||||
appSecret: undefined,
|
||||
token: undefined,
|
||||
tokenExpireTime: undefined,
|
||||
authType: '0',
|
||||
status: '0',
|
||||
remark: undefined
|
||||
};
|
||||
|
||||
const data = reactive<PageData<PlatformForm, PlatformQuery>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
platformCode: undefined,
|
||||
platformName: undefined,
|
||||
status: undefined
|
||||
},
|
||||
rules: {
|
||||
platformCode: [{ required: true, message: '平台编码不能为空', trigger: 'blur' }],
|
||||
platformName: [{ required: true, message: '平台名称不能为空', trigger: 'blur' }],
|
||||
baseUrl: [{ required: true, message: '请求地址不能为空', trigger: 'blur' }],
|
||||
authType: [{ required: true, message: '认证方式不能为空', trigger: 'change' }]
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true;
|
||||
const res = await listPlatform(queryParams.value);
|
||||
platformList.value = res.rows;
|
||||
total.value = res.total;
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
reset();
|
||||
dialog.visible = false;
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
form.value = { ...initFormData };
|
||||
platformFormRef.value?.resetFields();
|
||||
};
|
||||
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value?.resetFields();
|
||||
handleQuery();
|
||||
};
|
||||
|
||||
const handleSelectionChange = (selection: PlatformVO[]) => {
|
||||
ids.value = selection.map((item) => item.platformId);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
};
|
||||
|
||||
const handleAdd = () => {
|
||||
reset();
|
||||
dialog.visible = true;
|
||||
dialog.title = '新增接口平台';
|
||||
};
|
||||
|
||||
const handleUpdate = async (row?: PlatformVO) => {
|
||||
reset();
|
||||
const platformId = row?.platformId || ids.value[0];
|
||||
const res = await getPlatform(platformId);
|
||||
Object.assign(form.value, res.data);
|
||||
dialog.visible = true;
|
||||
dialog.title = '修改接口平台';
|
||||
};
|
||||
|
||||
const submitForm = () => {
|
||||
platformFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
if (form.value.platformId) {
|
||||
await updatePlatform(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await addPlatform(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
proxy?.$modal.msgSuccess('操作成功');
|
||||
dialog.visible = false;
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const handleDelete = async (row?: PlatformVO) => {
|
||||
const platformIds = row?.platformId || ids.value;
|
||||
await proxy?.$modal.confirm('是否确认删除平台编号为"' + platformIds + '"的数据项?');
|
||||
await delPlatform(platformIds);
|
||||
proxy?.$modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
const handleExport = () => {
|
||||
proxy?.download('biz/platform/export', { ...queryParams.value }, `platform_${new Date().getTime()}.xlsx`);
|
||||
};
|
||||
|
||||
const handleStatusChange = async (row: PlatformVO) => {
|
||||
const text = row.status === '0' ? '启用' : '停用';
|
||||
try {
|
||||
await proxy?.$modal.confirm('确认要"' + text + '""' + row.platformName + '"平台吗?');
|
||||
await changePlatformStatus(row.platformId, row.status);
|
||||
proxy?.$modal.msgSuccess(text + '成功');
|
||||
} catch {
|
||||
row.status = row.status === '0' ? '1' : '0';
|
||||
}
|
||||
};
|
||||
|
||||
const handleResetSecret = async () => {
|
||||
if (!form.value.platformId) {
|
||||
return;
|
||||
}
|
||||
await proxy?.$modal.confirm('确认要重置该平台的AppSecret吗?');
|
||||
const res = await resetPlatformSecret(form.value.platformId);
|
||||
form.value.appSecret = res.data;
|
||||
proxy?.$modal.msgSuccess('重置成功');
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user