package com.zt.plat.module.base.dal.dao.materialgradeext;

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.materialgradeext.vo.MaterialGradeExtPageReqVO;
import com.zt.plat.module.base.dal.dataobject.materialgradeext.MaterialGradeExtDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 物料牌号扩展 Mapper
 */
@Mapper
public interface MaterialGradeExtMapper extends BaseMapperX<MaterialGradeExtDO> {

    default PageResult<MaterialGradeExtDO> selectPage(MaterialGradeExtPageReqVO reqVO) {
        LambdaQueryWrapperX<MaterialGradeExtDO> query = new LambdaQueryWrapperX<MaterialGradeExtDO>()
                .eqIfPresent(MaterialGradeExtDO::getCompanyCode, reqVO.getCompanyCode())
                .likeIfPresent(MaterialGradeExtDO::getCompanyName, reqVO.getCompanyName())
                .eqIfPresent(MaterialGradeExtDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(MaterialGradeExtDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(MaterialGradeExtDO::getChineseBrand, reqVO.getChineseBrand())
                .likeIfPresent(MaterialGradeExtDO::getEnglishBrand, reqVO.getEnglishBrand())
                .likeIfPresent(MaterialGradeExtDO::getSpecificationModel, reqVO.getSpecificationModel())
                .eqIfPresent(MaterialGradeExtDO::getLineType, reqVO.getLineType())
                .likeIfPresent(MaterialGradeExtDO::getPackageDesc, reqVO.getPackageDesc())
                .betweenIfPresent(MaterialGradeExtDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialGradeExtDO::getId);
        return selectPage(reqVO, query);
    }
}