package com.yuchen.saas.park.service.controller.device;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.entity.park.PmgBatParkCompany;
import com.yuchen.saas.park.api.entity.park.PmgBatParkPeople;
import com.yuchen.saas.park.api.entity.park.PmgBatParkVisitor;
import com.yuchen.saas.park.api.entity.park.PmgBtnDeviceOther;
import com.yuchen.saas.park.api.vo.park.DeviceAndOtherVo;
import com.yuchen.saas.park.api.vo.park.PmgBatParkCompanyVo;
import com.yuchen.saas.park.api.vo.park.PmgBatSmartEquipmentVo;
import com.yuchen.saas.park.service.service.PmgBtnDeviceOtherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author 刘通
 * @date 2020/12/31 10:49
 */
@RestController
@AllArgsConstructor
@RequestMapping("/deviceOther")
@Api(value = "设备关联对象", tags = "设备关联接口")
public class PmgBtnDeviceOtherController {
    @Autowired
    PmgBtnDeviceOtherService pmgBtnDeviceOtherService;
    /************** 设备关联园内人员接口开始 ***************/
    /**
     * 未与该设备绑定的人员
     */
    @GetMapping("/getParkPeopleList")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<DeviceAndOtherVo>> getParkPeopleList(@RequestParam String deviceId) {
        List<DeviceAndOtherVo> getParkPeopleList = pmgBtnDeviceOtherService.getParkPeopleList(deviceId);
        return  R.data(getParkPeopleList);
    }
    /**
     * 园内人员列表接口(与该设备绑定的人员)
     */
    @GetMapping("/getParkPeopleListV2")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<PmgBatParkPeople>> getParkPeopleListV2(@RequestParam String deviceId) {
        List<PmgBatParkPeople> getParkPeopleList = pmgBtnDeviceOtherService.getParkPeopleListV2(deviceId);
        return  R.data(getParkPeopleList);
    }

    /**
     * 通过人员ID 获取绑定的设备
     * @param peopleId 人员ID
     * @return
     */
    @GetMapping("/getParkPeopleListV3")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "查询", notes = "传入人员ID")
    public R<List<PmgBatSmartEquipment>> getParkPeopleListV3(String peopleId) {
        List<PmgBatSmartEquipment> getParkPeopleList = pmgBtnDeviceOtherService.getParkPeopleListV3(peopleId);
        return  R.data(getParkPeopleList);
    }
    /************** 设备关联园内人员接口结束 ***************/

    /************** 设备关联访客人员接口开始 ***************/
    /**
     * 访客人员列表接口(未与该设备绑定的人员)
     */
    @GetMapping("/getParkVisitorList")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<DeviceAndOtherVo>> getParkVisitorList(String deviceId) {
        List<DeviceAndOtherVo> getParkVisitorList = pmgBtnDeviceOtherService.getParkVisitorList(deviceId);
        return  R.data(getParkVisitorList);
    }
    /**
     * 人员/公司/设备 列表接口(与该设备绑定的人员/公司/设备)
     */
    @GetMapping("/getParkVisitorListV2")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<PmgBatParkVisitor>> getParkVisitorListV2(String deviceId) {
        List<PmgBatParkVisitor> getParkVisitorListV2 = pmgBtnDeviceOtherService.getParkVisitorListV2(deviceId);
        return  R.data(getParkVisitorListV2);
    }
    /**
     * 通过人员ID 获取绑定的设备
     * @param peopleId 人员ID
     * @return
     */
    @GetMapping("/getParkVisitorListV3")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "查询", notes = "传入人员ID")
    public R<List<PmgBatSmartEquipment>> getParkVisitorListV3(String peopleId) {
        List<PmgBatSmartEquipment> getParkPeopleList = pmgBtnDeviceOtherService.getParkVisitorListV3(peopleId);
        return  R.data(getParkPeopleList);
    }
    /************** 设备关联访客人员接口结束 ***************/
    /************** 设备关联公司接口开始 ***************/
    @GetMapping("/getParkCompanyList")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<DeviceAndOtherVo>> getParkCompanyList(String deviceId) {
        List<DeviceAndOtherVo> getParkCompanyList = pmgBtnDeviceOtherService.getParkCompanyList(deviceId);
        return  R.data(getParkCompanyList);
    }
    /**
     * 与该设备绑定的公司列表
     */
    @GetMapping("/getParkCompanyListV2")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<PmgBatParkCompany>> getParkCompanyListV2(String deviceId) {
        List<PmgBatParkCompany> getParkCompanyList = pmgBtnDeviceOtherService.getParkCompanyListV2(deviceId);
        return  R.data(getParkCompanyList);
    }
    /**
     * 与该设备绑定的公司列表
     */
    @GetMapping("/getParkCompanyListV3")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<PmgBatParkCompanyVo>> getParkCompanyListV3(@RequestParam String productKey, @RequestParam String deviceName) {
        List<PmgBatParkCompanyVo> getParkCompanyList = pmgBtnDeviceOtherService.getParkCompanyListV3(productKey, deviceName);
        return  R.data(getParkCompanyList);
    }
    /************** 设备关联公司接口结束 ***************/
    /************** 设备关联设备接口开始 ***************/
    @GetMapping("/getParkDeviceList")
    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<DeviceAndOtherVo>> getParkDeviceList(String deviceId) {
        List<DeviceAndOtherVo> getParkDeviceList = pmgBtnDeviceOtherService.getParkDeviceList(deviceId);
        return  R.data(getParkDeviceList);
    }
    /**
     * 与该设备绑定的设备列表
     */
    @GetMapping("/getParkDeviceListV2")
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<PmgBatSmartEquipmentVo>> getParkDeviceListV2(String deviceId) {
        List<PmgBatSmartEquipmentVo> getParkDeviceList =
                pmgBtnDeviceOtherService.getParkDeviceListV2(deviceId);
        return  R.data(getParkDeviceList);
    }
    /************** 设备关联设备接口结束 ***************/

    /************** 共有接口开始 ***************/
    /**
     * 人员/公司/设备和设备绑定的保存接口(批量)
     */
    @PostMapping("/saveList")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "新增", notes = "传入设备关联对象")
    public R saveList(@Valid @RequestBody List<PmgBtnDeviceOther> pmgBtnDeviceOtherList) {
        return R.status(pmgBtnDeviceOtherService.saveList(pmgBtnDeviceOtherList));
    }
    /**
     * 解绑接口(批量)
     */
    @PostMapping("/deleteList")
    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "新增", notes = "传入设备关联对象")
    public R deleteList(@Valid @RequestBody List<PmgBtnDeviceOther> pmgBtnDeviceOtherList) {
        return R.status(pmgBtnDeviceOtherService.deleteList(pmgBtnDeviceOtherList));
    }
    /**
     * 查询未绑定当前人员/公司/设备的设备列表
     */
    @GetMapping("/getDeviceListByOtherId")
    @ApiOperationSupport(order = 13)
    @ApiOperation(value = "查询", notes = "传入设备ID")
    public R<List<PmgBatSmartEquipmentVo>> getDeviceListByOtherId(String productKey, String otherId) {
        List<PmgBatSmartEquipmentVo> getParkOtherList =
                pmgBtnDeviceOtherService.getDeviceListByOtherId(productKey, otherId);
        return  R.data(getParkOtherList);
    }
    /************** 共有接口结束 ***************/


 }
