package cn.iocoder.yudao.module.bpm.dal.mysql.oa.business;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.business.vo.OaBusinessPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.business.OaBusinessDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 出差流程信息 Mapper
 *
 * @author dp
 */
@Mapper
public interface OaBusinessMapper extends BaseMapperX<OaBusinessDO> {

    default PageResult<OaBusinessDO> selectPage(OaBusinessPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OaBusinessDO>()
                .eqIfPresent(OaBusinessDO::getId, reqVO.getId())
                .eqIfPresent(OaBusinessDO::getBusinessId, reqVO.getBusinessId())
                .eqIfPresent(OaBusinessDO::getEmployeeId, reqVO.getEmployeeId())
                .likeIfPresent(OaBusinessDO::getEmployeeName, reqVO.getEmployeeName())
                .eqIfPresent(OaBusinessDO::getEmployeePhone, reqVO.getEmployeePhone())
                .eqIfPresent(OaBusinessDO::getUserId, reqVO.getUserId())
                .eqIfPresent(OaBusinessDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(OaBusinessDO::getPosition, reqVO.getPosition())
                .eqIfPresent(OaBusinessDO::getReason, reqVO.getReason())
                .eqIfPresent(OaBusinessDO::getDestination, reqVO.getDestination())
                .betweenIfPresent(OaBusinessDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(OaBusinessDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(OaBusinessDO::getDay, reqVO.getDay())
                .eqIfPresent(OaBusinessDO::getEstimatedCost, reqVO.getEstimatedCost())
                .eqIfPresent(OaBusinessDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(OaBusinessDO::getProcInstId, reqVO.getProcInstId())
                .eqIfPresent(OaBusinessDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(OaBusinessDO::getCurrentAuditEmployeeId, reqVO.getCurrentAuditEmployeeId())
                .likeIfPresent(OaBusinessDO::getCurrentAuditEmployeeName, reqVO.getCurrentAuditEmployeeName())
                .eqIfPresent(OaBusinessDO::getCurrentAuditUserId, reqVO.getCurrentAuditUserId())
                .betweenIfPresent(OaBusinessDO::getFinalAuditDate, reqVO.getFinalAuditDate())
                .eqIfPresent(OaBusinessDO::getStartUserSelectAssignees, reqVO.getStartUserSelectAssignees())
                .eqIfPresent(OaBusinessDO::getApplyEmployeeId, reqVO.getApplyEmployeeId())
                .likeIfPresent(OaBusinessDO::getApplyEmployeeName, reqVO.getApplyEmployeeName())
                .betweenIfPresent(OaBusinessDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OaBusinessDO::getId));
    }

}