<?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.ruoyi.szxc.mapper.SzxcHkbgRecardMapper">

    <resultMap type="SzxcHkbgRecard" id="SzxcHkbgRecardResult">
        <result property="id"    column="id"    />
        <result property="acountNo"    column="acount_no"    />
        <result property="jmId"    column="jm_id"    />
        <result property="name"    column="name"    />
        <result property="idCard"    column="id_card"    />
        <result property="yJmId"    column="y_jm_id"    />
        <result property="yName"    column="y_name"    />
        <result property="yIdCard"    column="y_id_card"    />
        <result property="bgReason"    column="bg_reason"    />
        <result property="xJmId"    column="x_jm_id"    />
        <result property="xName"    column="x_name"    />
        <result property="xIdCard"    column="x_id_card"    />
        <result property="relation"    column="relation"    />
        <result property="bgTime"    column="bg_time"    />
        <result property="hjAddress"    column="hj_address"    />
        <result property="jgNature"    column="jg_nature"    />
        <result property="longLive"    column="long_live"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="deptId"    column="dept_id"    />
        <result property="userId"    column="user_id"    />
        <result property="deptName"    column="dept_name"    />
    </resultMap>

    <sql id="selectSzxcHkbgRecardVo">
        select id, acount_no, jm_id, name, id_card, y_jm_id, y_name, y_id_card, bg_reason, x_jm_id, x_name, x_id_card, relation, bg_time, hj_address, jg_nature, long_live, remark, create_by, create_time, update_by, update_time, dept_id, user_id, dept_name from szxc_hkbg_recard
    </sql>

    <select id="selectSzxcHkbgRecardList" parameterType="SzxcHkbgRecard" resultMap="SzxcHkbgRecardResult">
        <include refid="selectSzxcHkbgRecardVo"/> as h
        <where>
            <if test="acountNo != null "> and acount_no = #{acountNo}</if>
            <if test="jmId != null "> and jm_id = #{jmId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="yJmId != null "> and y_jm_id = #{yJmId}</if>
            <if test="yName != null  and yName != ''"> and y_name like concat('%', #{yName}, '%')</if>
            <if test="yIdCard != null  and yIdCard != ''"> and y_id_card = #{yIdCard}</if>
            <if test="bgReason != null  and bgReason != ''"> and bg_reason = #{bgReason}</if>
            <if test="xJmId != null "> and x_jm_id = #{xJmId}</if>
            <if test="xName != null  and xName != ''"> and x_name like concat('%', #{xName}, '%')</if>
            <if test="xIdCard != null  and xIdCard != ''"> and x_id_card = #{xIdCard}</if>
            <if test="relation != null  and relation != ''"> and relation = #{relation}</if>
            <if test="bgTime != null "> and bg_time = #{bgTime}</if>
            <if test="hjAddress != null  and hjAddress != ''"> and hj_address = #{hjAddress}</if>
            <if test="jgNature != null  and jgNature != ''"> and jg_nature = #{jgNature}</if>
            <if test="longLive != null  and longLive != ''"> and long_live = #{longLive}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <!--数据范围过滤-->
            <if test="params.dataScope != null and params.dataScope != ''">
                ${params.dataScope}
            </if>
        </where>
    </select>

    <select id="selectSzxcHkbgRecardById" parameterType="Long" resultMap="SzxcHkbgRecardResult">
        <include refid="selectSzxcHkbgRecardVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcHkbgRecard" parameterType="SzxcHkbgRecard" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_hkbg_recard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="acountNo != null">acount_no,</if>
            <if test="jmId != null">jm_id,</if>
            <if test="name != null">name,</if>
            <if test="idCard != null">id_card,</if>
            <if test="yJmId != null">y_jm_id,</if>
            <if test="yName != null">y_name,</if>
            <if test="yIdCard != null">y_id_card,</if>
            <if test="bgReason != null">bg_reason,</if>
            <if test="xJmId != null">x_jm_id,</if>
            <if test="xName != null">x_name,</if>
            <if test="xIdCard != null">x_id_card,</if>
            <if test="relation != null">relation,</if>
            <if test="bgTime != null">bg_time,</if>
            <if test="hjAddress != null">hj_address,</if>
            <if test="jgNature != null">jg_nature,</if>
            <if test="longLive != null">long_live,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="deptName != null">dept_name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="acountNo != null">#{acountNo},</if>
            <if test="jmId != null">#{jmId},</if>
            <if test="name != null">#{name},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="yJmId != null">#{yJmId},</if>
            <if test="yName != null">#{yName},</if>
            <if test="yIdCard != null">#{yIdCard},</if>
            <if test="bgReason != null">#{bgReason},</if>
            <if test="xJmId != null">#{xJmId},</if>
            <if test="xName != null">#{xName},</if>
            <if test="xIdCard != null">#{xIdCard},</if>
            <if test="relation != null">#{relation},</if>
            <if test="bgTime != null">#{bgTime},</if>
            <if test="hjAddress != null">#{hjAddress},</if>
            <if test="jgNature != null">#{jgNature},</if>
            <if test="longLive != null">#{longLive},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="deptName != null">#{deptName},</if>
        </trim>
    </insert>

    <update id="updateSzxcHkbgRecard" parameterType="SzxcHkbgRecard">
        update szxc_hkbg_recard
        <trim prefix="SET" suffixOverrides=",">
            <if test="acountNo != null">acount_no = #{acountNo},</if>
            <if test="jmId != null">jm_id = #{jmId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="yJmId != null">y_jm_id = #{yJmId},</if>
            <if test="yName != null">y_name = #{yName},</if>
            <if test="yIdCard != null">y_id_card = #{yIdCard},</if>
            <if test="bgReason != null">bg_reason = #{bgReason},</if>
            <if test="xJmId != null">x_jm_id = #{xJmId},</if>
            <if test="xName != null">x_name = #{xName},</if>
            <if test="xIdCard != null">x_id_card = #{xIdCard},</if>
            <if test="relation != null">relation = #{relation},</if>
            <if test="bgTime != null">bg_time = #{bgTime},</if>
            <if test="hjAddress != null">hj_address = #{hjAddress},</if>
            <if test="jgNature != null">jg_nature = #{jgNature},</if>
            <if test="longLive != null">long_live = #{longLive},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="deptName != null">dept_name = #{deptName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcHkbgRecardById" parameterType="Long">
        delete from szxc_hkbg_recard where id = #{id}
    </delete>

    <delete id="deleteSzxcHkbgRecardByIds" parameterType="String">
        delete from szxc_hkbg_recard where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>