package com.huimv.admin.controller;


import com.huimv.admin.common.utils.Result;
import com.huimv.admin.entity.EnvDevice;
import com.huimv.admin.service.IEnvDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-02-13
 */
@RestController
@RequestMapping("/envDevice")
@CrossOrigin
public class EnvDeviceController {
    @Autowired
    private IEnvDeviceService envDeviceService;

    @RequestMapping("/DeviceCount")
    public Result getDevice(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.count(httpServletRequest,paramsMap);
    }

    @RequestMapping("/DeviceList")
    public Result getDeviceList(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.list(httpServletRequest,paramsMap);
    }

    @RequestMapping("/DeviceAdd")
    public Result getDeviceAdd(HttpServletRequest httpServletRequest, @RequestBody EnvDevice envDevice) {
        return envDeviceService.add(httpServletRequest,envDevice);
    }

    @RequestMapping("/DeviceEdit")
    public Result getDeviceEdit(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.edit(httpServletRequest,paramsMap);
    }

    @RequestMapping("/DeviceDelete")
    public Result getDeviceDelete(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.delete(httpServletRequest,paramsMap);
    }

    @RequestMapping("/listPigpen")
    public Result listPigpen(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.listPigpen(httpServletRequest,paramsMap);
    }
    @RequestMapping("/listPigpenAll")
    public Result listPigpenAll(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.listPigpenAll(httpServletRequest,paramsMap);
    }

    @RequestMapping("/listEnv")
    public Result listEnv(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.listEnv(httpServletRequest,paramsMap);
    }

    @RequestMapping("/listDeviceCount")
    public Result listDeviceCount(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.listDeviceCount(httpServletRequest,paramsMap);
    }
    @RequestMapping("/bandingUnitId")
    public Result bandingUnitId(HttpServletRequest httpServletRequest, @RequestBody EnvDevice envDevice) {
        return envDeviceService.bandingUnitId(httpServletRequest,envDevice);
    }
    @RequestMapping("/unBandingUnitId")
    public Result unBandingUnitId(HttpServletRequest httpServletRequest, @RequestBody EnvDevice envDevice) {
        envDevice.setUnitId(0);
        envDevice.setUnitName("");
        envDeviceService.updateById(envDevice);
        return new Result(10000,"解绑成功",true);
    }
    @RequestMapping("/listByScreen")
    public Result listByScreen(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.listEnvCount(httpServletRequest,paramsMap);
    }

    @RequestMapping("/listData")
    public Result listData(HttpServletRequest httpServletRequest, @RequestBody Map<String, String> paramsMap) {
        return envDeviceService.listData(httpServletRequest,paramsMap);
    }
}
