package com.yh.saas.plugin.yiliangyiyun.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.CustomerInfo;
import com.yh.saas.plugin.yiliangyiyun.service.ICustomerInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 客户信息 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-07-21
 */
@RestController
@RequestMapping("/customerInfo")
public class CustomerInfoController {
    @Autowired
    private ICustomerInfoService customerInfoService;
    /**
     * 客户管理列表
     * @param customerInfo
     * @return
     */
    @GetMapping("/selectCustomerInfo")
    public Page<CustomerInfo> selectCustomerInfo(CustomerInfo customerInfo) {
        return customerInfoService.selectCustomerInfo(customerInfo);
    }

    /**
     * 增加\退回定金
     * @param customerInfo
     * @return
     */
    @PostMapping("/api/editCustomerInfo")
    public String editCustomerInfo(@RequestBody CustomerInfo customerInfo){
        return customerInfoService.editCustomerInfo(customerInfo);
    }
    /**
     * 设置默认定金比例
     * @param compId
     */
    @GetMapping("/api/installDepositRatio")
    public void installDepositRatio(String compId,Float depositRatio){
        customerInfoService.installDepositRatio(compId,depositRatio);
    }
    /**
     * 查看客户信息
     * @param id
     * @return
     */
    @GetMapping("/getCustomerInfo")
    public CustomerInfo getCustomerInfo(String id) {
        return customerInfoService.getCustomerInfo(id);
    }
     /**
     * 添加客户信息
     * @param customerInfo
     * @return
     */
    @PostMapping("/api/addCustomerInfo")
    public String addCustomerInfo(@RequestBody CustomerInfo customerInfo){
        return customerInfoService.addCustomerInfo(customerInfo);
    }
    /**
     * 编辑客户信息
     * @param customerInfo
     * @return
     */
    @PostMapping("/api/modifyCustomerInfo")
    public String modifyCustomerInfo(@RequestBody CustomerInfo customerInfo){
        return customerInfoService.modifyCustomerInfo(customerInfo);
    }

    /**
     * 删除客户信息
     *
     * @param example
     * @return
     */
    @PostMapping("/deleteCustomerInfo")
    public void deleteCustomerInfo(@RequestBody CustomerInfo example) {
        customerInfoService.deleteCustomerInfo(example.getId());
    }
    /**
     * 客户下拉列表
     * @param compId
     * @return
     */
    @GetMapping("/customerList")
    public List<CustomerInfo> customerList(@RequestParam String compId) {
        return customerInfoService.customerList(compId);
    }
    /**
     * 查看客户账户信息
     * @param customerInfo
     * @return
     */
    @GetMapping("/getPayeeInfo")
    public CustomerInfo getPayeeInfo(CustomerInfo customerInfo) {
        return customerInfoService.getPayeeInfo(customerInfo);
    }

}

