其他分享
首页 > 其他分享> > Spring-Boot之业务逻辑层Service

Spring-Boot之业务逻辑层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);
    }
}

标签:classId,逻辑,Service,Spring,Boot,接口,findByClass,public
来源: https://www.cnblogs.com/jian-chen/p/14478997.html