import request from '@/utils/request';
import { wrapTreeNode } from '@/utils/format';
import type { UserTypeModel } from './data';

// 获取模块列表数据
export async function getUserTypeList(params?: any) {
    
    const data = await request('/FrameWork/GetUserTypeList', {
        method: 'GET',
        params: {...params,pageindex: params.current,pagesize:params.pageSize},
    })


    if (data.Result_Code !== 100) {
        return []
    }
    const treeTable = wrapTreeNode(data.Result_Data.List);
  
    return treeTable;
}
// 获取模块列表数据
export async function getUserTypeCount(params?: any) {
    
    const data = await request('/FrameWork/GetUserTypeCount', {
        method: 'GET',
        params,
    })


    if (data.Result_Code !== 100) {
        return {}
    }
  
    return data.Result_Data;
}
// 更新模块
export async function updataUserType(params?: UserTypeModel) {
    return request('/platform/synchroUserType', {
        method: 'POST',
        data: {
            ...params,
        },
        requestType: 'form'
    });
}

// 删除模块
export async function delUserType(UserType: number) {
    return request(`/Platform/DeleteUserType`, {
        method: 'GET', 
        params: {
            UserType
        }
    });
}
/* 模块列表end */

