package com.zt.plat.module.base.dal.mysql.base;

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.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;

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

    default PageResult<MaterialInfomationDO> selectPage(MaterialInfomationPageReqVO reqVO) {
        return selectPage(reqVO, (Collection<Long>) null);
    }

    default PageResult<MaterialInfomationDO> selectPage(MaterialInfomationPageReqVO reqVO, Collection<Long> infomationIds) {
        return BaseMapperX.super.selectPage(reqVO, new LambdaQueryWrapperX<MaterialInfomationDO>()
                // code 字段的查询已在 Service 层处理（包含中铜编码、中铝编码），此处不再重复查询
                .likeIfPresent(MaterialInfomationDO::getName, reqVO.getName())
                .likeIfPresent(MaterialInfomationDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(MaterialInfomationDO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(MaterialInfomationDO::getId, infomationIds)
                .orderByDesc(MaterialInfomationDO::getId));
    }

    default PageResult<MaterialInfomationDO> selectSimplePage(MaterialInfomationSimplePageReqVO reqVO, LambdaQueryWrapperX<MaterialInfomationDO> wrapper) {
        return BaseMapperX.super.selectPage(reqVO, wrapper);
    }

}