IotLsyPlcConfigMapper.xml 4.4 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.zhonglai.luhui.device.mapper.IotLsyPlcConfigMapper">
    
    <resultMap type="IotLsyPlcConfig" id="IotLsyPlcConfigResult">
        <result property="id"    column="id"    />
        <result property="alterName"    column="alter_name"    />
        <result property="alterAddr"    column="alter_addr"    />
        <result property="upName"    column="up_name"    />
        <result property="upInterval"    column="up_interval"    />
        <result property="createTime"    column="create_time"    />
        <result property="prejectType"    column="preject_type"    />
        <result property="deviceType"    column="device_type"    />
    </resultMap>

    <sql id="selectIotLsyPlcConfigVo">
        select id, alter_name, alter_addr, up_name, up_interval, create_time, preject_type, device_type from iot_lsy_plc_config
    </sql>

    <select id="selectIotLsyPlcConfigList" parameterType="IotLsyPlcConfig" resultMap="IotLsyPlcConfigResult">
        <include refid="selectIotLsyPlcConfigVo"/>
        <where>  
            <if test="id != null "> and id = #{id}</if>
            <if test="alterName != null  and alterName != ''"> and alter_name like concat('%', #{alterName}, '%')</if>
            <if test="alterAddr != null  and alterAddr != ''"> and alter_addr = #{alterAddr}</if>
            <if test="upName != null  and upName != ''"> and up_name like concat('%', #{upName}, '%')</if>
            <if test="upInterval != null "> and up_interval = #{upInterval}</if>
            <if test="prejectType != null "> and preject_type = #{prejectType}</if>
            <if test="deviceType != null "> and device_type = #{deviceType}</if>
        </where>
    </select>
    
    <select id="selectIotLsyPlcConfigById" parameterType="Integer" resultMap="IotLsyPlcConfigResult">
        <include refid="selectIotLsyPlcConfigVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertIotLsyPlcConfig" parameterType="IotLsyPlcConfig" useGeneratedKeys="true" keyProperty="id">
        insert into iot_lsy_plc_config
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="alterName != null and alterName != ''">alter_name,</if>
            <if test="alterAddr != null and alterAddr != ''">alter_addr,</if>
            <if test="upName != null and upName != ''">up_name,</if>
            <if test="upInterval != null">up_interval,</if>
            <if test="createTime != null">create_time,</if>
            <if test="prejectType != null">preject_type,</if>
            <if test="deviceType != null">device_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="alterName != null and alterName != ''">#{alterName},</if>
            <if test="alterAddr != null and alterAddr != ''">#{alterAddr},</if>
            <if test="upName != null and upName != ''">#{upName},</if>
            <if test="upInterval != null">#{upInterval},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="prejectType != null">#{prejectType},</if>
            <if test="deviceType != null">#{deviceType},</if>
         </trim>
    </insert>

    <update id="updateIotLsyPlcConfig" parameterType="IotLsyPlcConfig">
        update iot_lsy_plc_config
        <trim prefix="SET" suffixOverrides=",">
            <if test="alterName != null and alterName != ''">alter_name = #{alterName},</if>
            <if test="alterAddr != null and alterAddr != ''">alter_addr = #{alterAddr},</if>
            <if test="upName != null and upName != ''">up_name = #{upName},</if>
            <if test="upInterval != null">up_interval = #{upInterval},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="prejectType != null">preject_type = #{prejectType},</if>
            <if test="deviceType != null">device_type = #{deviceType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteIotLsyPlcConfigById" parameterType="Integer">
        delete from iot_lsy_plc_config where id = #{id}
    </delete>

    <delete id="deleteIotLsyPlcConfigByIds" parameterType="Integer">
        delete from iot_lsy_plc_config where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>