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

import java.util.*;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.business.bus.controller.vo.*;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustFileDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 委检登记附件业务 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface BusinessSampleEntrustFileMapper extends BaseMapperX<BusinessSampleEntrustFileDO> {

    default PageResult<BusinessSampleEntrustFileExtendRespVO> selectPage(BusinessSampleEntrustFilePageReqVO reqVO) {
        return selectJoinPage(reqVO, BusinessSampleEntrustFileExtendRespVO.class, new MPJLambdaWrapperX<BusinessSampleEntrustFileDO>()
        		.leftJoin(BusinessSampleEntrustRegistrationDO.class, BusinessSampleEntrustRegistrationDO::getId, BusinessSampleEntrustFileDO::getBusinessSampleEntrustRegistrationId)
        		.selectAll(BusinessSampleEntrustFileDO.class)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustNumber, BusinessSampleEntrustFileExtendRespVO::getEntrustNumber)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustUnit, BusinessSampleEntrustFileExtendRespVO::getEntrustUnit)
                .eqIfPresent(BusinessSampleEntrustFileDO::getBusinessSampleEntrustRegistrationId, reqVO.getBusinessSampleEntrustRegistrationId())
                .eqIfPresent(BusinessSampleEntrustFileDO::getBusinessSampleEntrustDepartmentId, reqVO.getBusinessSampleEntrustDepartmentId())
                .eqIfPresent(BusinessSampleEntrustFileDO::getFileCategory, reqVO.getFileCategory())
                .eqIfPresent(BusinessSampleEntrustFileDO::getFileId, reqVO.getFileId())
                .likeIfPresent(BusinessSampleEntrustFileDO::getFileName, reqVO.getFileName())
                .eqIfPresent(BusinessSampleEntrustFileDO::getFilePath, reqVO.getFilePath())
                .eqIfPresent(BusinessSampleEntrustFileDO::getExternalInfomation, reqVO.getExternalInfomation())
                .eqIfPresent(BusinessSampleEntrustFileDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSampleEntrustFileDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSampleEntrustFileDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessSampleEntrustFileDO::getFileCategory)
                .orderByDesc(BusinessSampleEntrustFileDO::getId));
    }

	default List<BusinessSampleEntrustFileExtendRespVO> selectList(BusinessSampleEntrustFilePageReqVO reqVO) {
		return selectJoinList(BusinessSampleEntrustFileExtendRespVO.class, new MPJLambdaWrapperX<BusinessSampleEntrustFileDO>()
        		.leftJoin(BusinessSampleEntrustRegistrationDO.class, BusinessSampleEntrustRegistrationDO::getId, BusinessSampleEntrustFileDO::getBusinessSampleEntrustRegistrationId)
        		.selectAll(BusinessSampleEntrustFileDO.class)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustNumber, BusinessSampleEntrustFileExtendRespVO::getEntrustNumber)
        		.selectAs(BusinessSampleEntrustRegistrationDO::getEntrustUnit, BusinessSampleEntrustFileExtendRespVO::getEntrustUnit)
                .eqIfPresent(BusinessSampleEntrustFileDO::getBusinessSampleEntrustRegistrationId, reqVO.getBusinessSampleEntrustRegistrationId())
                .eqIfPresent(BusinessSampleEntrustFileDO::getBusinessSampleEntrustDepartmentId, reqVO.getBusinessSampleEntrustDepartmentId())
                .eqIfPresent(BusinessSampleEntrustFileDO::getFileCategory, reqVO.getFileCategory())
                .eqIfPresent(BusinessSampleEntrustFileDO::getFileId, reqVO.getFileId())
                .likeIfPresent(BusinessSampleEntrustFileDO::getFileName, reqVO.getFileName())
                .eqIfPresent(BusinessSampleEntrustFileDO::getFilePath, reqVO.getFilePath())
                .eqIfPresent(BusinessSampleEntrustFileDO::getExternalInfomation, reqVO.getExternalInfomation())
                .eqIfPresent(BusinessSampleEntrustFileDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSampleEntrustFileDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSampleEntrustFileDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessSampleEntrustFileDO::getFileCategory)
                .orderByDesc(BusinessSampleEntrustFileDO::getId));
	}

    /**
     * 物理批量删除删除
     * @param idList
     * @return
     */
    int physicalDeleteByIds(@Param("idList") List<Long> idList);
    

    /**
     * 根据委托登记id物理删除
     * @param businessSampleEntrustRegistrationId 委托登记id
     * @return
     */
    int physicalDeleteByBusinessSampleEntrustRegistrationId(@Param("businessSampleEntrustRegistrationId") Long businessSampleEntrustRegistrationId);

}