<?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.ho.business.mapper.DeviceTypeMapper">


    <sql id="Base_Column_List">
        id
        ,type_id,pid,
        name,device_type
    </sql>


    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete
        from device_type
        where id = #{id}
    </delete>

    <select id="selectByPrimaryKey" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        where id = #{id}
    </select>

    <select id="selectAll" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
    </select>



    <select id="selectByPid" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        where id=#{pid}
    </select>

    <select id="selectByIds" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        <where>
            <if test="typeIds != null and typeIds.size() != 0">
                id in
                <foreach collection="typeIds" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    <select id="selectByPids" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        <where>
            <if test="pIds != null and pIds.size() != 0">
                id in
                <foreach collection="pIds" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>

    <select id="getDeviceType" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        where id = #{deviceTypeId}
    </select>

    <select id="selectByDeviceType" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        where device_type = #{deviceType,jdbcType=VARCHAR}
    </select>

    <select id="selectName" resultType="com.ho.business.entity.DeviceType">
        select
        <include refid="Base_Column_List"/>
        from device_type
        <where>
            <if test="deviceTypeList != null and deviceTypeList.size() != 0">
                device_type in
                <foreach collection="deviceTypeList" open="(" close=")" separator="," item="item">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>



    <insert id="insert">
        insert into device_type
        ( id, type_id, pid
        , name)
        values ( #{id,jdbcType=INTEGER}, #{typeId,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}
               , #{name,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective">
        insert into device_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="typeId != null">type_id,</if>
            <if test="pid != null">pid,</if>
            <if test="name != null">name,</if>
            <if test="deviceType != null">device_type</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id,jdbcType=INTEGER},</if>
            <if test="typeId != null">#{typeId,jdbcType=INTEGER},</if>
            <if test="pid != null">#{pid,jdbcType=INTEGER},</if>
            <if test="name != null">#{name,jdbcType=VARCHAR},</if>
            <if test="deviceType != null">#{deviceType,jdbcType=VARCHAR},</if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.DeviceType">
        update device_type
        <set>
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="typeId != null">
                type_id = #{typeId,jdbcType=INTEGER},
            </if>
            <if test="pid != null">
                pid = #{pid,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                name = #{name,jdbcType=VARCHAR},
            </if>
            <if test="deviceType != null">
                device_type = #{deviceType,jdbcType=VARCHAR}
            </if>
        </set>
        where
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ho.business.entity.DeviceType">
        update device_type
        set id      = #{id,jdbcType=INTEGER},
            type_id = #{typeId,jdbcType=INTEGER},
            pid     = #{pid,jdbcType=INTEGER},
            name    = #{name,jdbcType=VARCHAR} device_type = #{deviceType,jdbcType=VARCHAR}
        where
    </update>
</mapper>
