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

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

import java.util.List;

/**
 * 取货点位 Mapper
 *
 * @author 陈宾顺
 */
@Mapper
public interface WareHouseTakePointMapper extends BaseMapperX<WareHouseTakePointDO> {

    default PageResult<WareHouseTakePointDO> selectPage(WareHouseTakePointPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WareHouseTakePointDO>()
                .likeIfPresent(WareHouseTakePointDO::getPointName, reqVO.getPointName())
                .eqIfPresent(WareHouseTakePointDO::getPointType, reqVO.getPointType())
                .eqIfPresent(WareHouseTakePointDO::getTotalHeight, reqVO.getTotalHeight())
                .eqIfPresent(WareHouseTakePointDO::getTrayHeight, reqVO.getTrayHeight())
                .eqIfPresent(WareHouseTakePointDO::getPointStatus, reqVO.getPointStatus())
                .eqIfPresent(WareHouseTakePointDO::getPositionMapId, reqVO.getPositionMapId())
                .eqIfPresent(WareHouseTakePointDO::getPositionMapItemId, reqVO.getPositionMapItemId())
                .eqIfPresent(WareHouseTakePointDO::getActualLocationX, reqVO.getActualLocationX())
                .eqIfPresent(WareHouseTakePointDO::getActualLocationY, reqVO.getActualLocationY())
                .betweenIfPresent(WareHouseTakePointDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WareHouseTakePointDO::getId));
    }

    void setTakePointMapIdEmpty(@Param("positionMapId") Long positionMapId,
                                @Param("ids") List<Long> ids);

    void updateHouseTakePointByItemIdAndStorey(WareHouseTakePointDO pointDO);
}