SmartDeviceStatusMapper.xml 11.1 KB
<?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.glsx.smart.dao.mapper.SmartDeviceStatusMapper">
    <resultMap id="BaseResultMap" type="com.glsx.smart.dao.entity.SmartDeviceStatus">
        <!--@mbg.generated-->
        <!--@Table smart_device_status-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
        <result column="device_order_code" jdbcType="VARCHAR" property="deviceOrderCode"/>
        <result column="device_order_value" jdbcType="VARCHAR" property="deviceOrderValue"/>
        <result column="createtime" jdbcType="TIMESTAMP" property="createtime"/>
        <result column="updatetime" jdbcType="TIMESTAMP" property="updatetime"/>
        <result column="product_key" jdbcType="VARCHAR" property="productKey"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, device_id, device_order_code, device_order_value, createtime, updatetime,
        product_key
    </sql>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update smart_device_status
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="device_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.deviceId,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="device_order_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then
                    #{item.deviceOrderCode,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="device_order_value = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then
                    #{item.deviceOrderValue,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="createtime = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.createtime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="updatetime = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.updatetime,jdbcType=TIMESTAMP}
                </foreach>
            </trim>
            <trim prefix="product_key = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.productKey,jdbcType=VARCHAR}
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update smart_device_status
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="device_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.deviceId != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.deviceId,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="device_order_code = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.deviceOrderCode != null">
                        when id = #{item.id,jdbcType=INTEGER} then
                        #{item.deviceOrderCode,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="device_order_value = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.deviceOrderValue != null">
                        when id = #{item.id,jdbcType=INTEGER} then
                        #{item.deviceOrderValue,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="createtime = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.createtime != null">
                        when id = #{item.id,jdbcType=INTEGER} then
                        #{item.createtime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="updatetime = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.updatetime != null">
                        when id = #{item.id,jdbcType=INTEGER} then
                        #{item.updatetime,jdbcType=TIMESTAMP}
                    </if>
                </foreach>
            </trim>
            <trim prefix="product_key = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.productKey != null">
                        when id = #{item.id,jdbcType=INTEGER} then
                        #{item.productKey,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>
    <select id="findDevStatusByIdAndCode" resultMap="BaseResultMap">
    select * from smart_device_status where device_id=#{deviceId} and  device_order_code=#{code}
    </select>
    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_device_status
        (device_id, device_order_code, device_order_value, createtime, updatetime,
        product_key)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.deviceId,jdbcType=VARCHAR},
            #{item.deviceOrderCode,jdbcType=VARCHAR},
            #{item.deviceOrderValue,jdbcType=VARCHAR}, #{item.createtime,jdbcType=TIMESTAMP},
            #{item.updatetime,jdbcType=TIMESTAMP}, #{item.productKey,jdbcType=VARCHAR})
        </foreach>
    </insert>
    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.smart.dao.entity.SmartDeviceStatus" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_device_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            device_id,
            device_order_code,
            device_order_value,
            createtime,
            updatetime,
            product_key,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            #{deviceId,jdbcType=VARCHAR},
            #{deviceOrderCode,jdbcType=VARCHAR},
            #{deviceOrderValue,jdbcType=VARCHAR},
            #{createtime,jdbcType=TIMESTAMP},
            #{updatetime,jdbcType=TIMESTAMP},
            #{productKey,jdbcType=VARCHAR},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            device_id = #{deviceId,jdbcType=VARCHAR},
            device_order_code = #{deviceOrderCode,jdbcType=VARCHAR},
            device_order_value = #{deviceOrderValue,jdbcType=VARCHAR},
            createtime = #{createtime,jdbcType=TIMESTAMP},
            updatetime = #{updatetime,jdbcType=TIMESTAMP},
            product_key = #{productKey,jdbcType=VARCHAR},
        </trim>
    </insert>
    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.smart.dao.entity.SmartDeviceStatus" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_device_status
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="deviceId != null and deviceId != ''">
                device_id,
            </if>
            <if test="deviceOrderCode != null and deviceOrderCode != ''">
                device_order_code,
            </if>
            <if test="deviceOrderValue != null and deviceOrderValue != ''">
                device_order_value,
            </if>
            <if test="createtime != null">
                createtime,
            </if>
            <if test="updatetime != null">
                updatetime,
            </if>
            <if test="productKey != null and productKey != ''">
                product_key,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="deviceId != null and deviceId != ''">
                #{deviceId,jdbcType=VARCHAR},
            </if>
            <if test="deviceOrderCode != null and deviceOrderCode != ''">
                #{deviceOrderCode,jdbcType=VARCHAR},
            </if>
            <if test="deviceOrderValue != null and deviceOrderValue != ''">
                #{deviceOrderValue,jdbcType=VARCHAR},
            </if>
            <if test="createtime != null">
                #{createtime,jdbcType=TIMESTAMP},
            </if>
            <if test="updatetime != null">
                #{updatetime,jdbcType=TIMESTAMP},
            </if>
            <if test="productKey != null and productKey != ''">
                #{productKey,jdbcType=VARCHAR},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="deviceId != null and deviceId != ''">
                device_id = #{deviceId,jdbcType=VARCHAR},
            </if>
            <if test="deviceOrderCode != null and deviceOrderCode != ''">
                device_order_code = #{deviceOrderCode,jdbcType=VARCHAR},
            </if>
            <if test="deviceOrderValue != null and deviceOrderValue != ''">
                device_order_value = #{deviceOrderValue,jdbcType=VARCHAR},
            </if>
            <if test="createtime != null">
                createtime = #{createtime,jdbcType=TIMESTAMP},
            </if>
            <if test="updatetime != null">
                updatetime = #{updatetime,jdbcType=TIMESTAMP},
            </if>
            <if test="productKey != null and productKey != ''">
                product_key = #{productKey,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
</mapper>