接口 IBaseService<T extends BaseEntity,​ID>

  • 所有已知实现类:
    BaseServiceImpl

    public interface IBaseService<T extends BaseEntity,​ID>
    服务层接口的父接口,继承此接口默认下面的这些方法要实现的,采用泛型的写法
    作者:
    youta
    • 方法概要

      所有方法 实例方法 抽象方法 
      修饰符和类型 方法 说明
      List<T> advancedQuery​(T entity)
      Description: 高级模糊查询,查询条件在实体中
      org.springframework.data.domain.Page<T> advancedQuery​(T entity, org.springframework.data.domain.Pageable pageable)
      Description: 高级模糊查询及分页
      Set advanceSearchProperty​(String property, String value)
      查询某个属性集合,不包含重复数据
      long count()
      Description:
      <S extends T>
      long
      count​(org.springframework.data.domain.Example<S> example)
      Returns the number of instances matching the given Example.
      void delete​(T var1)
      Description:
      void deleteAll()
      Description:
      void deleteAll​(Iterable<? extends T> var1)
      Description:
      int deleteAllById​(Iterable<ID> var1)
      Description:使用主键批量删除
      void deleteAllInBatch()
      Description:
      void deleteById​(ID var1)
      根据id查询
      void deleteInBatch​(Iterable<T> var1)
      Description:
      <S extends T>
      boolean
      exists​(org.springframework.data.domain.Example<S> example)
      Checks whether the data store contains elements that match the given Example.
      boolean existsByEntityProperty​(String propertyName, String propertyValue)
      Description: 根据实体的属性名称判断,实体是否存在, 注意:使用此方法,要自己保证属性名称的正确性,否则抛异常!
      boolean existsById​(ID var1)
      Description: 根据ID检查实体是否存在
      Iterable<T> findAll()
      Description:
      <S extends T>
      Iterable<S>
      findAll​(org.springframework.data.domain.Example<S> example)
      Returns all entities matching the given Example.
      <S extends T>
      org.springframework.data.domain.Page<S>
      findAll​(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Pageable pageable)
      Returns a Page of entities matching the given Example.
      <S extends T>
      Iterable<S>
      findAll​(org.springframework.data.domain.Example<S> example, org.springframework.data.domain.Sort sort)
      Returns all entities matching the given Example applying the given Sort.
      org.springframework.data.domain.Page<T> findAll​(org.springframework.data.domain.Pageable var1)
      Description:
      Iterable<T> findAll​(org.springframework.data.domain.Sort var1)
      Description:
      Iterable<T> findAllById​(Iterable<ID> var1)
      Description:
      Optional<T> findById​(ID var1)
      Description:
      <S extends T>
      Optional<S>
      findOne​(org.springframework.data.domain.Example<S> example)
      Returns a single entity matching the given Example or null if none was found.
      void flush()
      Description:
      T getOne​(ID var1)
      Description:
      void notifyOthers​(Object arg)
      自己的状态改变了,通知所有依赖自己的组件进行缓存清除, 通常的增删改的方法都需要调用这个方法,来维持缓存一致性
      void registObservers​(Observer... observers)
      注册观察者,即哪些组件观察自己,让子类调用此方法实现观察者注册
      <S extends T>
      S
      save​(S var1)
      Description:
      <S extends T>
      Iterable<S>
      saveAll​(Iterable<S> var1)
      Description:
      <S extends T>
      S
      saveAndFlush​(S var1)
      Description:
      void update​(Observable o, Object arg)
      这是观察别人,别人更新了之后来更新自己的 其实此处不需要被观察者的任何数据,只是为了知道被观察者状态变了,自己的相关缓存也就需要清除了,否则不一致 例如:观察A对象,但是A对象被删除了,那个自己这边关联查询与A有关的缓存都应该清除 子类重写此方法在方法前面加上清除缓存的注解,或者在方法体内具体执行一些清除缓存的代码。
      <S extends T>
      S
      update​(S var1)
      Description:更新实体的方法,很多时候保存和更新的处理逻辑是不一样的,权限也是不一样的,所以单独分开
    • 方法详细资料

      • findAll

        Iterable<T> findAll()
        Description:
        返回:
        Iterable
      • findAll

        org.springframework.data.domain.Page<T> findAll​(org.springframework.data.domain.Pageable var1)
        Description:
        参数:
        var1 - 分页对象
        返回:
        Page
      • findAll

        Iterable<T> findAll​(org.springframework.data.domain.Sort var1)
        Description:
        参数:
        var1 - sort对象
        返回:
        Iterable
      • findAllById

        Iterable<T> findAllById​(Iterable<ID> var1)
        Description:
        参数:
        var1 - 可迭代的id集合
        返回:
        java.lang.Iterable
      • getOne

        T getOne​(ID var1)
        Description:
        参数:
        var1 - id
        返回:
        T
      • findById

        Optional<T> findById​(ID var1)
        Description:
        参数:
        var1 - id
        返回:
        java.util.Optional
      • findOne

        <S extends TOptional<S> findOne​(org.springframework.data.domain.Example<S> example)
        Returns a single entity matching the given Example or null if none was found.
        参数:
        example - must not be null.
        返回:
        a single entity matching the given Example or Optional.empty() if none was found.
        抛出:
        org.springframework.dao.IncorrectResultSizeDataAccessException - if the Example yields more than one result.
      • findAll

        <S extends TIterable<S> findAll​(org.springframework.data.domain.Example<S> example)
        Returns all entities matching the given Example. In case no match could be found an empty Iterable is returned.
        参数:
        example - must not be null.
        返回:
        all entities matching the given Example.
      • findAll

        <S extends TIterable<S> findAll​(org.springframework.data.domain.Example<S> example,
                                          org.springframework.data.domain.Sort sort)
        Returns all entities matching the given Example applying the given Sort. In case no match could be found an empty Iterable is returned.
        参数:
        example - must not be null.
        sort - the Sort specification to sort the results by, must not be null.
        返回:
        all entities matching the given Example.
        从以下版本开始:
        1.10
      • findAll

        <S extends T> org.springframework.data.domain.Page<S> findAll​(org.springframework.data.domain.Example<S> example,
                                                                      org.springframework.data.domain.Pageable pageable)
        Returns a Page of entities matching the given Example. In case no match could be found, an empty Page is returned.
        参数:
        example - must not be null.
        pageable - can be null.
        返回:
        a Page of entities matching the given Example.
      • saveAll

        <S extends TIterable<S> saveAll​(Iterable<S> var1)
        Description:
        参数:
        var1 - 可迭代的实体集合
        返回:
        java.lang.Iterable
      • flush

        void flush()
        Description:
      • saveAndFlush

        <S extends T> S saveAndFlush​(S var1)
        Description:
        参数:
        var1 - 实体
        返回:
        S
      • save

        <S extends T> S save​(S var1)
        Description:
        参数:
        var1 - 实体
        返回:
        S
      • delete

        void delete​(T var1)
        Description:
        参数:
        var1 - 实体
      • deleteById

        void deleteById​(ID var1)
        根据id查询
        参数:
        var1 - id
      • deleteAll

        void deleteAll()
        Description:
      • deleteAll

        void deleteAll​(Iterable<? extends T> var1)
        Description:
        参数:
        var1 - 可迭代的对象
      • deleteAllInBatch

        void deleteAllInBatch()
        Description:
      • deleteInBatch

        void deleteInBatch​(Iterable<T> var1)
        Description:
        参数:
        var1 - 可迭代的对象
      • existsById

        boolean existsById​(ID var1)
        Description: 根据ID检查实体是否存在
        参数:
        var1 - id主键
        返回:
        boolean true存在,false 不存在
      • count

        long count()
        Description:
        返回:
        long
      • count

        <S extends T> long count​(org.springframework.data.domain.Example<S> example)
        Returns the number of instances matching the given Example.
        参数:
        example - the Example to count instances for. Must not be null.
        返回:
        the number of instances matching the Example.
      • exists

        <S extends T> boolean exists​(org.springframework.data.domain.Example<S> example)
        Checks whether the data store contains elements that match the given Example.
        参数:
        example - the Example to use for the existence check. Must not be null.
        返回:
        true if the data store contains elements that match the given Example.
      • existsByEntityProperty

        boolean existsByEntityProperty​(String propertyName,
                                       String propertyValue)
                                throws NoSuchFieldException
        Description: 根据实体的属性名称判断,实体是否存在, 注意:使用此方法,要自己保证属性名称的正确性,否则抛异常!
        参数:
        propertyName - 实体的属性名,暂时支持字符串类型
        propertyValue - 实体的属性名对应的值,仅支持简单的基本类型的值为字符串的,不支持其他的自定义类的类型
        返回:
        boolean true实体存在;false 不存在。
        抛出:
        NoSuchFieldException
      • deleteAllById

        int deleteAllById​(Iterable<ID> var1)
        Description:使用主键批量删除
        参数:
        var1 - 可迭代的id集合
        返回:
        int
      • update

        <S extends T> S update​(S var1)
        Description:更新实体的方法,很多时候保存和更新的处理逻辑是不一样的,权限也是不一样的,所以单独分开
        参数:
        var1 - 要更新的实体
        返回:
        S
      • advancedQuery

        List<T> advancedQuery​(T entity)
        Description: 高级模糊查询,查询条件在实体中
        参数:
        entity - 包含高级查询条件的实体
        返回:
        java.util.List<T>
      • advancedQuery

        org.springframework.data.domain.Page<T> advancedQuery​(T entity,
                                                              org.springframework.data.domain.Pageable pageable)
        Description: 高级模糊查询及分页
        参数:
        entity - 包含高级查询条件的实体
        pageable - 分页参数对象
        返回:
        Page
      • advanceSearchProperty

        Set advanceSearchProperty​(String property,
                                  String value)
        查询某个属性集合,不包含重复数据
        参数:
        property - 驼峰式的属性
        value - 模糊查询的value值
        返回:
        Set 集合
      • registObservers

        @Async
        void registObservers​(Observer... observers)
        注册观察者,即哪些组件观察自己,让子类调用此方法实现观察者注册
      • notifyOthers

        @Async
        void notifyOthers​(Object arg)
        自己的状态改变了,通知所有依赖自己的组件进行缓存清除, 通常的增删改的方法都需要调用这个方法,来维持缓存一致性
        参数:
        arg - 通知观察者时可以传递礼物arg,即数据,如果不需要数据就传递null;
      • update

        @Async
        void update​(Observable o,
                    Object arg)
        这是观察别人,别人更新了之后来更新自己的 其实此处不需要被观察者的任何数据,只是为了知道被观察者状态变了,自己的相关缓存也就需要清除了,否则不一致 例如:观察A对象,但是A对象被删除了,那个自己这边关联查询与A有关的缓存都应该清除 子类重写此方法在方法前面加上清除缓存的注解,或者在方法体内具体执行一些清除缓存的代码。
        参数:
        o - 被观察的对象
        arg - 传递的数据