diff --git a/src/main/java/com/xydl/cac/controller/WarningController.java b/src/main/java/com/xydl/cac/controller/WarningController.java index be9086c..a823667 100644 --- a/src/main/java/com/xydl/cac/controller/WarningController.java +++ b/src/main/java/com/xydl/cac/controller/WarningController.java @@ -64,4 +64,14 @@ public class WarningController extends BasicController { return Response.success("OK"); } + + @PostMapping("oneKeyUpdateState") + @ApiOperation("一键修改处理状态") + public Response oneKeyUpdateState() throws Exception { + ConditionModel condition = new ConditionModel(); + condition.setState("1"); + List warnings = service.listAll(condition); + service.oneKeyUpdateState(warnings); + return Response.success("OK"); + } } diff --git a/src/main/java/com/xydl/cac/service/WarningService.java b/src/main/java/com/xydl/cac/service/WarningService.java index 8e9dcb5..c643197 100644 --- a/src/main/java/com/xydl/cac/service/WarningService.java +++ b/src/main/java/com/xydl/cac/service/WarningService.java @@ -14,4 +14,6 @@ public interface WarningService { List listAll(ConditionModel condition) throws Exception; void updateState(Warning warning) throws Exception; + + void oneKeyUpdateState(List warnings); } diff --git a/src/main/java/com/xydl/cac/service/impl/WarningServiceImpl.java b/src/main/java/com/xydl/cac/service/impl/WarningServiceImpl.java index df14452..32a2199 100644 --- a/src/main/java/com/xydl/cac/service/impl/WarningServiceImpl.java +++ b/src/main/java/com/xydl/cac/service/impl/WarningServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.persistence.criteria.Predicate; +import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -101,4 +102,16 @@ public class WarningServiceImpl implements WarningService { war.setState(warning.getState()); repository.save(war); } + + @Override + public void oneKeyUpdateState(List warnings) { + for (Warning warning : warnings) { + warning.setState("0"); + } + if (null != warnings && warnings.size() > 0) { + repository.saveAll(warnings); + } + } + + }