Commit 110561ddf991de39c3a621a283d916d7a9a2104d

Authored by xp.Huang
1 parent 60963931

fix: 删除产品时,验证是否有设备在使用

... ... @@ -181,11 +181,12 @@ public class TkDeviceProfileController extends BaseController {
181 181 @DeleteMapping
182 182 @ApiOperation("删除")
183 183 @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{'api:yt:deviceProfile:delete'})")
184   - public void deleteDevices(@Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO)
  184 + public void deleteDeviceProfiles(@Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO)
185 185 throws ThingsboardException {
186 186 String tenantId = getCurrentUser().getCurrentTenantId();
187 187 ytDeviceProfileService.checkDeviceProfiles(tenantId, deleteDTO.getIds());
188 188
  189 +
189 190 for (String id : deleteDTO.getIds()) {
190 191 deleteTbDeviceProfile(id);
191 192 }
... ...
... ... @@ -146,9 +146,9 @@ public class TkDeviceProfileServiceImpl
146 146 // check if ids bind to device
147 147 int count =
148 148 deviceMapper.selectCount(
149   - new QueryWrapper<TkDeviceEntity>().lambda().in(TkDeviceEntity::getProfileId, ids));
  149 + new QueryWrapper<TkDeviceEntity>().lambda().in(TkDeviceEntity::getDeviceProfileId, ids));
150 150 if (count > 0) {
151   - throw new TkDataValidationException("有设备使用待删除配置,请先删除设备或者修改设备配置");
  151 + throw new TkDataValidationException(ErrorMessage.DEVICE_PROFILE_USED_BY_DEVICE.getMessage());
152 152 }
153 153 }
154 154
... ...