Просмотр исходного кода

优化 预警记录批量删除限制最大一次删除100条

zhaiyifei 9 месяцев назад
Родитель
Сommit
f09c7f0129

+ 2 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/controller/IotWarnlogController.java

@@ -17,6 +17,7 @@ import com.yunfeiyun.agmp.iotm.web.domain.resvo.IotWarnlogResVo;
 import com.yunfeiyun.agmp.iotm.web.service.IIotWarnlogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -118,6 +119,7 @@ public class IotWarnlogController extends BaseController{
      */
     @PreAuthorize("@ss.hasPermi('iot:warn:record:remove')")
     @Log(title = "告警记录", businessType = BusinessType.DELETE)
+    @Transactional(rollbackFor = Exception.class)
 	@DeleteMapping("/delete/{wrBids}")
     public AjaxResult remove(@PathVariable String[] wrBids){
         return toAjax(iotWarnlogService.deleteIotWarnlogByWlBids(wrBids,SecurityUtils.getTid()));

+ 6 - 0
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotWarnlogServiceImpl.java

@@ -184,6 +184,12 @@ public class IotWarnlogServiceImpl implements IIotWarnlogService {
      */
     @Override
     public int deleteIotWarnlogByWlBids(String[] wlBids, String tid){
+        if(null == wlBids || 0 == wlBids.length){
+            throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"参数不能为空");
+        }
+        if(wlBids.length > 100){
+            throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(),"一次最多删除100条数据");
+        }
         return iotWarnlogMapper.deleteIotWarnlogByWlBids(wlBids, tid);
     }