package com.yida.data.device.camera.controller.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.camera.EduCamera;
import com.yida.data.common.core.entity.camera.EduCameraAreaGroup;
import com.yida.data.common.core.utils.FebsUtil;
import com.yida.data.device.camera.service.EduCameraAreaGroupService;
import com.yida.data.device.vo.camera.H5ThemeListVO;
import com.yida.data.device.vo.camera.ThemeListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ccl
 */
@Api(tags = "监控-教师端")
@Slf4j
@Validated
@RestController
@RequestMapping("/camera/teacher")
@RequiredArgsConstructor
public class H5EduCameraController {
    private final EduCameraAreaGroupService cameraAreaGroupService;


    @ApiOperation("查询分组列表")
    @GetMapping("/listCameraGroup")
    public ResultBean<List<EduCameraAreaGroup>> listCameraGroup() {

        return ResultBean.buildSuccess(cameraAreaGroupService.listCameraGroup(FebsUtil.getCurrentUser().getDeptId()));
    }

    @ApiOperation("查询分组对应所有设备")
    @GetMapping("/listCamera")
    public ResultBean<Page<EduCamera>> listCamera(@RequestParam Long groupId,
                                                  @RequestParam(required = false) String cameraCode,
                                                  @RequestParam(required = false) Long staffId,
                                                  @RequestParam(defaultValue = "1") Integer pageNum,
                                                  @RequestParam(defaultValue = "10") Integer pageSize) {
        Page<EduCamera> cameraPage = new Page<>();
        cameraPage.setCurrent(pageNum);
        cameraPage.setSize(pageSize);
        return ResultBean.buildSuccess(cameraAreaGroupService.listCamera(cameraPage, groupId,cameraCode,staffId));
    }

    @ApiOperation("家长查询所有主题")
    @GetMapping("/listParentTheme")
    public ResultBean<List<H5ThemeListVO>> listParentTheme(@RequestParam Long parentId) {
        return ResultBean.buildSuccess(cameraAreaGroupService.listParentTheme(parentId));
    }
}
