package com.zhangmeng.model.base.baseService;

import com.github.pagehelper.PageInfo;

import com.zhangmeng.model.base.baseEntity.BaseEntity;
import com.zhangmeng.model.dto.query.JpaQueryData;
import com.zhangmeng.model.dto.query.QueryParams;
import com.zhangmeng.model.dto.query.QueryResult;
import com.zhangmeng.model.dto.query.QuerySingleParams;
import com.zhangmeng.model.vo.Result;
import org.springframework.lang.NonNull;
import tk.mybatis.mapper.entity.Condition;

import java.util.List;
import java.util.Map;

/**
 * @param <T>
 * @author zhangmeng
 * @version 1.0
 * @date 2020年11月13日09:55:45
 */
public interface BaseService<T extends BaseEntity<Long>> {

    public void save(T model);//持久化

    public void save(List<T> models);//批量持久化

    public void deleteById(Long id);//通过主鍵刪除

    public void deleteByIds(String ids);//批量刪除 eg：ids -> “1,2,3,4”

    public void update(T model);//更新

    public T findById(Long id);//通过ID查找

    public List<T> findByObj(T t);

    public List<T> findByIds(String ids);//通过多个ID查找//eg：ids -> “1,2,3,4”

    public List<T> findByCondition(Condition condition);//根据条件查找

    public List<T> findAll();//获取所有

    public List<T>  findAll(QueryParams queryParams);

    public List<Map<String, Object>> query(String sql);

    public List<T> findByCondition(QueryParams queryParams);

    public Integer selectCountByCondition(Condition condition);

    public Integer selectCountEq(String key, Object value);

    public PageInfo<T> findByCondition(QueryParams queryParams, boolean isPageInfo);

    public List<T> findBySingleParams(@NonNull QuerySingleParams querySingleParams);

    public List<T> findByParams(List<QuerySingleParams> querySingleParamsList);

    public List<T> findByMapWithEq(Map<String, Object> map);

    public Result<T> findByByConditionWithResult(QueryParams queryParams);

    public QueryResult<T> findByCondition(QueryParams QueryParams, boolean isPageInfo, boolean isQueryResult);

    public T jpa_findById(Long id);

    public List<T> jpa_findByCondition(List<JpaQueryData> jpaQueryDataList);
}
