public class ThirdRiskControlManager extends RiskControlManager {
public ThirdRiskControlManager(String name) {
super(name);
}
@Override
public void handlerRequest(Request request) {
if(RequestType.valueOf(request.getRequestType())!=null && request.getMoney()>10000){
System.out.println("大额操作,输入支付密码+验证码+人脸识别 ");
System.out.println(name+":"+request.getRequestType() + ", 金额:"+request.getMoney() +" 处理完成");
}else {
//下个节点进行处理
if(superior!=null){
superior.handlerRequest(request);
}
}
}
}
public class Main {
public static void main(String[] args) {
RiskControlManager firstControlManager = new FirstRiskControlManager("初级风控");
RiskControlManager secondControlManager = new SecondRiskControlManager("中级风控");
RiskControlManager thirdControlManager = new ThirdRiskControlManager("高级风控");
//形成调用链
firstControlManager.setSuperior(secondControlManager);
secondControlManager.setSuperior(thirdControlManager);
//使用
Request request1 = new Request();
request1.setRequestType(RequestType.CASH_OUT.name());
request1.setMoney(20000);
firstControlManager.handlerRequest(request1);
}
}