package cn.hzxy.springbootusejpa.service.impl;

import cn.hzxy.springbootusejpa.entity.NewTeacher;
import cn.hzxy.springbootusejpa.repository.TeacherRepository;
import cn.hzxy.springbootusejpa.service.NewTeacherService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.awt.print.Pageable;
import java.util.Collection;
import java.util.List;

@Service
public class NewTeacherServiceImpl implements NewTeacherService {
    @Resource
    private TeacherRepository teacherRepository;
    @Override
    public NewTeacher findById(String id) {
        return teacherRepository.findById(id).orElse(null);
    }

    @Override
    public List<NewTeacher> findAll() {
        List<NewTeacher> newTeacherList=teacherRepository.findAll();
        return newTeacherList;
    }

    @Override
    public NewTeacher sava(NewTeacher newTeacher) {
        return teacherRepository.save(newTeacher);
    }

    @Override
    public void delete(String id) {
    teacherRepository.deleteById(id);
    }

    @Override
    public Page<NewTeacher> findAll(PageRequest pageRequest) {
        return teacherRepository.findAll(pageRequest);
    }


    @Override
    public List<NewTeacher> findByName(String name) {
        return teacherRepository.findByName(name);
    }

    @Override
    public List<NewTeacher> findByNameLike(String name) {
        return teacherRepository.findByNameLike(name);
    }

    @Override
    public List<NewTeacher> findByIdIn(Collection<String> ids) {
        return teacherRepository.findByIdIn(ids);
    }
}
