一般,一个接口会调用业务逻辑层的一个方法,来实现该接口的具体业务逻辑和功能。
- 业务逻辑层需要编写接口
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);
}
}