先贴代码
@IocBean
public class IocBeans {
@Inject("refer:$ioc")
Ioc ioc;
@IocBean(name = "businessController")
public BaseController getBusinessController() {
if (ProjectType.xzfwzx.equals(CacheData.project_type)) {
return ioc.get(XBusinessController.class);
}
return ioc.get(BusinessController.class);
}
}
@IocBean
@At("/base/business")
public class BusinessApi {
@Inject
BusinessController businessController;
@At("/getBusinesses")
@Ok("json")
@AdaptBy(type = JsonAdaptor.class)
public Object getBusinesses(@Param("venueId") Integer venueId) {
if(venueId==null) {
return Result.error(ErrorCode.PARAMETER_ERROR, "参数缺失");
}
return businessController.getBusinesses(venueId);
}
@At("/getBusinessesType")
@Ok("json")
@AdaptBy(type = JsonAdaptor.class)
public Object getBusinessesType(@Param("venueId") Integer venueId) {
if(venueId==null) {
return Result.error(ErrorCode.PARAMETER_ERROR, "参数缺失");
}
return businessController.getBusinessesType(venueId);
}
}
BusinessController继承BaseController,XBusinessController继承BusinessController
当ProjectType.xzfwzx.equals(CacheData.project_type)条件为false时,
getBusinessController方法递归死循环