| | |
| | | import com.fgkj.dto.ServiceModelOnce; |
| | | import com.fgkj.mapper.impl.Database_backupMapper; |
| | | 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 org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private Database_backupMapper mapper;; |
| | | @Autowired |
| | | DataSourceTransactionManager dataSourceTransactionManager; |
| | | @Autowired |
| | | TransactionDefinition transactionDefinition; |
| | | |
| | | //根据数据库名和表名修改备份数据库的使能(多笔记录) |
| | | public ServiceModel updatePro(List<Database_backup> obj) { |
| | | boolean bl=mapper.updatePro(obj)>0; |
| | | if(bl){ |
| | | ServiceModel model = new ServiceModel(); |
| | | TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); |
| | | boolean bl = true; |
| | | try { |
| | | bl = mapper.updatePro(obj) > 0; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setCode(0); |
| | | model.setMsg("修改失败!"); |
| | | return model; |
| | | } |
| | | if (bl) { |
| | | dataSourceTransactionManager.commit(transactionStatus); |
| | | model.setCode(1); |
| | | model.setMsg("修改成功!"); |
| | | }else{ |
| | | } else { |
| | | dataSourceTransactionManager.rollback(transactionStatus); |
| | | model.setCode(0); |
| | | model.setMsg("修改失败!"); |
| | | } |
| | |
| | | } |
| | | //根据数据库名和表名修改备份数据库的使能(一键修改) |
| | | public ServiceModel updateProAll() { |
| | | boolean bl=mapper.updateProAll()>0; |
| | | if(bl){ |
| | | ServiceModel model = new ServiceModel(); |
| | | boolean bl = mapper.updateProAll() > 0; |
| | | if (bl) { |
| | | model.setCode(1); |
| | | model.setMsg("修改成功!"); |
| | | }else{ |
| | | } else { |
| | | model.setCode(0); |
| | | model.setMsg("修改失败!"); |
| | | } |
| | |
| | | |
| | | //查询所有数据库备份信息 |
| | | public ServiceModel searchAll() { |
| | | ServiceModel model = new ServiceModel(); |
| | | List list=mapper.searchAll(); |
| | | if(list!=null&&list.size()>0){ |
| | | model.setData(list); |
| | |
| | | |
| | | //查询数据库备份表中所有的数据库 |
| | | public ServiceModel searchAllDatabase() { |
| | | ServiceModel model = new ServiceModel(); |
| | | List list=mapper.searchAllDatabase(); |
| | | if(list!=null&&list.size()>0){ |
| | | model.setData(list); |
| | |
| | | |
| | | //根据数据库名查询所有的表 |
| | | public ServiceModel searchAllTable(Database_backup obj) { |
| | | ServiceModel model = new ServiceModel(); |
| | | List list=mapper.searchAllTable(obj); |
| | | if(list!=null&&list.size()>0){ |
| | | model.setData(list); |
| | |
| | | //查询个数 |
| | | public ServiceModelOnce searchNum() { |
| | | ServiceModelOnce model = new ServiceModelOnce(); |
| | | Database_backup baseup=new Database_backup(); |
| | | Database_backup baseup = new Database_backup(); |
| | | //总数 |
| | | baseup.setNum(0); |
| | | int sum=mapper.searchNum(baseup); |
| | | int sum = mapper.searchNum(baseup); |
| | | //处于备份的数目 |
| | | baseup.setNum(1); |
| | | int baseup_num=mapper.searchNum(baseup); |
| | | //TODO perry |
| | | model.setSum(sum); |
| | | model.setNewsum(baseup_num); |
| | | model.setCode(1); |
| | | int baseup_num = mapper.searchNum(baseup); |
| | | model.setSum(sum); |
| | | model.setNewsum(baseup_num); |
| | | model.setCode(1); |
| | | return model; |
| | | } |
| | | } |