Commit b1ccf0e917da95234093239b635d615fd3c96076

Authored by xp.Huang
1 parent 6d683506

fix: 禁用脚本去掉是否有产品使用的逻辑判断,调整到删除的时候判断

... ... @@ -98,14 +98,6 @@ public class TkDeviceScriptServiceImpl
98 98 if (!entity.getTenantId().equals(tenantId)) {
99 99 throw new TkDataValidationException(ErrorMessage.NOT_BELONG_CURRENT_TENANT.getMessage());
100 100 }
101   - if(Objects.equals(status,StatusEnum.DISABLE.getIndex())){
102   - List<DeviceProfileDTO> profileList = tkDeviceProfileService.findDeviceProfileByScriptId(tenantId,id);
103   - if(null != profileList && !profileList.isEmpty()){
104   -
105   - throw new TkDataValidationException(String.format(ErrorMessage.CURRENT_DATA_IN_USE.getMessage(),
106   - profileList.get(0).getName()));
107   - }
108   - }
109 101 entity.setStatus(status);
110 102 return baseMapper.updateById(entity) > FastIotConstants.MagicNumber.ZERO;
111 103 }
... ... @@ -133,15 +125,16 @@ public class TkDeviceScriptServiceImpl
133 125 @Override
134 126 public void checkDeviceScriptes(String tenantId, Set<String> ids) {
135 127 // check if ids bind to device
136   - List<TkDeviceProfileEntity> usedList =
137   - profileMapper.selectList(
138   - new QueryWrapper<TkDeviceProfileEntity>()
139   - .lambda()
140   - .in(TkDeviceProfileEntity::getScriptId, ids));
141   - if (usedList != null && usedList.size() > 0) {
142   - List<String> names = usedList.stream().map(TkDeviceProfileEntity::getName).collect(Collectors.toList());
143   - throw new TkDataValidationException(
144   - String.format(ErrorMessage.PROJECT_USED_SCRIPT.getMessage(), names));
  128 + if(ids == null || ids.isEmpty()){
  129 + throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  130 + }
  131 + for(String id : ids){
  132 + List<DeviceProfileDTO> profileList = tkDeviceProfileService.findDeviceProfileByScriptId(tenantId,id);
  133 + if(null != profileList && !profileList.isEmpty()){
  134 +
  135 + throw new TkDataValidationException(String.format(ErrorMessage.PROJECT_USED_SCRIPT.getMessage(),
  136 + profileList.get(0).getName()));
  137 + }
145 138 }
146 139 }
147 140
... ...