package com.zt.plat.module.qms.resource.record.dal.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.resource.record.controller.admin.recordrecord.vo.RecordRecordPageReqVO;
import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordSaveReqVO;
import com.zt.plat.module.qms.resource.record.dal.dataobject.recordrecord.RecordRecordDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 文件、模板、记录 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface RecordRecordMapper extends BaseMapperX<RecordRecordDO> {

    default PageResult<RecordRecordDO> selectPage(RecordRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RecordRecordDO>()
                .eqIfPresent(RecordRecordDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(RecordRecordDO::getCode, reqVO.getCode())
                .eqIfPresent(RecordRecordDO::getFormKey, reqVO.getFormKey())
                .likeIfPresent(RecordRecordDO::getName, reqVO.getName())
                .eqIfPresent(RecordRecordDO::getVersion, reqVO.getVersion())
                .eqIfPresent(RecordRecordDO::getCurrentFlag, reqVO.getCurrentFlag())
                .betweenIfPresent(RecordRecordDO::getMakeDate, reqVO.getMakeDate())
                .eqIfPresent(RecordRecordDO::getConfidentialFlag, reqVO.getConfidentialFlag())
                .eqIfPresent(RecordRecordDO::getConfidentialLevel, reqVO.getConfidentialLevel())
                .eqIfPresent(RecordRecordDO::getConfidentialWay, reqVO.getConfidentialWay())
                .eqIfPresent(RecordRecordDO::getConfidentialKey, reqVO.getConfidentialKey())
                .eqIfPresent(RecordRecordDO::getPermanently, reqVO.getPermanently())
                .betweenIfPresent(RecordRecordDO::getExpirationDate, reqVO.getExpirationDate())
                .eqIfPresent(RecordRecordDO::getExpirationStatus, reqVO.getExpirationStatus())
                .eqIfPresent(RecordRecordDO::getCancelFlag, reqVO.getCancelFlag())
                .eqIfPresent(RecordRecordDO::getFormData, reqVO.getFormData())
                .eqIfPresent(RecordRecordDO::getDataCollectionId, reqVO.getDataCollectionId())
                .eqIfPresent(RecordRecordDO::getSourceUrl, reqVO.getSourceUrl())
                .eqIfPresent(RecordRecordDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(RecordRecordDO::getRemark, reqVO.getRemark())
                .eqIfPresent(RecordRecordDO::getMainId, reqVO.getMainId())
                .betweenIfPresent(RecordRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RecordRecordDO::getId));
    }


    IPage<RecordRecordDO> getEffectRecordPage(Page<RecordRecordSaveReqVO> page,
                                                 RecordRecordPageReqVO reqVO);


//    IPage<RecordRecordDO> getNotSubmitEffectRecordPage(Page<RecordRecordSaveReqVO> page, @Param("reqVO") RecordRecordPageReqVO reqVO);

}