|
|
@@ -121,8 +121,7 @@ public class DevicePermissService extends SuperService {
|
|
|
for (OrganizationUser organizationUser : orgUsers) {
|
|
|
String userId = organizationUser.getUserId();
|
|
|
// 判断是否是编辑
|
|
|
- DevicePermiss permiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(
|
|
|
- deviceInfo.getDeviceId(), userId, projectOid);
|
|
|
+ DevicePermiss permiss = devicePermissDao.findTopByUserIdAndDeviceIdAndProjectOid(deviceInfo.getDeviceId(), userId, projectOid);
|
|
|
if (ObjectUtils.isEmpty(permiss)) {
|
|
|
permiss = new DevicePermiss();
|
|
|
initEntity(permiss);
|
|
|
@@ -230,9 +229,19 @@ public class DevicePermissService extends SuperService {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
|
devicePermissDao.delete(entity);
|
|
|
+ // 发送通知
|
|
|
+ DevicePermissChangeEvent event = new DevicePermissChangeEvent(this, List.of(entity.getDeviceId()), DataOperationType.Update);
|
|
|
+ applicationContext.publishEvent(event);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 改变状态
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @param dataState
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ResultContent changeState(String id, DataState dataState) {
|
|
|
DevicePermiss entity = devicePermissDao.findTopById(id);
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
|
@@ -242,15 +251,27 @@ public class DevicePermissService extends SuperService {
|
|
|
devicePermissDao.save(entity);
|
|
|
|
|
|
// 通知设备权限发生了变化
|
|
|
- DevicePermissChangeEvent event = new DevicePermissChangeEvent(this,
|
|
|
- List.of(entity.getDeviceId()), DataOperationType.Update);
|
|
|
+ DevicePermissChangeEvent event = new DevicePermissChangeEvent(this, List.of(entity.getDeviceId()), DataOperationType.Update);
|
|
|
applicationContext.publishEvent(event);
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除多个
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public ResultContent deleteByIds(IDsParam param) {
|
|
|
if (ObjectUtils.isNotEmpty(param.getIds())) {
|
|
|
+ List<DevicePermiss> list = devicePermissDao.findByIdIn(param.getIds());
|
|
|
devicePermissDao.deleteAllById(param.getIds());
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
+ List<String> deviceIds = list.stream().map(it -> it.getDeviceId()).collect(Collectors.toUnmodifiableList());
|
|
|
+ // 通知权限发生变化
|
|
|
+ DevicePermissChangeEvent event = new DevicePermissChangeEvent(this, deviceIds, DataOperationType.Update);
|
|
|
+ applicationContext.publishEvent(event);
|
|
|
+ }
|
|
|
}
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|