package com.boying.common;
|
|
import com.boying.entity.WhiteList;
|
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Sort;
|
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.io.Serializable;
|
import java.util.List;
|
|
public abstract class BaseService <T, ID extends Serializable>{
|
|
protected BaseDao<T, ID> baseDao;
|
|
protected abstract void setBaseDao(BaseDao<T, ID> baseDao);
|
|
@Transactional(readOnly = false)
|
public void save(T t) {
|
this.baseDao.save(t);
|
}
|
|
@Transactional(readOnly = false)
|
public void delete(ID id) {
|
this.baseDao.deleteById(id);
|
}
|
|
public T findById(ID id) {
|
return this.baseDao.getOne(id);
|
}
|
|
public List<T> findAll() {
|
return this.baseDao.findAll();
|
}
|
|
public long count(Specification specification) {
|
return this.baseDao.count(specification);
|
}
|
|
public List<T> findAll(Specification specification) {
|
return this.baseDao.findAll(specification);
|
}
|
|
|
public Page<T> findPage(Pageable pageable) {
|
Page<T> all = this.baseDao.findAll(pageable);
|
return all;
|
}
|
|
public Page<T> findPage(Pageable pageable, Specification specification) {
|
Page<T> all = this.baseDao.findAll(specification,pageable);
|
return all;
|
}
|
}
|