From cf2abed0458be6b97c36d650804fcbc655b50af4 Mon Sep 17 00:00:00 2001 From: whycrzh <ruanzhigang@whycst.com> Date: 星期五, 08 一月 2021 17:19:46 +0800 Subject: [PATCH] update interface --- src/main/java/com/fgkj/services/Batt_param_lowService.java | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/fgkj/services/Batt_param_lowService.java b/src/main/java/com/fgkj/services/Batt_param_lowService.java index eb7786d..3145333 100644 --- a/src/main/java/com/fgkj/services/Batt_param_lowService.java +++ b/src/main/java/com/fgkj/services/Batt_param_lowService.java @@ -4,7 +4,10 @@ import com.fgkj.dto.ServiceModel; import com.fgkj.mapper.impl.Batt_param_lowMapper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; import java.util.List; @@ -16,6 +19,10 @@ @Resource private Batt_param_lowMapper mapper;; + @Autowired + DataSourceTransactionManager dataSourceTransactionManager; + @Autowired + TransactionDefinition transactionDefinition; public ServiceModel add(Object obj) { Boolean bl=mapper.add(obj); @@ -29,16 +36,24 @@ return model; } - public ServiceModel update(Object obj) { - Boolean bl=mapper.update(obj); - if(bl){ + public ServiceModel update(List<Batt_param_low> list) { + ServiceModel model = new ServiceModel(); + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); + Boolean bl = true; + for (int i = 0; i < list.size(); i++) { + if (!(mapper.update(list.get(i)) > 0)) { + bl = false; + } + } + if (bl) { + dataSourceTransactionManager.commit(transactionStatus); model.setCode(1); model.setMsg("淇敼鎴愬姛!"); - } - else{ + } else { + dataSourceTransactionManager.rollback(transactionStatus); model.setMsg("淇敼澶辫触!"); } - return model; + return model; } @@ -84,6 +99,7 @@ } public ServiceModel searchAll(){ + ServiceModel model = new ServiceModel(); List<Batt_param_low> list=mapper.searchAll(); //System.out.println(list); if(list!=null && list.size()>0){ -- Gitblit v1.9.1