在此仅记录一种思路
public interface SuperMapper<T> extends BaseMapper<T> {
default List<T> idNotInList(List<?> idList) {
return selectList(new QueryWrapper<T>().notIn("id", idList));
}
}
public interface UserMapper extends SupperMapper<User> {
}
service基类
public class SupperServiceImpl<M extends SupperMapper<T>, T> extends ServiceImpl<M, T> {
}
public interface UserService extends IService<User> {
List<User> idNotInList(List<Integer> idList);
}
@Service
public class UserServiceImpl extends SupperServiceImpl<UserMapper, User> implements UserService {
@Override
public List<User> idNotInList(List<Integer> idList) {
//在SupperMapper中定义的默认方法, 可以在此直接使用
return baseMapper.idNotInList(idList);
}
}
注意: 本文归作者所有, 未经作者允许, 不得转载. 若有谬误, 欢迎指出