feat: 短信渠道
This commit is contained in:
@@ -1,49 +1,55 @@
|
|||||||
import type {
|
import type {
|
||||||
ProColumns,
|
ProColumns,
|
||||||
ProDescriptionsItemProps,
|
ProDescriptionsItemProps,
|
||||||
|
ProFormColumnsType,
|
||||||
} from '@ant-design/pro-components';
|
} from '@ant-design/pro-components';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import type { LoginLogVO } from '@/services/system/log/login';
|
import type { SmsChannelVO } from '@/services/system/message/sms/channel';
|
||||||
export const baseTenantColumns: ProColumns<LoginLogVO>[] = [
|
export const baseTenantColumns: ProColumns<SmsChannelVO>[] = [
|
||||||
{
|
{
|
||||||
title: '日志编号',
|
title: '编号',
|
||||||
dataIndex: 'id',
|
dataIndex: 'id',
|
||||||
tip: '日志编号',
|
|
||||||
width: 100,
|
width: 100,
|
||||||
hideInSearch: true, // 在搜索表单中隐藏
|
hideInSearch: true, // 在搜索表单中隐藏
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作类型',
|
title: '短信签名',
|
||||||
dataIndex: 'logType',
|
dataIndex: 'signature',
|
||||||
hideInSearch: true, // 在搜索表单中隐藏
|
|
||||||
tip: '操作类型', // 提示信息
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作模块',
|
|
||||||
dataIndex: 'type',
|
|
||||||
hideInSearch: true, // 在搜索表单中隐藏
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '用户名称',
|
|
||||||
dataIndex: 'username',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '登录地址',
|
|
||||||
dataIndex: 'userIp',
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: '浏览器',
|
title: '渠道编码',
|
||||||
dataIndex: 'userAgent',
|
dataIndex: 'code',
|
||||||
hideInSearch: true, // 在搜索表单中隐藏
|
hideInSearch: true, // 在搜索表单中隐藏
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '登录结果',
|
title: '启用状态',
|
||||||
dataIndex: 'result',
|
dataIndex: 'status',
|
||||||
|
valueType: 'select',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '备注',
|
||||||
|
dataIndex: 'remark',
|
||||||
|
hideInSearch: true, // 在搜索表单中隐藏
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '短信 API 的账号',
|
||||||
|
dataIndex: 'apiKey',
|
||||||
|
hideInSearch: true, // 在搜索表单中隐藏
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: '短信 API 的密钥',
|
||||||
|
dataIndex: 'apiSecret',
|
||||||
|
hideInSearch: true, // 在搜索表单中隐藏
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '短信发送回调 URL',
|
||||||
|
dataIndex: 'callbackUrl',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '登录日期',
|
title: '创建时间',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
valueType: 'dateRange',
|
valueType: 'dateRange',
|
||||||
search: {
|
search: {
|
||||||
@@ -58,48 +64,64 @@ export const baseTenantColumns: ProColumns<LoginLogVO>[] = [
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render: (_, record: LoginLogVO) =>
|
render: (_, record: SmsChannelVO) =>
|
||||||
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
|
dayjs(record.createTime).format('YYYY-MM-DD HH:mm:ss'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const descriptionsColumns = (): ProDescriptionsItemProps<
|
export const formColumns = (type: string): ProFormColumnsType[] => [
|
||||||
Record<string, any>,
|
|
||||||
'text'
|
|
||||||
>[] => [
|
|
||||||
{
|
{
|
||||||
title: '日志编号',
|
title: '短信签名',
|
||||||
key: 'id',
|
dataIndex: 'signature',
|
||||||
dataIndex: 'id',
|
formItemProps: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入用户名',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作类型',
|
title: '渠道编码',
|
||||||
key: 'logType',
|
dataIndex: 'code',
|
||||||
dataIndex: 'logType',
|
valueType: 'select',
|
||||||
|
formItemProps: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入用户名',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '用户名称',
|
title: '启用状态',
|
||||||
key: 'username',
|
dataIndex: 'status',
|
||||||
dataIndex: 'username',
|
valueType: 'radio',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '登录地址',
|
title: '备注',
|
||||||
key: 'userIp',
|
dataIndex: 'remark',
|
||||||
dataIndex: 'userIp',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '浏览器',
|
title: '短信 API 的账号',
|
||||||
key: 'userAgent',
|
dataIndex: 'apiKey',
|
||||||
dataIndex: 'userAgent',
|
formItemProps: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请输入用户名',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '登录结果',
|
title: '短信 API 的密钥',
|
||||||
key: 'result',
|
dataIndex: 'apiSecret',
|
||||||
dataIndex: 'result',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '登录日期',
|
title: '短信发送回调 URL',
|
||||||
key: 'createTime',
|
dataIndex: 'callbackUrl',
|
||||||
dataIndex: 'createTime',
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,22 +1,38 @@
|
|||||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import React, { useRef } from 'react';
|
import type {
|
||||||
|
ActionType,
|
||||||
|
ProColumns,
|
||||||
|
ProCoreActionType,
|
||||||
|
} from '@ant-design/pro-components';
|
||||||
|
import { message, Popconfirm } from 'antd';
|
||||||
|
import React, { useCallback, useRef, useState } from 'react';
|
||||||
|
import ConfigurableDrawerForm, {
|
||||||
|
type ConfigurableDrawerFormRef,
|
||||||
|
} from '@/components/DrawerForm';
|
||||||
import EnhancedProTable from '@/components/EnhancedProTable';
|
import EnhancedProTable from '@/components/EnhancedProTable';
|
||||||
import ModalDescriptions, {
|
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
|
||||||
type DescriptionsFormRef,
|
import { formStatusType } from '@/constants';
|
||||||
} from '@/components/ModalDescriptions';
|
import {
|
||||||
import { getLoginLogPage, type LoginLogVO } from '@/services/system/log/login';
|
createSmsChannel,
|
||||||
import { baseTenantColumns, descriptionsColumns } from './config';
|
deleteSmsChannel,
|
||||||
|
getSmsChannelPage,
|
||||||
|
type SmsChannelVO,
|
||||||
|
updateSmsChannel,
|
||||||
|
} from '@/services/system/message/sms/channel';
|
||||||
|
import { baseTenantColumns, formColumns } from './config';
|
||||||
|
|
||||||
const SyStemLogLogin = () => {
|
const SyStemLogLogin = () => {
|
||||||
const tableRef = useRef<ActionType>(null);
|
const tableRef = useRef<ActionType>(null);
|
||||||
const descriptionsRef = useRef<DescriptionsFormRef>(null);
|
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
|
||||||
|
const [type, setType] = useState<'create' | 'update'>('create');
|
||||||
|
const [currentItem, setCurrentItem] = useState<SmsChannelVO>();
|
||||||
const onFetch = async (
|
const onFetch = async (
|
||||||
params: LoginLogVO & {
|
params: SmsChannelVO & {
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
current?: number;
|
current?: number;
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const data = await getLoginLogPage({
|
const data = await getSmsChannelPage({
|
||||||
...params,
|
...params,
|
||||||
pageNo: params.current,
|
pageNo: params.current,
|
||||||
pageSize: params.pageSize,
|
pageSize: params.pageSize,
|
||||||
@@ -28,37 +44,88 @@ const SyStemLogLogin = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDetail = (record: LoginLogVO) => {
|
const handleEdit = (record: SmsChannelVO) => {
|
||||||
descriptionsRef.current?.open(record);
|
setType('update');
|
||||||
|
setCurrentItem(record);
|
||||||
|
configurableDrawerRef.current?.open(record);
|
||||||
};
|
};
|
||||||
|
const handleAdd = () => {
|
||||||
const actionColumns: ProColumns<LoginLogVO> = {
|
setType('create');
|
||||||
|
configurableDrawerRef.current?.open({});
|
||||||
|
};
|
||||||
|
const toolbarActions: ToolbarAction[] = [
|
||||||
|
{
|
||||||
|
key: 'add',
|
||||||
|
label: '新建',
|
||||||
|
type: 'primary',
|
||||||
|
icon: <PlusOutlined />,
|
||||||
|
onClick: handleAdd,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const actionColumns: ProColumns<SmsChannelVO> = {
|
||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'option',
|
dataIndex: 'option',
|
||||||
valueType: 'option',
|
valueType: 'option',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 80,
|
width: 80,
|
||||||
render: (text: React.ReactNode, record: LoginLogVO) => [
|
render: (
|
||||||
<a key="editable" onClick={() => handleDetail(record)}>
|
text: React.ReactNode,
|
||||||
详情
|
record: SmsChannelVO,
|
||||||
|
_: number,
|
||||||
|
action: ProCoreActionType | undefined,
|
||||||
|
) => [
|
||||||
|
<a key="editable" onClick={() => handleEdit(record)}>
|
||||||
|
编辑
|
||||||
</a>,
|
</a>,
|
||||||
|
<Popconfirm
|
||||||
|
title="是否删除?"
|
||||||
|
key="delete"
|
||||||
|
onConfirm={async () => {
|
||||||
|
await deleteSmsChannel(record.id);
|
||||||
|
message.success('删除成功');
|
||||||
|
action?.reload?.();
|
||||||
|
}}
|
||||||
|
okText="是"
|
||||||
|
cancelText="否"
|
||||||
|
>
|
||||||
|
<a style={{ color: 'var(--ant-red)' }} key="delete">
|
||||||
|
删除
|
||||||
|
</a>
|
||||||
|
</Popconfirm>,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
const handleSubmit = useCallback(
|
||||||
|
async (values: SmsChannelVO) => {
|
||||||
|
if (type === 'create') {
|
||||||
|
await createSmsChannel(values);
|
||||||
|
} else {
|
||||||
|
await updateSmsChannel({
|
||||||
|
...values,
|
||||||
|
id: currentItem!.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
tableRef.current?.reload();
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
[type, currentItem],
|
||||||
|
);
|
||||||
const columns = [...baseTenantColumns, actionColumns];
|
const columns = [...baseTenantColumns, actionColumns];
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<EnhancedProTable<LoginLogVO>
|
<EnhancedProTable<SmsChannelVO>
|
||||||
ref={tableRef}
|
ref={tableRef}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
request={onFetch}
|
request={onFetch}
|
||||||
headerTitle="登录日志"
|
toolbarActions={toolbarActions}
|
||||||
|
headerTitle="短信渠道"
|
||||||
showIndex={false}
|
showIndex={false}
|
||||||
showSelection={false}
|
showSelection={false}
|
||||||
/>
|
/>
|
||||||
<ModalDescriptions
|
<ConfigurableDrawerForm
|
||||||
ref={descriptionsRef}
|
ref={configurableDrawerRef}
|
||||||
title="登录日志详情"
|
title={formStatusType[type]}
|
||||||
columns={descriptionsColumns()}
|
columns={formColumns(type)}
|
||||||
|
onSubmit={handleSubmit}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export async function createSmsChannel(data: SmsChannelVO) {
|
|||||||
// return request.put({ url: '/system/sms-channel/update', data })
|
// return request.put({ url: '/system/sms-channel/update', data })
|
||||||
// }
|
// }
|
||||||
export async function updateSmsChannel(data: SmsChannelVO) {
|
export async function updateSmsChannel(data: SmsChannelVO) {
|
||||||
return request("/system/sms-channel/create", {
|
return request("/system/sms-channel/update", {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
@@ -66,7 +66,7 @@ export async function updateSmsChannel(data: SmsChannelVO) {
|
|||||||
// return request.delete({ url: '/system/sms-channel/delete?id=' + id })
|
// return request.delete({ url: '/system/sms-channel/delete?id=' + id })
|
||||||
// }
|
// }
|
||||||
export async function deleteSmsChannel(id: number) {
|
export async function deleteSmsChannel(id: number) {
|
||||||
return request("/system/sms-channel/create", {
|
return request("/system/sms-channel/delete", {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
params: { id },
|
params: { id },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user