SmartSceneDataMapper.xml 9.34 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.SmartSceneDataMapper">
    <resultMap id="BaseResultMap" type="com.glsx.smart.dao.entity.SmartSceneData">
        <!--@mbg.generated-->
        <!--@Table smart_scene_data-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="scene_id" jdbcType="BIGINT" property="sceneId"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
        <result column="sort" jdbcType="TINYINT" property="sort"/>
        <result column="param_key" jdbcType="VARCHAR" property="paramKey"/>
        <result column="param_value" jdbcType="VARCHAR" property="paramValue"/>
        <result column="device_id" jdbcType="VARCHAR" property="deviceId"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, scene_id, `type`, sort, param_key, device_id, param_value
    </sql>
    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update smart_scene_data
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="scene_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.sceneId,jdbcType=BIGINT}
                </foreach>
            </trim>
            <trim prefix="`type` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.type,jdbcType=TINYINT}
                </foreach>
            </trim>
            <trim prefix="sort = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.sort,jdbcType=TINYINT}
                </foreach>
            </trim>
            <trim prefix="param_key = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.paramKey,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="param_value = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=BIGINT} then #{item.paramValue,jdbcType=VARCHAR}
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    <update id="updateBatchSelective" parameterType="java.util.List">
        <!--@mbg.generated-->
        update smart_scene_data
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="scene_id = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.sceneId != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.sceneId,jdbcType=BIGINT}
                    </if>
                </foreach>
            </trim>
            <trim prefix="`type` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.type != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.type,jdbcType=TINYINT}
                    </if>
                </foreach>
            </trim>
            <trim prefix="sort = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.sort != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.sort,jdbcType=TINYINT}
                    </if>
                </foreach>
            </trim>
            <trim prefix="param_key = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.paramKey != null">
                        when id = #{item.id,jdbcType=BIGINT} then #{item.paramKey,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="param_value = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.paramValue != null">
                        when id = #{item.id,jdbcType=BIGINT} then
                        #{item.paramValue,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
        </trim>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_scene_data
        (scene_id, `type`, sort, param_key, device_id, param_value)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.sceneId,jdbcType=BIGINT}, #{item.type,jdbcType=TINYINT},
            #{item.sort,jdbcType=TINYINT}, #{item.paramKey,jdbcType=VARCHAR},
            #{item.deviceId,jdbcType=VARCHAR}, #{item.paramValue,jdbcType=VARCHAR})
        </foreach>
    </insert>
    <delete id="deleteBySceneId" parameterType="java.lang.Long">
        delete from smart_scene_data
        where scene_id = #{id,jdbcType=BIGINT}
    </delete>
    <select id="getBySceneId" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select <include refid="Base_Column_List"/> from smart_scene_data
        where scene_id = #{sceneId,jdbcType=BIGINT}
    </select>
    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.smart.dao.entity.SmartSceneData" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_scene_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            scene_id,
            `type`,
            sort,
            param_key,
            param_value,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            #{sceneId,jdbcType=BIGINT},
            #{type,jdbcType=TINYINT},
            #{sort,jdbcType=TINYINT},
            #{paramKey,jdbcType=VARCHAR},
            #{paramValue,jdbcType=VARCHAR},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            scene_id = #{sceneId,jdbcType=BIGINT},
            `type` = #{type,jdbcType=TINYINT},
            sort = #{sort,jdbcType=TINYINT},
            param_key = #{paramKey,jdbcType=VARCHAR},
            param_value = #{paramValue,jdbcType=VARCHAR},
        </trim>
    </insert>
    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="com.glsx.smart.dao.entity.SmartSceneData" useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into smart_scene_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="sceneId != null">
                scene_id,
            </if>
            <if test="type != null">
                `type`,
            </if>
            <if test="sort != null">
                sort,
            </if>
            <if test="paramKey != null and paramKey != ''">
                param_key,
            </if>
            <if test="paramValue != null and paramValue != ''">
                param_value,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="sceneId != null">
                #{sceneId,jdbcType=BIGINT},
            </if>
            <if test="type != null">
                #{type,jdbcType=TINYINT},
            </if>
            <if test="sort != null">
                #{sort,jdbcType=TINYINT},
            </if>
            <if test="paramKey != null and paramKey != ''">
                #{paramKey,jdbcType=VARCHAR},
            </if>
            <if test="paramValue != null and paramValue != ''">
                #{paramValue,jdbcType=VARCHAR},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=BIGINT},
            </if>
            <if test="sceneId != null">
                scene_id = #{sceneId,jdbcType=BIGINT},
            </if>
            <if test="type != null">
                `type` = #{type,jdbcType=TINYINT},
            </if>
            <if test="sort != null">
                sort = #{sort,jdbcType=TINYINT},
            </if>
            <if test="paramKey != null and paramKey != ''">
                param_key = #{paramKey,jdbcType=VARCHAR},
            </if>
            <if test="paramValue != null and paramValue != ''">
                param_value = #{paramValue,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
</mapper>