分享单个或全部设备功能实现,用户设备列表接口调整,新增别人分享给自己的设备

This commit is contained in:
hp
2022-04-27 13:05:36 +08:00
parent 909bc54249
commit cabc91f3bc
12 changed files with 214 additions and 47 deletions

View File

@@ -129,10 +129,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
order by create_time desc
</select>
<select id="selectDeviceListAccurate" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
<include refid="selectDeviceVo"/>
<where>
<if test="deviceName != null and deviceName != ''"> and device_name = #{deviceName}</if>
<if test="deviceName != null and deviceName != ''"> and device_name = #{deviceName} </if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name = #{productName}</if>
<if test="userId != null "> and user_id = #{userId}</if>
@@ -166,7 +167,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name like concat('%', #{productName}, '%')</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userId != null ">
and user_id = #{userId}
or device_id in (select device_id from iot_device_user where iot_device_user.user_name = #{userName})
</if>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
@@ -183,7 +187,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productId != null "> and product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and product_name = #{productName}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="userName != null and userName != ''"> and user_name = #{userName}</if>
<if test="userName != null and userName != ''">
and user_name = #{userName}
or device_id in (select device_id from iot_device_user where iot_device_user.user_name = #{userName})
</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name=#{tenantName}</if>
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>

View File

@@ -36,10 +36,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDeviceUserVo"/>
where device_id = #{deviceId}
</select>
<insert id="insertDeviceUser" parameterType="com.ruoyi.iot.domain.DeviceUser" useGeneratedKeys="true" keyProperty="deviceId">
<select id="selectDeviceUserByDeviceIdAndUserId" resultMap="DeviceUserResult">
<include refid="selectDeviceUserVo"/>
where device_id = #{deviceId} and user_id = #{userId}
</select>
<insert id="insertDeviceUser" parameterType="com.ruoyi.iot.domain.DeviceUser" keyProperty="deviceId">
insert into iot_device_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="userId != null">user_id,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="userName != null and userName != ''">user_name,</if>
@@ -55,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceId != null">#{deviceId},</if>
<if test="userId != null">#{userId},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="userName != null and userName != ''">#{userName},</if>
@@ -71,6 +78,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="insertDeviceUserList" parameterType="java.util.ArrayList">
insert into iot_device_user
(device_id, user_id, device_name, user_name, is_owner,tenant_id,tenant_name,phonenumber, create_time) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.deviceId},#{item.userId},#{item.deviceName}, #{item.userName}, #{item.isOwner}, #{item.tenantId},#{item.tenantName},#{item.phonenumber}, #{item.createTime})
</foreach>
</insert>
<update id="updateDeviceUser" parameterType="com.ruoyi.iot.domain.DeviceUser">
update iot_device_user
<trim prefix="SET" suffixOverrides=",">
@@ -88,7 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where device_id = #{deviceId}
where device_id = #{deviceId} and user_id = #{userId}
</update>
<delete id="deleteDeviceUserByDeviceId" parameterType="Long">
@@ -101,4 +116,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{deviceId}
</foreach>
</delete>
<delete id="deleteDeviceUser">
delete from iot_device_user where device_id = #{deviceId} and is_owner !=1 and user_id = #{userId}
</delete>
</mapper>