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

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.universal.vo.OaUniversalPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.universal.OaUniversalDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 通用事项审批流程信息 Mapper
 *
 * @author dp
 */
@Mapper
public interface OaUniversalMapper extends BaseMapperX<OaUniversalDO> {

    default PageResult<OaUniversalDO> selectPage(OaUniversalPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OaUniversalDO>()
                .eqIfPresent(OaUniversalDO::getUniversalId, reqVO.getUniversalId())
                .eqIfPresent(OaUniversalDO::getEmployeeId, reqVO.getEmployeeId())
                .likeIfPresent(OaUniversalDO::getEmployeeName, reqVO.getEmployeeName())
                .likeIfPresent(OaUniversalDO::getEmployeePhone, reqVO.getEmployeePhone())
                .eqIfPresent(OaUniversalDO::getUserId, reqVO.getUserId())
                .likeIfPresent(OaUniversalDO::getUserPhone, reqVO.getUserPhone())
                .eqIfPresent(OaUniversalDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(OaUniversalDO::getDeptUuid, reqVO.getDeptUuid())
                .eqIfPresent(OaUniversalDO::getPosition, reqVO.getPosition())
                .likeIfPresent(OaUniversalDO::getTitle, reqVO.getTitle())
                .eqIfPresent(OaUniversalDO::getDescription, reqVO.getDescription())
                .eqIfPresent(OaUniversalDO::getRemarks, reqVO.getRemarks())
                .eqIfPresent(OaUniversalDO::getProcInstId, reqVO.getProcInstId())
                .eqIfPresent(OaUniversalDO::getAuditStatus, reqVO.getAuditStatus())
                .eqIfPresent(OaUniversalDO::getCurrentAuditUserId, reqVO.getCurrentAuditUserId())
                .eqIfPresent(OaUniversalDO::getCurrentAuditEmployeeId, reqVO.getCurrentAuditEmployeeId())
                .betweenIfPresent(OaUniversalDO::getFinalAuditDate, reqVO.getFinalAuditDate())
                .eqIfPresent(OaUniversalDO::getInfoSource, reqVO.getInfoSource())
                .betweenIfPresent(OaUniversalDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OaUniversalDO::getId));
    }

}