import { defHttp } from '/@/utils/http/axios';
import {
  GetUnitListModel,
  DeleteBatchesParams,
  UnitIdParams,
  AddUnitParams,
  EditUnitParams,
  GetPersonListModel,
  GetUnitModel,
  GetPersonModel,
  PersonIdParams,
  AddPersonParams,
  EditPersonParams,
  GetMemberListModel,
  GetMemberModel,
  MemberIdParams,
  AddMemberParams,
  EditMemberParams,
} from './model/memberModel';

enum Api {
  MemberUrl = '/member/',
  UnitUrl = '/member/unit',
  PersonUrl = '/member/person',
}

/**
 * @description: GetUnitList
 */
export function getUnitList(params) {
  console.log('-------------------getUnitList---------------');
  return defHttp.request<GetUnitListModel>({
    url: Api.UnitUrl,
    method: 'GET',
    params,
  });
}

/**
 * @description: addUnit
 */
export function addUnit(params: AddUnitParams) {
  return defHttp.request<GetUnitListModel>({
    url: Api.UnitUrl,
    method: 'POST',
    params,
  });
}
/**
 * @description: 批量删除单位
 */
export function deleteBatchesUnit(params: DeleteBatchesParams) {
  return defHttp.request<GetUnitListModel>({
    url: Api.UnitUrl,
    method: 'DELETE',
    params,
  });
}

/**
 * @description: 获取单个单位
 */
export function getUnit(params: UnitIdParams) {
  return defHttp.request<GetUnitModel>({
    url: Api.UnitUrl + '/' + params.id,
    method: 'GET',
  });
}
/**
 * @description: 修改单个单位
 */
export function editUnit(params: EditUnitParams) {
  return defHttp.request<GetUnitListModel>({
    url: Api.UnitUrl + '/' + params.id,
    method: 'PUT',
    params,
  });
}
/**
 * @description: 删除单个会员
 */
export function deleteUnit(params: UnitIdParams) {
  return defHttp.request<GetUnitListModel>({
    url: Api.UnitUrl + '/' + params.id,
    method: 'DELETE',
  });
}

/**
 * @description: GetPersonList -----------------------------------------------
 */
export function getPersonList(params) {
  console.log('-------------------getPersonList---------------');
  return defHttp.request<GetPersonListModel>({
    url: Api.PersonUrl,
    method: 'GET',
    params,
  });
}

/**
 * @description: addPerson
 */
export function addPerson(params: AddPersonParams) {
  return defHttp.request<GetPersonListModel>({
    url: Api.PersonUrl,
    method: 'POST',
    params,
  });
}
/**
 * @description: 批量删除个人
 */
export function deleteBatchesPerson(params: DeleteBatchesParams) {
  return defHttp.request<GetPersonListModel>({
    url: Api.PersonUrl,
    method: 'DELETE',
    params,
  });
}

/**
 * @description: 获取单个个人
 */
export function getPerson(params: PersonIdParams) {
  return defHttp.request<GetPersonModel>({
    url: Api.PersonUrl + '/' + params.id,
    method: 'GET',
  });
}
/**
 * @description: 修改单个个人
 */
export function editPerson(params: EditPersonParams) {
  return defHttp.request<GetPersonListModel>({
    url: Api.PersonUrl + '/' + params.id,
    method: 'PUT',
    params,
  });
}
/**
 * @description: 删除单个个人
 */
export function deletePerson(params: PersonIdParams) {
  return defHttp.request<GetPersonListModel>({
    url: Api.PersonUrl + '/' + params.id,
    method: 'DELETE',
  });
}

/**
 * @description: GetMemberList -----------------------------------------------
 */
export function getMemberList(params) {
  console.log('-------------------getMemberList---------------');
  return defHttp.request<GetMemberListModel>({
    url: Api.MemberUrl,
    method: 'GET',
    params,
  });
}

/**
 * @description: addMember
 */
export function addMember(params: AddMemberParams) {
  return defHttp.request<GetMemberListModel>({
    url: Api.MemberUrl,
    method: 'POST',
    params,
  });
}
/**
 * @description: 批量删除会员
 */
export function deleteBatchesMember(params: DeleteBatchesParams) {
  return defHttp.request<GetMemberListModel>({
    url: Api.MemberUrl,
    method: 'DELETE',
    params,
  });
}

/**
 * @description: 获取单个会员
 */
export function getMember(params: MemberIdParams) {
  return defHttp.request<GetMemberModel>({
    url: Api.MemberUrl + params.id,
    method: 'GET',
  });
}
/**
 * @description: 修改单个会员
 */
export function editMember(params: EditMemberParams) {
  return defHttp.request<GetMemberListModel>({
    url: Api.MemberUrl + params.id,
    method: 'PUT',
    params,
  });
}
/**
 * @description: 删除单个会员
 */
export function deleteMember(params: MemberIdParams) {
  return defHttp.request<GetMemberListModel>({
    url: Api.MemberUrl + params.id,
    method: 'DELETE',
  });
}
