import { Service } from '@zenview/micro-basic-library';
import { cache } from '@zenview/micro-utils';
import URL from "./url";
const getHeaders = () => {
  return {
    Authorization: cache.getCache('token', 'session')
  }
}
class RelationShipServer {
  getSignatureByAidOrPersonId(option) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getSignatureByAidOrPersonId.value,
      method: "post",
      data: option,
      requestId: URL.getSignatureByAidOrPersonId.requestId,
    })
  }

  getPersonById(option) {
    return Service.$http({
      headers: getHeaders(),
      url: option.url,
      data: { ...option, url: undefined },
      method: "post",
      requestId: URL.getPersonById.requestId,
    })
  }
  
  queryPersonTags(option) {
    return Service.$http({
      headers: getHeaders(),
      url: option,
      data:{},
      method: "post",
      requestId: URL.queryPersonTags.requestId,
    })
  }

  queryRecentAppearance(option) {
    return Service.$http({
      headers: getHeaders(),
      url: option,
      data:{},
      method: "post",
      requestId: URL.queryRecentAppearance.requestId,
    })
  }
  queryVehicleOwnerInfoUrl(option) {
    return Service.$http({
      headers: getHeaders(),
      url: option,
      data:{},
      method: "post",
      requestId: 'queryVehicleOwnerInfoUrl',
    })
  }
  queryVehicleAndNonVehicleRelationUrl(option) {
    return Service.$http({
      headers: getHeaders(),
      url: option,
      data:{},
      method: "post",
      requestId:'queryVehicleAndNonVehicleRelationUrl',
    })
  }

  getSignatureUrlByPlateIds(option) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getSignatureUrlByPlateIds.value,
      method: "post",
      data: option,
      requestId: URL.getSignatureUrlByPlateIds.requestId,
    })
  }

  getUrl(option) {
    return Service.$http({
      headers: getHeaders(),
      url: option,
      data:{},
      method: "post",
      requestId: 'vehicleGetUrl',
    })
  }

  queryVehicleBaseInfo(data) {
    if (data.url.viewByPlateIdUrl) {
      return Service.$http({
        headers: getHeaders(),
        url: data.url.viewByPlateIdUrl,
        method: "post",
        data: data.plateId||{},
        requestId: URL.queryVehicleBaseInfo.requestId,
      })
    } else {
      return Service.$http({
        headers: getHeaders(),
        url: URL.queryVehicleBaseInfo.value,
        method: "post",
        data: data.plateId||{},
        requestId: URL.queryVehicleBaseInfo.requestId,
      })
    }
  }

  queryLastAppearInfo(data) {
    if (data.url.queryLastAppearInfoUrl) {
      return Service.$http({
        headers: getHeaders(),
        url: data.url.queryLastAppearInfoUrl,
        method: "post",
        data: data.plateId||{},
        requestId: URL.queryLastAppearInfo.requestId,
      })
    } else {
      return Service.$http({
        headers: getHeaders(),
        url: URL.queryLastAppearInfo.value,
        method: "post",
        data: data.plateId||{},
        requestId: URL.queryLastAppearInfo.requestId,
      })
    }
  }

  queryFirstAppearInfo(data) {
    if (data.url.queryFirstAppearInfoUrl) {
      return Service.$http({
        headers: getHeaders(),
        url: data.url.queryFirstAppearInfoUrl,
        method: "post",
        data: data.plateId||{},
        requestId: URL.queryFirstAppearInfo.requestId,
      })
    } else {
      return Service.$http({
        headers: getHeaders(),
        url: URL.queryFirstAppearInfo.value,
        method: "post",
        data: data.plateId||{},
        requestId: URL.queryFirstAppearInfo.requestId,
      })
    }
  }

  getVehicleById(id) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getVehicleById.value.replace("<id>", id),
      method: "post",
      data: { id },
      requestId: URL.getVehicleById.requestId,
    })
  }
  
  queryPersons(id) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryPersons.value.replace("<id>", id),
      method: "post",
      data: {id},
      requestId: URL.queryPersons.requestId,
    })
  }
  
  queryPersonAccompanies(url) {
    return Service.$http({
      headers: getHeaders(),
      url,
      data:{},
      method: "post",
      requestId: 'queryPersonAccompanies',
    })
  }

  getAidsTogetherByAid(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getAidsTogetherByAid.value,
      method: "post",
      data: options,
      requestId: URL.getAidsTogetherByAid.requestId,
    })
  }

  getPersonFrequentedPlaces(url, data, options) {
    return Service.$http({
      headers: getHeaders(),
      url,
      method: "post",
      data: options,
      requestId: URL.getPersonFrequentedPlaces.requestId,
    })
  }

  getLivePlaceByAid(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getLivePlaceByAid.value,
      method: "post",
      data: options,
      requestId: URL.getLivePlaceByAid.requestId,
    })
  }

  queryAidAndXidRelation(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryAidAndXidRelation.value,
      method: "post",
      data: options,
      requestId: URL.queryAidAndXidRelation.requestId,
    })
  }
  
  queryAidAndCidRelation(url) {
    return Service.$http({
      headers: getHeaders(),
      url,
      method: "post",
      data: {},
      requestId: URL.queryAidAndCidRelation.requestId,
    })
  }
  
  getPersonRoommates(url) {
    return Service.$http({
      headers: getHeaders(),
      url,
      method: "post",
      data: {},
      requestId: 'getPersonRoommates',
    })
  }

  getAidsByCidAndAids(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getAidsByCidAndAids.value,
      method: "post",
      data: options,
      requestId: URL.getAidsByCidAndAids.requestId,
    })
  }

  getAidsByFrequentPid(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.getAidsByFrequentPid.value,
      method: "post",
      data: options,
      requestId: URL.getAidsByFrequentPid.requestId,
    })
  }
  
  queryVehicleAndXidRelation(data) {
    if (data.url) {
      return Service.$http({
        headers: getHeaders(),
        url: data.url,
        method: "post",
        data: {plateId:data.plateId||{}},
        requestId: URL.queryVehicleAndXidRelation.requestId,
      })
    } else {
      return Service.$http({
        headers: getHeaders(),
        url: URL.queryVehicleAndXidRelation.value,
        method: "post",
        data: {plateId:data.plateId||{}},
        requestId: URL.queryVehicleAndXidRelation.requestId,
      })
    }
  }

  queryDetailAccompany(url, data) {
    return Service.$http({
      headers: getHeaders(),
      url,
      data,
      method: "post",
      requestId: 'queryDetailAccompany',
    })
  }

  getDetailTogether(url, data) {
    return Service.$http({
      headers: getHeaders(),
      url,
      method: "post",
      data,
      requestId: URL.getDetailTogether.requestId,
    })
  }
  
  queryAidDetail(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryAidDetail.value,
      method: "post",
      data: options,
      requestId: URL.queryAidDetail.requestId,
    })
  }

  queryVehicleAndXidDetail(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryVehicleAndXidDetail.value,
      method: "post",
      data: options,
      requestId: URL.queryVehicleAndXidDetail.requestId,
    })
  }

  queryAidSamePassengerDetail(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryAidSamePassengerDetail.value,
      method: "post",
      data: options,
      requestId: URL.queryAidSamePassengerDetail.requestId,
    })
  }

  queryAidDriverDetail(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryAidDriverDetail.value,
      method: "post",
      data: options,
      requestId: URL.queryAidDriverDetail.requestId,
    })
  }
  queryAidAndNonVehicleRelation(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryAidAndNonVehicleRelation.value,
      method: "post",
      data: options,
      requestId: URL.queryAidAndNonVehicleRelation.requestId,
    })
  }
  queryPersonAndVehicleOwnerRelation(options) {
    return Service.$http({
      headers: getHeaders(),
      url: URL.queryPersonAndVehicleOwnerRelation.value,
      method: "post",
      data: options,
      requestId: URL.queryPersonAndVehicleOwnerRelation.requestId,
    })
  }


}
const relationShip = new RelationShipServer();

export default relationShip;
