package com.zt.plat.module.qms.business.reportdoc.dal.mapper;

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.qms.business.reportdoc.controller.vo.ReportDocumentFilePageReqVO;
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentFileDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 检测报告附件 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ReportDocumentFileMapper extends BaseMapperX<ReportDocumentFileDO> {

    default PageResult<ReportDocumentFileDO> selectPage(ReportDocumentFilePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReportDocumentFileDO>()
                .eqIfPresent(ReportDocumentFileDO::getMainId, reqVO.getMainId())
                .eqIfPresent(ReportDocumentFileDO::getFileId, reqVO.getFileId())
                .likeIfPresent(ReportDocumentFileDO::getName, reqVO.getName())
                .eqIfPresent(ReportDocumentFileDO::getPath, reqVO.getPath())
                .eqIfPresent(ReportDocumentFileDO::getUrl, reqVO.getUrl())
                .eqIfPresent(ReportDocumentFileDO::getType, reqVO.getType())
                .eqIfPresent(ReportDocumentFileDO::getVersion, reqVO.getVersion())
                .eqIfPresent(ReportDocumentFileDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(ReportDocumentFileDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ReportDocumentFileDO::getRemark, reqVO.getRemark())
                .orderByDesc(ReportDocumentFileDO::getId));
    }

    default List<ReportDocumentFileDO> selectList(ReportDocumentFileDO reqVO) {
        LambdaQueryWrapperX<ReportDocumentFileDO> query = new LambdaQueryWrapperX<>();
        query.eqIfPresent(ReportDocumentFileDO::getMainId, reqVO.getMainId())
                .eqIfPresent(ReportDocumentFileDO::getFileId, reqVO.getFileId())
                .likeIfPresent(ReportDocumentFileDO::getName, reqVO.getName())
                .eqIfPresent(ReportDocumentFileDO::getPath, reqVO.getPath())
                .eqIfPresent(ReportDocumentFileDO::getUrl, reqVO.getUrl())
                .eqIfPresent(ReportDocumentFileDO::getType, reqVO.getType())
                .eqIfPresent(ReportDocumentFileDO::getVersion, reqVO.getVersion())
                .eqIfPresent(ReportDocumentFileDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(ReportDocumentFileDO::getRemark, reqVO.getRemark())
                .orderByDesc(ReportDocumentFileDO::getId);
        return selectList(query);
    }

}