package com.tuoheng.admin.controller;

import com.tuoheng.admin.entity.domain.Camera;
import com.tuoheng.admin.entity.request.camera.QueryCameraListRequest;
import com.tuoheng.admin.service.camera.ICameraService;
import com.tuoheng.common.common.OperationEnum;
import com.tuoheng.common.utils.JsonResult;
import com.tuoheng.system.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @desc: 摄像头 前端控制器
 * @team: tuoheng
 * @author: wanjing
 * @date: 2023-02-06
 */
@RestController
@RequestMapping("/camera")
public class CameraController {

    @Autowired
    private ICameraService cameraService;

    /**
     * 查询摄像头列表
     */
    @GetMapping("/list")
    public JsonResult getList(QueryCameraListRequest request) {
        return cameraService.getList(request);
    }

    /**
     * 查询摄像头分页列表
     */
    @GetMapping("/page")
    public JsonResult getPage(QueryCameraListRequest request) {
        return cameraService.getPage(request);
    }


    /**
     * 获取摄像头详细信息
     */
    @GetMapping(value = "/{id}")
    public JsonResult getOneById(@PathVariable("id") Integer id) {
        return cameraService.getOneById(id);
    }

    /**
     * 添加摄像头
     *
     * @param entity 实体对象
     * @return
     */
    @PostMapping("/add")
    public JsonResult add(@RequestBody Camera entity) {
        return cameraService.editInfo(entity);
    }

    /**
     * 编辑摄像头
     *
     * @param entity 实体对象
     * @return
     */
    @PutMapping("/edit")
    public JsonResult edit(@RequestBody Camera entity) {
        return cameraService.editInfo(entity);
    }

    /**
     * 删除摄像头
     *
     * @param ids 摄像头ID
     * @return
     */
    @DeleteMapping("/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return cameraService.deleteByIds(ids);
    }

}
