autosprout/AutoSprout-watering/src/main/resources/mapper/device/AsDeviceMapper.xml

304 lines
17 KiB
XML
Raw Normal View History

<?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.ruoyi.device.mapper.AsDeviceMapper">
<resultMap type="AsDevice" id="AsDeviceResult">
<result property="deviceId" column="device_id" />
<result property="picture" column="picture" />
<result property="deviceName" column="device_name" />
<result property="classifyId" column="classify_id" />
<result property="classifyName" column="classify_name" />
<result property="modelId" column="model_id" />
<result property="model" column="model" />
<result property="mac" column="mac" />
<result property="activationTime" column="activation_time" />
<result property="onlineStatus" column="online_status" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="regularWatering" column="regular_watering" />
<result property="soilMoistureOpen" column="soil_moisture_open" />
<result property="soilMoistureClose" column="soil_moisture_close" />
<result property="waterIntensity" column="water_intensity" />
<result property="pulseMode" column="pulse_mode" />
<result property="pulseModeParam" column="pulse_mode_param" />
<result property="screenRestTime" column="screen_rest_time" />
<result property="version" column="version" />
<result property="versionId" column="version_id" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
2023-11-15 16:53:20 +08:00
<result property="regularWateringJson" column="regular_watering_json" />
<result property="soilMoisture" column="soil_moisture" />
<result property="waterIntensitySwitch" column="water_intensity_switch" />
2024-04-03 17:38:01 +08:00
<result property="isNetwork" column="is_network" />
<result property="isDefault" column="is_default" />
2024-04-10 16:09:43 +08:00
<result property="modeStr" column="mode_str" />
2024-04-24 15:53:18 +08:00
<result property="bluetoothId" column="bluetooth_id" />
<result property="bluetoothName" column="bluetooth_name" />
2025-04-02 15:40:49 +08:00
<result property="pre" column="pre" />
</resultMap>
<sql id="selectAsDeviceVo">
2025-04-16 15:17:45 +08:00
select ad.device_id,
ad.picture,
ad.device_name,
ad.classify_id,
ad.classify_name,
ad.model_id,
ad.model,
ad.mac,
ad.activation_time,
ad.online_status,
ad.user_id,
ad.user_name,
ad.nick_name,
ad.regular_watering,
ad.soil_moisture_open,
ad.soil_moisture_close,
ad.water_intensity,
ad.pulse_mode,
ad.pulse_mode_param,
ad.screen_rest_time,
ad.version,
ad.version_id,
ad.create_by,
ad.create_time,
ad.update_by,
ad.update_time,
ad.remark,
ad.regular_watering_json,
ad.soil_moisture,
ad.water_intensity_switch,
ad.is_network,
ad.is_default,
ad.mode_str,
ad.bluetooth_id,
ad.bluetooth_name,
2025-04-18 10:24:27 +08:00
ad.model_name,
ad.pre,
am.picture as modelPicture
2025-04-16 15:17:45 +08:00
from as_device ad
2025-04-18 10:24:27 +08:00
left join as_model am on ad.model_id = am.model_id
</sql>
<select id="selectAsDeviceList" parameterType="AsDevice" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
<where>
status = 0
2025-04-16 15:17:45 +08:00
<if test="deviceName != null and deviceName != ''"> and ad.device_name like concat('%', #{deviceName}, '%')</if>
<if test="classifyName != null and classifyName != ''"> and ad.classify_name like concat('%', #{classifyName}, '%')</if>
<if test="model != null and model != ''"> and ad.model like concat('%', #{model}, '%')</if>
<if test="mac != null and mac != ''"> and ad.mac like concat('%', #{mac}, '%')</if>
<if test="onlineStatus != null and onlineStatus != ''"> and ad.online_status = #{onlineStatus}</if>
<if test="nickName != null and nickName != ''"> and ad.nick_name like concat('%', #{nickName}, '%')</if>
<if test="userName != null and userName != ''"> and ad.user_name like concat('%', #{userName}, '%')</if>
<if test="userId != null "> and ad.user_id = #{userId}</if>
<if test="deviceId != null "> and ad.device_id = #{deviceId}</if>
<if test="modelId != null "> and ad.model_id = #{modelId}</if>
<if test="isDefault != null and isDefault != ''"> and ad.is_default = #{isDefault}</if>
2024-11-06 16:59:37 +08:00
<if test="macList != null and macList.size() > 0">
2025-04-16 15:17:45 +08:00
and ad.mac in
2024-11-06 16:59:37 +08:00
<foreach collection="macList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</where>
2024-11-02 17:00:08 +08:00
order by is_default desc
</select>
<select id="selectAsDeviceByDeviceId" parameterType="Long" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
where device_id = #{deviceId}
</select>
<select id="selectAsDeviceByMac" parameterType="String" resultMap="AsDeviceResult">
<include refid="selectAsDeviceVo"/>
where mac = #{mac}
</select>
<select id="isBandByMac" resultType="java.lang.Integer">
select count(1) from as_device
2025-02-15 16:24:00 +08:00
where mac = #{mac} and user_id IS NOT NULL and user_id != 0
</select>
2025-04-16 15:17:45 +08:00
<select id="selectBindDeviceNumByUserId" resultType="java.lang.Integer">
select count(1) from as_device ad LEFT JOIN as_user u ON ad.user_id = u.user_id
where ad.user_id = #{userId}
</select>
<insert id="insertAsDevice" parameterType="AsDevice" useGeneratedKeys="true" keyProperty="deviceId">
insert into as_device
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="picture != null">picture,</if>
<if test="deviceName != null">device_name,</if>
<if test="classifyId != null">classify_id,</if>
<if test="classifyName != null and classifyName != ''">classify_name,</if>
<if test="modelId != null">model_id,</if>
<if test="model != null">model,</if>
<if test="mac != null">mac,</if>
<if test="activationTime != null">activation_time,</if>
<if test="onlineStatus != null">online_status,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="regularWatering != null">regular_watering,</if>
<if test="soilMoistureOpen != null">soil_moisture_open,</if>
<if test="soilMoistureClose != null">soil_moisture_close,</if>
<if test="waterIntensity != null">water_intensity,</if>
<if test="pulseMode != null">pulse_mode,</if>
<if test="pulseModeParam != null">pulse_mode_param,</if>
<if test="screenRestTime != null">screen_rest_time,</if>
<if test="version != null">version,</if>
<if test="versionId != null">version_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
2025-04-16 11:12:45 +08:00
<if test="modelName != null">model_name,</if>
<if test="remark != null">remark,</if>
2023-11-15 16:53:20 +08:00
<if test="regularWateringJson != null">regular_watering_json,</if>
<if test="soilMoisture != null">soil_moisture,</if>
2025-04-16 11:12:45 +08:00
<if test="waterIntensitySwitch != null">water_intensity_switch,</if>
2025-04-16 18:10:50 +08:00
<if test="bluetoothId != null">bluetooth_id,</if>
<if test="bluetoothName != null">bluetooth_name,</if>
2025-04-16 11:12:45 +08:00
<if test="pre != null">pre</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="picture != null">#{picture},</if>
<if test="deviceName != null">#{deviceName},</if>
<if test="classifyId != null">#{classifyId},</if>
<if test="classifyName != null and classifyName != ''">#{classifyName},</if>
<if test="modelId != null">#{modelId},</if>
<if test="model != null">#{model},</if>
<if test="mac != null">#{mac},</if>
<if test="activationTime != null">#{activationTime},</if>
<if test="onlineStatus != null">#{onlineStatus},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="regularWatering != null">#{regularWatering},</if>
<if test="soilMoistureOpen != null">#{soilMoistureOpen},</if>
<if test="soilMoistureClose != null">#{soilMoistureClose},</if>
<if test="waterIntensity != null">#{waterIntensity},</if>
<if test="pulseMode != null">#{pulseMode},</if>
<if test="pulseModeParam != null">#{pulseModeParam},</if>
<if test="screenRestTime != null">#{screenRestTime},</if>
<if test="version != null">#{version},</if>
<if test="versionId != null">#{versionId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
2025-04-16 11:12:45 +08:00
<if test="modelName != null">#{modelName},</if>
<if test="remark != null">#{remark},</if>
2023-11-15 16:53:20 +08:00
<if test="regularWateringJson != null">#{regularWateringJson},</if>
<if test="soilMoisture != null">#{soilMoisture},</if>
2025-04-16 11:12:45 +08:00
<if test="waterIntensitySwitch != null">#{waterIntensitySwitch},</if>
2025-04-16 18:10:50 +08:00
<if test="bluetoothId != null">#{bluetoothId},</if>
<if test="bluetoothName != null">#{bluetoothName},</if>
2025-04-16 11:12:45 +08:00
<if test="pre != null">#{pre}</if>
</trim>
</insert>
<update id="updateAsDevice" parameterType="AsDevice">
update as_device
<trim prefix="SET" suffixOverrides=",">
<if test="picture != null">picture = #{picture},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="classifyId != null">classify_id = #{classifyId},</if>
<if test="classifyName != null and classifyName != ''">classify_name = #{classifyName},</if>
<if test="modelId != null">model_id = #{modelId},</if>
<if test="model != null">model = #{model},</if>
<if test="mac != null">mac = #{mac},</if>
<if test="activationTime != null">activation_time = #{activationTime},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="regularWatering != null">regular_watering = #{regularWatering},</if>
<if test="soilMoistureOpen != null">soil_moisture_open = #{soilMoistureOpen},</if>
<if test="soilMoistureClose != null">soil_moisture_close = #{soilMoistureClose},</if>
<if test="waterIntensity != null">water_intensity = #{waterIntensity},</if>
<if test="pulseMode != null">pulse_mode = #{pulseMode},</if>
<if test="pulseModeParam != null">pulse_mode_param = #{pulseModeParam},</if>
<if test="screenRestTime != null">screen_rest_time = #{screenRestTime},</if>
<if test="version != null">version = #{version},</if>
<if test="versionId != null">version_id = #{versionId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
2023-11-15 16:53:20 +08:00
<if test="regularWateringJson != null">regular_watering_json = #{regularWateringJson},</if>
<if test="soilMoisture != null">soil_moisture = #{soilMoisture},</if>
2024-04-03 17:38:01 +08:00
<if test="waterIntensitySwitch != null">water_intensity_switch = #{waterIntensitySwitch},</if>
<if test="status != null">status = #{status},</if>
2024-04-10 16:09:43 +08:00
<if test="isNetwork != null">is_network = #{isNetwork},</if>
<if test="isDefault != null">is_default = #{isDefault},</if>
2024-04-24 15:53:18 +08:00
<if test="modeStr != null">mode_str = #{modeStr},</if>
<if test="bluetoothId != null">bluetooth_id = #{bluetoothId},</if>
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName}</if>
2025-04-02 15:40:49 +08:00
<if test="pre != null">pre = #{pre}</if>
</trim>
where device_id = #{deviceId}
</update>
2024-04-19 14:11:08 +08:00
<update id="updateAsDeviceByMac" parameterType="AsDevice">
update as_device
<trim prefix="SET" suffixOverrides=",">
<if test="picture != null">picture = #{picture},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="classifyId != null">classify_id = #{classifyId},</if>
<if test="classifyName != null and classifyName != ''">classify_name = #{classifyName},</if>
<if test="modelId != null">model_id = #{modelId},</if>
<if test="model != null">model = #{model},</if>
<if test="activationTime != null">activation_time = #{activationTime},</if>
<if test="onlineStatus != null">online_status = #{onlineStatus},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="regularWatering != null">regular_watering = #{regularWatering},</if>
<if test="soilMoistureOpen != null">soil_moisture_open = #{soilMoistureOpen},</if>
<if test="soilMoistureClose != null">soil_moisture_close = #{soilMoistureClose},</if>
<if test="waterIntensity != null">water_intensity = #{waterIntensity},</if>
<if test="pulseMode != null">pulse_mode = #{pulseMode},</if>
<if test="pulseModeParam != null">pulse_mode_param = #{pulseModeParam},</if>
<if test="screenRestTime != null">screen_rest_time = #{screenRestTime},</if>
<if test="version != null">version = #{version},</if>
<if test="versionId != null">version_id = #{versionId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="regularWateringJson != null">regular_watering_json = #{regularWateringJson},</if>
<if test="soilMoisture != null">soil_moisture = #{soilMoisture},</if>
<if test="waterIntensitySwitch != null">water_intensity_switch = #{waterIntensitySwitch},</if>
<if test="status != null">status = #{status},</if>
<if test="isNetwork != null">is_network = #{isNetwork},</if>
<if test="isDefault != null">is_default = #{isDefault},</if>
<if test="modeStr != null">mode_str = #{modeStr}</if>
2025-04-02 15:40:49 +08:00
<if test="bluetoothId != null">bluetooth_id = #{bluetoothId}</if>
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName}</if>
<if test="pre != null">pre = #{pre}</if>
2024-04-19 14:11:08 +08:00
</trim>
where mac = #{mac}
</update>
<delete id="deleteAsDeviceByDeviceId" parameterType="Long">
delete from as_device where device_id = #{deviceId}
</delete>
<delete id="deleteAsDeviceByDeviceIds" parameterType="String">
delete from as_device where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
</mapper>