package com.zt.plat.module.qms.common.data.dal.mapper;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.qms.common.data.controller.vo.*;
import com.zt.plat.module.qms.common.data.controller.vo.DataFormPageReqVO;
import com.zt.plat.module.qms.common.data.dal.dataobject.DataFormDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 通用数据 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface DataFormMapper extends BaseMapperX<DataFormDO> {

    default PageResult<DataFormDO> selectPage(DataFormPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DataFormDO>()
                .eqIfPresent(DataFormDO::getDataCollectionId, reqVO.getDataCollectionId())
                .eqIfPresent(DataFormDO::getParentId, reqVO.getParentId())
                .eqIfPresent(DataFormDO::getBusinessId, reqVO.getBusinessId())
                .eqIfPresent(DataFormDO::getBusinessType, reqVO.getBusinessType())
                .eqIfPresent(DataFormDO::getBusinessTypeCode, reqVO.getBusinessTypeCode())
                .eqIfPresent(DataFormDO::getApplyUser, reqVO.getApplyUser())
                .eqIfPresent(DataFormDO::getApplyUserId, reqVO.getApplyUserId())
                .eqIfPresent(DataFormDO::getApplyDepartment, reqVO.getApplyDepartment())
                .eqIfPresent(DataFormDO::getApplyDepartmentId, reqVO.getApplyDepartmentId())
                .betweenIfPresent(DataFormDO::getApplyTime, reqVO.getApplyTime())
                .eqIfPresent(DataFormDO::getSubmitStatus, reqVO.getSubmitStatus())
                .eqIfPresent(DataFormDO::getApprovalStatus, reqVO.getApprovalStatus())
                .eqIfPresent(DataFormDO::getUseStatus, reqVO.getUseStatus())
                .eqIfPresent(DataFormDO::getFormData, reqVO.getFormData())
                .eqIfPresent(DataFormDO::getFormTemplate, reqVO.getFormTemplate())
                .eqIfPresent(DataFormDO::getFlowInstanceId, reqVO.getFlowInstanceId())
                .eqIfPresent(DataFormDO::getFlowStatus, reqVO.getFlowStatus())
                .eqIfPresent(DataFormDO::getOpinion, reqVO.getOpinion())
                .eqIfPresent(DataFormDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(DataFormDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DataFormDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DataFormDO::getId));
    }

}