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

    <resultMap id="BaseResultMap" type="com.ho.business.entity.TypeContrast">
            <id property="id" column="id" jdbcType="INTEGER"/>
            <result property="deviceTypeId" column="device_type_id" jdbcType="INTEGER"/>
            <result property="category" column="category" jdbcType="INTEGER"/>
            <result property="type" column="type" jdbcType="INTEGER"/>
            <result property="subType" column="sub_type" jdbcType="INTEGER"/>
            <result property="name" column="name" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,device_type_id,category,
        type,sub_type,name
    </sql>

    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from type_contrast
        where  id = #{id,jdbcType=INTEGER} 
    </select>
    <select id="selectByCategory" resultType="com.ho.business.entity.TypeContrast">
        select
        <include refid="Base_Column_List" />
        from type_contrast
        where category = #{id}
    </select>
    <select id="getDeviceTypeId" resultType="com.ho.business.entity.TypeContrast">
        select
        <include refid="Base_Column_List"/>
        from type_contrast
        where category = #{record.category}
        and type = #{record.type}
        and sub_type = #{record.subType}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from type_contrast
        where  id = #{id,jdbcType=INTEGER} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.TypeContrast" useGeneratedKeys="true">
        insert into type_contrast
        ( id,device_type_id,category
        ,type,sub_type,name
        )
        values (#{id,jdbcType=INTEGER},#{deviceTypeId,jdbcType=INTEGER},#{category,jdbcType=INTEGER}
        ,#{type,jdbcType=INTEGER},#{subType,jdbcType=INTEGER},#{name,jdbcType=VARCHAR}
        )
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ho.business.entity.TypeContrast" useGeneratedKeys="true">
        insert into type_contrast
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="deviceTypeId != null">device_type_id,</if>
                <if test="category != null">category,</if>
                <if test="type != null">type,</if>
                <if test="subType != null">sub_type,</if>
                <if test="name != null">name,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=INTEGER},</if>
                <if test="deviceTypeId != null">#{deviceTypeId,jdbcType=INTEGER},</if>
                <if test="category != null">#{category,jdbcType=INTEGER},</if>
                <if test="type != null">#{type,jdbcType=INTEGER},</if>
                <if test="subType != null">#{subType,jdbcType=INTEGER},</if>
                <if test="name != null">#{name,jdbcType=VARCHAR},</if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.ho.business.entity.TypeContrast">
        update type_contrast
        <set>
                <if test="deviceTypeId != null">
                    device_type_id = #{deviceTypeId,jdbcType=INTEGER},
                </if>
                <if test="category != null">
                    category = #{category,jdbcType=INTEGER},
                </if>
                <if test="type != null">
                    type = #{type,jdbcType=INTEGER},
                </if>
                <if test="subType != null">
                    sub_type = #{subType,jdbcType=INTEGER},
                </if>
                <if test="name != null">
                    name = #{name,jdbcType=VARCHAR},
                </if>
        </set>
        where   id = #{id,jdbcType=INTEGER} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.ho.business.entity.TypeContrast">
        update type_contrast
        set 
            device_type_id =  #{deviceTypeId,jdbcType=INTEGER},
            category =  #{category,jdbcType=INTEGER},
            type =  #{type,jdbcType=INTEGER},
            sub_type =  #{subType,jdbcType=INTEGER},
            name =  #{name,jdbcType=VARCHAR}
        where   id = #{id,jdbcType=INTEGER} 
    </update>
</mapper>
