package com.sooka.sponest.monitor.LabelManagement.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.sooka.sponest.monitor.LabelManagement.domain.CentermonitorCamera;
import com.sooka.sponest.monitor.LabelManagement.domain.CentermonitorSetLabel;
import com.sooka.sponest.monitor.LabelManagement.service.CentermonitorSetLabelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/SetLabel")
public class CentermonitorSetLabelController extends BaseController {
    @Resource
    private CentermonitorSetLabelService centermonitorSetLabelService;

    /**
     * 查询标签列表
     */
    @GetMapping("/getSetLabelList")
    public AjaxResult labelList(CentermonitorSetLabel centermonitorSetLabel) {
        return AjaxResult.success(centermonitorSetLabelService.getLabel(centermonitorSetLabel));
    }

    /**
     * 新增标签
     */
    @PostMapping("/addLabel")
    public AjaxResult addLabel(@RequestBody CentermonitorSetLabel centermonitorSetLabel) {
        return centermonitorSetLabelService.addLabel(centermonitorSetLabel);
    }

    /**
     * 修改标签
     */
    @PostMapping("/updateLabel")
    public AjaxResult updateLabel(@RequestBody CentermonitorSetLabel centermonitorSetLabel) {
        return centermonitorSetLabelService.UpdateLabel(centermonitorSetLabel);
    }

    /**
     * 查询设置标签修改页
     */
    @GetMapping("/getLabels/{id}")
    public AjaxResult getLabels(@PathVariable("id") Integer id) {
        return AjaxResult.success(centermonitorSetLabelService.getLabels(id));
    }

    /**
     * 设置标签页删除
     */
    @DeleteMapping("/deleteLabel/{id}")
    public AjaxResult deleteLabel(@PathVariable("id") Integer id) {
        return centermonitorSetLabelService.deletelabel(id);
    }

    /**
     * 设置标签页查询
     */
    @GetMapping("/Searchtags/{name}")
    public TableDataInfo Searchtags(@PathVariable("name") String name) {
        startPage();
        List<CentermonitorSetLabel> list = centermonitorSetLabelService.Searchtags(name);
        return getDataTable(list);
    }

    /**
     * 查询摄像头设备列表
     */
    @GetMapping("/getdevice")
    public TableDataInfo getdevice(CentermonitorSetLabel centermonitorSetLabel) {
        startPage();
        List<CentermonitorSetLabel> list = centermonitorSetLabelService.getdevice(centermonitorSetLabel);
        return getDataTable(list);
    }

    /**
     * 添加摄像头
     */
    @PostMapping("/addCamera")
    public AjaxResult addCamera(@RequestBody CentermonitorCamera centermonitorCamera) {
        return AjaxResult.success(centermonitorSetLabelService.addCamera(centermonitorCamera));
    }

    /**
     * 根据标签id查询摄像头设备列表
     */
    @GetMapping("/getCameraByLabelId")
    public TableDataInfo getCameraByLabelId(CentermonitorSetLabel centermonitorSetLabel) {
        startPage();
        List<CentermonitorSetLabel> list = centermonitorSetLabelService.getCameraByLabelId(centermonitorSetLabel);
        return getDataTable(list);
    }

    /*
     * 根据标签id和摄像头id删除
     */
    @DeleteMapping("/removeCameraByLabelId")
    public AjaxResult removeCameraByLabelId(CentermonitorSetLabel centermonitorSetLabel) {
        return AjaxResult.success(centermonitorSetLabelService.removeCameraByLabelId(centermonitorSetLabel));

    }

    /**
     * 可视化查询全部已经绑定标签
     */
    @GetMapping("/queryLabels")
    public AjaxResult queryLabels(CentermonitorSetLabel centermonitorSetLabel) {
        List<CentermonitorSetLabel> list = centermonitorSetLabelService.queryLabels(centermonitorSetLabel);
        return AjaxResult.success(list);
    }

    /**
     * 根据标签id查询摄像头预置点等信息
     */
    @GetMapping("/getCameraById")
    public AjaxResult getCameraById(CentermonitorSetLabel centermonitorSetLabel) {
        return AjaxResult.success(centermonitorSetLabelService.getCameraByLabelId(centermonitorSetLabel));
    }

    /**
     * 选择预置点
     */
    @PostMapping("/updatePresetPoint")
    public AjaxResult updatePresetPoint(@RequestBody CentermonitorSetLabel centermonitorSetLabel) {
        return toAjax(centermonitorSetLabelService.updatePresetPoint(centermonitorSetLabel));
    }

    /**
     * 根据标签子表id和设备id查询预置点信息
     */
    @GetMapping("/getCameraByIdAndDeviceId")
    public AjaxResult getCameraByIdAndDeviceId(CentermonitorSetLabel centermonitorSetLabel) {
        return AjaxResult.success(centermonitorSetLabelService.getCameraByIdAndDeviceId(centermonitorSetLabel));
    }
}