package com.sz.admin.monitor.controller;


import com.sz.admin.monitor.pojo.dto.camera.CameraListDTO;
import com.sz.admin.monitor.pojo.dto.camera.CameraUpdateDTO;
import com.sz.admin.monitor.pojo.vo.camera.CameraVO;
import com.sz.admin.monitor.service.CameraService;
import com.sz.core.common.entity.ApiPageResult;
import com.sz.core.common.entity.ApiResult;
import com.sz.core.common.entity.PageResult;
import com.sz.core.common.entity.SelectIdsDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: CameraController
 * Package: com.sz.admin.monitor.controller
 * Description:
 */
@Tag(name = "摄像头表")
@RestController
@RequestMapping("camera")
@RequiredArgsConstructor
@Profile({"dev", "local", "preview"})
public class CameraController {
    private final CameraService cameraService;

    @Operation(summary = "修改")
    @PutMapping
    public ApiResult<Void> update(@RequestBody CameraUpdateDTO dto) {
        cameraService.update(dto);
        return ApiResult.success();
    }

    @Operation(summary = "删除")
    @DeleteMapping
    public ApiResult<Void> remove(@RequestBody SelectIdsDTO dto) {
        cameraService.remove(dto);
        return ApiResult.success();
    }

    @Operation(summary = "列表查询")
    @GetMapping
    public ApiResult<PageResult<CameraVO>> list(CameraListDTO dto) {
        return ApiPageResult.success(cameraService.page(dto));
    }

    @Operation(summary = "详情")
    @GetMapping("/{id}")
    public ApiResult<CameraVO> detail(@PathVariable Long id) {
        return ApiResult.success(cameraService.detail(id));
    }

    @Operation(summary = "远程搜索测试接口")
    @GetMapping("/remote/{keyword}")
    public ApiResult<List<CameraVO.CameraTypeEnum>> remoteSearch(@PathVariable String keyword) {
        return ApiResult.success(cameraService.remoteSearch(keyword));
    }

    @Operation(summary = "获取还没有绑定盒子的摄像头")
    @GetMapping("/unboundList")
    public ApiResult<List<CameraVO>> getUnboundList() {
        return ApiResult.success(cameraService.getUnboundList());
    }

    @Operation(summary = "获取已经绑定盒子的摄像头")
    @GetMapping("/boundList")
    public ApiResult<List<CameraVO>> getBoundList(@RequestParam("boxId") Long boxId) {
        return ApiResult.success(cameraService.getBoundList(boxId));
    }
}
