TEmergencyDeviceMapper.xml 5.07 KB
Newer Older
zhangjianqian's avatar
zhangjianqian committed
1 2 3 4 5 6 7 8 9 10 11 12
<?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.zehong.system.mapper.TEmergencyDeviceMapper">
    
    <resultMap type="TEmergencyDevice" id="TEmergencyDeviceResult">
        <result property="id"    column="id"    />
        <result property="deviceType"    column="device_type"    />
        <result property="deviceName"    column="device_name"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
13 14
        <result property="contacts"    column="contacts"    />
        <result property="phone"    column="phone"    />
zhangjianqian's avatar
zhangjianqian committed
15
        <result property="address"    column="address"    />
16
        <result property="introduce"    column="introduce"    />
zhangjianqian's avatar
zhangjianqian committed
17 18 19 20 21 22
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectTEmergencyDeviceVo">
23
        select id, device_type, device_name, longitude, latitude, contacts, phone, address, introduce, create_time, update_time, is_del from t_emergency_device
zhangjianqian's avatar
zhangjianqian committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    </sql>

    <select id="selectTEmergencyDeviceList" parameterType="TEmergencyDevice" resultMap="TEmergencyDeviceResult">
        <include refid="selectTEmergencyDeviceVo"/>
        <where>  
            <if test="deviceType != null "> and device_type = #{deviceType}</if>
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
        </where>
    </select>
    
    <select id="selectTEmergencyDeviceById" parameterType="String" resultMap="TEmergencyDeviceResult">
        <include refid="selectTEmergencyDeviceVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTEmergencyDevice" parameterType="TEmergencyDevice">
        insert into t_emergency_device
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="deviceType != null">device_type,</if>
            <if test="deviceName != null">device_name,</if>
            <if test="longitude != null">longitude,</if>
            <if test="latitude != null">latitude,</if>
50 51
            <if test="contacts != null">contacts,</if>
            <if test="phone != null">phone,</if>
zhangjianqian's avatar
zhangjianqian committed
52
            <if test="address != null">address,</if>
53
            <if test="introduce != null">introduce,</if>
zhangjianqian's avatar
zhangjianqian committed
54 55 56
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
57
        </trim>
zhangjianqian's avatar
zhangjianqian committed
58 59 60 61 62 63
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="deviceType != null">#{deviceType},</if>
            <if test="deviceName != null">#{deviceName},</if>
            <if test="longitude != null">#{longitude},</if>
            <if test="latitude != null">#{latitude},</if>
64 65
            <if test="contacts != null">#{contacts},</if>
            <if test="phone != null">#{phone},</if>
zhangjianqian's avatar
zhangjianqian committed
66
            <if test="address != null">#{address},</if>
67
            <if test="introduce != null">#{introduce},</if>
zhangjianqian's avatar
zhangjianqian committed
68 69 70
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
71
        </trim>
zhangjianqian's avatar
zhangjianqian committed
72 73 74 75 76 77 78 79 80
    </insert>

    <update id="updateTEmergencyDevice" parameterType="TEmergencyDevice">
        update t_emergency_device
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceType != null">device_type = #{deviceType},</if>
            <if test="deviceName != null">device_name = #{deviceName},</if>
            <if test="longitude != null">longitude = #{longitude},</if>
            <if test="latitude != null">latitude = #{latitude},</if>
81 82
            <if test="contacts != null">contacts = #{contacts},</if>
            <if test="phone != null">phone = #{phone},</if>
zhangjianqian's avatar
zhangjianqian committed
83
            <if test="address != null">address = #{address},</if>
84
            <if test="introduce != null">introduce = #{introduce},</if>
zhangjianqian's avatar
zhangjianqian committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTEmergencyDeviceById" parameterType="String">
        delete from t_emergency_device where id = #{id}
    </delete>

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