Commit 0263eb6b18ae088e7e4a044dd732aef532169ebe

Authored by lifeontrip
2 parents 526d437c 4c71b7d9

Merge branch 'master' into 后端权限控制

... ... @@ -103,21 +103,21 @@ public class YtDataComponentController extends BaseController {
103 103 throws ThingsboardException {
104 104 String tenantId = getCurrentUser().getCurrentTenantId();
105 105 deleteDTO.setTenantId(tenantId);
  106 +
  107 + DataBoardDTO dataBoardDTO = ytDataBoardService.findDataBoardInfoById(dataBoardId, tenantId);
  108 + if (null == dataBoardDTO) {
  109 + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage());
  110 + }
106 111 int deleteNum = ytDataComponentService.deleteDataComponent(deleteDTO);
107 112
108 113 int zero = FastIotConstants.MagicNumber.ZERO;
109 114 boolean result = deleteNum > zero;
110 115 if (result) {
111   - DataBoardDTO dataBoardDTO = ytDataBoardService.findDataBoardInfoById(dataBoardId, tenantId);
112   - if (null != dataBoardDTO) {
113   - int count =
114   - dataBoardDTO.getComponentNum() != null
115   - ? dataBoardDTO.getComponentNum() - deleteNum < zero
116   - ? zero
117   - : dataBoardDTO.getComponentNum() - deleteNum
118   - : zero;
119   - ytDataBoardService.updateDataBoardComponentNum(dataBoardId, tenantId, count);
120   - }
  116 + int count =
  117 + dataBoardDTO.getComponentNum() != null
  118 + ? Math.max(dataBoardDTO.getComponentNum() - deleteNum, zero)
  119 + : zero;
  120 + ytDataBoardService.updateDataBoardComponentNum(dataBoardId, tenantId, count);
121 121 }
122 122 return ResponseResult.success(result);
123 123 }
... ...