Browse Source

白名单和刷数据

master
nili 8 months ago
parent
commit
aaf15d65d6
  1. 7
      config/routes.ts
  2. 233
      dist/269.4542f5a4.async.js
  3. 2
      dist/270.f1c2a3da.async.js
  4. 13
      dist/287.93586c34.async.js
  5. 2
      dist/601.e46b1579.async.js
  6. 40
      dist/676.a53a9987.async.js
  7. 30
      dist/706.1c4598f2.async.js
  8. 42
      dist/858.8af04f5f.async.js
  9. 272
      dist/991.963f9c47.async.js
  10. 2
      dist/index.html
  11. 1
      dist/p__AdminManagement.1126dff2.async.js
  12. 1
      dist/p__AdminManagement.c1a3991d.async.js
  13. 1
      dist/p__SuperAdmin.5409346e.async.js
  14. 1
      dist/p__User__Login__index.a9369d80.async.js
  15. 1
      dist/p__User__Login__index.da479be3.async.js
  16. 433
      dist/umi.087695e7.js
  17. 433
      dist/umi.bb0368ff.js
  18. 1
      src/access.ts
  19. 8
      src/app.tsx
  20. 328
      src/pages/SuperAdmin.tsx
  21. 58
      src/services/matrix/admin.ts
  22. 15
      src/services/matrix/matrixController.ts
  23. 66
      src/services/matrix/typings.d.ts

7
config/routes.ts

