<?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.xunmei.system.mapper.SysNfcBindMapper">

    <resultMap type="com.xunmei.system.domain.SysNfcBind" id="SysNfcBindResult">
                <result property="id" column="id"/>
                <result property="areaId" column="area_id"/>
                <result property="enable" column="enable"/>
                <result property="code" column="code"/>
                <result property="createTime" column="create_time"/>
                <result property="updateId" column="update_id"/>
                <result property="updateBy" column="update_by"/>
                <result property="updateTime" column="update_time"/>
                <result property="orgId" column="org_id"/>
                <result property="orgName" column="org_name"/>
                <result property="orgPath" column="org_path"/>
                <result property="collectionAreaName" column="collection_area_name"/>
                <result property="checkId" column="check_id"/>
    </resultMap>

    <sql id="selectSysNfcBindVo">
        select id, area_id, enable, code, create_time, update_id, update_by, update_time, org_id, org_name, org_path, collection_area_name, check_id
        from sys_nfc_bind
    </sql>

    <select id="selectSysNfcBindList" parameterType="com.xunmei.system.domain.SysNfcBind"
            resultMap="SysNfcBindResult">
        <include refid="selectSysNfcBindVo"/>
        <where>
                        <if test="areaId != null ">
                            and area_id = #{areaId}
                        </if>
                        <if test="enable != null ">
                            and enable = #{enable}
                        </if>
                        <if test="code != null  and code != ''">
                            and code = #{code}
                        </if>
                        <if test="updateId != null ">
                            and update_id = #{updateId}
                        </if>
                        <if test="orgId != null ">
                            and org_id = #{orgId}
                        </if>
                        <if test="orgName != null  and orgName != ''">
                            and org_name like concat('%', #{orgName}, '%')
                        </if>
                        <if test="orgPath != null  and orgPath != ''">
                            and org_path = #{orgPath}
                        </if>
                        <if test="collectionAreaName != null  and collectionAreaName != ''">
                            and collection_area_name like concat('%', #{collectionAreaName}, '%')
                        </if>
                        <if test="checkId != null ">
                            and check_id = #{checkId}
                        </if>
        </where>
    </select>

    <select id="selectSysNfcBindById" parameterType="Long"
            resultMap="SysNfcBindResult">
            <include refid="selectSysNfcBindVo"/>
            where id = #{id}
    </select>

    <insert id="insertSysNfcBind" parameterType="com.xunmei.system.domain.SysNfcBind">
        insert into sys_nfc_bind
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="id != null">id,
                    </if>
                    <if test="areaId != null">area_id,
                    </if>
                    <if test="enable != null">enable,
                    </if>
                    <if test="code != null">code,
                    </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="updateId != null">update_id,
                    </if>
                    <if test="updateBy != null">update_by,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
                    <if test="orgId != null">org_id,
                    </if>
                    <if test="orgName != null">org_name,
                    </if>
                    <if test="orgPath != null">org_path,
                    </if>
                    <if test="collectionAreaName != null">collection_area_name,
                    </if>
                    <if test="checkId != null">check_id,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="id != null">#{id},
                    </if>
                    <if test="areaId != null">#{areaId},
                    </if>
                    <if test="enable != null">#{enable},
                    </if>
                    <if test="code != null">#{code},
                    </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="updateId != null">#{updateId},
                    </if>
                    <if test="updateBy != null">#{updateBy},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
                    <if test="orgId != null">#{orgId},
                    </if>
                    <if test="orgName != null">#{orgName},
                    </if>
                    <if test="orgPath != null">#{orgPath},
                    </if>
                    <if test="collectionAreaName != null">#{collectionAreaName},
                    </if>
                    <if test="checkId != null">#{checkId},
                    </if>
        </trim>
    </insert>

    <update id="updateSysNfcBind" parameterType="com.xunmei.system.domain.SysNfcBind">
        update sys_nfc_bind
        <trim prefix="SET" suffixOverrides=",">
                    <if test="areaId != null">area_id =
                        #{areaId},
                    </if>
                    <if test="enable != null">enable =
                        #{enable},
                    </if>
                    <if test="code != null">code =
                        #{code},
                    </if>
                    <if test="createTime != null">create_time =
                        #{createTime},
                    </if>
                    <if test="updateId != null">update_id =
                        #{updateId},
                    </if>
                    <if test="updateBy != null">update_by =
                        #{updateBy},
                    </if>
                    <if test="updateTime != null">update_time =
                        #{updateTime},
                    </if>
                    <if test="orgId != null">org_id =
                        #{orgId},
                    </if>
                    <if test="orgName != null">org_name =
                        #{orgName},
                    </if>
                    <if test="orgPath != null">org_path =
                        #{orgPath},
                    </if>
                    <if test="collectionAreaName != null">collection_area_name =
                        #{collectionAreaName},
                    </if>
                    <if test="checkId != null">check_id =
                        #{checkId},
                    </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysNfcBindById" parameterType="Long">
        delete
        from sys_nfc_bind where id = #{id}
    </delete>

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