import { AddReq, UserPageQuery } from '@fast-crud/fast-crud';
import { request } from '/@/utils/service';

export const apiPrefix = '/api/system/app_user/';
export async function  GetList(query: UserPageQuery) {
		const res=request({
			url: apiPrefix+'?user_type=1',
			method: 'get',
			params: query,
		});
		console.log("ressssss",res)
		return res


		// const [res1, res3] = await Promise.all([
		// request({
		// 	url: apiPrefix + '?user_type=1',
		// 	method: 'get',
		// 	params: query,
		// }),
		// request({
		// 	url: apiPrefix + '?user_type=3',
		// 	method: 'get',
		// 	params: query,
		// }),
		// ])
		// console.log("ressssss",res1)
		// console.log("ressssss3333",res3)
		// console.log("resdatassss::",res1.data)

		// // 提取并合并 data 数组
		// const mergedData = [...(res1?.data|| []), ...(res3?.data || [])]

		// console.log("mergedDataddddddd::",mergedData)

		// // 可选：合并分页信息（根据需要处理）
		// const mergedResult = {
		// code: 2000,
		// msg: 'success',
		// total: mergedData.length,
		// data: mergedData,
		// page: 1,
		// limit: mergedData.length,
		// is_next: false,
		// is_previous: false,
		// }

		// console.log("mergedResultaaaaaaa::",mergedResult)

		// return mergedResult





}
export function GetObj(id: InfoReq) {
	return request({
		url: apiPrefix + id+ '/',
		method: 'get',
	});
}

export function AddObj(obj: AddReq) {
	return request({
		url: apiPrefix,
		method: 'post',
		data: obj,
	});
}

export function UpdateObj(obj: EditReq) {
	return request({
		url: apiPrefix + obj.id + '/',
		method: 'put',
		data: obj,
	});
}

export function DelObj(id: DelReq) {
	return request({
		url: apiPrefix + id + '/',
		method: 'delete',
		data: { id },
	});
}
export function GetPermission() {
    return request({
        url: apiPrefix,
        method: 'get',
    });
	// const users =  getUsersByTypes([1, 3])
	// return users
}

// const getUsersByTypes = async (types: number[]) => {
// 	const requests = types.map(type =>
// 		request({
// 			url: apiPrefix,
// 			method: 'get',
// 			params: { user_type: type }
// 		})
// 	)
// 	const results = await Promise.all(requests)
// 	return results.flatMap(res => res.data.data)
//   }
  

export function GetTree() {
	return request({
		url: `/api/system/organization/tree/`,
		method: 'get',
	});
}