<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.love.mapper.CertificateMapper">

    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*,b.nickname,b.avatar
        FROM love_certificate a
        LEFT JOIN sys_user b ON a.user_id = b.user_id
        <where>
            <if test="param.certificateId != null">
                AND a.certificate_id = #{param.certificateId}
            </if>
            <if test="param.certificateName != null">
                AND a.certificate_name LIKE CONCAT('%', #{param.certificateName}, '%')
            </if>
            <if test="param.fullName != null">
                AND a.full_name LIKE CONCAT('%', #{param.fullName}, '%')
            </if>
            <if test="param.certificateCode != null">
                AND a.certificate_code LIKE CONCAT('%', #{param.certificateCode}, '%')
            </if>
            <if test="param.certificateType != null">
                AND a.certificate_type = #{param.certificateType}
            </if>
            <if test="param.files != null">
                AND a.files LIKE CONCAT('%', #{param.files}, '%')
            </if>
            <if test="param.realName != null">
                AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
            </if>
            <if test="param.phone != null">
                AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
            </if>
            <if test="param.expirationTime != null">
                AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
            </if>
            <if test="param.businessEntity != null">
                AND a.business_entity LIKE CONCAT('%', #{param.businessEntity}, '%')
            </if>
            <if test="param.college != null">
                AND a.college LIKE CONCAT('%', #{param.college}, '%')
            </if>
            <if test="param.comments != null">
                AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
            </if>
            <if test="param.authentication != null">
                AND a.authentication = #{param.authentication}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.sortNumber != null">
                AND a.sort_number = #{param.sortNumber}
            </if>
            <if test="param.userId != null">
                AND a.user_id = #{param.userId}
            </if>
            <if test="param.deleted != null">
                AND a.deleted = #{param.deleted}
            </if>
            <if test="param.deleted == null">
                AND a.deleted = 0
            </if>
            <if test="param.createTimeStart != null">
                AND a.create_time &gt;= #{param.createTimeStart}
            </if>
            <if test="param.createTimeEnd != null">
                AND a.create_time &lt;= #{param.createTimeEnd}
            </if>
        </where>
    </sql>

    <!-- 分页查询 -->
    <select id="selectPageRel" resultType="com.gxwebsoft.love.entity.Certificate">
        <include refid="selectSql"></include>
    </select>

    <!-- 查询全部 -->
    <select id="selectListRel" resultType="com.gxwebsoft.love.entity.Certificate">
        <include refid="selectSql"></include>
    </select>

</mapper>
