Commit 04ea404eedf8eddff01c81690763eab072a43cf3

Authored by xp.Huang
1 parent 2e6ddb3e

fix: [DEFECT-1550] 新增、编辑存在的产品名称时,没有把异常正确返回给前端

@@ -65,14 +65,17 @@ public class TkDeviceProfileController extends BaseController { @@ -65,14 +65,17 @@ public class TkDeviceProfileController extends BaseController {
65 deviceProfileDTO.setTbProfileId(saveDeviceProfile.getId().toString()); 65 deviceProfileDTO.setTbProfileId(saveDeviceProfile.getId().toString());
66 tkDeviceProfileService.insertOrUpdate(deviceProfileDTO); 66 tkDeviceProfileService.insertOrUpdate(deviceProfileDTO);
67 }catch (Exception e){ 67 }catch (Exception e){
68 - if (created) { 68 + if (created && null !=saveDeviceProfile) {
69 logEntityAction(emptyId(EntityType.DEVICE_PROFILE), saveDeviceProfile, 69 logEntityAction(emptyId(EntityType.DEVICE_PROFILE), saveDeviceProfile,
70 null, created ? ActionType.ADDED : ActionType.UPDATED, e); 70 null, created ? ActionType.ADDED : ActionType.UPDATED, e);
71 deviceProfileService.deleteDeviceProfile(getTenantId(), saveDeviceProfile.getId()); 71 deviceProfileService.deleteDeviceProfile(getTenantId(), saveDeviceProfile.getId());
72 tbClusterService.onDeviceProfileDelete(saveDeviceProfile, null); 72 tbClusterService.onDeviceProfileDelete(saveDeviceProfile, null);
73 tbClusterService.broadcastEntityStateChangeEvent(saveDeviceProfile.getTenantId(), saveDeviceProfile.getId(), ComponentLifecycleEvent.DELETED); 73 tbClusterService.broadcastEntityStateChangeEvent(saveDeviceProfile.getTenantId(), saveDeviceProfile.getId(), ComponentLifecycleEvent.DELETED);
74 - throw handleException(e);  
75 } 74 }
  75 + if(e instanceof TkDataValidationException){
  76 + throw new TkDataValidationException(e.getMessage());
  77 + }
  78 + throw handleException(e);
76 } 79 }
77 80
78 81