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.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailPageReqVO;
import com.zt.plat.module.qms.resource.record.controller.admin.recordrecord.vo.RecordRecordSaveReqVO;
import com.zt.plat.module.qms.resource.record.dal.dataobject.recordapply.RecordApplyDO;
import com.zt.plat.module.qms.resource.record.dal.dataobject.recordapplydetail.RecordApplyDetailDO;
import com.zt.plat.module.qms.resource.record.controller.admin.recordapplydetail.vo.RecordApplyDetailJoinVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * 文件记录通用申请明细 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface RecordApplyDetailMapper extends BaseMapperX<RecordApplyDetailDO> {

    default PageResult<RecordApplyDetailDO> selectPage(RecordApplyDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RecordApplyDetailDO>()
                .eqIfPresent(RecordApplyDetailDO::getApplyId, reqVO.getApplyId())
                .eqIfPresent(RecordApplyDetailDO::getDocumentId, reqVO.getDocumentId())
                .eqIfPresent(RecordApplyDetailDO::getPermanently, reqVO.getPermanently())
                .betweenIfPresent(RecordApplyDetailDO::getApplyStartDate, reqVO.getApplyStartDate())
                .betweenIfPresent(RecordApplyDetailDO::getApplyEndDate, reqVO.getApplyEndDate())
                .eqIfPresent(RecordApplyDetailDO::getSortNo, reqVO.getSortNo())
                .eqIfPresent(RecordApplyDetailDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(RecordApplyDetailDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(RecordApplyDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RecordApplyDetailDO::getId));
    }

    IPage<RecordApplyDetailJoinVO> selectDetailAndApplyList(Page<RecordRecordSaveReqVO> page,
                                                            RecordApplyDetailPageReqVO reqVO);

}