import http from '@/utils/http';
import { Customer } from '@/enums/api'
import {
    AddCustomerReqParams,
    CustomerListReqParams,
    ModifyCustomerReqParams,
    CustomerListResParams,
    AddCustomerResParams,
    CustomerDetailResParams
} from '@/types/customer'

/**
 * 获取客户信息列表
 * @param params RequestCustomerListParams
 * @returns
 */
export const getCustomerList = (data: CustomerListReqParams) => {
    const url = Customer.BIZ_CUSTOMER_LIST
    return http.post<CustomerListResParams>(
        url,
        data
    )
}

/**
 * 添加客户
 * @param params RequestAddCustomerParams
 * @returns
 */
export const addCustomer = (data: AddCustomerReqParams) => {
    const url = Customer.BIZ_CUSTOMER_ADD;
    return http.post<AddCustomerResParams>(
        url,
        data
    )
}

/**
 * 修改客户信息
 * @param params RequestModifyCustomerParams
 * @returns
 */
export const modifyCustomer = (data: ModifyCustomerReqParams) => {
    const url = Customer.BIZ_CUSTOMER_MODIFY;
    return http.post<BaseResParams>(
        url,
        data
    )
}

/**
 * 删除客户
 * @param id 客户编号
 * @returns
 */
export const removeCustomer = (id: string) => {
    const url = Customer.BIZ_CUSTOMER_REMOVE;
    const data = {id}
    return http.post<BaseResParams>(
        url,
        data
    )
}

/**
 * 获取客户详情
 * @param id 客户编号
 * @returns
 */
export const getCustomerDetail = (id: string) => {
    const url = Customer.BIZ_CUSTOMER_DETAIL;
    const data = {id}
    return http.post<CustomerDetailResParams>(
        url,
        data
    )
}
