mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-10 10:32:54 +08:00
完善设备授权
This commit is contained in:
@@ -47,6 +47,18 @@ public class DeviceController extends BaseController
|
||||
return getDataTable(deviceService.selectDeviceList(device));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配授权码设备列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('iot:device:list')")
|
||||
@GetMapping("/unAuthlist")
|
||||
@ApiOperation("设备分页列表")
|
||||
public TableDataInfo unAuthlist(Device device)
|
||||
{
|
||||
startPage();
|
||||
return getDataTable(deviceService.selectUnAuthDeviceList(device));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分组可添加设备
|
||||
*/
|
||||
|
@@ -89,6 +89,14 @@ public interface DeviceMapper
|
||||
*/
|
||||
public List<Device> selectDeviceList(Device device);
|
||||
|
||||
/**
|
||||
* 查询未分配授权码设备列表
|
||||
*
|
||||
* @param device 设备
|
||||
* @return 设备集合
|
||||
*/
|
||||
public List<Device> selectUnAuthDeviceList(Device device);
|
||||
|
||||
/**
|
||||
* 查询分组可添加设备分页列表
|
||||
*
|
||||
|
@@ -79,6 +79,14 @@ public interface IDeviceService
|
||||
*/
|
||||
public List<Device> selectDeviceList(Device device);
|
||||
|
||||
/**
|
||||
* 查询未分配授权码设备列表
|
||||
*
|
||||
* @param device 设备
|
||||
* @return 设备集合
|
||||
*/
|
||||
public List<Device> selectUnAuthDeviceList(Device device);
|
||||
|
||||
/**
|
||||
* 查询分组可添加设备分页列表
|
||||
*
|
||||
|
@@ -251,6 +251,28 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
return deviceMapper.selectDeviceList(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询未分配授权码设备列表
|
||||
*
|
||||
* @param device 设备
|
||||
* @return 设备
|
||||
*/
|
||||
@Override
|
||||
public List<Device> selectUnAuthDeviceList(Device device) {
|
||||
SysUser user = getLoginUser().getUser();
|
||||
List<SysRole> roles=user.getRoles();
|
||||
for(int i=0;i<roles.size();i++){
|
||||
if(roles.get(i).getRoleKey().equals("tenant")){
|
||||
// 租户查看产品下所有设备
|
||||
device.setTenantId(user.getUserId());
|
||||
}else if (roles.get(i).getRoleKey().equals("general")){
|
||||
// 用户查看自己设备
|
||||
device.setUserId(user.getUserId());
|
||||
}
|
||||
}
|
||||
return deviceMapper.selectUnAuthDeviceList(device);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分组可添加设备分页列表(分组用户与设备用户匹配)
|
||||
*
|
||||
|
@@ -77,8 +77,8 @@ public class ProductAuthorizeServiceImpl implements IProductAuthorizeService {
|
||||
if(productAuthorize.getDeviceId()!=null && productAuthorize.getDeviceId()!=0){
|
||||
// 1=未使用,2=使用中
|
||||
productAuthorize.setStatus(2);
|
||||
productAuthorize.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
productAuthorize.setUpdateTime(DateUtils.getNowDate());
|
||||
return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
|
||||
}
|
||||
|
||||
|
@@ -126,6 +126,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectUnAuthDeviceList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
|
||||
select d.device_id, d.device_name, d.product_id, d.product_name, d.user_id, d.user_name, d.tenant_id, d.tenant_name,
|
||||
d.serial_number, d.firmware_version, d.status,d.is_shadow ,d.location_way,d.active_time, d.img_url,a.device_id as auth_device_id
|
||||
from iot_device d
|
||||
left join iot_product_authorize a on a.device_id=d.device_id
|
||||
<where>
|
||||
<if test="1==1"> and ISNULL(a.device_id)</if>
|
||||
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
|
||||
<if test="productId != null "> and d.product_id = #{productId}</if>
|
||||
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="userId != null "> and d.user_id = #{userId}</if>
|
||||
<if test="userName != null and userName != ''"> and d.user_name like concat('%', #{userName}, '%')</if>
|
||||
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
|
||||
<if test="tenantName != null and tenantName != ''"> and d.tenant_name like concat('%', #{tenantName}, '%')</if>
|
||||
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
|
||||
<if test="status != null "> and d.status = #{status}</if>
|
||||
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
|
||||
</where>
|
||||
order by d.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectDeviceListByGroup" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
|
||||
select d.device_id, d.device_name, d.product_name, d.user_name, d.serial_number, d.firmware_version, d.status,d.rssi,d.is_shadow ,
|
||||
d.location_way, d.active_time,d.network_address,d.longitude,latitude
|
||||
@@ -152,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="userId != null "> and u.user_id = #{userId}</if>
|
||||
<if test="tenantId != null "> and d.tenant_id = #{tenantId}</if>
|
||||
<if test="productId != null "> and d.product_id = #{productId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
Reference in New Issue
Block a user