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


import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.DriverCarInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.DriverViewInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.view.DistinguishView;
import com.yh.saas.plugin.yiliangyiyun.exception.AppServiceException;
import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
import com.yh.saas.plugin.yiliangyiyun.service.IDriverViewInfoService;
import com.yh.saas.plugin.yiliangyiyun.util.EntityAnalyse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 记录司机信息 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-29
 */
@RestController
@RequestMapping("/driverViewInfo")
public class DriverViewInfoController {
    @Autowired
    private IDriverViewInfoService driverViewInfoService;

    /**
     * 司机管理页面列表
     * @param driverViewInfo
     * @return
     */
    @GetMapping("/selectDriverInfoPage")
    public Page<DriverViewInfo> selectDriverInfoPage(DriverViewInfo driverViewInfo){
        return driverViewInfoService.selectDriverInfoPage(driverViewInfo);
    }
    /**
     * 查看司机信息
     * @param id
     * @return
     */
    @GetMapping("/getDriver")
    public DriverViewInfo getDriver (String id){
        return driverViewInfoService.getDriver(id);
    }

    /**
     * 删除司机信息
     * @param driverViewInfo
     */
    @PostMapping("/api/deleteDriver")
    public void deleteDriver(@RequestBody DriverViewInfo driverViewInfo) {
        driverViewInfoService.deleteDriver(driverViewInfo.getId());
    }

    /**
    * 添加信息
     */
    @PostMapping("/api/addInfo")
    public String addInfo(@RequestBody DriverViewInfo driverViewInfo){
        return driverViewInfoService.addInfo(driverViewInfo);
    }

    /**
     * 编辑信息
     */
    @PostMapping("/api/editInfo")
    public String editInfo(@RequestBody DriverViewInfo driverViewInfo) {
        return driverViewInfoService.editInfo(driverViewInfo);
    }

    /**
     * 禁用
     */
    @PostMapping("/api/editDisableInfo")
    public String editDisableInfo(@RequestBody DriverViewInfo driverViewInfo){
        return driverViewInfoService.editDisableInfo(driverViewInfo);
    }

    /**
     * 识别身份证
     * @param personImg
     * @return
     */
    @GetMapping("/personShibie")
    public DistinguishView personShibie (String personImg){
        return EntityAnalyse.personShibie(personImg);
    }

    /**
     * 银行卡
     * @param bankImg
     * @return
     */
    @GetMapping("/bankShibie")
    public DistinguishView bankShibie (String bankImg){
        return EntityAnalyse.bankShibie(bankImg);
    }

    /**
     * 司机姓名电话下拉列表
     */
    @GetMapping("/selectDriverName")
    public List<DriverViewInfo> selectDriverName(String compId){
        return driverViewInfoService.selectDriverName(compId);
    }

    /**
     * 根据姓名查电话、根据电话查姓名
     */
    @GetMapping("/selectDriverDetail")
    public DriverCarInfo selectDriverPhoneByName(String id){
        return driverViewInfoService.selectDriverDetail(id);
    }
    /**
     * 审核
     * @param driverViewInfo
     * @return
     */
    @PostMapping("/api/examine")
    public String examine(@RequestBody DriverViewInfo driverViewInfo){
        return driverViewInfoService.examine(driverViewInfo);
    }
    /**
     * 查手机号是否存在
     * @param driverViewInfo
     * @return
     */
    @GetMapping("/selectPhone")
    public DriverViewInfo selectPhone(DriverViewInfo driverViewInfo) throws AppServiceException {
        return driverViewInfoService.selectPhone(driverViewInfo);
    }
    /**
     * 更改手机号
     * @param driverViewInfo
     * @return
     */
    @PostMapping("/api/modifyPhone")
    public String modifyPhone(@RequestBody DriverViewInfo driverViewInfo) {
        return driverViewInfoService.modifyPhone(driverViewInfo);
    }
    /**
     * 根据用户id查看司机
     */
    @GetMapping("/getInfo")
    public DriverViewInfo getInfo(@RequestParam String commonId) throws ServiceException {
        return driverViewInfoService.getInfo(commonId);
    }

}

