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

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.departmentmaterial.DepartmentMaterialDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.*;

/**
 * 组织架构物料 Mapper
 *
 * @author 后台管理-1
 */
@Mapper
public interface DepartmentMaterialMapper extends BaseMapperX<DepartmentMaterialDO> {

    default PageResult<DepartmentMaterialDO> selectPage(DepartmentMaterialPageReqVO reqVO) {
    return selectPage(reqVO, new LambdaQueryWrapperX<DepartmentMaterialDO>()
        .eqIfPresent(DepartmentMaterialDO::getInfomationId, reqVO.getInfomationId())
        .inIfPresent(DepartmentMaterialDO::getInfomationId, reqVO.getInfomationIds())
        .eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
        .eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
        .inIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptIds())
        .eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
    .eqIfPresent(DepartmentMaterialDO::getStatus, reqVO.getStatus())
        .eqIfPresent(DepartmentMaterialDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DepartmentMaterialDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DepartmentMaterialDO::getId));
    }

    default Long countExist(DepartmentMaterialDO reqVO) {
        return selectCount(new LambdaQueryWrapperX<DepartmentMaterialDO>()
                .eqIfPresent(DepartmentMaterialDO::getInfomationId, reqVO.getInfomationId())
                .eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
                .eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
                .neIfPresent(DepartmentMaterialDO::getId,reqVO.getId())); // 更新时判断要排除自身
    }

}