package com.zt.plat.module.qms.office.supplier.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.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.zt.plat.module.qms.office.supplier.controller.vo.SupplierEvaluationRespVO;
import com.zt.plat.module.qms.office.supplier.dal.dataobject.SupplierDO;
import com.zt.plat.module.qms.office.supplier.dal.dataobject.SupplierEvaluationDO;
import com.zt.plat.module.qms.office.supplier.controller.vo.SupplierEvaluationPageReqVO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 供应商评价 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface SupplierEvaluationMapper extends BaseMapperX<SupplierEvaluationDO> {

    default PageResult<SupplierEvaluationRespVO> selectPage(SupplierEvaluationPageReqVO reqVO) {
        return selectJoinPage(reqVO,SupplierEvaluationRespVO.class, new MPJLambdaWrapperX<SupplierEvaluationDO>()
                .leftJoin(SupplierDO.class,SupplierDO::getId, SupplierEvaluationDO::getSupplierId)
                .selectAll(SupplierEvaluationDO.class)
                .selectAs(SupplierDO::getName, SupplierEvaluationRespVO::getSupplierName)
                .eqIfPresent(SupplierEvaluationDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(SupplierEvaluationDO::getFormId, reqVO.getFormId())
                .eqIfPresent(SupplierEvaluationDO::getContent, reqVO.getContent())
                .eqIfPresent(SupplierEvaluationDO::getConclusion, reqVO.getConclusion())
                .eqIfPresent(SupplierEvaluationDO::getEvaluator, reqVO.getEvaluator())
                .eqIfPresent(SupplierEvaluationDO::getEvaluatorId, reqVO.getEvaluatorId())
                .betweenIfPresent(SupplierEvaluationDO::getEvaluationDate, reqVO.getEvaluationDate())
                .eqIfPresent(SupplierEvaluationDO::getFlowStatus, reqVO.getFlowStatus())
                .eqIfPresent(SupplierEvaluationDO::getFlowInstanceId, reqVO.getFlowInstanceId())
                .eqIfPresent(SupplierEvaluationDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .eqIfPresent(SupplierEvaluationDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(SupplierEvaluationDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(SupplierDO::getName, reqVO.getSupplierName())
                .orderByDesc(SupplierEvaluationDO::getId));
    }


}

