ssm项目中,通过循环调用多个接口,在业务层如何实现?

假设有三个接口,对应的是三张表。

前端给该接口传入一个ID。

然后这个接口里面的方法是一个判断的循环。

如果在A接口查到数据了,那就就直接返回给前端。

不会继续调用B和C的接口了。

以此类推,如果A接口没有查到数据,那么就会接着调到B接口,如果B接口也是没有数据,那么就调到C接口。

以此类推,相当于一级和二级的查询。

只不过二级有很多个接口。

如果可以,还请好心人贴上代买示例,小白现在很头疼,谢谢愿意帮助我的人。

A simple check-in and user management system.

提供下思路供参考:
Controller层提供接口给前端,可以把在Controller层提供业务逻辑处理;
或者通过Controller调用Service提供的接口,业务逻辑在Service中处理;


//以下为Controller层业务处理伪代码,如Result是返回类型,需替换成实际

@Autowired
protected AMapper aMapper;

@Autowired
protected BMapper bMapper;

@Autowired
protected CMapper cMapper;

@RequestMapping(value = "/myweb/getDataById",method = {RequestMethod.POST})
@ResponseBody
public Result  getDataById(@RequestBody Request request){
//根据业务逻辑处理 todo
Result resultA= aMapper.getDataA(request.getId);
Result resultB= aMapper.getDataB(request.getId);
Result resultC= aMapper.getDataC(request.getId);
if(null!=resultA&&resultA.count>0){
    return resultA;//resultA需要转换Result类型
}
if(null!=result&&resultB.count>0){
    return resultB;//resultB需要转换Result类型
}
if(null!=result&&resultC.count>0){
    return resultC;//resultC需要转换Result类型
}
return 默认的Result;
}