package com.ningdatech.carapi.industry.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ningdatech.carapi.industry.entity.DriverTrainingCertificateOperJoin;

/**
 * <p>
 * 驾驶员合格证操作 Mapper 接口
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-04
 */
public interface DriverTrainingCertificateOperJoinMapper extends BaseMapper<DriverTrainingCertificateOperJoin> {
    String QUERY_SQL = "SELECT cp.*, d.driver_name," +
            " d.id_card,c.name company_name,cp.issue_date training_time," +
            " '合格' training_result,cp.expiry_date effective_time,'浙江省散装水泥、预拌混凝土、预拌砂浆专用车辆驾驶员业务技能和安全知识培训' training_program " +
            " FROM nd_driver_training_certificate_oper AS cp " +
            //" LEFT JOIN nd_certificate AS cc ON cp.certificate_id = cc.id" +
            " LEFT JOIN nd_driver_info d ON cp.driver_id = d.id " +
            " LEFT JOIN nd_company_info c ON d.company_id = c.id ";
    String WRAPPER_SQL = "SELECT * from ( " + QUERY_SQL + " ) AS q ${ew.customSqlSegment}";

    @Select(WRAPPER_SQL)
    Page<DriverTrainingCertificateOperJoin> pageJoin(Page page, @Param("ew") LambdaQueryWrapper<DriverTrainingCertificateOperJoin> wrapper);
    @Select(WRAPPER_SQL)
    DriverTrainingCertificateOperJoin getOneJoin(@Param("ew") LambdaQueryWrapper<DriverTrainingCertificateOperJoin> wrapper);
}
