package cn.iocoder.yudao.module.pms.dal.mysql.iotcarzhbd;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.pms.controller.admin.iotcarzhbd.vo.IotCarZhbdPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.iotcarzhbd.IotCarZhbdDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 中航北斗车辆表 Mapper
 *
 * @author ruiqi
 */
@Mapper
public interface IotCarZhbdMapper extends BaseMapperX<IotCarZhbdDO> {

    default PageResult<IotCarZhbdDO> selectPage(IotCarZhbdPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotCarZhbdDO>()
                .eqIfPresent(IotCarZhbdDO::getDeviceCode, reqVO.getDeviceCode())
                .likeIfPresent(IotCarZhbdDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(IotCarZhbdDO::getCarId, reqVO.getCarId())
                .betweenIfPresent(IotCarZhbdDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotCarZhbdDO::getUserName, reqVO.getUserName())
                .eqIfPresent(IotCarZhbdDO::getUserId, reqVO.getUserId())
                .orderByDesc(IotCarZhbdDO::getId));
    }

    @DataPermission(enable = false)
    @TenantIgnore
    default List<IotCarZhbdDO> selectList(IotCarZhbdPageReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<IotCarZhbdDO>()
                .eqIfPresent(IotCarZhbdDO::getDeviceCode, reqVO.getDeviceCode())
                .inIfPresent(IotCarZhbdDO::getDeviceCode, reqVO.getDeviceCodes())
                .likeIfPresent(IotCarZhbdDO::getDeviceName, reqVO.getDeviceName())
                .eqIfPresent(IotCarZhbdDO::getCarId, reqVO.getCarId())
                .inIfPresent(IotCarZhbdDO::getCarId, reqVO.getCarIds())
                .betweenIfPresent(IotCarZhbdDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotCarZhbdDO::getUserName, reqVO.getUserName())
                .inIfPresent(IotCarZhbdDO::getUserName, reqVO.getCustomDeviceCodes())
                .eqIfPresent(IotCarZhbdDO::getUserId, reqVO.getUserId())
                .orderByDesc(IotCarZhbdDO::getId));
    }

}