mirror of https://gitee.com/topiam/eiam
⚡ 优化代码
parent
c960cb8c84
commit
be09062d44
|
@ -16,7 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { AppProtocolType } from '@/constant';
|
||||
import { getApp } from '@/services/app';
|
||||
import { getApp } from '../../service';
|
||||
import { ProCard } from '@ant-design/pro-components';
|
||||
|
||||
import { useAsyncEffect } from 'ahooks';
|
||||
|
@ -25,7 +25,7 @@ import { useState } from 'react';
|
|||
import FromConfig from './FromProtocolConfig';
|
||||
import JwtConfig from './JwtProtocolConfig';
|
||||
import OidcConfig from './OidcProtocolConfig';
|
||||
import { GetApp } from '../../data';
|
||||
import { GetApp } from '../../data.d';
|
||||
import { useIntl } from '@@/exports';
|
||||
|
||||
export default (props: { appId: string }) => {
|
||||
|
|
|
@ -128,8 +128,8 @@ export async function moveOrganization(
|
|||
*/
|
||||
export async function getUserList(
|
||||
params: Record<string, any>,
|
||||
sort?: Record<string, SortOrder>,
|
||||
filter?: Record<string, (string | number)[] | null>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AccountAPI.ListUser>> {
|
||||
return request<API.ApiResult<AccountAPI.ListUser>>('/api/v1/user/list', {
|
||||
params: { ...params, ...sortParamConverter(sort), ...filterParamConverter(filter) },
|
||||
|
@ -170,8 +170,8 @@ export async function batchGetUser(ids: string[]): Promise<API.ApiResult<Account
|
|||
*/
|
||||
export async function getLoginAuditList(
|
||||
params: Record<string, any>,
|
||||
sort?: Record<string, SortOrder>,
|
||||
filter?: Record<string, (string | number)[] | null>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AccountAPI.UserLoginAuditList>> {
|
||||
return request<API.ApiResult<AccountAPI.UserLoginAuditList>>('/api/v1/user/login_audit/list', {
|
||||
method: 'GET',
|
||||
|
@ -353,8 +353,8 @@ export async function getUserListNotInGroup(
|
|||
*/
|
||||
export async function getUserGroupList(
|
||||
params: Record<string, any>,
|
||||
sort?: Record<string, SortOrder>,
|
||||
filter?: Record<string, (string | number)[] | null>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AccountAPI.ListUserGroup>> {
|
||||
return request<API.ApiResult<AccountAPI.ListUserGroup>>('/api/v1/user_group/list', {
|
||||
params: { ...params, ...sortParamConverter(sort), ...filterParamConverter(filter) },
|
||||
|
@ -433,8 +433,8 @@ export async function removeUserGroupMember(
|
|||
*/
|
||||
export async function getUserGroupMemberList(
|
||||
params: Record<string, any>,
|
||||
sort?: Record<string, SortOrder>,
|
||||
filter?: Record<string, (string | number)[] | null>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AccountAPI.ListUser>> {
|
||||
return request<API.ApiResult<AccountAPI.ListUser>>(
|
||||
`/api/v1/user_group/${params.id}/member_list`,
|
||||
|
|
|
@ -19,15 +19,14 @@ import { download, filterParamConverter, sortParamConverter } from '@/utils/util
|
|||
import type { RequestData } from '@ant-design/pro-components';
|
||||
import type { SortOrder } from 'antd/es/table/interface';
|
||||
import { request } from '@umijs/max';
|
||||
import type { UploadFile } from 'antd/es/upload/interface';
|
||||
|
||||
/**
|
||||
* 获取应用列表
|
||||
*/
|
||||
export async function getAppList(
|
||||
params?: Record<string, any>,
|
||||
sort?: Record<string, SortOrder>,
|
||||
filter?: Record<string, (string | number)[] | null>,
|
||||
params: Record<string, any>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AppAPI.AppList>> {
|
||||
return request<API.ApiResult<AppAPI.AppList>>('/api/v1/app/list', {
|
||||
params: { ...params, ...sortParamConverter(sort), ...filterParamConverter(filter) },
|
||||
|
@ -192,32 +191,61 @@ export async function removeAppAccessPolicy(id: string): Promise<API.ApiResult<b
|
|||
}
|
||||
|
||||
/**
|
||||
* parse Saml2 MetadataUrl
|
||||
* 获取应用分组列表
|
||||
*/
|
||||
export async function parseSaml2MetadataUrl(
|
||||
metadataUrl: string,
|
||||
): Promise<API.ApiResult<Record<string, any>>> {
|
||||
return request(`/api/v1/app/saml2/parse/metadata_url`, {
|
||||
method: 'POST',
|
||||
params: { metadataUrl },
|
||||
}).catch(({ response: { data } }) => {
|
||||
return data;
|
||||
export async function getAppGroupList(
|
||||
params: Record<string, any>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AppAPI.AppGroupList>> {
|
||||
return request<API.ApiResult<AppAPI.AppGroupList>>('/api/v1/app/group/list', {
|
||||
params: { ...params, ...sortParamConverter(sort), ...filterParamConverter(filter) },
|
||||
}).then((result: API.ApiResult<AppAPI.AppGroupList>) => {
|
||||
const data: RequestData<AppAPI.AppGroupList> = {
|
||||
data: result?.result?.list ? result?.result?.list : [],
|
||||
success: result?.success,
|
||||
total: result?.result?.pagination ? result?.result?.pagination.total : 0,
|
||||
totalPages: result?.result?.pagination?.totalPages,
|
||||
};
|
||||
return Promise.resolve(data);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* parse Saml2 MetadataFile
|
||||
*/
|
||||
export async function parseSaml2MetadataFile(
|
||||
file: UploadFile,
|
||||
): Promise<API.ApiResult<Record<string, any>>> {
|
||||
return request(`/api/v1/app/saml2/parse/metadata_file`, {
|
||||
method: 'POST',
|
||||
data: { file: file.originFileObj },
|
||||
headers: {
|
||||
'content-type': 'multipart/form-data',
|
||||
},
|
||||
}).catch(({ response: { data } }) => {
|
||||
return data;
|
||||
});
|
||||
export async function getAllAppGroupList(
|
||||
params: Record<string, any>,
|
||||
sort: Record<string, SortOrder>,
|
||||
filter: Record<string, (string | number)[] | null>,
|
||||
): Promise<RequestData<AppAPI.AppGroupList>> {
|
||||
let pageSize = 100,
|
||||
current = 1;
|
||||
// 存储所有数据的数组
|
||||
let result: RequestData<AppAPI.AppGroupList> = {
|
||||
data: [],
|
||||
success: false,
|
||||
total: undefined,
|
||||
};
|
||||
|
||||
while (true) {
|
||||
// 调用分页接口
|
||||
const { success, data, total } = await getAppGroupList(
|
||||
{ current, pageSize, ...params },
|
||||
sort,
|
||||
filter,
|
||||
);
|
||||
if (success && data) {
|
||||
// 如果当前页没有数据,表示已经加载完全部数据,退出循环
|
||||
if (data?.length === 0) {
|
||||
break;
|
||||
}
|
||||
result = { data: result.data?.concat(data), success: success, total: total };
|
||||
// 增加当前页码
|
||||
if (total && total <= pageSize * current) {
|
||||
break;
|
||||
} else {
|
||||
current = current + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue