/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.example.service; import com.example.repository.StudentsRepo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.example.model.Students; import java.util.List; import java.util.Optional; /** * * @author acer */ @Service public class StudentsService { @Autowired private StudentsRepo studentsRepo; public Students save(Students students) { return studentsRepo.save(students); } public List listAll() { return studentsRepo.findAll(); } public Students get(long id) { return studentsRepo.findById(id).get(); } public void delete(long id) { studentsRepo.deleteById(id); } public Optional findById(long id) { return studentsRepo.findById(id); } public void deleteById(long id) { studentsRepo.deleteById(id); } }