package com.fdkankan.platform.goods.mapper;

import com.fdkankan.platform.goods.entity.CameraSpace;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fdkankan.platform.user.vo.ResponseCameraSpace;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 相机容量表 Mapper 接口
 * </p>
 *
 * @author 
 * @since 2021-12-24
 */
@Mapper
public interface ICameraSpaceMapper extends BaseMapper<CameraSpace> {

    @Select(" select s.id, s.space_end_time, c.child_name, s.space from t_camera_space s " +
            "LEFT JOIN t_camera c on s.camera_id = c.id where s.tb_status = 0 and " +
            "s.space_type = 2 and s.camera_id = #{cameraId} and TIMESTAMPDIFF(MINUTE, NOW(), s.space_end_time) > -1 ORDER BY s.space_end_time ")
    List<ResponseCameraSpace> getVoListByCameraId(@Param("cameraId")Long cameraId);

    @Select(" SELECT * FROM t_camera_space WHERE (DATEDIFF(space_end_time,NOW())=-1) AND ((space_type=1) or (space_type=2)) AND tb_status = 0 ")
    List<CameraSpace> findExpiredList();
}
