|
|
|
<?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.example.device.mapper.StatusMapper">
|
|
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="com.example.device.entity.Status">
|
|
|
|
<result column="id" jdbcType="BIGINT" property="id"/>
|
|
|
|
<result column="device_no" jdbcType="VARCHAR" property="deviceNo"/>
|
|
|
|
<result column="device_name" jdbcType="VARCHAR" property="deviceName"/>
|
|
|
|
<result column="device_status" jdbcType="INTEGER" property="deviceStatus"/>
|
|
|
|
<result column="device_ip" jdbcType="VARCHAR" property="deviceIp"/>
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<insert id="Add" parameterType="com.example.device.entity.Status">
|
|
|
|
INSERT INTO status
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="status.deviceNo != null">
|
|
|
|
device_no,
|
|
|
|
</if>
|
|
|
|
<if test="status.deviceName != null">
|
|
|
|
device_name,
|
|
|
|
</if>
|
|
|
|
<if test="status.deviceStatus != null">
|
|
|
|
device_status,
|
|
|
|
</if>
|
|
|
|
<if test="status.time != null">
|
|
|
|
time,
|
|
|
|
</if>
|
|
|
|
</trim>
|
|
|
|
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
|
|
|
<if test="status.deviceNo != null">
|
|
|
|
#{status.deviceNo,jdbcType=VARCHAR},
|
|
|
|
</if>
|
|
|
|
<if test="status.deviceName != null">
|
|
|
|
#{status.deviceName,jdbcType=VARCHAR},
|
|
|
|
</if>
|
|
|
|
<if test="status.deviceStatus != null">
|
|
|
|
#{status.deviceStatus,jdbcType=INTEGER},
|
|
|
|
</if>
|
|
|
|
<if test="status.time != null">
|
|
|
|
#{status.time,jdbcType=DATE},
|
|
|
|
</if>
|
|
|
|
</trim>
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<sql id="selectStatus">
|
|
|
|
select id, device_no, device_name, device_status, time from status
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="listStatus" parameterType="com.example.device.entity.Status" resultMap="BaseResultMap">
|
|
|
|
select s.id, s.device_no, s.device_name, s.device_status, s.time, d.device_ip
|
|
|
|
from status s
|
|
|
|
LEFT JOIN device d on s.device_no = d.device_no
|
|
|
|
<where>
|
|
|
|
<if test="status.time != null">
|
|
|
|
AND s.time BETWEEN #{status.startTime,jdbcType=DATE} AND #{status.time,jdbcType=DATE}
|
|
|
|
</if>
|
|
|
|
<if test="status.deviceNo != null">
|
|
|
|
AND s.device_no = #{status.deviceNo}
|
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
</mapper>
|