<?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.nantian.cloud.jljc.mapper.RecordCertificateManagerMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.nantian.cloud.jljc.entity.RecordCertificateManager">
        <id column="id" property="id"/>
        <result column="record_person_id" property="recordPersonId"/>
        <result column="certificate_code" property="certificateCode"/>
        <result column="certificate_unit" property="certificateUnit"/>
        <result column="certificate_name" property="certificateName"/>
        <result column="certificate_type" property="certificateType"/>
        <result column="certificate_date" property="certificateDate"/>
        <result column="certificate_picture" property="certificatePicture"/>
        <result column="remark" property="remark"/>
        <result column="update_id" property="updateId"/>
        <result column="update_date" property="updateDate"/>
        <result column="delete_flag" property="deleteFlag"/>
        <result column="dept_id" property="deptId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, record_person_id, certificate_code, certificate_unit, certificate_name, certificate_type, certificate_date,
        certificate_picture, remark, update_id, update_date, delete_flag, dept_id
    </sql>

    <insert id="addCertificate">
        insert into record_certificate_manager
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recordPersonId != null">
                record_person_id,
            </if>
            <if test="certificateCode != null">
                certificate_code,
            </if>
            <if test="certificateUnit != null">
                certificate_unit,
            </if>
            <if test="certificateName != null">
                certificate_name,
            </if>
            <if test="certificateType != null">
                certificate_type,
            </if>
            <if test="certificateDate != null">
                certificate_date,
            </if>
            <if test="certificatePicture != null">
                certificate_picture,
            </if>
            <if test="remark != null">
                remark,
            </if>
            <if test="updateId != null">
                update_id,
            </if>
            <if test="updateDate != null">
                update_date,
            </if>
            <if test="deleteFlag != null">
                delete_flag,
            </if>
            <if test="deptId != null">
                dept_id,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recordPersonId != null">
                #{recordPersonId},
            </if>
            <if test="certificateCode != null">
                #{certificateCode},
            </if>
            <if test="certificateUnit != null">
                #{certificateUnit},
            </if>
            <if test="certificateName != null">
                #{certificateName},
            </if>
            <if test="certificateType != null">
                #{certificateType},
            </if>
            <if test="certificateDate != null">
                #{certificateDate},
            </if>
            <if test="certificatePicture != null">
                #{certificatePicture},
            </if>
            <if test="remark != null">
                #{remark},
            </if>
            <if test="updateId != null">
                #{updateId},
            </if>
            <if test="updateDate != null">
                #{updateDate},
            </if>
            <if test="deleteFlag != null">
                #{deleteFlag},
            </if>
            <if test="deptId != null">
                #{deptId},
            </if>
        </trim>
    </insert>

    <update id="updateCertificateById">
        update record_certificate_manager
        <set>
            <if test="recordPersonId != null">
                record_person_id = #{recordPersonId},
            </if>
            <if test="certificateCode != null">
                certificate_code = #{certificateCode},
            </if>
            <if test="certificateUnit != null">
                certificate_unit = #{certificateUnit},
            </if>
            <if test="certificateName != null">
                certificate_name = #{certificateName},
            </if>
            <if test="certificateType != null">
                certificate_type = #{certificateType},
            </if>
            <if test="certificateDate != null">
                certificate_date = #{certificateDate},
            </if>
            <if test="certificatePicture != null">
                certificate_picture = #{certificatePicture},
            </if>
            <if test="remark != null">
                remark = #{remark},
            </if>
            <if test="updateId != null">
                update_id = #{updateId},
            </if>
            <if test="updateDate != null">
                update_date = #{updateDate},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag},
            </if>
        </set>
        where id = #{id}
    </update>

    <delete id="removeByCertificateId">
        update record_certificate_manager
        <set>
            <if test="updateId != null">
                update_id = #{updateId},
            </if>
            <if test="updateDate != null">
                update_date = #{updateDate},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag},
            </if>
        </set>
        where id = #{id}
    </delete>

    <delete id="removeByPersonId">
        update record_certificate_manager
        <set>
            <if test="updateId != null">
                update_id = #{updateId},
            </if>
            <if test="updateDate != null">
                update_date = #{updateDate},
            </if>
            <if test="deleteFlag != null">
                delete_flag = #{deleteFlag},
            </if>
        </set>
        where record_person_id = #{recordPersonId}
    </delete>

    <select id="getCertificateByPersonId" resultType="com.nantian.cloud.jljc.entity.RecordCertificateManager">
        select
        <include refid="Base_Column_List"></include>
        from record_certificate_manager
        where record_person_id = #{id} and delete_flag = "1"
    </select>

    <select id="getCertificateByPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"></include>
        from record_certificate_manager
        where record_person_id = #{id} and delete_flag = "1"
    </select>


</mapper>
