由Action调用Service抽取公共方法

使用中,Action通常需要调用Service层

而在使用Service层的时候常常碰到需要使用到相似的方法,如

Service里

findUserById() findDepartmentById() findCourseById()

findAllUser() findAllDepartment()

findByUserIds()

这时候需要抽取出这样的相似方法来简化代码, 令程序更简明清晰

首先定义BaseDao<T> BaseDaoImpl<T>, 在BaseDao<T> BaseDaoImpl<T>中定义公共相似方法增删改查

在Service 中, UserService extends BaseDao<User> ....

UserServiceImpl extends BaseDaoImpl<T> implements UserService

DepartmentService也类似

I'm falling off the sky all alone.The courage inside is gonna break the fall. Nothing can dim my light within. I am That I am 程序 = 数据结构 + 算法
原文地址:https://www.cnblogs.com/IamThat/p/2917480.html