import { defHttp } from '/@/utils/http/axios';
import { PageParams, ListGetResultModel, DelParams } from './model';
import { Result } from '/#/axios';

enum Api {
  pageList = '/zfb-api/zfb/shop/sys/user/staffList',
  preDel = '/zfb-api/zfb/shop/sys/user/preDeleteStaff',
  roleList = '/zfb-api/zfb/shop/sys/user/roleList',
  staffSave = '/zfb-api/zfb/shop/sys/user/staffSave',
  update = '/zfb-api/zfb/shop/sys/user/update',
  checkUser = '/zfb-api/zfb/user/checkUserExists',
  deleteStaff = '/zfb-api/zfb/shop/sys/user/deleteStaff',
  getNumByStaff = '/zfb-api/zfb/shop/sys/user/getNumByStaff',
}

/**
 * @description: Get sample list value
 */

export const ListApi = (params: PageParams) =>
  defHttp.post<ListGetResultModel>({
    url: Api.pageList,
    params,
    data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const getNumByStaff = (params: any) =>
  defHttp.get<Result>({
    url: Api.getNumByStaff,
    params,
    data: params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const delApi = (params: DelParams) =>
  defHttp.post<Result>({
    url: Api.deleteStaff,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const preDelApi = (params: number) =>
  defHttp.post<Result>({
    url: Api.preDel,
    params: { userId: params },
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const roleLIstApi = (params) =>
  defHttp.post<Result>({
    url: Api.roleList,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const checkUserApi = (params) =>
  defHttp.post<boolean>({
    url: Api.checkUser,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });

export const saveApi = (params) =>
  defHttp.post<Result>({
    url: Api.staffSave,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
export const updateApi = (params) =>
  defHttp.post<Result>({
    url: Api.update,
    params,
    headers: {
      // @ts-ignore
      ignoreCancelToken: true,
    },
  });
