|
@@ -9,10 +9,7 @@ import com.middle.platform.common.exception.BusinessException;
|
|
|
import com.middle.platform.data.api.constant.TopicType;
|
|
import com.middle.platform.data.api.constant.TopicType;
|
|
|
import com.middle.platform.data.api.feign.DynamicTopicApi;
|
|
import com.middle.platform.data.api.feign.DynamicTopicApi;
|
|
|
import com.middle.platform.data.api.pojo.TopicDto;
|
|
import com.middle.platform.data.api.pojo.TopicDto;
|
|
|
-import com.middle.platform.manage.biz.constant.UrlCategory;
|
|
|
|
|
-import com.middle.platform.manage.biz.constant.UrlInit;
|
|
|
|
|
-import com.middle.platform.manage.biz.constant.UrlProtocol;
|
|
|
|
|
-import com.middle.platform.manage.biz.constant.UrlType;
|
|
|
|
|
|
|
+import com.middle.platform.manage.biz.constant.*;
|
|
|
import com.middle.platform.manage.biz.domain.req.IotUrlPage;
|
|
import com.middle.platform.manage.biz.domain.req.IotUrlPage;
|
|
|
import com.middle.platform.manage.biz.domain.req.IotUrlPara;
|
|
import com.middle.platform.manage.biz.domain.req.IotUrlPara;
|
|
|
import com.middle.platform.manage.biz.domain.vo.IotUrlVo;
|
|
import com.middle.platform.manage.biz.domain.vo.IotUrlVo;
|
|
@@ -109,6 +106,7 @@ public class IotUrlService {
|
|
|
public Object saveUrl(IotUrlPara iotUrlPara) {
|
|
public Object saveUrl(IotUrlPara iotUrlPara) {
|
|
|
//topi规则校验
|
|
//topi规则校验
|
|
|
checkTopic(iotUrlPara);
|
|
checkTopic(iotUrlPara);
|
|
|
|
|
+ checkType(iotUrlPara.getType());
|
|
|
IotUrl iotUrl = new IotUrl();
|
|
IotUrl iotUrl = new IotUrl();
|
|
|
iotUrl.setProductId(iotUrlPara.getProductId());
|
|
iotUrl.setProductId(iotUrlPara.getProductId());
|
|
|
iotUrl.setCategory(iotUrlPara.getCategory());
|
|
iotUrl.setCategory(iotUrlPara.getCategory());
|
|
@@ -119,13 +117,22 @@ public class IotUrlService {
|
|
|
iotUrl.setRemark(iotUrlPara.getRemark());
|
|
iotUrl.setRemark(iotUrlPara.getRemark());
|
|
|
iotUrlMapper.insert(iotUrl);
|
|
iotUrlMapper.insert(iotUrl);
|
|
|
//新增订阅的topic
|
|
//新增订阅的topic
|
|
|
- if (Objects.equals(iotUrlPara.getType(), UrlType.MQTT)
|
|
|
|
|
|
|
+ if (Objects.equals(iotUrlPara.getType(), UrlTypeEnum.MQTT.getVal())
|
|
|
&& (Objects.equals(iotUrlPara.getPermission(), TopicType.PUB) || Objects.equals(iotUrlPara.getPermission(), TopicType.BOTH))) {
|
|
&& (Objects.equals(iotUrlPara.getPermission(), TopicType.PUB) || Objects.equals(iotUrlPara.getPermission(), TopicType.BOTH))) {
|
|
|
subUrl(iotUrl.getUrl(), iotUrl.getFunc() + String.valueOf(iotUrl.getPermission()));
|
|
subUrl(iotUrl.getUrl(), iotUrl.getFunc() + String.valueOf(iotUrl.getPermission()));
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void checkType(Integer type) {
|
|
|
|
|
+ for (UrlTypeEnum value : UrlTypeEnum.values()) {
|
|
|
|
|
+ if (Objects.equals(value.getVal(), type)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new BusinessException("地址类型异常");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 修改topic
|
|
* 修改topic
|
|
@@ -154,7 +161,7 @@ public class IotUrlService {
|
|
|
iotUrl.setRemark(iotUrlPara.getRemark());
|
|
iotUrl.setRemark(iotUrlPara.getRemark());
|
|
|
iotUrlMapper.updateById(iotUrl);
|
|
iotUrlMapper.updateById(iotUrl);
|
|
|
//取消订阅原topic 订阅topic
|
|
//取消订阅原topic 订阅topic
|
|
|
- if (Objects.equals(iotUrlPara.getType(), UrlType.MQTT) && (Objects.equals(iotUrlPara.getPermission(), TopicType.PUB) || Objects.equals(iotUrlPara.getPermission(), TopicType.BOTH))) {
|
|
|
|
|
|
|
+ if (Objects.equals(iotUrlPara.getType(), UrlTypeEnum.MQTT.getVal()) && (Objects.equals(iotUrlPara.getPermission(), TopicType.PUB) || Objects.equals(iotUrlPara.getPermission(), TopicType.BOTH))) {
|
|
|
removeUrl(iotUrlCheck.getUrl());
|
|
removeUrl(iotUrlCheck.getUrl());
|
|
|
subUrl(iotUrl.getUrl(), iotUrl.getFunc() + String.valueOf(iotUrl.getPermission()));
|
|
subUrl(iotUrl.getUrl(), iotUrl.getFunc() + String.valueOf(iotUrl.getPermission()));
|
|
|
}
|
|
}
|
|
@@ -177,7 +184,7 @@ public class IotUrlService {
|
|
|
iotUrl.setDelFlag(Global.DEL);
|
|
iotUrl.setDelFlag(Global.DEL);
|
|
|
iotUrlMapper.update(iotUrl, new LambdaQueryWrapper<IotUrl>().eq(IotUrl::getId, id).eq(IotUrl::getDelFlag, Global.UN_DEL));
|
|
iotUrlMapper.update(iotUrl, new LambdaQueryWrapper<IotUrl>().eq(IotUrl::getId, id).eq(IotUrl::getDelFlag, Global.UN_DEL));
|
|
|
//取消订阅
|
|
//取消订阅
|
|
|
- if (Objects.equals(iotUrlCheck.getType(), UrlType.MQTT) && (Objects.equals(iotUrlCheck.getPermission(), TopicType.PUB) || Objects.equals(iotUrlCheck.getPermission(), TopicType.BOTH))) {
|
|
|
|
|
|
|
+ if (Objects.equals(iotUrlCheck.getType(), UrlTypeEnum.MQTT.getVal()) && (Objects.equals(iotUrlCheck.getPermission(), TopicType.PUB) || Objects.equals(iotUrlCheck.getPermission(), TopicType.BOTH))) {
|
|
|
removeUrl(iotUrlCheck.getUrl());
|
|
removeUrl(iotUrlCheck.getUrl());
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
@@ -197,11 +204,11 @@ public class IotUrlService {
|
|
|
}
|
|
}
|
|
|
PageInfo<IotUrlVo> pageInfo = new PageInfo<>(iotUrls);
|
|
PageInfo<IotUrlVo> pageInfo = new PageInfo<>(iotUrls);
|
|
|
iotUrls.forEach(a -> {
|
|
iotUrls.forEach(a -> {
|
|
|
- Optional.ofNullable(dictApi.query(DictType.URL_TYPE, String.valueOf(a.getType()))).ifPresent(cache -> a.setTypeLabel(cache.getLabel()));
|
|
|
|
|
- Optional.ofNullable(dictApi.query(DictType.CATEGORY_TYPE, String.valueOf(a.getCategory()))).ifPresent(cache -> a.setCategoryLabel(cache.getLabel()));
|
|
|
|
|
- Optional.ofNullable(dictApi.query(DictType.FUNC_TYPE, String.valueOf(a.getFunc()))).ifPresent(cache -> a.setFuncLabel(cache.getLabel()));
|
|
|
|
|
- Optional.ofNullable(dictApi.query(DictType.PERMISSION_TYPE, String.valueOf(a.getPermission()))).ifPresent(cache -> a.setPermissionLabel(cache.getLabel()));
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.URL_TYPE, String.valueOf(a.getType()))).ifPresent(cache -> a.setTypeLabel(cache.getLabel()));
|
|
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.CATEGORY_TYPE, String.valueOf(a.getCategory()))).ifPresent(cache -> a.setCategoryLabel(cache.getLabel()));
|
|
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.FUNC_TYPE, String.valueOf(a.getFunc()))).ifPresent(cache -> a.setFuncLabel(cache.getLabel()));
|
|
|
|
|
+ Optional.ofNullable(dictApi.query(DictType.PERMISSION_TYPE, String.valueOf(a.getPermission()))).ifPresent(cache -> a.setPermissionLabel(cache.getLabel()));
|
|
|
|
|
+ });
|
|
|
return new PageRes<>(pageInfo, iotUrls);
|
|
return new PageRes<>(pageInfo, iotUrls);
|
|
|
}
|
|
}
|
|
|
|
|
|