From a13f590f4b6734b0e6b98ae14286542ebbfc59ae Mon Sep 17 00:00:00 2001 From: qi_liang Date: Tue, 17 Sep 2019 20:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E7=94=A8jdk8=E6=96=B0=E7=89=B9?= =?UTF-8?q?=E6=95=88:=E9=BB=98=E8=AE=A4=E6=96=B9=E6=B3=95=20=E6=B7=98?= =?UTF-8?q?=E6=B1=B0BaseServiceImpl=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/lq/code/service/BaseService.java | 36 ++++++++++++++----- .../lq/code/service/impl/BaseServiceImpl.java | 2 ++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/lq/code/service/BaseService.java b/src/main/java/com/lq/code/service/BaseService.java index 21f1f36..863c3ac 100755 --- a/src/main/java/com/lq/code/service/BaseService.java +++ b/src/main/java/com/lq/code/service/BaseService.java @@ -1,6 +1,7 @@ package com.lq.code.service; import com.lq.code.dao.BaseDao; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -11,20 +12,39 @@ public interface BaseService { BaseDao getBaseDao(); - T findOne(Long id); + default T findOne(Long id){ + return getBaseDao().findOne(id); + } - List findAll(); + default List findAll(){ + return getBaseDao().findAll(); + } - Long save(T entity); + default Long save(T entity){ + return getBaseDao().save(entity); + } - void update(T entity); + default void update(T entity){ + getBaseDao().update(entity); + } - void delete(Long id); + default void delete(Long id){ + getBaseDao().delete(id); + } - void batchSave(List entitylist); + @Transactional + default void batchSave(List entitylist){ + getBaseDao().batchSave(entitylist); + } - void batchUpdate(List entitylist); + @Transactional + default void batchUpdate(List entitylist){ + getBaseDao().batchSave(entitylist); + } - void batchDelete(List entitylist); + @Transactional + default void batchDelete(List entitylist){ + getBaseDao().batchDelete(entitylist); + } } diff --git a/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java b/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java index 1f52d4f..534f880 100755 --- a/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java +++ b/src/main/java/com/lq/code/service/impl/BaseServiceImpl.java @@ -8,7 +8,9 @@ import java.util.List; /** * Created by qi_liang on 2018/6/21. + *  采用jdk8 默认方法,所以该实现类废弃 */ +@Deprecated public abstract class BaseServiceImpl implements BaseService{ @Override public abstract BaseDao getBaseDao();