import { CustomUserModel, CustomUserQueryParam, CustomUserDto } from '@/types'
import request from '@/until/request'

/**
 * 获取客户列表
 * @param data CustomUserQueryParam
 */
const QueryCustomUserList = (data: CustomUserQueryParam) =>
    request({
        url: '/CustomUserAction/list',
        method: 'post',
        data: data
    })

/**
* 新增客户
* @param data CustomUserModel
*/
const AddCustomUser = (data: CustomUserModel) =>
    request({
        url: '/CustomUserAction/saveCustomUser',
        method: 'post',
        data: data
    })

/**
* 编辑客户
* @param data CustomUserModel
*/
const EditCustomUser = (data: CustomUserModel) =>
    request({
        url: '/CustomUserAction/updateCustomUser',
        method: 'post',
        data: data
    })

/**
* 删除客户
* @param  id number
*/
const DeleteCustomUser = (id: number) =>
    request({
        url: '/CustomUserAction/deleteCustomUser/' + id,
        method: 'get',
    })

/**
* 客户登陆
* @param loginId string
* @param loginPwd string
*/
const Login = (loginId: string, loginPwd: string) =>
    request({
        url: '/CustomUserAction/loginCustomUser/' + loginId + "/" + loginPwd,
        method: 'get',
    })


/**
* 客户注册
* @param data CustomUserDto
*/
const RegistUser = (data: CustomUserDto) =>
    request({
        url: '/CustomUserAction/registCustomUser/' + data.authCode + "/" + data.userName + "/" + data.loginId + "/" + data.loginPwd,
        method: 'get',
    })

export default {
    QueryCustomUserList,
    AddCustomUser,
    EditCustomUser,
    DeleteCustomUser,
    Login,
    RegistUser
}