DeviceActionDetailMapper.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="cn.com.glsx.openplatform.mapper.DeviceActionDetailMapper">
    <resultMap id="BaseResultMap" type="cn.com.glsx.openplatform.model.DeviceActionDetail">
        <!--@mbg.generated-->
        <!--@Table t_device_action_detail-->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="device_sn" jdbcType="VARCHAR" property="deviceSn"/>
        <result column="type" jdbcType="VARCHAR" property="type"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
    </resultMap>

    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, device_sn, `type`, create_time
    </sql>

    <select id="countByMonth" resultType="int">
        select count(1)
        from t_platform_device
        <where>
            <if test="startMonth != null">
                and activat_time >= #{startMonth,jdbcType=TIMESTAMP}
            </if>
            <if test="endMonth != null">
                and activat_time &lt; #{endMonth,jdbcType=TIMESTAMP}
            </if>
        </where>
    </select>

    <select id="selectByMonth" resultType="cn.com.glsx.openplatform.model.PlatformDevice">
        select id, device_sn deviceSn, device_type deviceType, customer_id customerId,
            user_id userId, activat_time activatTime, status, create_time createTime,
            update_time updateTime, create_by createBy, update_by updateBy, remark
        from t_platform_device
        <where>
            <if test="startMonth != null">
                and activat_time >= #{startMonth,jdbcType=TIMESTAMP}
            </if>
            <if test="endMonth != null">
                and activat_time &lt; #{endMonth,jdbcType=TIMESTAMP}
            </if>
        </where>
        <if test="count != null">
            limit #{count,jdbcType=INTEGER}
        </if>
    </select>

    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from t_device_action_detail
        where id = #{id,jdbcType=INTEGER}
    </select>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--@mbg.generated-->
        delete
        from t_device_action_detail
        where id = #{id,jdbcType=INTEGER}
    </delete>

    <insert id="insert" keyColumn="id" keyProperty="id"
            parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        <selectKey order="AFTER" keyProperty="id" resultType="integer">
            select LAST_INSERT_ID()
        </selectKey>
        insert into t_device_action_detail (device_sn, `type`, create_time)
        values (#{deviceSn,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
            #{createTime,jdbcType=TIMESTAMP})
    </insert>

    <insert id="insertSelective" keyColumn="id" keyProperty="id"
            parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        <selectKey order="AFTER" keyProperty="id" resultType="integer">
            select LAST_INSERT_ID()
        </selectKey>
        insert into t_device_action_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceSn != null and deviceSn != ''">
                device_sn,
            </if>
            <if test="type != null and type != ''">
                `type`,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceSn != null and deviceSn != ''">
                #{deviceSn,jdbcType=VARCHAR},
            </if>
            <if test="type != null and type != ''">
                #{type,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>

    <update id="updateByPrimaryKeySelective"
            parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail">
        <!--@mbg.generated-->
        update t_device_action_detail
        <set>
            <if test="deviceSn != null and deviceSn != ''">
                device_sn = #{deviceSn,jdbcType=VARCHAR},
            </if>
            <if test="type != null and type != ''">
                `type` = #{type,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>

    <update id="updateByPrimaryKey"
            parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail">
        <!--@mbg.generated-->
        update t_device_action_detail
        set device_sn = #{deviceSn,jdbcType=VARCHAR},
                `type` = #{type,jdbcType=VARCHAR},
                create_time = #{createTime,jdbcType=TIMESTAMP}
        where id = #{id,jdbcType=INTEGER}
    </update>

    <update id="updateBatch" parameterType="java.util.List">
        <!--@mbg.generated-->
        update t_device_action_detail
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="device_sn = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.deviceSn,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="`type` = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.type,jdbcType=VARCHAR}
                </foreach>
            </trim>
            <trim prefix="create_time = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    when id = #{item.id,jdbcType=INTEGER} then #{item.createTime,jdbcType=TIMESTAMP}
                </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 t_device_action_detail
        <trim prefix="set" suffixOverrides=",">
            <trim prefix="device_sn = case" suffix="end,">
                <foreach collection="list" index="index" item="item">
                    <if test="item.deviceSn != null">
                        when id = #{item.id,jdbcType=INTEGER} then #{item.deviceSn,jdbcType=VARCHAR}
                    </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=INTEGER} then #{item.type,jdbcType=VARCHAR}
                    </if>
                </foreach>
            </trim>
            <trim prefix="create_time = 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>
        where id in
        <foreach close=")" collection="list" item="item" open="(" separator=", ">
            #{item.id,jdbcType=INTEGER}
        </foreach>
    </update>

    <insert id="batchInsert" keyColumn="id" keyProperty="id" parameterType="map"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_device_action_detail
                (device_sn, `type`, create_time)
                values
        <foreach collection="list" item="item" separator=",">
            (#{item.deviceSn,jdbcType=VARCHAR}, #{item.type,jdbcType=VARCHAR},
             #{item.createTime,jdbcType=TIMESTAMP})
        </foreach>
    </insert>

    <insert id="insertOrUpdate" keyColumn="id" keyProperty="id"
            parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_device_action_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            device_sn,
            `type`,
            create_time,
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            #{deviceSn,jdbcType=VARCHAR},
            #{type,jdbcType=VARCHAR},
            #{createTime,jdbcType=TIMESTAMP},
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            device_sn = #{deviceSn,jdbcType=VARCHAR},
                    `type` = #{type,jdbcType=VARCHAR},
                    create_time = #{createTime,jdbcType=TIMESTAMP},
        </trim>
    </insert>

    <insert id="insertOrUpdateSelective" keyColumn="id" keyProperty="id"
            parameterType="cn.com.glsx.openplatform.model.DeviceActionDetail"
            useGeneratedKeys="true">
        <!--@mbg.generated-->
        insert into t_device_action_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="deviceSn != null and deviceSn != ''">
                device_sn,
            </if>
            <if test="type != null and type != ''">
                `type`,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="deviceSn != null and deviceSn != ''">
                #{deviceSn,jdbcType=VARCHAR},
            </if>
            <if test="type != null and type != ''">
                #{type,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="deviceSn != null and deviceSn != ''">
                device_sn = #{deviceSn,jdbcType=VARCHAR},
            </if>
            <if test="type != null and type != ''">
                `type` = #{type,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
</mapper>