完善设备授权

This commit is contained in:
kerwincui
2022-06-08 23:57:40 +08:00
parent f2b80eaf2f
commit 9dd368c883
16 changed files with 278 additions and 118 deletions

View File

@@ -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));
}
/**
* 查询分组可添加设备
*/

View File

@@ -89,6 +89,14 @@ public interface DeviceMapper
*/
public List<Device> selectDeviceList(Device device);
/**
* 查询未分配授权码设备列表
*
* @param device 设备
* @return 设备集合
*/
public List<Device> selectUnAuthDeviceList(Device device);
/**
* 查询分组可添加设备分页列表
*

View File

@@ -79,6 +79,14 @@ public interface IDeviceService
*/
public List<Device> selectDeviceList(Device device);
/**
* 查询未分配授权码设备列表
*
* @param device 设备
* @return 设备集合
*/
public List<Device> selectUnAuthDeviceList(Device device);
/**
* 查询分组可添加设备分页列表
*

View File

@@ -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);
}
/**
* 查询分组可添加设备分页列表(分组用户与设备用户匹配)
*

View File

@@ -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);
}