package com.zt.plat.module.qms.resource.material.dal.mapper;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.qms.resource.material.controller.vo.*;
import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO;
import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialInfomationDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 物料实例 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomationDO> {

    default PageResult<MaterialInfomationDO> selectPage(MaterialInfomationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialInfomationDO>()
                .eqIfPresent(MaterialInfomationDO::getProductId, reqVO.getProductId())
                .inIfPresent(MaterialInfomationDO::getProductId, reqVO.getProductIds())
                .eqIfPresent(MaterialInfomationDO::getBatchId, reqVO.getBatchId())
                .eqIfPresent(MaterialInfomationDO::getLocationId, reqVO.getLocationId())
                .eqIfPresent(MaterialInfomationDO::getCode, reqVO.getCode())
                .eqIfPresent(MaterialInfomationDO::getParameter, reqVO.getParameter())
                .eqIfPresent(MaterialInfomationDO::getManagerUserId, reqVO.getManagerUserId())
                .likeIfPresent(MaterialInfomationDO::getManagerUserName, reqVO.getManagerUserName())
                .eqIfPresent(MaterialInfomationDO::getPublishStatus, reqVO.getPublishStatus())
                .eqIfPresent(MaterialInfomationDO::getUsageStatus, reqVO.getUsageStatus())
                .eqIfPresent(MaterialInfomationDO::getOpenStatus, reqVO.getOpenStatus())
                .likeIfPresent(MaterialInfomationDO::getOpenUserName, reqVO.getOpenUserName())
                .eqIfPresent(MaterialInfomationDO::getOpenUserId, reqVO.getOpenUserId())
                .betweenIfPresent(MaterialInfomationDO::getOpenDate, reqVO.getOpenDate())
                .betweenIfPresent(MaterialInfomationDO::getExpirationDate, reqVO.getExpirationDate())
                .eqIfPresent(MaterialInfomationDO::getExpirationFlag, reqVO.getExpirationFlag())
                .eqIfPresent(MaterialInfomationDO::getRemainingVolume, reqVO.getRemainingVolume())
                .eqIfPresent(MaterialInfomationDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(MaterialInfomationDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(MaterialInfomationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialInfomationDO::getId));
    }

}