<?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.bonus.sgzb.material.mapper.BmQrcodeInfoMapper">
    
    <resultMap type="com.bonus.sgzb.material.domain.BmQrcodeInfo" id="BmQrcodeInfoResult">
        <result property="qrId"    column="qr_id"    />
        <result property="qrCode"    column="qr_code"    />
        <result property="typeId"    column="type_id"    />
        <result property="qrType"    column="qr_type"    />
        <result property="taskId"    column="task_id"    />
        <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="remark"    column="remark"    />
        <result property="companyId"    column="company_id"    />
    </resultMap>

    <sql id="selectBmQrcodeInfoVo">
        select qr_id, qr_code, type_id, qr_type, task_id, create_by, create_time, update_by, update_time, remark, company_id from bm_qrcode_info
    </sql>

    <select id="selectBmQrcodeInfoList" parameterType="com.bonus.sgzb.material.domain.BmQrcodeInfo" resultMap="BmQrcodeInfoResult">
        <include refid="selectBmQrcodeInfoVo"/>
        <where>  
            <if test="qrCode != null  and qrCode != ''"> and qr_code = #{qrCode}</if>
            <if test="typeId != null "> and type_id = #{typeId}</if>
            <if test="qrType != null  and qrType != ''"> and qr_type = #{qrType}</if>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
        </where>
    </select>
    
    <select id="selectBmQrcodeInfoByQrId" parameterType="Long" resultMap="BmQrcodeInfoResult">
        <include refid="selectBmQrcodeInfoVo"/>
        where qr_id = #{qrId}
    </select>

    <insert id="insertBmQrcodeInfo" parameterType="com.bonus.sgzb.material.domain.BmQrcodeInfo" useGeneratedKeys="true" keyProperty="qrId">
        insert into bm_qrcode_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="qrCode != null">qr_code,</if>
            <if test="typeId != null">type_id,</if>
            <if test="qrType != null">qr_type,</if>
            <if test="taskId != null">task_id,</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="remark != null">remark,</if>
            <if test="companyId != null">company_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="qrCode != null">#{qrCode},</if>
            <if test="typeId != null">#{typeId},</if>
            <if test="qrType != null">#{qrType},</if>
            <if test="taskId != null">#{taskId},</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="remark != null">#{remark},</if>
            <if test="companyId != null">#{companyId},</if>
         </trim>
    </insert>

    <update id="updateBmQrcodeInfo" parameterType="com.bonus.sgzb.material.domain.BmQrcodeInfo">
        update bm_qrcode_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="qrCode != null">qr_code = #{qrCode},</if>
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="qrType != null">qr_type = #{qrType},</if>
            <if test="taskId != null">task_id = #{taskId},</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="remark != null">remark = #{remark},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
        </trim>
        where qr_id = #{qrId}
    </update>

    <delete id="deleteBmQrcodeInfoByQrId" parameterType="Long">
        delete from bm_qrcode_info where qr_id = #{qrId}
    </delete>

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