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.DriverTrainingCertificateJoin;

/**
 * <p>
 * 驾驶员合格证 Mapper 接口
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-03
 */
public interface DriverTrainingCertificateJoinMapper extends BaseMapper<DriverTrainingCertificateJoin> {
    String QUERY_SQL = "SELECT cc.*,  " +
            " d.id_card,cc.issue_date training_time," +
            " '合格' training_result,cc.expiry_date effective_time,'浙江省散装水泥、预拌混凝土、预拌砂浆专用车辆驾驶员业务技能和安全知识培训' training_program " +
            " FROM nd_certificate cc " +
            " LEFT JOIN nd_driver_info d ON cc.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<DriverTrainingCertificateJoin> pageJoin(Page page, @Param("ew") LambdaQueryWrapper<DriverTrainingCertificateJoin> wrapper);
    @Select(WRAPPER_SQL)
    DriverTrainingCertificateJoin getOneJoin(@Param("ew") LambdaQueryWrapper<DriverTrainingCertificateJoin> wrapper);
}
