package com.yida.data.attendance.controller.in;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yida.data.attendance.service.EduAttendanceDeviceService;
import com.yida.data.common.core.common.ResultBean;
import com.yida.data.common.core.entity.attendance.EduAttendanceDevice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "考勤-设备(不鉴权)")
@RestController
@RequestMapping("/in/device")
public class InEduAttendanceDeviceController {

    @Resource
    private EduAttendanceDeviceService eduAttendanceDeviceService;

    @GetMapping("/listDeviceByType")
    public ResultBean<List<EduAttendanceDevice>> listDeviceByType(String type) {
        return ResultBean.buildSuccess(eduAttendanceDeviceService.list(
            Wrappers.lambdaQuery(new EduAttendanceDevice()).eq(EduAttendanceDevice::getDeviceType, type)));
    }

    @ApiOperation("更新设备在线状态")
    @GetMapping("/updateDeviceStatus")
    public ResultBean updateDeviceStatus() {
        eduAttendanceDeviceService.updateDeviceStatus();
        return ResultBean.buildSuccess();
    }

    @ApiOperation("校时所有设备")
    @GetMapping("/timingAllDevice")
    public ResultBean timingAllDevice() {
        eduAttendanceDeviceService.timingAllDevice();
        return ResultBean.buildSuccess();
    }
}
