import request from '@/utils/request'

export function listByCustomerId(customerId) {
  return request({
    url: '/crm/customerProperty/list/' + customerId,
    method: 'get'
  })
}

export function getById(id) {
  return request({
    url: '/crm/customerProperty/' + id,
    method: 'get'
  })
}

export function add(data) {
  return request({
    url: '/crm/customerProperty/add',
    method: 'post',
    data: data
  })
}

export function addOrUpdate(data) {
  return request({
    url: '/crm/customerProperty/addOrUpdate',
    method: 'post',
    data: data
  })
}

export function addByTemplateId(customerId, templateId, propertyValue) {
  return request({
    url: '/crm/customerProperty/addByTemplateId',
    method: 'post',
    params: { customerId, templateId, propertyValue }
  })
}

export function addOrUpdateByTemplateId(customerId, templateId, propertyValue) {
  return request({
    url: '/crm/customerProperty/addOrUpdateByTemplateId',
    method: 'post',
    params: { customerId, templateId, propertyValue }
  })
}

export function batchAddByTemplateIds(customerId, propertyMap) {
  return request({
    url: '/crm/customerProperty/batchAddByTemplateIds/' + customerId,
    method: 'post',
    data: propertyMap
  })
}

export function update(data) {
  return request({
    url: '/crm/customerProperty',
    method: 'put',
    data: data
  })
}

export function del(ids) {
  return request({
    url: '/crm/customerProperty/' + ids,
    method: 'delete'
  })
}

export function deleteByPropertyId(customerId, propertyId) {
  return request({
    url: '/crm/customerProperty/deleteByPropertyId',
    method: 'delete',
    params: { customerId, propertyId }
  })
}
