mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-16 13:10:39 +08:00
分享设备列表接口以及sql修改
This commit is contained in:
@@ -45,7 +45,7 @@ public class DeviceController extends BaseController
|
||||
{
|
||||
startPage();
|
||||
List<Device> list = new ArrayList<>();
|
||||
if(device.getUserName()==null || device.getUserName()=="" )
|
||||
if(device.getUserId() == null)
|
||||
{
|
||||
list = deviceService.selectDeviceList(device);
|
||||
}else {
|
||||
@@ -65,7 +65,7 @@ public class DeviceController extends BaseController
|
||||
{
|
||||
startPage();
|
||||
List<DeviceShortOutput> list = new ArrayList<>();
|
||||
if(device.getUserName()==null || device.getUserName()=="" )
|
||||
if(device.getUserId() == null)
|
||||
{
|
||||
list = deviceService.selectDeviceShortList(device);
|
||||
}else {
|
||||
|
@@ -167,10 +167,7 @@ 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}
|
||||
or device_id in (select device_id from iot_device_user where iot_device_user.user_name = #{userName})
|
||||
</if>
|
||||
<if test="userId != null "> and user_id = #{userId}</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>
|
||||
@@ -180,24 +177,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceShortListAccurate" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceShortResult">
|
||||
<include refid="selectDeviceShortVo"/>
|
||||
select device.device_id, device.device_name, device.product_id, device.product_name,
|
||||
device.user_id, device.user_name, device.tenant_id, device.tenant_name, device.serial_number,
|
||||
device.firmware_version, device.status,device.rssi,device.is_shadow ,device.is_custom_location,
|
||||
device.things_model_value, device.active_time,img_url
|
||||
|
||||
from iot_device_user device_user
|
||||
inner join iot_device device on device_user.device_id = device.device_id
|
||||
<where>
|
||||
<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>
|
||||
<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>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
|
||||
<if test="userId != null and userId != ''"> and device_user.user_id = #{userId} </if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
order by device.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult">
|
||||
|
@@ -18,6 +18,9 @@ const user = {
|
||||
SET_NAME: (state, name) => {
|
||||
state.name = name
|
||||
},
|
||||
SET_USERID: (state, userId) => {
|
||||
state.userId = userId
|
||||
},
|
||||
SET_AVATAR: (state, avatar) => {
|
||||
state.avatar = avatar
|
||||
},
|
||||
@@ -94,6 +97,7 @@ const user = {
|
||||
}
|
||||
commit('SET_NAME', user.userName)
|
||||
commit('SET_AVATAR', avatar)
|
||||
commit('SET_USERID', user.userId)
|
||||
resolve(res)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
|
@@ -112,6 +112,7 @@ export default {
|
||||
pageSize: 10,
|
||||
deviceName: null,
|
||||
userName: null,
|
||||
userId: null,
|
||||
tenantName: null,
|
||||
isOwner: null,
|
||||
},
|
||||
@@ -238,7 +239,7 @@ export default {
|
||||
// 获取设备列表
|
||||
// 判断是否是admin角色
|
||||
if (this.$store.state.user.roles.indexOf("admin") === -1) {
|
||||
this.queryParams.userName = this.$store.state.user.name
|
||||
this.queryParams.userId = this.$store.state.user.userId
|
||||
}
|
||||
listDeviceShort(this.queryParams).then(response => {
|
||||
let deviceList = response.rows;
|
||||
|
@@ -452,7 +452,7 @@ export default {
|
||||
}
|
||||
// 判断是否是admin角色
|
||||
if (this.$store.state.user.roles.indexOf("admin") === -1) {
|
||||
this.queryParams.userName = this.$store.state.user.name
|
||||
this.queryParams.userId = this.$store.state.user.userId
|
||||
}
|
||||
listDeviceShort(this.queryParams).then(response => {
|
||||
this.deviceList = response.rows;
|
||||
|
Reference in New Issue
Block a user