fix[通用模块]:新增后端管理接口逻辑

This commit is contained in:
2025-02-10 17:54:33 +08:00
parent f78cb47f93
commit 8184407a6a
18 changed files with 304 additions and 13 deletions
@@ -12,7 +12,7 @@ const Settings: LayoutSettings & {
fixedHeader: false,
fixSiderbar: true,
colorWeak: false,
title: '开源项目演示环境',
title: 'Iking-Platform',
pwa: false,
logo: './logo.png',
iconfontUrl: '',
@@ -32,6 +32,10 @@
target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
'/api-order/': {
target: 'http://127.0.0.1:9900',
changeOrigin: true,
},
},
test: {
'/api/': {
@@ -47,6 +47,19 @@
}
],
},
{
path: '/orders',
routes: [
{
path: '/orders/order.html',
component: './orders/Order',
},
{
path: '/orders/orderFiles.html',
component: './orders/OrderFile',
}
],
},
{
path: '/search',
routes: [
@@ -4,7 +4,7 @@
"private": true,
"scripts": {
"analyze": "cross-env ANALYZE=1 umi build",
"build": "umi build",
"build": "node --openssl-legacy-provider umi build",
"deploy": "npm run build && npm run gh-pages",
"dev": "npm run start:dev",
"gh-pages": "gh-pages -d dist",
@@ -22,7 +22,7 @@
"prettier": "prettier -c --write \"src/**/*\"",
"serve": "umi-serve",
"start": "cross-env UMI_ENV=dev umi dev --port=8066",
"start:dev": "cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev",
"start:dev": "node --openssl-legacy-provider cross-env REACT_APP_ENV=dev MOCK=none UMI_ENV=dev umi dev",
"start:no-mock": "cross-env MOCK=none UMI_ENV=dev umi dev",
"start:no-ui": "cross-env UMI_UI=none UMI_ENV=dev umi dev",
"start:pre": "cross-env REACT_APP_ENV=pre UMI_ENV=dev umi dev",
@@ -86,7 +86,7 @@
"@umijs/preset-ant-design-pro": "^1.3.0",
"@umijs/preset-dumi": "^1.1.0",
"@umijs/preset-react": "^2.1.0",
"cross-env": "^7.0.0",
"cross-env": "^7.0.3",
"cross-port-killer": "^1.3.0",
"detect-installer": "^1.0.0",
"eslint": "^7.32.0",
@@ -38,7 +38,7 @@ export async function getInitialState(): Promise<{
try {
const msg = await queryCurrentUser();
// TODO
return msg.datas;
return msg.data;
} catch (error) {
history.push(loginPath);
}
@@ -6,7 +6,7 @@ const Footer: React.FC = () => {
const intl = useIntl();
const defaultMessage = intl.formatMessage({
id: 'app.copyright.produced',
defaultMessage: 'zlt版权所有:https://gitee.com/zlt2000/microservices-platform',
defaultMessage: '版权所有:https://gitee.com/L-Shilin/go-fly-platform-services.git',
});
// const currentYear = new Date().getFullYear();
@@ -18,7 +18,7 @@ const Footer: React.FC = () => {
{
key: 'github',
title: <GithubOutlined />,
href: 'https://github.com/zlt2000/microservices-platform',
href: 'https://gitee.com/L-Shilin/go-fly-platform-services.git',
blankTarget: true,
},
{
@@ -12,7 +12,7 @@
<meta name="description" content="
Out-of-the-box mid-stage front-end/design solution." />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>开源项目演示环境</title>
<title>Iking-Platform</title>
<link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" />
</head>
@@ -0,0 +1 @@
@import (reference) '~antd/es/style/themes/index';
@@ -0,0 +1,97 @@
import { order } from '@/services/orders/api';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import {
PageContainer,
ProFormText,
ProTable,
QueryFilter,
} from '@ant-design/pro-components';
import { Typography, message, Popconfirm } from 'antd';
import React, { useRef, useState } from 'react';
const { Link } = Typography;
// const handleDelete = async (deletefile: FILES.File) => {
// const hide = message.loading('正在删除');
// try {
// const result = await deleteFile(deletefile.id);
// hide();
// if (result.resp_code === 0) {
// message.success('删除File成功');
// return true;
// } else {
// message.error(result.resp_msg);
// return false;
// }
// } catch (error) {
// hide();
// message.error('删除File失败');
// return false;
// }
// };
const TableList: React.FC = () => {
const actionRef = useRef<ActionType>();
const [params, setParams] = useState<Record<string, string | number>>({ });
const columns: ProColumns<ORDERS.Order>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
},
{
title: '订单ID',
dataIndex: 'id',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateTime',
},
{
title: '操作',
key: 'action',
render: (_, entity) => <Popconfirm
title={`确认删除文件[${entity.id}]?`}
onConfirm={async () => {
// const success = await handleDelete(entity);
// if (success) {
// if (actionRef.current) {
// actionRef.current.reload();
// }
// }
}}
>
<Link>删除</Link>
</Popconfirm>,
},
];
return (
<PageContainer header={{ subTitle: '管理任务' }}>
<QueryFilter
defaultCollapsed
split
span={6}
className="query-filter"
onFinish={async (values) => setParams(values)}
>
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
</QueryFilter>
<ProTable<ORDERS.Order>
rowKey="id"
headerTitle="任务列表"
request={order}
actionRef={actionRef}
columns={columns}
search={false}
params={params}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
}}
/>
</PageContainer>
);
};
export default TableList;
@@ -0,0 +1 @@
@import (reference) '~antd/es/style/themes/index';
@@ -0,0 +1,114 @@
import { orderFiles,deleteFile } from '@/services/orders/api';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import {
PageContainer,
ProFormText,
ProTable,
QueryFilter,
} from '@ant-design/pro-components';
import { Typography, message, Popconfirm } from 'antd';
import React, { useRef, useState } from 'react';
const { Link } = Typography;
const handleDelete = async (deletefile: ORDERS.orderFile) => {
const hide = message.loading('正在删除');
try {
const result = await deleteFile(deletefile.id);
hide();
if (result.resp_code === 0) {
message.success('删除File成功');
return true;
} else {
message.error(result.resp_msg);
return false;
}
} catch (error) {
hide();
message.error('删除File失败');
return false;
}
};
const TableList: React.FC = () => {
const actionRef = useRef<ActionType>();
const [params, setParams] = useState<Record<string, string | number>>({ });
const columns: ProColumns<ORDERS.orderFile>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
},
{
title: '订单文件ID',
dataIndex: 'id',
},
{
title: '文件ID',
dataIndex: 'fileId',
},
{
title: '文件路径',
dataIndex: 'filePath',
},
{
title: '文件类型',
dataIndex: 'fileType',
},
{
title: '订单编号',
dataIndex: 'orderNo',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateTime',
},
{
title: '操作',
key: 'action',
render: (_, entity) => <Popconfirm
title={`确认删除文件[${entity.id}]?`}
onConfirm={async () => {
const success = await handleDelete(entity);
if (success) {
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
>
<Link>删除</Link>
</Popconfirm>,
},
];
return (
<PageContainer header={{ subTitle: '管理任务' }}>
<QueryFilter
defaultCollapsed
split
span={6}
className="query-filter"
onFinish={async (values) => setParams(values)}
>
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
</QueryFilter>
<ProTable<ORDERS.orderFile>
rowKey="id"
headerTitle="任务列表"
request={orderFiles}
actionRef={actionRef}
columns={columns}
search={false}
params={params}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
}}
/>
</PageContainer>
);
};
export default TableList;
@@ -33,7 +33,7 @@ const Login: React.FC = () => {
id: 'pages.login.success',
defaultMessage: '登录成功!',
});
const loginResult = msg.datas;
const loginResult = msg.data;
if (loginResult && loginResult.access_token)
sessionStorage.setItem('access_token', loginResult.access_token);
message.success(defaultLoginSuccessMessage);
@@ -14,10 +14,10 @@ export async function currentUser2(options?: { [key: string]: any }) {
method: 'GET',
...(options || {}),
});
return result.datas ?? {};
return result.data ?? {};
}
export async function fetchMenuData(options?: { [key: string]: any }) {
export async function fetchMenuData(options?: { [key: string]: any }) {
return request<API.Menu[]>('/api-user/menus/current', {
method: 'GET',
...(options || {}),
@@ -0,0 +1,29 @@
// @ts-ignore
/* eslint-disable */
import { request } from 'umi';
export async function order(params?: { [key: string]: string | number }) {
const { current, pageSize, ...rest } = params ?? {};
const result = await request<SYSTEM.Page<ORDERS.Order>>('/api-order', {
method: 'GET',
params: { page: current, limit: pageSize, ...rest },
});
return { data: result.data, total: result.count };
}
export async function deleteFile(id: number) {
const url = `/api-order/files/${id}`;
const result = await request<API.Result<void>>(url, {
method: 'DELETE',
});
return result;
}
export async function orderFiles(params?: { [key: string]: string | number }) {
const { current, pageSize, ...rest } = params ?? {};
const result = await request<SYSTEM.Page<ORDERS.orderFile>>('/api-order/files', {
method: 'GET',
params: { page: current, limit: pageSize, ...rest },
});
return { data: result.data, total: result.count };
}
@@ -0,0 +1,8 @@
// @ts-ignore
/* eslint-disable */
// API 更新时间:
// API 唯一标识:
import * as api from './api';
export default {
api,
};
@@ -0,0 +1,24 @@
// @ts-ignore
/* eslint-disable */
declare namespace ORDERS {
type Order = {
id: number;
createTime?: string;
tenantId?: string;
updateTime?: string;
}
type orderFile = {
id: number;
userId: string;
fileId: string;
filePath: string;
orderNo: string;
file_type: string;
createTime?: string;
tenantId?: string;
updateTime?: string;
}
}
@@ -16,7 +16,7 @@ export async function index(indexName: string) {
method: 'GET',
params: { indexName },
});
return result.datas;
return result.data;
}
export async function syslog(params?: { [key: string]: string | number }) {
@@ -162,7 +162,7 @@ export async function appAll() {
const result = await request<API.Result<SYSTEM.App>>('/api-uaa/clients/all', {
method: 'GET',
});
return result.datas;
return result.data;
}
export async function saveOrUpdateApp(data: SYSTEM.App): Promise<API.Result<SYSTEM.App>> {