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

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.biz.vo.MaterialConfigPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.biz.MaterialConfigDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface MaterialConfigMapper extends BaseMapperX<MaterialConfigDO> {

    default PageResult<MaterialConfigDO> selectPage(MaterialConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialConfigDO>()
                .likeIfPresent(MaterialConfigDO::getName, reqVO.getName())
                .eqIfPresent(MaterialConfigDO::getPinyinCode, reqVO.getPinyinCode())
                .eqIfPresent(MaterialConfigDO::getType, reqVO.getType())
                .eqIfPresent(MaterialConfigDO::getUnit, reqVO.getUnit())
                .eqIfPresent(MaterialConfigDO::getSpecification, reqVO.getSpecification())
                .eqIfPresent(MaterialConfigDO::getSaleFlag, reqVO.getSaleFlag())
                .eqIfPresent(MaterialConfigDO::getItemAmount, reqVO.getItemAmount())
                .eqIfPresent(MaterialConfigDO::getSafetyStock, reqVO.getSafetyStock())
                .eqIfPresent(MaterialConfigDO::getDescription, reqVO.getDescription())
                .eqIfPresent(MaterialConfigDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MaterialConfigDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(MaterialConfigDO::getOrgType, reqVO.getOrgType())
                .inIfPresent(MaterialConfigDO::getTenantId, reqVO.getTenantIds())
                .orderByDesc(MaterialConfigDO::getId));
    }

}
