perfect the user log tenant and project modules (#1478)

* Add user log item Manage

* edit Item Management

* merge from develop

* add router

* add router

* edit logmanage

* edit tenant

* update item

* update user tenant log user

* edit userName
pull/1480/head
baiJinjin 1 year ago committed by GitHub
parent d543979a0c
commit 159fd9cbad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,7 +21,7 @@ const zhTranslationMap: { [key: string]: string } = {
[STR_MAP.EDIT]: '操作',
[STR_MAP.TENANT_MANAGE]: '租户管理',
[STR_MAP.PROJECT_MANAGE]: '项目管理',
[STR_MAP.USER_MANAGE]: '用户管理',
[STR_MAP.USER_MANAGE]: '用户权限',
[STR_MAP.LOG_MANAGE]: '日志管理',
};

@ -1,29 +1,104 @@
import { useRequest } from 'ahooks';
import { Form, Modal, Input, Select } from 'antd';
import React from 'react';
import { fetchTenantList } from '../tenant/service';
import { Form, Modal, Input, Select, notification } from 'antd';
import React, { useEffect } from 'react';
import { fetchTenantOptions } from '../tenant/service';
import { fetchAddItem, fetchUpdateItem } from './service';
const ItemCreate: React.FC<{
interface IProps {
type: string;
data: any;
visible: boolean;
onClose: () => void;
}> = props => {
const { visible, onClose, data, type } = props;
const { data: tenant } = useRequest(fetchTenantList);
console.log('tenant', tenant);
reset: () => void;
}
const ItemCreate: React.FC<IProps> = props => {
const { visible, onClose, data, type, reset } = props;
const [form] = Form.useForm();
const tenantRequest = useRequest(fetchTenantOptions, {
ready: !!type,
});
const updateRequest = useRequest(fetchUpdateItem, {
manual: true,
onSuccess: () => {
notification.success({ message: '更新成功' });
form.resetFields();
onClose();
reset();
},
onError: err => {
notification.error({ message: err.message });
},
});
const addRequest = useRequest(fetchAddItem, {
manual: true,
onSuccess: () => {
notification.success({ message: '创建成功' });
form.resetFields();
onClose();
reset();
},
onError: err => {
notification.error({ message: err.message });
},
});
const onSave = () => {
form
.validateFields()
.then(values => {
addRequest.run({ ...values });
})
.catch(info => {
console.log('Validate Failed:', info);
});
};
const onUpdate = () => {
form
.validateFields()
.then(values => {
updateRequest.run({ id: data.id, ...values });
})
.catch(info => {
console.log('Validate Failed:', info);
});
};
useEffect(() => {
if (type === 'edit') {
form.setFieldsValue({
...data,
});
}
}, [type, data, form]);
return (
<Modal open={visible} onCancel={onClose} footer={null} width={600} title={type === 'edit' ? '编辑' : '创建'}>
<Form>
<Form.Item label="租户" name="">
{/* <Select options={tenant}></Select> */}
<Modal
open={visible}
onCancel={onClose}
width={600}
title={type === 'edit' ? '编辑' : '创建'}
onOk={type === 'edit' ? onUpdate : onSave}
confirmLoading={addRequest.loading || updateRequest.loading}
>
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 15 }} form={form}>
<Form.Item label="租户" name="tenantId" rules={[{ required: true }]}>
<Select
options={tenantRequest.data}
placeholder="请选择"
loading={tenantRequest.loading}
disabled={type === 'edit'}
/>
</Form.Item>
<Form.Item label="项目" name="itemId" rules={[{ required: true }]}>
<Input placeholder="请输入" disabled={type === 'edit'} />
</Form.Item>
<Form.Item label="项目名称" name="itemName" rules={[{ required: true }]}>
<Input placeholder="请输入" />
</Form.Item>
<Form.Item label="项目" name="">
<Input />
<Form.Item label="负责人" name="owner" rules={[{ required: true }]}>
<Input placeholder="请输入" />
</Form.Item>
<Form.Item label="负责人" name="">
<Input />
<Form.Item label="项目简介" name="itemDesc" rules={[{ required: true }]}>
<Input.TextArea placeholder="请输入" />
</Form.Item>
</Form>
</Modal>

@ -1,8 +1,8 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd';
import { useAntdTable, useRequest } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal, notification, message } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import React, { useState } from 'react';
import { fetchItemList } from './service';
import { fetchDeleteItem, fetchItemList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less';
import ItemCreate from './create';
@ -23,6 +23,10 @@ const baseColumns = [
dataIndex: 'itemId',
with: 200,
},
{
title: '项目',
dataIndex: 'itemId',
},
{
title: '项目名称',
dataIndex: 'itemName',
@ -46,16 +50,26 @@ const Tenant: React.FC = () => {
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchItemList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const deleteRequest = useRequest(fetchDeleteItem, { manual: true });
const handleSearch = () => {
setUrl();
search.submit();
};
const handleDelete = (item: any) => {
Modal.confirm({
title: `此操作将删除${item.itemName}, 是否继续?`,
onOk: () => {
search.submit();
title: '提示',
content: `此操作将删除 ${item.itemId}, 是否继续?`,
onOk: async () => {
try {
const res = await deleteRequest.runAsync(item.itemId);
if (res && res.success) {
notification.success({ message: '删除成功' });
search.reset();
}
} catch (e: any) {
message.error(e.message || '服务器开小差啦~');
}
},
});
};
@ -87,7 +101,7 @@ const Tenant: React.FC = () => {
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="项目" />
<Input placeholder="项目" allowClear />
</Form.Item>
</Col>
<Col span={18}>
@ -95,7 +109,7 @@ const Tenant: React.FC = () => {
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
<Button onClick={() => actions('add')} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
@ -131,7 +145,15 @@ const Tenant: React.FC = () => {
},
]}
/>
<ItemCreate data={curItem} onClose={handleClose} visible={editVisible} type={type} />
{editVisible && (
<ItemCreate
data={curItem}
onClose={handleClose}
visible={editVisible}
type={type}
reset={() => search.reset()}
/>
)}
</div>
);
};

@ -19,10 +19,10 @@ const fetchItemList = async (
list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
};
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchAddTenant = async (params: {
const fetchAddItem = async (params: {
itemDesc: string; // 项目简介
itemId: string; // 项目
itemName: string; // 项目名称
@ -31,39 +31,47 @@ const fetchAddTenant = async (params: {
tenantDesc?: string;
tenantName?: string;
}) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
const res = await request('/hippo4j/v1/cs/item/save', {
method: 'POST',
body: { ...params },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchDeleteItem = async (id: string) => {
const url = 'hippo4j/v1/cs/item/delete/prescription/' + id;
const res = await request(url, {
method: 'DELETE',
const fetchUpdateItem = async (params: {
id: string;
itemDesc: string; // 项目简介
itemId: string; // 项目
itemName: string; // 项目名称
owner: string; // 负责人
tenantId: string; // 租户
tenantDesc?: string;
tenantName?: string;
}) => {
const res = await request('/hippo4j/v1/cs/item/update', {
method: 'POST',
body: { ...params },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchUpdateItem = async (id: string) => {
const res = await request('/hippo4j/v1/cs/item/update', {
method: 'POST',
params: { id },
const fetchDeleteItem = async (id: string) => {
const url = 'hippo4j/v1/cs/item/delete/prescription/' + id;
const res = await request(url, {
method: 'DELETE',
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
export { fetchItemList, fetchAddTenant, fetchDeleteItem, fetchUpdateItem };
export { fetchItemList, fetchAddItem, fetchDeleteItem, fetchUpdateItem };

@ -0,0 +1,96 @@
import { useRequest } from 'ahooks';
import { Form, Modal, Input, notification } from 'antd';
import React, { useEffect } from 'react';
import { fetchAddTenant, fetchUpdateTenant } from './service';
interface IProps {
type: string;
data: any;
visible: boolean;
onClose: () => void;
reset: () => void;
}
const TenantCreate: React.FC<IProps> = props => {
const { visible, onClose, data, type, reset } = props;
const [form] = Form.useForm();
const updateRequest = useRequest(fetchUpdateTenant, {
manual: true,
onSuccess: () => {
notification.success({ message: '更新成功' });
form.resetFields();
onClose();
reset();
},
onError: err => {
notification.error({ message: err.message });
},
});
const addRequest = useRequest(fetchAddTenant, {
manual: true,
onSuccess: () => {
notification.success({ message: '创建成功' });
form.resetFields();
onClose();
reset();
},
onError: err => {
notification.error({ message: err.message });
},
});
const onSave = () => {
form
.validateFields()
.then(values => {
addRequest.run({ ...values });
})
.catch(info => {
console.log('Validate Failed:', info);
});
};
const onUpdate = () => {
form
.validateFields()
.then(values => {
updateRequest.run({ id: data.id, ...values });
})
.catch(info => {
console.log('Validate Failed:', info);
});
};
useEffect(() => {
if (type === 'edit') {
form.setFieldsValue({
...data,
});
}
}, [type, data, form]);
return (
<Modal
open={visible}
onCancel={onClose}
width={600}
title={type === 'edit' ? '编辑' : '创建'}
onOk={type === 'edit' ? onUpdate : onSave}
confirmLoading={addRequest.loading || updateRequest.loading}
>
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 15 }} form={form}>
<Form.Item label="租户" name="tenantId" rules={[{ required: true }]}>
<Input placeholder="请输入" disabled={type === 'edit'} />
</Form.Item>
<Form.Item label="租户名称" name="tenantName" rules={[{ required: true }]}>
<Input placeholder="请输入" />
</Form.Item>
<Form.Item label="负责人" name="owner" rules={[{ required: true }]}>
<Input placeholder="请输入" />
</Form.Item>
<Form.Item label="租户简介" name="tenantDesc" rules={[{ required: true }]}>
<Input.TextArea placeholder="请输入" />
</Form.Item>
</Form>
</Modal>
);
};
export default TenantCreate;

@ -1,15 +1,16 @@
import React, { useState } from 'react';
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd';
import { useAntdTable, useRequest } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal, notification, message } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import { useUrlSet } from '@/hooks/useUrlSet';
import { fetchTenantList } from './service';
import { fetchDeleteTenant, fetchTenantList } from './service';
import style from './index.module.less';
import TenantCreate from './create';
const baseColumns = [
{
title: '序号',
dataIndex: 'id',
dataIndex: 'index',
},
{
title: '租户',
@ -31,11 +32,13 @@ const baseColumns = [
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [curItem, setCurItem] = useState({});
const [type, setType] = useState('add');
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchTenantList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const deleteRequest = useRequest(fetchDeleteTenant, { manual: true });
const handleSearch = () => {
setUrl();
search.submit();
@ -43,18 +46,29 @@ const Tenant: React.FC = () => {
const handleDelete = (item: any) => {
Modal.confirm({
title: '提示',
content: `此操作将删除${item.tenantName},是否继续?`,
onOk: () => {
search.submit();
content: `此操作将删除 ${item.tenantId},是否继续?`,
onOk: async () => {
try {
const res = await deleteRequest.runAsync(item.tenantId);
if (res && res.success) {
notification.success({ message: '删除成功' });
search.reset();
}
} catch (e: any) {
message.error(e.message || '服务器开小差啦~');
}
},
});
};
const actions = (type: string, item?: any) => {
switch (type) {
case 'add':
setType('add');
setEditVisible(true);
break;
case 'edit':
setType('edit');
setCurItem(item);
setEditVisible(true);
break;
case 'delete':
@ -64,6 +78,9 @@ const Tenant: React.FC = () => {
break;
}
};
const handleClose = () => {
setEditVisible(false);
};
return (
<div className={style.tenant_wrapper}>
@ -71,7 +88,7 @@ const Tenant: React.FC = () => {
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="租户" />
<Input placeholder="租户" allowClear />
</Form.Item>
</Col>
<Col span={18}>
@ -79,7 +96,7 @@ const Tenant: React.FC = () => {
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
<Button onClick={() => actions('add')} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
@ -114,6 +131,15 @@ const Tenant: React.FC = () => {
},
]}
/>
{editVisible && (
<TenantCreate
data={curItem}
onClose={handleClose}
visible={editVisible}
type={type}
reset={() => search.reset()}
/>
)}
</div>
);
};

@ -1,5 +1,21 @@
import request from '@/utils';
const fetchTenantOptions = async (tencent: string) => {
const res: any = await request('/hippo4j/v1/cs/tenant/query/page', {
method: 'POST',
body: {
tencent,
current: 1,
size: 10,
desc: true,
},
});
if (res && res.success) {
return res.data && res.data.records.map((item: any) => ({ value: item.tenantId, label: item.tenantId }));
}
throw new Error(res.message || '服务器开小差啦~');
};
const fetchTenantList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
@ -16,58 +32,53 @@ const fetchTenantList = async (
if (res && res.success) {
return {
total: res.data.total,
list: res.data.records,
list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
};
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchAddTenant = async (id: string) => {
const fetchAddTenant = async (params: {
tenantDesc: string; // 项目简介
tenantId: string; // 项目
tenantName: string; // 项目名称
owner: string; // 负责人
}) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchDeleteTenant = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
body: { ...params },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchUpdateTenant = async (id: string) => {
const fetchUpdateTenant = async (params: {
tenantDesc: string; // 项目简介
tenantId: string; // 项目
tenantName: string; // 项目名称
owner: string; // 负责人
}) => {
const res = await request('hippo4j/v1/cs/tenant/update', {
method: 'POST',
params: { id },
body: { ...params },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchTenantDetail = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
const fetchDeleteTenant = async (id: string) => {
const url = 'hippo4j/v1/cs/item/delete/prescription/' + id;
const res = await request(url, {
method: 'DELETE',
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
export { fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };
export { fetchTenantOptions, fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant };

@ -0,0 +1,115 @@
import { useRequest } from 'ahooks';
import { Form, Modal, Input, notification, Select, Checkbox, message } from 'antd';
import React, { useEffect } from 'react';
import { fetchAddUser, fetchUpdateUser } from './service';
import { fetchTenantOptions } from '../tenant/service';
interface IProps {
type: string;
data: any;
visible: boolean;
onClose: () => void;
reset: () => void;
}
const ROLE_OPTIONS = [
{
label: 'ROLE_USER',
value: 'ROLE_USER',
},
{
label: 'ROLE_ADMIN',
value: 'ROLE_ADMIN',
},
{
label: 'ROLE_MANAGE',
value: 'ROLE_MANAGE',
},
];
const UserCreate: React.FC<IProps> = props => {
const { visible, onClose, data, type, reset } = props;
const [form] = Form.useForm();
const tenantRequest = useRequest(fetchTenantOptions, {
ready: !!type,
});
const updateRequest = useRequest(fetchUpdateUser, {
manual: true,
onSuccess: () => {
notification.success({ message: '更新成功' });
form.resetFields();
onClose();
reset();
},
onError: err => {
message.error(err.message);
},
});
const addRequest = useRequest(fetchAddUser, {
manual: true,
onSuccess: () => {
notification.success({ message: '创建成功' });
form.resetFields();
onClose();
reset();
},
onError: err => {
message.error(err.message);
},
});
const onSave = () => {
form
.validateFields()
.then(values => {
addRequest.run({ ...values });
})
.catch(info => {
console.log('Validate Failed:', info);
});
};
const onUpdate = () => {
form
.validateFields()
.then(values => {
updateRequest.run({ id: data.id, ...values });
})
.catch(info => {
console.log('Validate Failed:', info);
});
};
useEffect(() => {
if (type === 'edit') {
form.setFieldsValue({
...data,
});
}
}, [type, data, form]);
return (
<Modal
open={visible}
onCancel={onClose}
width={600}
title={type === 'edit' ? '编辑' : '创建'}
onOk={type === 'edit' ? onUpdate : onSave}
confirmLoading={addRequest.loading || updateRequest.loading}
>
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 15 }} form={form}>
<Form.Item label="用户名" name="userName" rules={[{ required: true }]}>
<Input placeholder="请输入" disabled={type === 'edit'} />
</Form.Item>
<Form.Item label="密码" name="password" rules={[{ required: true }]}>
<Input placeholder="请输入" />
</Form.Item>
<Form.Item label="角色" name="role" rules={[{ required: true }]}>
<Select options={ROLE_OPTIONS} placeholder="请选择" disabled={type === 'edit'} />
</Form.Item>
<Form.Item label="租户" name="tempResources">
<Checkbox.Group options={tenantRequest.data} />
</Form.Item>
</Form>
</Modal>
);
};
export default UserCreate;

@ -1,10 +1,11 @@
import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col } from 'antd';
import { useAntdTable, useRequest } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal, notification, message } from 'antd';
import { SearchOutlined, EditOutlined } from '@ant-design/icons';
import React, { useState } from 'react';
import { fetchUserList } from './service';
import { fetchDeleteUser, fetchUserList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less';
import UserCreate from './create';
const baseColumns = [
{
@ -32,37 +33,54 @@ const baseColumns = [
const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState('add');
const [curItem, setCurItem] = useState({});
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchUserList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const deleteRequest = useRequest(fetchDeleteUser, { manual: true });
const handleSearch = () => {
setUrl();
search.submit();
};
const handleDelete = (item: any) => {
Modal.confirm({
title: '提示',
content: `此操作将删除 ${item.userName},是否继续?`,
onOk: async () => {
try {
const res = await deleteRequest.runAsync(item.userName);
if (res && res.success) {
notification.success({ message: '删除成功' });
search.reset();
}
} catch (e: any) {
message.error(e.message || '服务器开小差啦~');
}
},
});
};
const actions = (type: string, item?: any) => {
switch (type) {
case 'add':
setType('add');
setEditVisible(true);
break;
case 'edit':
setType('edit');
setCurItem(item);
setEditVisible(true);
break;
case 'delete':
// handleDelete();
handleDelete(item);
break;
default:
break;
}
};
const handleSearch = () => {
setUrl();
search.submit();
const handleClose = () => {
setEditVisible(false);
};
// const handleDelete = (item: any) => {
// Modal.confirm({
// title: `此操作将删除${item.tenantName}, 是否继续?`,
// onOk: () => {
// search.submit();
// },
// });
// };
return (
<div className={style.tenant_wrapper}>
@ -70,7 +88,7 @@ const Tenant: React.FC = () => {
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="用户名" />
<Input placeholder="用户名" allowClear />
</Form.Item>
</Col>
<Col span={18}>
@ -78,7 +96,7 @@ const Tenant: React.FC = () => {
<Button onClick={() => handleSearch()} type="primary" icon={<SearchOutlined />}>
</Button>
<Button onClick={() => setEditVisible(true)} type="primary" icon={<EditOutlined />}>
<Button onClick={() => actions('add')} type="primary" icon={<EditOutlined />}>
</Button>
</Space>
@ -104,7 +122,12 @@ const Tenant: React.FC = () => {
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
<Button
onClick={() => actions('delete', record)}
type="link"
className={style.opreate_btn}
disabled={record.userName === 'admin'}
>
</Button>
</Space>
@ -113,6 +136,15 @@ const Tenant: React.FC = () => {
},
]}
/>
{editVisible && (
<UserCreate
data={curItem}
onClose={handleClose}
visible={editVisible}
type={type}
reset={() => search.reset()}
/>
)}
</div>
);
};

@ -6,12 +6,6 @@ const fetchUserList = async (
): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/auth/users/page', {
method: 'POST',
headers: {
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
body: {
...formData,
current: pageProps.current,
@ -24,55 +18,67 @@ const fetchUserList = async (
list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
};
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchAddTenant = async (id: string) => {
const res = await request('/hippo4j/v1/cs/tenant/save', {
const fetchAddUser = async (params: {
password?: string;
permission?: string;
role: string;
userName: string;
tempResources: Array<string>;
tenant: Array<string>;
resources?: Array<{ resource: string; action: 'rw' }>;
}) => {
const { tempResources = [] } = params;
const res = await request('/hippo4j/v1/cs/auth/users/add', {
method: 'POST',
params: { id },
body: {
...params,
tempResources: tempResources.length > 0 ? true : false,
resources: tempResources.map(item => ({ resource: item, action: 'rw' })),
},
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchDeleteTenant = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
if (res && res.success) {
return res;
const fetchUpdateUser = async (params: {
password?: string;
permission?: string;
role: string;
userName: string;
tempResources: Array<any>;
resources?: Array<{ resource: string; action: 'rw' }>;
}) => {
const { tempResources = [] } = params;
if (tempResources.length > 0) {
params.resources = tempResources.map(item => ({ resource: item, action: 'rw' }));
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchUpdateTenant = async (id: string) => {
const res = await request('hippo4j/v1/cs/tenant/update', {
method: 'POST',
params: { id },
const res = await request('/hippo4j/v1/cs/auth/users/update', {
method: 'PUT',
body: { ...params },
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
const fetchTenantDetail = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
const fetchDeleteUser = async (id: string) => {
const url = '/hippo4j/v1/cs/auth/users/remove/' + id;
const res = await request(url, {
method: 'DELETE',
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
throw new Error(res.message || '服务器开小差啦~');
};
export { fetchUserList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };
export { fetchUserList, fetchAddUser, fetchDeleteUser, fetchUpdateUser };

Loading…
Cancel
Save