package cn.iocoder.yudao.module.system.dal.mysql.parkingspot;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.parkingspot.vo.ParkingSpotPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.parkingspot.ParkingSpotDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 停车点 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface ParkingSpotMapper extends BaseMapperX<ParkingSpotDO> {

    default PageResult<ParkingSpotDO> selectPage(ParkingSpotPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ParkingSpotDO>()
                .eqIfPresent(ParkingSpotDO::getPositionMapId, reqVO.getPositionMapId())
                .eqIfPresent(ParkingSpotDO::getPositionMapItemId, reqVO.getPositionMapItemId())
                .eqIfPresent(ParkingSpotDO::getLocationX, reqVO.getLocationX())
                .eqIfPresent(ParkingSpotDO::getLocationY, reqVO.getLocationY())
                .eqIfPresent(ParkingSpotDO::getLocationWide, reqVO.getLocationWide())
                .eqIfPresent(ParkingSpotDO::getLocationDeep, reqVO.getLocationDeep())
                .eqIfPresent(ParkingSpotDO::getDirection, reqVO.getDirection())
                .eqIfPresent(ParkingSpotDO::getInDirection, reqVO.getInDirection())
                .eqIfPresent(ParkingSpotDO::getOutDirection, reqVO.getOutDirection())
                .betweenIfPresent(ParkingSpotDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ParkingSpotDO::getId));
    }

    /**
     * 根据地图id删除
     * @param mapId
     */
    void deleteParkingByMapId(@Param("mapId") Long mapId);
}
