@Service
public class TestService{
@Autowired
private List<IPushHandler> pushHandlers;
public Response<PushMonitorResp> toPushMonitor(PushMonitor pushMonitor, String operator) {
IPushHandler pushHandler = getPushHandler(pushMonitor.getOrderCategory());
}
}
//接口
public interface IPushHandler {
//是否支持该实体类
boolean canHandle(String pushOrderCategory) ;
//处理发送前
PushDTO createPushData(PushMonitor pushMonitor);
//处理回传结果
Response<PushMonitorResp> deserializeResponse(Result<String> result);
}
//实现类
@Service
public class DefaultPushHandler implements IPushHandler {
@Override
public PushDTO createPushData(PushMonitor pushMonitor) {
}
@Override
public Response<PushMonitorResp> deserializeResponse(Result<String> result) {
}
@Override
public boolean canHandle(String pushOrderCategory) {
}
}
//实现类
@Service
public class VaccinePushHandler implements IPushHandler {
@Override
public PushDTO createPushData(PushMonitor pushMonitor) {
}
@Override
public Response<PushMonitorResp> deserializeResponse(Result<String> result) {
}
@Override
public boolean canHandle(String pushOrderCategory) {
}
}