<?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.SzxcHjAddressMapper">

    <resultMap type="SzxcHjAddress" id="SzxcHjAddressResult">
        <result property="id"    column="id"    />
        <result property="jmId"    column="jm_id"    />
        <result property="name"    column="name"    />
        <result property="idCard"    column="id_card"    />
        <result property="acountNo"    column="acount_no"    />
        <result property="hjAddress"    column="hj_address"    />
        <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="deptName"    column="dept_name"    />
        <result property="userId"    column="user_id"    />
    </resultMap>

    <sql id="selectSzxcHjAddressVo">
        select id, jm_id, name, id_card, acount_no, hj_address, create_by, create_time, update_by, update_time, dept_id, dept_name, user_id from szxc_hj_address
    </sql>

    <select id="selectSzxcHjAddressList" parameterType="SzxcHjAddress" resultMap="SzxcHjAddressResult">
        <include refid="selectSzxcHjAddressVo"/>
        <where>
            <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="acountNo != null "> and acount_no = #{acountNo}</if>
            <if test="hjAddress != null  and hjAddress != ''"> and hj_address = #{hjAddress}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>

    <select id="selectSzxcHjAddressById" parameterType="Long" resultMap="SzxcHjAddressResult">
        <include refid="selectSzxcHjAddressVo"/>
        where id = #{id}
    </select>

    <insert id="insertSzxcHjAddress" parameterType="SzxcHjAddress" useGeneratedKeys="true" keyProperty="id">
        insert into szxc_hj_address
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="jmId != null">jm_id,</if>
            <if test="name != null">name,</if>
            <if test="idCard != null">id_card,</if>
            <if test="acountNo != null">acount_no,</if>
            <if test="hjAddress != null">hj_address,</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="deptName != null">dept_name,</if>
            <if test="userId != null">user_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="jmId != null">#{jmId},</if>
            <if test="name != null">#{name},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="acountNo != null">#{acountNo},</if>
            <if test="hjAddress != null">#{hjAddress},</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="deptName != null">#{deptName},</if>
            <if test="userId != null">#{userId},</if>
        </trim>
    </insert>

    <update id="updateSzxcHjAddress" parameterType="SzxcHjAddress">
        update szxc_hj_address
        <trim prefix="SET" suffixOverrides=",">
            <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="acountNo != null">acount_no = #{acountNo},</if>
            <if test="hjAddress != null">hj_address = #{hjAddress},</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="deptName != null">dept_name = #{deptName},</if>
            <if test="userId != null">user_id = #{userId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSzxcHjAddressById" parameterType="Long">
        delete from szxc_hj_address where id = #{id}
    </delete>

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