<?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.fastbee.iot.mapper.ProtocolMapper">
    <resultMap id="BaseResultMap" type="com.fastbee.iot.domain.Protocol">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="protocol_code" jdbcType="VARCHAR" property="protocolCode"/>
        <result column="protocol_name" jdbcType="VARCHAR" property="protocolName"/>
        <result column="protocol_file_url" jdbcType="VARCHAR" property="protocolFileUrl"/>
        <result column="protocol_type" jdbcType="INTEGER" property="protocolType"/>
        <result column="jar_sign" jdbcType="VARCHAR" property="jarSign"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="protocol_status" jdbcType="INTEGER" property="protocolStatus"/>
        <result column="del_flag" jdbcType="INTEGER" property="delFlag"/>
        <result column="display" jdbcType="INTEGER" property="display"/>
        <result column="data_format" jdbcType="VARCHAR" property="dataFormat"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, protocol_code, protocol_name, protocol_file_url, protocol_type,
    jar_sign, create_time, update_time, protocol_status, del_flag, display, data_format
    </sql>

    <sql id="selectProtocolVo">
        select id, protocol_code, protocol_name, protocol_file_url, protocol_type,
               jar_sign, create_time, update_time, protocol_status, del_flag, display, data_format from iot_protocol
    </sql>


    <select id="selectByUnion" parameterType="com.fastbee.iot.domain.Protocol" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from iot_protocol
        where
        1 = 1
        and del_flag = 0
        <if test="protocolStatus != null">
            AND protocol_status = #{protocolStatus}
        </if>
        <if test="delFlag != null">
            AND del_flag = #{delFlag,jdbcType=INTEGER}
        </if>
    </select>

    <select id="selectAll" parameterType="com.fastbee.iot.domain.Protocol" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from iot_protocol
        where
        1 = 1
        and del_flag = 0
        <if test="protocolCode != null">
            AND protocol_code = #{protocolCode,jdbcType=VARCHAR}
        </if>
        <if test="protocolName != null">
            AND protocol_name = #{protocolName,jdbcType=VARCHAR}
        </if>

        <if test="protocolFileUrl != null">
            AND protocol_file_url = #{protocolFileUrl,jdbcType=VARCHAR}
        </if>
        <if test="protocolType != null">
            AND protocol_type = #{protocolType,jdbcType=INTEGER},
        </if>
        <if test="jarSign != null">
            AND jar_sign = #{jarSign,jdbcType=VARCHAR},
        </if>
        <if test="createTime != null">
            AND create_time = #{createTime,jdbcType=TIMESTAMP}
        </if>
        <if test="updateTime != null">
            AND update_time = #{updateTime,jdbcType=TIMESTAMP}
        </if>
        <if test="protocolStatus != null">
            AND protocol_status = #{protocolStatus,jdbcType=INTEGER}
        </if>
    </select>

</mapper>
