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

import java.util.*;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.materialclasses.vo.*;

/**
 * 物料分类 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface MaterialClassesMapper extends BaseMapperX<MaterialClassesDO> {

    default PageResult<MaterialClassesDO> selectPage(MaterialClassesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MaterialClassesDO>()
                .eqIfPresent(MaterialClassesDO::getParentId, reqVO.getParentId())
                .eqIfPresent(MaterialClassesDO::getCode, reqVO.getCode())
                .likeIfPresent(MaterialClassesDO::getName, reqVO.getName())
                .eqIfPresent(MaterialClassesDO::getLevel, reqVO.getLevel())
                .eqIfPresent(MaterialClassesDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(MaterialClassesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MaterialClassesDO::getId));
    }

    default List<MaterialClassesDO> selectByCodes(Collection<String> codes) {
        if (codes == null || codes.isEmpty()) {
            return Collections.emptyList();
        }
        return selectList(new LambdaQueryWrapperX<MaterialClassesDO>()
                .in(MaterialClassesDO::getCode, codes));
    }

}