package cd.casic.framework.mongo.core.sdk;

import cd.casic.framework.mongo.core.entity.Page;
import cd.casic.framework.mongo.core.wrapper.LambdaQueryWrapper;
import org.springframework.data.mongodb.core.query.Update;

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

public interface MongoService<T> {

    T getOne(LambdaQueryWrapper<T> queryWrapper);

    boolean save(T entity);

    boolean saveBatch(Collection<T> entityList);

    boolean removeById(Serializable id);

    long remove(LambdaQueryWrapper<T> queryWrapper);

    boolean updateById(T entity);

    long update(T entity, LambdaQueryWrapper<T> queryWrapper);

    long update(Update update, LambdaQueryWrapper<T> queryWrapper);

    boolean upsert(T entity, LambdaQueryWrapper<T> queryWrapper);

    T getById(Serializable id);

    Collection<T> listByIds(Collection<? extends Serializable> idList);

    long count(LambdaQueryWrapper<T> queryWrapper);

    List<T> list(LambdaQueryWrapper<T> queryWrapper);

    Page<T> page(LambdaQueryWrapper<T> queryWrapper, int pageNum, int pageSize);

    boolean exist(LambdaQueryWrapper<T> queryWrapper);
}
