|
@@ -105,12 +105,17 @@ public class IotServiceImpl extends SuperService {
|
|
|
* @param id
|
|
* @param id
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
|
|
+ @Transactional
|
|
|
public ResultContent deleteTemplate(String id) {
|
|
public ResultContent deleteTemplate(String id) {
|
|
|
IotTemplate template = iotTemplateDao.findTopById(id);
|
|
IotTemplate template = iotTemplateDao.findTopById(id);
|
|
|
if (ObjectUtils.isEmpty(template)) {
|
|
if (ObjectUtils.isEmpty(template)) {
|
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
|
|
|
}
|
|
}
|
|
|
iotTemplateDao.delete(template);
|
|
iotTemplateDao.delete(template);
|
|
|
|
|
+
|
|
|
|
|
+ // 删除对应的 物模型 数据
|
|
|
|
|
+ iotMainDao.deleteByIotTemplate(template);
|
|
|
|
|
+
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -338,6 +343,8 @@ public class IotServiceImpl extends SuperService {
|
|
|
// 判断名称是否重复
|
|
// 判断名称是否重复
|
|
|
IotMain nameTemp = iotMainDao.findTopByNameAndIotTemplate(param.getName(), iotTemplate);
|
|
IotMain nameTemp = iotMainDao.findTopByNameAndIotTemplate(param.getName(), iotTemplate);
|
|
|
IotMain topicTemp = iotMainDao.findTopByIotTopicAndIotTemplate(param.getIotTopic(), iotTemplate);
|
|
IotMain topicTemp = iotMainDao.findTopByIotTopicAndIotTemplate(param.getIotTopic(), iotTemplate);
|
|
|
|
|
+ IotMain identifierTemp = iotMainDao.findTopByIdentifierAndIotTemplate(param.getIdentifier(), iotTemplate);
|
|
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
if (StringUtils.isNotEmpty(param.getId())) {
|
|
|
entity = iotMainDao.findTopById(param.getId());
|
|
entity = iotMainDao.findTopById(param.getId());
|
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
if (ObjectUtils.isEmpty(entity)) {
|
|
@@ -349,6 +356,9 @@ public class IotServiceImpl extends SuperService {
|
|
|
if (ObjectUtils.isNotEmpty(topicTemp) && !topicTemp.getId().equals(param.getId())) {
|
|
if (ObjectUtils.isNotEmpty(topicTemp) && !topicTemp.getId().equals(param.getId())) {
|
|
|
return ResultContent.buildFail(String.format("iotTopic已存在:%s", param.getIotTopic()));
|
|
return ResultContent.buildFail(String.format("iotTopic已存在:%s", param.getIotTopic()));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(identifierTemp) && !identifierTemp.getId().equals(param.getId())) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format("identifier已存在:%s", param.getIdentifier()));
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
entity = new IotMain();
|
|
entity = new IotMain();
|
|
|
initEntity(entity);
|
|
initEntity(entity);
|
|
@@ -358,6 +368,9 @@ public class IotServiceImpl extends SuperService {
|
|
|
if (ObjectUtils.isNotEmpty(topicTemp)) {
|
|
if (ObjectUtils.isNotEmpty(topicTemp)) {
|
|
|
return ResultContent.buildFail(String.format("iotTopic已存在:%s", param.getIotTopic()));
|
|
return ResultContent.buildFail(String.format("iotTopic已存在:%s", param.getIotTopic()));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(identifierTemp)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format("identifier已存在:%s", param.getIdentifier()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
BeanUtils.copyProperties(param, entity);
|