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();