@ -29,6 +29,13 @@ export default [
icon: 'smile', icon: 'smile',
component: './Welcome', component: './Welcome',
}, },
{
path: '/super',
name: '魔法之地',
icon: 'smile',
access: 'superAdmin',
component: './SuperAdmin',
},
{ {
path: '/advList/:code', path: '/advList/:code',
name: '广告列表', name: '广告列表',

233
dist/269.4542f5a4.async.js

File diff suppressed because one or more lines are too long

2
dist/270.514d6aaa.async.js → dist/270.f1c2a3da.async.js

File diff suppressed because one or more lines are too long

13
dist/287.93586c34.async.js

File diff suppressed because one or more lines are too long

2
dist/601.976fca1c.async.js → dist/601.e46b1579.async.js

File diff suppressed because one or more lines are too long

40
dist/676.a53a9987.async.js

File diff suppressed because one or more lines are too long

30
dist/706.1c4598f2.async.js

File diff suppressed because one or more lines are too long

42
dist/858.8af04f5f.async.js

File diff suppressed because one or more lines are too long

272
dist/991.963f9c47.async.js

File diff suppressed because one or more lines are too long

2
dist/index.html

@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/umi.bb0368ff.js"></script> <script src="/umi.087695e7.js"></script>
</body></html> </body></html>

1
dist/p__AdminManagement.1126dff2.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdminManagement.c1a3991d.async.js

File diff suppressed because one or more lines are too long

1
dist/p__SuperAdmin.5409346e.async.js

File diff suppressed because one or more lines are too long

1
dist/p__User__Login__index.a9369d80.async.js

File diff suppressed because one or more lines are too long

1
dist/p__User__Login__index.da479be3.async.js

File diff suppressed because one or more lines are too long

433
dist/umi.087695e7.js

File diff suppressed because one or more lines are too long

433
dist/umi.bb0368ff.js

File diff suppressed because one or more lines are too long

1
src/access.ts

@ -5,6 +5,7 @@ export default function access(initialState: { currentUser?: API.MatrixAdmin } |
const { currentUser } = initialState ?? {}; const { currentUser } = initialState ?? {};
let data = { let data = {
canAdmin: currentUser && currentUser.role && currentUser.role <= 3, canAdmin: currentUser && currentUser.role && currentUser.role <= 3,
superAdmin: currentUser && currentUser.role && currentUser.role === 1,
canDeviceOwner: currentUser && currentUser.role && currentUser.role > 3, canDeviceOwner: currentUser && currentUser.role && currentUser.role > 3,
}; };
return data; return data;

8
src/app.tsx

@ -60,7 +60,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
request: async () => { request: async () => {
const apps = await appList(); const apps = await appList();
const menuData: MenuDataItem[] = []; const menuData: MenuDataItem[] = [];
apps.data?.forEach((x) => { apps.data?.forEach((x: any) => {
menuData.push({ menuData.push({
path: '/advList/' + x.code, path: '/advList/' + x.code,
name: x.name, name: x.name,
@ -94,6 +94,12 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
access: 'canAdmin', access: 'canAdmin',
}); });
menuData.push({
path: '/super',
name: '魔法之地',
access: 'superAdmin',
});
return menuData; return menuData;
}, },
}, },

328
src/pages/SuperAdmin.tsx

@ -0,0 +1,328 @@
import {
addSchedule,
addWhiteList1,
appList,
deleteWhiteList,
scheduleList,
whiteList1,
} from '@/services/matrix/admin';
import { PageContainer } from '@ant-design/pro-components';
import {
Button,
DatePicker,
Form,
Input,
Modal,
Popover,
Select,
Table,
Tabs,
Tag,
message,
} from 'antd';
import { ColumnsType } from 'antd/es/table';
import TabPane from 'antd/es/tabs/TabPane';
import moment from 'moment';
import React, { useEffect, useState } from 'react';
// import { RequestOptionsType, ProFieldRequestData } from "@ant-design/pro-utils";
const SuperAdmin: React.FC = () => {
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]);
const [whiteList, setWhiteList] = useState<API.MatrixWhiteDevice[]>([]);
const [scheduleArr, setScheduleArr] = useState<API.MatrixMockSchedule[]>([]);
const [visible, setVisible] = useState(false);
const [sVisible, setSVisible] = useState(false);
const [whiteListForm] = Form.useForm();
const [scheduleForm] = Form.useForm();
/**
* @en-US International configuration
* @zh-CN
* */
const fetchWhiteList = async () => {
const res = await whiteList1();
if (res.data) {
setWhiteList(res.data);
}
};
const deleteDevice = async (deviceId: string | undefined) => {
if (!deviceId) {
return;
}
await deleteWhiteList({ deviceId: deviceId });
fetchWhiteList();
};
const columns: ColumnsType<API.MatrixWhiteDevice> = [
{
title: '设备id',
dataIndex: 'deviceId',
ellipsis: true,
},
{
title: '渠道',
dataIndex: 'channel',
render: (r: string) => {
switch (r) {
case 'fanmiyou':
return '凡米游';
case 'qiji':
return '奇迹';
}
return r;
},
},
{
title: '操作',
dataIndex: 'operate',
render: (_, record: API.MatrixWhiteDevice) => {
return (
<Popover
title="确认删除吗"
content={
<div style={{ textAlign: 'center' }}>
<p>
ecpm会降低
<br />
使
</p>
<a onClick={() => deleteDevice(record.deviceId)}></a>
</div>
}
>
<a></a>
</Popover>
);
},
},
];
const getAppNameById = (appId: number) => {
const app = appArr.find((app) => app.id === appId);
return app ? app.name : '';
};
const formatIncome = (v: number | undefined) => {
if (!v) {
return 0;
}
return parseFloat((v / 1000_00).toFixed(2));
};
const sColumns: ColumnsType<API.MatrixMockSchedule> = [
{
title: '应用',
dataIndex: 'appId',
render: (appId) => (
<Tag color="blue" key={appId}>
{getAppNameById(appId)}
</Tag>
),
},
{
title: '渠道',
dataIndex: 'channel',
render: (r: string) => {
switch (r) {
case 'fanmiyou':
return '凡米游';
case 'qiji':
return '奇迹';
}
return r;
},
},
{
title: '目标金额',
dataIndex: 'incomeYuan',
},
{
title: '已刷金额',
dataIndex: 'mockIncome',
render: (r: number) => {
return formatIncome(r);
},
},
{
title: '开始时间',
dataIndex: 'scheduleTime',
render: (r: string) => {
return moment(r).format('YYYY-MM-DD HH:mm');
},
},
{
title: '状态',
dataIndex: 'status',
render: (r: number) => {
switch (r) {
case 0:
return '未开始';
case 1:
return '进行中';
case 2:
return '已完成';
}
return r;
},
},
{
title: '创建时间',
dataIndex: 'createdAt',
render: (r: string) => {
return moment(r).format('YYYY-MM-DD HH:mm');
},
},
{
title: '更新时间',
dataIndex: 'updatedAt',
render: (r: string) => {
return moment(r).format('YYYY-MM-DD HH:mm');
},
},
];
const fetchScheduleList = async () => {
const res = await scheduleList();
if (res.data) {
setScheduleArr(res.data);
}
};
const fetchApp = async () => {
const res = await appList();
if (res.data) {
setAppArr(res.data);
}
};
useEffect(() => {
fetchApp();
fetchWhiteList();
fetchScheduleList();
}, []);
const handleSaveMock = async (params: API.AddMockScheduleReq) => {
const { scheduleTime, ...otherValues } = params;
const timestamp = moment(scheduleTime).valueOf(); // 使用 moment.js 将日期转换为时间戳
await addSchedule({ scheduleTime: timestamp, ...otherValues }); // 将时间戳作为参数传递给后端
message.success('任务提交成功');
fetchScheduleList();
setSVisible(false);
};
const addWhiteList = () => {
whiteListForm.resetFields(); // 重置表单字段
setVisible(true);
};
const addScheduleTask = () => {
scheduleForm.resetFields(); // 重置表单字段
setSVisible(true);
};
const handleOk = () => {
whiteListForm.submit();
};
const handleCancel = () => {
setVisible(false);
};
const handleSOk = () => {
scheduleForm.submit();
};
const handleSCancel = () => {
setSVisible(false);
};
const handleSaveWhiteList = async (values: API.MatrixWhiteDevice) => {
try {
await addWhiteList1({ deviceId: values.deviceId || '', channel: values.channel || '' });
} catch (e) {
return;
}
setVisible(false);
fetchWhiteList();
};
return (
<PageContainer>
<Tabs
defaultActiveKey="1"
onChange={(activeKey) => {
if (activeKey === '1') {
fetchWhiteList();
} else if (activeKey === '2') {
fetchScheduleList();
}
}}
centered
style={{ backgroundColor: 'white', padding: '20px' }}
>
<TabPane tab="设备白名单" key="1">
<div>
<Button onClick={addWhiteList}></Button>
<Table columns={columns} dataSource={whiteList} />
<Modal title="添加白名单" visible={visible} onOk={handleOk} onCancel={handleCancel}>
<Form form={whiteListForm} onFinish={handleSaveWhiteList}>
<Form.Item name="deviceId" label="设备id">
<Input />
</Form.Item>
<Form.Item label="渠道" name="channel">
<Select>
<Select.Option value="fanmiyou"></Select.Option>
<Select.Option value="qiji"></Select.Option>
</Select>
</Form.Item>
</Form>
</Modal>
</div>
</TabPane>
<TabPane tab="刷数据" key="2">
<div>
<Button onClick={addScheduleTask}></Button>
<Table columns={sColumns} dataSource={scheduleArr} />
<Modal title="添加任务" visible={sVisible} onOk={handleSOk} onCancel={handleSCancel}>
<Form form={scheduleForm} onFinish={handleSaveMock}>
<Form.Item label="应用" name="appId">
<Select>
{appArr.map((app) => (
<Select.Option key={app.id} value={app.id}>
{app.name}
</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item name="channel" label="渠道">
<Select>
<Select.Option key="fanmiyou" value="fanmiyou">
</Select.Option>
<Select.Option key="qiji" value="qiji">
</Select.Option>
</Select>
</Form.Item>
<Form.Item name="incomeYuan" label="金额(元)">
<Input />
</Form.Item>
<Form.Item name="sheduleTime" label="开始时间">
<DatePicker format="YYYY-MM-DD HH:mm" showTime={{ format: 'HH:mm' }} />
</Form.Item>
</Form>
</Modal>
</div>
</TabPane>
</Tabs>
</PageContainer>
);
};
export default SuperAdmin;

58
src/services/matrix/admin.ts

@ -2,6 +2,33 @@
/* eslint-disable */ /* eslint-disable */
import { request } from '@umijs/max'; import { request } from '@umijs/max';
/** 此处后端没有提供注释 POST /api/admin/addSchedule */
export async function addSchedule(body: API.AddMockScheduleReq, options?: { [key: string]: any }) {
return request<API.RVoid>('/api/admin/addSchedule', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/addWhiteList */
export async function addWhiteList1(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.addWhiteList1Params,
options?: { [key: string]: any },
) {
return request<API.RVoid>('/api/admin/addWhiteList', {
method: 'POST',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 GET /api/admin/adminList */ /** 此处后端没有提供注释 GET /api/admin/adminList */
export async function adminList(options?: { [key: string]: any }) { export async function adminList(options?: { [key: string]: any }) {
return request<API.RListMatrixAdminBo>('/api/admin/adminList', { return request<API.RListMatrixAdminBo>('/api/admin/adminList', {
@ -38,6 +65,21 @@ export async function current(options?: { [key: string]: any }) {
}); });
} }
/** 此处后端没有提供注释 POST /api/admin/deleteWhiteList */
export async function deleteWhiteList(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.deleteWhiteListParams,
options?: { [key: string]: any },
) {
return request<API.RVoid>('/api/admin/deleteWhiteList', {
method: 'POST',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/grantApp */ /** 此处后端没有提供注释 POST /api/admin/grantApp */
export async function grantApp( export async function grantApp(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
@ -133,3 +175,19 @@ export async function saveApp(body: API.MatrixApp, options?: { [key: string]: an
...(options || {}), ...(options || {}),
}); });
} }
/** 此处后端没有提供注释 GET /api/admin/scheduleList */
export async function scheduleList(options?: { [key: string]: any }) {
return request<API.RListMatrixMockSchedule>('/api/admin/scheduleList', {
method: 'GET',
...(options || {}),
});
}
/** 此处后端没有提供注释 GET /api/admin/whiteList */
export async function whiteList1(options?: { [key: string]: any }) {
return request<API.RListMatrixWhiteDevice>('/api/admin/whiteList', {
method: 'GET',
...(options || {}),
});
}

15
src/services/matrix/matrixController.ts

@ -32,6 +32,21 @@ export async function bindDevice(
}); });
} }
/** 此处后端没有提供注释 GET /api/game/matrix/getAdvList */
export async function getAdvList(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getAdvListParams,
options?: { [key: string]: any },
) {
return request<API.RListMatrixAdvRecordSimple>('/api/game/matrix/getAdvList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/game/matrix/saveAdvRecord */ /** 此处后端没有提供注释 POST /api/game/matrix/saveAdvRecord */
export async function saveAdvRecord( export async function saveAdvRecord(
body: API.MatrixAdvRecordEditBo, body: API.MatrixAdvRecordEditBo,

66
src/services/matrix/typings.d.ts

@ -1,4 +1,16 @@
declare namespace API { declare namespace API {
type AddMockScheduleReq = {
appId?: number;
channel?: string;
incomeYuan?: number;
scheduleTime?: number;
};
type addWhiteList1Params = {
deviceId: string;
channel: string;
};
type addWhiteListParams = { type addWhiteListParams = {
deviceId: string; deviceId: string;
appCode: string; appCode: string;
@ -45,10 +57,19 @@ declare namespace API {
income?: number; income?: number;
}; };
type deleteWhiteListParams = {
deviceId: string;
};
type deviceListParams = { type deviceListParams = {
appCode: string; appCode: string;
}; };
type getAdvListParams = {
appCode: string;
deviceId: string;
};
type getAppInfoParams = { type getAppInfoParams = {
appId?: string; appId?: string;
}; };
@ -156,6 +177,14 @@ declare namespace API {
sign?: string; sign?: string;
}; };
type MatrixAdvRecordSimple = {
deviceId?: string;
platform?: number;
advType?: number;
ecpm?: number;
createdAt?: number;
};
type MatrixApp = { type MatrixApp = {
id?: number; id?: number;
name?: string; name?: string;
@ -165,6 +194,25 @@ declare namespace API {
secret?: string; secret?: string;
}; };
type MatrixMockSchedule = {
id?: number;
appId?: number;
channel?: string;
incomeYuan?: number;
mockIncome?: number;
status?: number;
scheduleTime?: string;
createdAt?: string;
updatedAt?: string;
};
type MatrixWhiteDevice = {
id?: number;
deviceId?: string;
channel?: string;
createdAt?: string;
};
type mockDataParams = { type mockDataParams = {
appCode: string; appCode: string;
incomeYuan: number; incomeYuan: number;
@ -242,12 +290,30 @@ declare namespace API {
data?: MatrixAdminDevice[]; data?: MatrixAdminDevice[];
}; };
type RListMatrixAdvRecordSimple = {
code?: number;
message?: string;
data?: MatrixAdvRecordSimple[];
};
type RListMatrixApp = { type RListMatrixApp = {
code?: number; code?: number;
message?: string; message?: string;
data?: MatrixApp[]; data?: MatrixApp[];
}; };
type RListMatrixMockSchedule = {
code?: number;
message?: string;
data?: MatrixMockSchedule[];
};
type RListMatrixWhiteDevice = {
code?: number;
message?: string;
data?: MatrixWhiteDevice[];
};
type RLoginBo = { type RLoginBo = {
code?: number; code?: number;
message?: string; message?: string;

Loading…
Cancel
Save