package com.project.zcustom.controller.backManager.engineering;


import com.project.zcustom.controller.core.AjaxResult;
import com.project.zcustom.controller.core.BaseController;
import com.project.zcustom.domain.addional.LargeCamera;
import com.project.zcustom.service.unit.ILargeCameraService;
import lombok.RequiredArgsConstructor;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 摄像头Controller
 *
 * @author change
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/zcustom/camera")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class LargeCameraController extends BaseController {

    @Autowired
    private final ILargeCameraService largeCameraService;

    @GetMapping("/list")
    public AjaxResult list(LargeCamera entity) {
        return AjaxResult.success("查询成功", largeCameraService.pagingLargeCameraList(entity));
    }

    @GetMapping("/listAll")
    public AjaxResult listAll(LargeCamera entity) {
        return AjaxResult.success("查询成功", largeCameraService.selectLargeCameraList(entity));
    }


    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success("查询成功", largeCameraService.getById(id));
    }


    @PostMapping("add")
    public AjaxResult add(@RequestBody LargeCamera entity) {
        return toAjax(largeCameraService.save(entity));
    }


    @PostMapping("edit")
    public AjaxResult edit(@RequestBody LargeCamera entity) {
        return toAjax(largeCameraService.updateById(entity));
    }


	@GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(largeCameraService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }


    /**
     * 某项目已接入摄像头
     */
    @GetMapping("/getConnectCameraNumByProject/{projectId}")
    public AjaxResult getConnectCameraNumByProject(@PathVariable Long projectId){
        return AjaxResult.success("查询成功", largeCameraService.getConnectCameraNumByProject(projectId));
    }

    /**
     * 在线摄像头数量
     */
    @GetMapping("/getConnectOnlineCameraNum")
    public AjaxResult getConnectOnlineCameraNum() {
        return AjaxResult.success("查询成功", largeCameraService.getConnectOnlineCameraNum());
    }
}
