package cn.estsh.i3plus.pojo.base.jpa.dao;

import cn.estsh.i3plus.pojo.base.common.Pager;
import org.bson.conversions.Bson;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.repository.NoRepositoryBean;

import java.io.Serializable;
import java.util.List;

/**
 * @Description : 自定义Repository的方法接口
 * @Reference : MongoRepository
 * @Author : alwaysfrin
 * @CreateDate : 2018-09-13 10:34
 * @Modify:
 **/
@NoRepositoryBean
public interface BaseMongoRepository<T, ID extends Serializable> extends MongoRepository<T, ID> {

    T getById(long id);

    List<T> findByProperty(String propertyName, Object value);

    List<T> findByProperty(String propertyName, Object value,String orderByParam, int ascOrDesc);

    List<T> findByPropertyLike(String propertyName, Object value);

    List<T> findByPropertyLike(String propertyName, Object value,String orderByParam, int ascOrDesc);

    T getByProperty(String propertyName, Object value);

    List<T> findByBson(Bson bson);

    List<T> findByBson(Bson bson,String orderByParam, int ascOrDesc);

    int findByBsonCount(Bson bson);

    List<T> findByBsonPager(Bson bson,Pager pager);

    List<T> findByBsonPager(Bson bson,Pager pager,String orderByParam, int ascOrDesc);

    int listCount();

    List<T> listPager(Pager pager);

    List<T> listPager(Pager pager,String orderByParam, int ascOrDesc);

    long deleteByProperty(Bson bson);
    long deleteByPropertyIn(String propName, Object[] propValues);
    long deleteByIds(ID[] ids);
}
