import { request } from '@vtx/utils';

export const getUserInfo = async id => {
    const res = await request.get('/cloud/gas/api/v1/gasUser/get', { data: { id } });
    if (res?.result === 0) {
        return res?.data;
    }
    return {};
};

export const getSecurityCheckRecordPage = (id, dataSearch) => async ({ current, pageSize }) => {
    const body = {
        page: current - 1,
        size: pageSize,
        ...dataSearch,
        gasUserId: id,
    };
    let list = [];
    let total = 0;
    const res = await request.get(`/cloud/gas/api/v1/homeSecurityCheckRecord/page`, {
        body,
    });
    if (res?.result === 0) {
        if (Array.isArray(res.data?.rows)) {
            list = res.data.rows.map(item => ({
                ...item,
                key: item.id,
            }));
            total = res.data.total;
        }
    }
    return {
        list,
        total,
    };
};
