package com.bonus.canteen.core.device.manage.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.bonus.canteen.core.device.manage.dto.DeviceStateLogSearchDTO;
import com.bonus.canteen.core.device.manage.mapper.DeviceStateLogMapper;
import com.bonus.canteen.core.device.manage.model.DeviceStateLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.invoke.SerializedLambda;
import java.util.List;

@Service
public class DeviceStateLogService {
   private static final Logger log = LoggerFactory.getLogger(DeviceStateLogService.class);
   @Autowired
   private DeviceStateLogMapper deviceStateLogMapper;

//   public void insert(DeviceStateLog deviceStateLog) {
//      this.deviceStateLogMapper.insert(deviceStateLog);
//   }

   public List<DeviceStateLog> query(DeviceStateLogSearchDTO deviceStateLogSearchDTO) {
      return this.deviceStateLogMapper.selectList((Wrappers.lambdaQuery(DeviceStateLog.class)
              .eq(DeviceStateLog::getDeviceSn, deviceStateLogSearchDTO.getDeviceSn()))
              .orderByDesc(DeviceStateLog::getCrtime));
   }
}
