<?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="org.dromara.zjk.expert.retirementRecords.mapper.ZjkRetirementRecordsMapper">
    <sql id="Base_Column_List">
        zrr.id,
        zrr.expert_id,
        zrr.user_id,
        zrr.retirement_time,
        zrr.expert_status,
        zrr.reason,
        zrr.file_path,
        zrr.del_flag,
        zrr.tenant_id,
        zrr.create_dept,
        zrr.create_by,
        zrr.create_time,
        zrr.update_by,
        zrr.update_time
    </sql>
    <select id="queryRetirement" resultType="org.dromara.zjk.expert.retirementRecords.domain.vo.ZjkRetirementRecordsVo">
        SELECT
        <include refid="Base_Column_List"/>,
        zp.expert_name,
        zp.contact,
        zp.id_card,
        zp.work_unit
        FROM
        zjk_retirement_records zrr
        LEFT JOIN zjk_expert zp ON zp.expert_id = zrr.expert_id and zp.delete_flag = 0
        <where>
            zrr.del_flag = 0
            <if test="bo.searchValue != null and bo.searchValue !=''">
                AND  (zp.expert_name like '%' || #{bo.searchValue} || '%' or zrr.id like '%' || #{bo.searchValue} || '%')
            </if>
            <if test="bo.contact != null and bo.contact !=''">
                and zp.contact = #{bo.contact}
            </if>
            <if test="bo.contact != null and bo.contact !=''">
                and zp.contact = #{bo.contact}
            </if>
            <if test="bo.idCard != null and bo.idCard !=''">
                and zp.id_card = #{bo.idCard}
            </if>
        </where>
        ORDER BY zrr.create_time desc
    </select>

<!--auto generated by MybatisCodeHelper on 2024-11-20-->
    <select id="queryById" resultType="org.dromara.zjk.expert.retirementRecords.domain.vo.ZjkRetirementRecordsVo">
        SELECT
        <include refid="Base_Column_List"/>,
        zp.expert_name,
        zp.contact,
        zp.id_card,
        zp.work_unit
        FROM
        zjk_retirement_records zrr
        LEFT JOIN zjk_expert zp ON zp.expert_id = zrr.expert_id and zp.delete_flag = 0
        where zrr.id=#{id}
    </select>
</mapper>
