SpringBoot之业务逻辑层Service


一般,一个接口会调用业务逻辑层的一个方法,来实现该接口的具体业务逻辑和功能。

  • 业务逻辑层需要编写接口
public interface StudentService {
    public List<Student> findByClass(Integer classId) throws Exception;
}
  • 接口的实现类
@Service
public class StudentServiceImp implements StudentService {

    @Autowired
    private StudentRepository studentRepository;


    @Override
    public List<Student> findByClass(Integer classId) throws Exception {
        if (classId == null) {
            throw new IllegalArgumentException("Parameter classId can't be null.");  
        }
        return studentRepository.findByClassId(classId);
    }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM